public interface Appenderator extends QuerySegmentWalker
You can provide a Committer or a Supplier of one when you call one of the methods that add(org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec, org.apache.druid.data.input.InputRow, com.google.common.base.Supplier<org.apache.druid.data.input.Committer>),
persistAll(org.apache.druid.data.input.Committer), or push(java.util.Collection<org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec>, org.apache.druid.data.input.Committer, boolean). The Committer should represent all data you have given to the Appenderator so
far. This Committer will be used when that data has been persisted to disk.
Concurrency: all methods defined in this class directly, including close() and closeNow(), i. e.
all methods of the data appending and indexing lifecycle except drop(org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec) must be called from a single thread.
Methods inherited from QuerySegmentWalker can be called concurrently from multiple threads.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Appenderator.AppenderatorAddResult
Result of
add(org.apache.druid.segment.realtime.appenderator.SegmentIdWithShardSpec, org.apache.druid.data.input.InputRow, com.google.common.base.Supplier<org.apache.druid.data.input.Committer>) containing following information
- SegmentIdWithShardSpec - identifier of segment to which rows are being added
- int - positive number indicating how many summarized rows exist in this segment so far and
- boolean - true if is set to false and persist is required; false otherwise |
| Modifier and Type | Method and Description |
|---|---|
default Appenderator.AppenderatorAddResult |
add(SegmentIdWithShardSpec identifier,
InputRow row,
com.google.common.base.Supplier<Committer> committerSupplier)
Same as
add(SegmentIdWithShardSpec, InputRow, Supplier, boolean), with allowIncrementalPersists set to
true |
Appenderator.AppenderatorAddResult |
add(SegmentIdWithShardSpec identifier,
InputRow row,
com.google.common.base.Supplier<Committer> committerSupplier,
boolean allowIncrementalPersists)
Add a row.
|
void |
clear()
Drop all in-memory and on-disk data, and forget any previously-remembered commit metadata.
|
void |
close()
Stop any currently-running processing and clean up after ourselves.
|
void |
closeNow()
Stop all processing, abandoning current pushes, currently running persist may be allowed to finish if they persist
critical metadata otherwise shutdown immediately.
|
com.google.common.util.concurrent.ListenableFuture<?> |
drop(SegmentIdWithShardSpec identifier)
Schedule dropping all data associated with a particular pending segment.
|
String |
getDataSource()
Return the name of the dataSource associated with this Appenderator.
|
String |
getId()
Return the identifier of this Appenderator; useful for log messages and such.
|
int |
getRowCount(SegmentIdWithShardSpec identifier)
Returns the number of rows in a particular pending segment.
|
List<SegmentIdWithShardSpec> |
getSegments()
Returns a list of all currently active segments.
|
int |
getTotalRowCount()
Returns the number of total rows in this appenderator of all segments pending push.
|
com.google.common.util.concurrent.ListenableFuture<Object> |
persistAll(Committer committer)
Persist any in-memory indexed data to durable storage.
|
com.google.common.util.concurrent.ListenableFuture<SegmentsAndCommitMetadata> |
push(Collection<SegmentIdWithShardSpec> identifiers,
Committer committer,
boolean useUniquePath)
Merge and push particular segments to deep storage.
|
Object |
startJob()
Perform any initial setup.
|
getQueryRunnerForIntervals, getQueryRunnerForSegmentsString getId()
String getDataSource()
Object startJob()
default Appenderator.AppenderatorAddResult add(SegmentIdWithShardSpec identifier, InputRow row, com.google.common.base.Supplier<Committer> committerSupplier) throws IndexSizeExceededException, SegmentNotWritableException
add(SegmentIdWithShardSpec, InputRow, Supplier, boolean), with allowIncrementalPersists set to
trueAppenderator.AppenderatorAddResult add(SegmentIdWithShardSpec identifier, InputRow row, @Nullable com.google.common.base.Supplier<Committer> committerSupplier, boolean allowIncrementalPersists) throws IndexSizeExceededException, SegmentNotWritableException
If no pending segment exists for the provided identifier, a new one will be created.
This method may trigger a persistAll(Committer) using the supplied Committer. If it does this, the
Committer is guaranteed to be *created* synchronously with the call to add, but will actually be used
asynchronously.
If committer is not provided, no metadata is persisted.
identifier - the segment into which this row should be addedrow - the row to addcommitterSupplier - supplier of a committer associated with all data that has been added, including
this row if allowIncrementalPersists is set to false then this will not be
used as no persist will be done automaticallyallowIncrementalPersists - indicate whether automatic persist should be performed or not if required.
If this flag is set to false then the return value should have
Appenderator.AppenderatorAddResult.isPersistRequired set to true if persist was skipped
because of this flag and it is assumed that the responsibility of calling
persistAll(Committer) is on the caller.Appenderator.AppenderatorAddResultIndexSizeExceededException - if this row cannot be added because it is too largeSegmentNotWritableException - if the requested segment is known, but has been closedList<SegmentIdWithShardSpec> getSegments()
int getRowCount(SegmentIdWithShardSpec identifier)
identifier - segment to examineIllegalStateException - if the segment is unknownint getTotalRowCount()
void clear()
throws InterruptedException
InterruptedExceptioncom.google.common.util.concurrent.ListenableFuture<?> drop(SegmentIdWithShardSpec identifier)
clear()), any on-disk
commit metadata will remain unchanged. If there is no pending segment with this identifier, then this method will
do nothing.
You should not write to the dropped segment after calling "drop". If you need to drop all your data and
re-write it, consider clear() instead.
This method might be called concurrently from a thread different from the "main data appending / indexing thread",
from where all other methods in this class (except those inherited from QuerySegmentWalker) are called.
This typically happens when drop() is called in an async future callback. drop() itself is cheap
and relays heavy dropping work to an internal executor of this Appenderator.
identifier - the pending segment to dropcom.google.common.util.concurrent.ListenableFuture<Object> persistAll(@Nullable Committer committer)
If committer is not provided, no metadata is persisted.
committer - a committer associated with all data that has been added so farcom.google.common.util.concurrent.ListenableFuture<SegmentsAndCommitMetadata> push(Collection<SegmentIdWithShardSpec> identifiers, @Nullable Committer committer, boolean useUniquePath)
persistAll(Committer) using the provided Committer.
After this method is called, you cannot add new data to any segments that were previously under construction.
If committer is not provided, no metadata is persisted.
identifiers - list of segments to pushcommitter - a committer associated with all data that has been added so faruseUniquePath - true if the segment should be written to a path with a unique identifiervoid close()
void closeNow()
Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.