Interface RowBatcher<T>

Type Parameters:
T - the Java class that stores a batch of retrieved roles
All Superinterfaces:
Batcher

public interface RowBatcher<T>extends Batcher
Coordinates threads to export all of the rows from a view in batches.

To construct a RowBatcher, use the DataMovementManager.newRowBatcher() factory method. You pass a sample handle (that is, an adapter for the Java class that stores a batch of retrieved rows). The sample handle must implement both the ContentHandle and StructuredReadHandle interfaces. Because RowBatcher can retrieve rows in multiple formats, you must specify the format or mime type on the sample handle if the handle can be used for multiple row formats. The RowBatcher takes a generic type for the Java class adapted by the sample handle.

The following example constructs a RowBatcher for retrieving the rows in CSV format as a Java String. The factory call passes a StringHandle configured with the appropriate format and mime type:


    RowBatcher<String> rowBatcher = dataMovementMgr.newRowBatcher(
        new StringHandle().withFormat(Format.TEXT).withMimetype("text/csv")
        );

After constructing the RowBatcher, use the getRowManager() method to get the RowManager for the rows. You can use the RowManager's setDatatypeStyle() method to emit data types in the header and setRowStructureStyle() method to emit rows as objects or arrays. The RowManager's newPlanBuilder() method provides a factory for constructing a PlanBuilder.

Use the RowManager's PlanBuilder to build a plan for retrieving the rows from a view. The plan must have the following characteristics:

  • Must start with a fromView() operation that specifies the view with the rows to be exported.
  • May filter the exported rows with a where() operation prior to any joins.
  • May project columns from the exported rows with a select() operation prior to any joins.
  • Must not limit, group, or sort over the exported view (either before or after any joins).
  • May join other views with the exported view, applying any operation to a joined view prior to the join.
  • May join documents or uris with the exported view.
  • Must not specify parameter placeholders.

Pass the built plan to the withBatchView() method to initialize the RowBatcher with the plan.

Specify the number of threads for retrieving rows with the withThreadCount() method and the number of rows in a batch with the withBatchSize() method.

Specify a success listener for processing each batch of rows retrieved from the server. The RowBatcher passes a response event to the success listener. The success listener calls the RowBatchResponseEvent.getRowsDoc() method to to get the rows in the batch. The rows are returned as an instance of the Java class adapted by the sample handle passed to the factory that constructs the RowBatcher (that is, the generic type of the RowBatcher).


    RowBatcher<String> rowBatcher = ...construct the row batcher...;
    rowBatcher.onSuccess(event -> {
        String rowBatch = event.getRowsDoc();
        ...process the batch of rows...
        });

Specify a failure listener to handle any errors during retrieval.

See Also: