Search in sources :

Example 6 with ColumnValue

use of org.apache.fluo.api.data.ColumnValue in project incubator-rya by apache.

the class JoinResultUpdater method fillSiblingBatch.

/**
 * Fetches batch to be processed by scanning over the Span specified by the
 * {@link JoinBatchInformation}. The number of results is less than or equal
 * to the batch size specified by the JoinBatchInformation.
 *
 * @param tx - Fluo transaction in which batch operation is performed
 * @param siblingSpan - span of sibling to retrieve elements to join with
 * @param bsSet- set that batch results are added to
 * @return Set - containing results of sibling scan.
 * @throws Exception
 */
private Optional<RowColumn> fillSiblingBatch(final TransactionBase tx, final Span siblingSpan, final Column siblingColumn, final Set<VisibilityBindingSet> bsSet, final int batchSize) throws Exception {
    final RowScanner rs = tx.scanner().over(siblingSpan).fetch(siblingColumn).byRow().build();
    final Iterator<ColumnScanner> colScannerIter = rs.iterator();
    boolean batchLimitMet = false;
    Bytes row = siblingSpan.getStart().getRow();
    while (colScannerIter.hasNext() && !batchLimitMet) {
        final ColumnScanner colScanner = colScannerIter.next();
        row = colScanner.getRow();
        final Iterator<ColumnValue> iter = colScanner.iterator();
        while (iter.hasNext() && !batchLimitMet) {
            bsSet.add(BS_SERDE.deserialize(iter.next().getValue()));
            // check if batch size has been met and set flag if it has been met
            if (bsSet.size() >= batchSize) {
                batchLimitMet = true;
            }
        }
    }
    if (batchLimitMet) {
        return Optional.of(new RowColumn(row, siblingColumn));
    } else {
        return Optional.absent();
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) RowColumn(org.apache.fluo.api.data.RowColumn) RowScanner(org.apache.fluo.api.client.scanner.RowScanner) ColumnScanner(org.apache.fluo.api.client.scanner.ColumnScanner) ColumnValue(org.apache.fluo.api.data.ColumnValue)

Aggregations

ColumnScanner (org.apache.fluo.api.client.scanner.ColumnScanner)6 RowScanner (org.apache.fluo.api.client.scanner.RowScanner)6 ColumnValue (org.apache.fluo.api.data.ColumnValue)6 Bytes (org.apache.fluo.api.data.Bytes)5 RowColumn (org.apache.fluo.api.data.RowColumn)3 NodeType (org.apache.rya.indexing.pcj.fluo.app.NodeType)3 HashSet (java.util.HashSet)2 Snapshot (org.apache.fluo.api.client.Snapshot)1 Transaction (org.apache.fluo.api.client.Transaction)1 Column (org.apache.fluo.api.data.Column)1 Span (org.apache.fluo.api.data.Span)1 BindingSetRow (org.apache.rya.indexing.pcj.fluo.app.BindingSetRow)1 PeriodicQueryMetadata (org.apache.rya.indexing.pcj.fluo.app.query.PeriodicQueryMetadata)1 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)1 LiteralImpl (org.openrdf.model.impl.LiteralImpl)1 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)1