Search in sources :

Example 11 with Column

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

the class JoinBatchInformationTypeAdapter method deserialize.

@Override
public JoinBatchInformation deserialize(final JsonElement element, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {
    final JsonObject json = element.getAsJsonObject();
    final int batchSize = json.get("batchSize").getAsInt();
    final Task task = Task.valueOf(json.get("task").getAsString());
    final String[] colArray = json.get("column").getAsString().split("\u0000");
    final Column column = new Column(colArray[0], colArray[1]);
    final String[] rows = json.get("span").getAsString().split("\u0000");
    final boolean startInc = json.get("startInc").getAsBoolean();
    final boolean endInc = json.get("endInc").getAsBoolean();
    final Span span = new Span(new RowColumn(rows[0]), startInc, new RowColumn(rows[1]), endInc);
    final VariableOrder updateVarOrder = new VariableOrder(json.get("updateVarOrder").getAsString());
    final VisibilityBindingSet bs = converter.convert(json.get("bindingSet").getAsString(), updateVarOrder);
    final Side side = Side.valueOf(json.get("side").getAsString());
    final JoinType join = JoinType.valueOf(json.get("joinType").getAsString());
    return JoinBatchInformation.builder().setBatchSize(batchSize).setTask(task).setSpan(span).setColumn(column).setBs(bs).setSide(side).setJoinType(join).build();
}
Also used : Task(org.apache.rya.indexing.pcj.fluo.app.batch.BatchInformation.Task) VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) RowColumn(org.apache.fluo.api.data.RowColumn) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) JsonObject(com.google.gson.JsonObject) JoinType(org.apache.rya.indexing.pcj.fluo.app.query.JoinMetadata.JoinType) Span(org.apache.fluo.api.data.Span) Side(org.apache.rya.api.function.join.LazyJoiningIterator.Side) RowColumn(org.apache.fluo.api.data.RowColumn) Column(org.apache.fluo.api.data.Column)

Example 12 with Column

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

the class SpanBatchInformationTypeAdapter method deserialize.

@Override
public SpanBatchDeleteInformation deserialize(JsonElement element, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonObject json = element.getAsJsonObject();
    int batchSize = json.get("batchSize").getAsInt();
    String[] colArray = json.get("column").getAsString().split("\u0000");
    Column column = new Column(colArray[0], colArray[1]);
    String[] rows = json.get("span").getAsString().split("\u0000");
    boolean startInc = json.get("startInc").getAsBoolean();
    boolean endInc = json.get("endInc").getAsBoolean();
    Span span = new Span(new RowColumn(rows[0]), startInc, new RowColumn(rows[1]), endInc);
    String nodeId = json.get("nodeId").getAsString();
    Optional<String> id = Optional.empty();
    if (!nodeId.isEmpty()) {
        id = Optional.of(nodeId);
    }
    return SpanBatchDeleteInformation.builder().setNodeId(id).setBatchSize(batchSize).setSpan(span).setColumn(column).build();
}
Also used : RowColumn(org.apache.fluo.api.data.RowColumn) Column(org.apache.fluo.api.data.Column) RowColumn(org.apache.fluo.api.data.RowColumn) JsonObject(com.google.gson.JsonObject) Span(org.apache.fluo.api.data.Span)

Example 13 with Column

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

the class SpanBatchInformationTypeAdapter method serialize.

@Override
public JsonElement serialize(SpanBatchDeleteInformation batch, Type typeOfSrc, JsonSerializationContext context) {
    JsonObject result = new JsonObject();
    result.add("class", new JsonPrimitive(batch.getClass().getName()));
    result.add("batchSize", new JsonPrimitive(batch.getBatchSize()));
    Column column = batch.getColumn();
    result.add("column", new JsonPrimitive(column.getsFamily() + "\u0000" + column.getsQualifier()));
    Span span = batch.getSpan();
    result.add("span", new JsonPrimitive(span.getStart().getsRow() + "\u0000" + span.getEnd().getsRow()));
    result.add("startInc", new JsonPrimitive(span.isStartInclusive()));
    result.add("endInc", new JsonPrimitive(span.isEndInclusive()));
    String nodeId = batch.getNodeId().orElse("");
    result.add("nodeId", new JsonPrimitive(nodeId));
    return result;
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) RowColumn(org.apache.fluo.api.data.RowColumn) Column(org.apache.fluo.api.data.Column) JsonObject(com.google.gson.JsonObject) Span(org.apache.fluo.api.data.Span)

