public final class SegmentWriterBuilder extends Object
SegmentWriter instances.
The returned instances are thread safe if withWriterPool()
was specified and not thread sage if withoutWriterPool()
was specified (default).
Default: calling one of the build() methods without previously
calling one of the with...() methods returns a SegmentWriter
as would the following chain of calls:
segmentWriterBuilder("name")
.with(LATEST_VERSION)
.withGeneration(0)
.withoutWriterPool()
.with(new WriterCacheManager.Default())
.build(store);
| Modifier and Type | Method and Description |
|---|---|
SegmentWriter |
build(FileStore store)
Build a
SegmentWriter for a FileStore. |
SegmentWriter |
build(MemoryStore store)
Build a
SegmentWriter for a MemoryStore. |
SegmentWriter |
build(ReadOnlyFileStore store)
Build a
SegmentWriter for a ReadOnlyFileStore. |
static SegmentWriterBuilder |
segmentWriterBuilder(String name)
Set the
name of this builder. |
SegmentWriterBuilder |
with(WriterCacheManager cacheManager)
Specify the
cacheManager used by the returned writer. |
SegmentWriterBuilder |
withGeneration(int generation)
Specify the
generation for the segment written by the returned
segment writer. |
SegmentWriterBuilder |
withGeneration(com.google.common.base.Supplier<Integer> generation)
Specify the
generation for the segment written by the returned
segment writer. |
SegmentWriterBuilder |
withoutCache()
Specify that the returned writer should not use a cache.
|
SegmentWriterBuilder |
withoutWriterPool()
Create a
SegmentWriter backed by a SegmentBufferWriter. |
SegmentWriterBuilder |
withWriterPool()
Create a
SegmentWriter backed by a SegmentBufferWriterPool. |
@Nonnull public static SegmentWriterBuilder segmentWriterBuilder(@Nonnull String name)
name of this builder. This name will appear in the segment's
meta data.@Nonnull public SegmentWriterBuilder withGeneration(@Nonnull com.google.common.base.Supplier<Integer> generation)
generation for the segment written by the returned
segment writer.
If withoutWriterPool() was specified all segments will be written
at the generation that generation.get() returned at the time
any of the build() methods is called.
If withWriterPool() was specified a segments will be written
at the generation that generation.get() returns when a new segment
is created by the returned writer.
@Nonnull public SegmentWriterBuilder withGeneration(int generation)
generation for the segment written by the returned
segment writer.@Nonnull public SegmentWriterBuilder withWriterPool()
SegmentWriter backed by a SegmentBufferWriterPool.
The returned instance is thread safe.@Nonnull public SegmentWriterBuilder withoutWriterPool()
SegmentWriter backed by a SegmentBufferWriter.
The returned instance is not thread safe.@Nonnull public SegmentWriterBuilder with(WriterCacheManager cacheManager)
cacheManager used by the returned writer.@Nonnull public SegmentWriterBuilder withoutCache()
with(WriterCacheManager)@Nonnull public SegmentWriter build(@Nonnull FileStore store)
SegmentWriter for a FileStore.@Nonnull public SegmentWriter build(@Nonnull ReadOnlyFileStore store)
SegmentWriter for a ReadOnlyFileStore.
Attempting to write to the returned writer will cause a
UnsupportedOperationException to be thrown.@Nonnull public SegmentWriter build(@Nonnull MemoryStore store)
SegmentWriter for a MemoryStore.Copyright © 2012-2017 The Apache Software Foundation. All Rights Reserved.