Search in sources :

Example 6 with Span

use of org.apache.fluo.api.data.Span 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 7 with Span

use of org.apache.fluo.api.data.Span 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 8 with Span

use of org.apache.fluo.api.data.Span 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 9 with Span

use of org.apache.fluo.api.data.Span 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 10 with Span

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

the class JoinBatchInformationTypeAdapter method serialize.

@Override
public JsonElement serialize(final JoinBatchInformation batch, final Type typeOfSrc, final JsonSerializationContext context) {
    final JsonObject result = new JsonObject();
    result.add("class", new JsonPrimitive(batch.getClass().getName()));
    result.add("batchSize", new JsonPrimitive(batch.getBatchSize()));
    result.add("task", new JsonPrimitive(batch.getTask().name()));
    final Column column = batch.getColumn();
    result.add("column", new JsonPrimitive(column.getsFamily() + "\u0000" + column.getsQualifier()));
    final 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()));
    result.add("side", new JsonPrimitive(batch.getSide().name()));
    result.add("joinType", new JsonPrimitive(batch.getJoinType().name()));
    final String updateVarOrderString = Joiner.on(";").join(batch.getBs().getBindingNames());
    final VariableOrder updateVarOrder = new VariableOrder(updateVarOrderString);
    result.add("bindingSet", new JsonPrimitive(converter.convert(batch.getBs(), updateVarOrder)));
    result.add("updateVarOrder", new JsonPrimitive(updateVarOrderString));
    return result;
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) RowColumn(org.apache.fluo.api.data.RowColumn) Column(org.apache.fluo.api.data.Column) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) JsonObject(com.google.gson.JsonObject) Span(org.apache.fluo.api.data.Span)

Aggregations

Span (org.apache.fluo.api.data.Span)10 Column (org.apache.fluo.api.data.Column)8 RowColumn (org.apache.fluo.api.data.RowColumn)8 Bytes (org.apache.fluo.api.data.Bytes)5 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)5 JsonObject (com.google.gson.JsonObject)4 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)4 Task (org.apache.rya.indexing.pcj.fluo.app.batch.BatchInformation.Task)3 JoinBatchInformation (org.apache.rya.indexing.pcj.fluo.app.batch.JoinBatchInformation)3 JsonPrimitive (com.google.gson.JsonPrimitive)2 HashSet (java.util.HashSet)2 FluoClient (org.apache.fluo.api.client.FluoClient)2 FluoClientImpl (org.apache.fluo.core.client.FluoClientImpl)2 RyaStatement (org.apache.rya.api.domain.RyaStatement)2 RyaURI (org.apache.rya.api.domain.RyaURI)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 CreateFluoPcj (org.apache.rya.indexing.pcj.fluo.api.CreateFluoPcj)2