Example 14 with Column

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

the class JoinBatchBindingSetUpdater 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 batch - batch order to be processed
 * @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 JoinBatchInformation batch, final Set<VisibilityBindingSet> bsSet) throws Exception {
    final Span span = batch.getSpan();
    final Column column = batch.getColumn();
    final int batchSize = batch.getBatchSize();
    final RowScanner rs = tx.scanner().over(span).fetch(column).byRow().build();
    final Iterator<ColumnScanner> colScannerIter = rs.iterator();
    boolean batchLimitMet = false;
    Bytes row = span.getStart().getRow();
    while (colScannerIter.hasNext() && !batchLimitMet) {
        final ColumnScanner colScanner = colScannerIter.next();
        row = colScanner.getRow();
        final Iterator<ColumnValue> iter = colScanner.iterator();
        while (iter.hasNext()) {
            if (bsSet.size() >= batchSize) {
                batchLimitMet = true;
                break;
            }
            bsSet.add(BS_SERDE.deserialize(iter.next().getValue()));
        }
    }
    if (batchLimitMet) {
        return Optional.of(new RowColumn(row, column));
    } else {
        return Optional.empty();
    }
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) RowColumn(org.apache.fluo.api.data.RowColumn) Column(org.apache.fluo.api.data.Column) 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) Span(org.apache.fluo.api.data.Span)

Example 15 with Column

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

the class JoinResultUpdater method getScanColumnFamily.

/**
 * Return the sibling node's binding set column to use for a scan. The column
 * that will be used is determined by the node's {@link NodeType}.
 *
 * @param siblingId - The Node ID of the sibling. (not null)
 */
private static Column getScanColumnFamily(final String siblingId) {
    checkNotNull(siblingId);
    // Determine which type of binding set the sibling is.
    final Optional<NodeType> siblingType = NodeType.fromNodeId(siblingId);
    if (!siblingType.isPresent()) {
        throw new IllegalStateException("The child's sibling is not of a recognized type.");
    }
    // Set the column to join with.
    Column column;
    switch(siblingType.get()) {
        case STATEMENT_PATTERN:
            column = FluoQueryColumns.STATEMENT_PATTERN_BINDING_SET;
            break;
        case FILTER:
            column = FluoQueryColumns.FILTER_BINDING_SET;
            break;
        case JOIN:
            column = FluoQueryColumns.JOIN_BINDING_SET;
            break;
        case PROJECTION:
            column = FluoQueryColumns.PROJECTION_BINDING_SET;
            break;
        default:
            throw new IllegalArgumentException("The child node's sibling is not of type StatementPattern, Join, Left Join, or Filter.");
    }
    return column;
}
Also used : RowColumn(org.apache.fluo.api.data.RowColumn) Column(org.apache.fluo.api.data.Column)

Aggregations

Column (org.apache.fluo.api.data.Column)22 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)13 Bytes (org.apache.fluo.api.data.Bytes)9 RowColumn (org.apache.fluo.api.data.RowColumn)9 Span (org.apache.fluo.api.data.Span)8 JsonObject (com.google.gson.JsonObject)4 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)4 HashSet (java.util.HashSet)3 Task (org.apache.rya.indexing.pcj.fluo.app.batch.BatchInformation.Task)3 JsonPrimitive (com.google.gson.JsonPrimitive)2 Transaction (org.apache.fluo.api.client.Transaction)2 IterativeJoin (org.apache.rya.api.function.join.IterativeJoin)2 Side (org.apache.rya.api.function.join.LazyJoiningIterator.Side)2 LeftOuterJoin (org.apache.rya.api.function.join.LeftOuterJoin)2 NaturalJoin (org.apache.rya.api.function.join.NaturalJoin)2 NodeType (org.apache.rya.indexing.pcj.fluo.app.NodeType)2 SpanBatchDeleteInformation (org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)2 JoinType (org.apache.rya.indexing.pcj.fluo.app.query.JoinMetadata.JoinType)2 IOException (java.io.IOException)1 InvalidClassException (java.io.InvalidClassException)1