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();
}
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();
}
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;
}
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();
}
}
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;
}
Aggregations