BatchListener<QueryBatch>
,
QueryBatchListener
OpticExportToWriterListener
public class OpticExportListener extends java.lang.Object implements QueryBatchListener
onRowRecordReady
for further processing or writing
to any target supported by Java For example:
Function<QueryBatch, PlanBuilder.Plan> fn = batch -> {
PlanBuilder.Plan plan = convertToOpticPlan(batch); return plan; }
where "convertToOpticPlan" is your custom code which converts the
QueryBatch into Optic plan from which records can be retrieved.
RowManager rowMgr = client.newRowManager() QueryBatcher
exportOpticBatcher = moveMgr.newQueryBatcher(query) .onUrisReady(
new OpticExportListener(fn, rowMgr) .onRowRecordReady(record ->
{ logger.debug(record.toString()); }) ) .onQueryFailure(exception
-> exception.printStackTrace()); JobTicket ticket =
moveMgr.startJob(exportBatcher); exportBatcher.awaitCompletion();
moveMgr.stopJob(ticket);Modifier and Type | Field | Description |
---|---|---|
protected
java.util.function.Function<QueryBatch,PlanBuilder.Plan> |
exportFunction |
|
protected RowManager |
rowManager |
Constructor | Description |
---|---|
OpticExportListener(java.util.function.Function<QueryBatch,PlanBuilder.Plan> function,
RowManager rowManager) |
Modifier and Type | Method | Description |
---|---|---|
protected java.util.List<BatchFailureListener<Batch<java.lang.String>>> |
getFailureListeners() |
|
OpticExportListener |
onBatchFailure(BatchFailureListener<Batch<java.lang.String>> listener) |
When a batch fails or a callback throws an
Exception, run this listener code.
|
OpticExportListener |
onRowRecordReady(java.util.function.Consumer<RowRecord> listener) |
Adds a listener to process each retrieved
RowRecord, which is the way users of OpticExportListener can
provide custom code to export records from the constructed Optic
Plan.
|
void |
processEvent(QueryBatch batch) |
This is the method QueryBatcher calls for
OpticExportListener to do its thing.
|
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, toString, wait, wait, wait
initializeListener
protected java.util.function.Function<QueryBatch,PlanBuilder.Plan> exportFunction
protected RowManager rowManager
public OpticExportListener(java.util.function.Function<QueryBatch,PlanBuilder.Plan> function, RowManager rowManager)
public void processEvent(QueryBatch batch)
processEvent
in interface BatchListener<QueryBatch>
processEvent
in interface QueryBatchListener
batch
- the batch of uris and some metadata about
the current status of the jobpublic OpticExportListener onRowRecordReady(java.util.function.Consumer<RowRecord> listener)
listener
- the code which will process each
RowRecord of the Optic APIConsumer
, RowRecord
public OpticExportListener onBatchFailure(BatchFailureListener<Batch<java.lang.String>> listener)
listener
- the code to run when a failure
occursprotected java.util.List<BatchFailureListener<Batch<java.lang.String>>> getFailureListeners()
Copyright © 2013-2019 MarkLogic Corporation.