use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class CreateDeletePeriodicPCJ method getFluoTableEntries.
private List<Bytes> getFluoTableEntries(final FluoClient fluoClient) {
try (Snapshot snapshot = fluoClient.newSnapshot()) {
final List<Bytes> rows = new ArrayList<>();
final RowScanner rscanner = snapshot.scanner().over(Span.prefix("")).byRow().build();
for (final ColumnScanner cscanner : rscanner) {
rows.add(cscanner.getRow());
}
return rows;
}
}
use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class DeleteFluoPcj method deleteMetadataColumns.
/**
* Deletes all metadata for a Query Node.
*
* @param tx - Transaction the deletes will be performed with. (not null)
* @param nodeId - The Node ID of the query node to delete. (not null)
* @param columns - The columns that will be deleted. (not null)
*/
private void deleteMetadataColumns(final Transaction tx, final String nodeId, final List<Column> columns) {
requireNonNull(tx);
requireNonNull(columns);
requireNonNull(nodeId);
final Bytes row = Bytes.of(nodeId);
for (final Column column : columns) {
tx.delete(row, column);
}
}
use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class DeleteFluoPcj method deleteData.
/**
* Deletes all results (BindingSets or Statements) associated with the specified nodeId.
*
* @param nodeId - nodeId whose {@link BindingSet}s will be deleted. (not null)
* @param client - Used to delete the data. (not null)
*/
private void deleteData(final FluoClient client, final String nodeId) {
requireNonNull(client);
requireNonNull(nodeId);
final NodeType type = NodeType.fromNodeId(nodeId).get();
Transaction tx = client.newTransaction();
Bytes prefixBytes = Bytes.of(type.getNodeTypePrefix());
SpanBatchDeleteInformation batch = SpanBatchDeleteInformation.builder().setColumn(type.getResultColumn()).setSpan(Span.prefix(prefixBytes)).setBatchSize(batchSize).setNodeId(Optional.of(nodeId)).build();
BatchInformationDAO.addBatch(tx, nodeId, batch);
tx.commit();
}
use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class FilterResultUpdater method updateFilterResults.
/**
* Updates the results of a Filter node when one of its child has added a
* new Binding Set to its results.
*
* @param tx - The transaction all Fluo queries will use. (not null)
* @param childBindingSet - A binding set that the query's child node has emitted. (not null)
* @param filterMetadata - The metadata of the Filter whose results will be updated. (not null)
* @throws Exception Something caused the update to fail.
*/
public void updateFilterResults(final TransactionBase tx, final VisibilityBindingSet childBindingSet, final FilterMetadata filterMetadata) throws Exception {
checkNotNull(tx);
checkNotNull(childBindingSet);
checkNotNull(filterMetadata);
log.trace("Transaction ID: {}\nFilter Node ID: {}\nBinding Set:\n{}\n", tx.getStartTimestamp(), filterMetadata.getNodeId(), childBindingSet);
// Parse the original query and find the Filter that represents filterId.
final String sparql = filterMetadata.getFilterSparql();
final Filter filter = FilterSerializer.deserialize(sparql);
// Evaluate whether the child BindingSet satisfies the filter's condition.
final ValueExpr condition = filter.getCondition();
if (isTrue(condition, childBindingSet)) {
// Create the Row Key for the emitted binding set. It does not contain visibilities.
final VariableOrder filterVarOrder = filterMetadata.getVariableOrder();
final Bytes resultRow = makeRowKey(filterMetadata.getNodeId(), filterVarOrder, childBindingSet);
// Serialize and emit BindingSet
final Bytes nodeValueBytes = BS_SERDE.serialize(childBindingSet);
log.trace("Transaction ID: {}\nNew Binding Set: {}\n", tx.getStartTimestamp(), childBindingSet);
tx.set(resultRow, FluoQueryColumns.FILTER_BINDING_SET, nodeValueBytes);
}
}
use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class JoinResultUpdater method getSpan.
/**
* Creates a Span for the sibling node to retrieve BindingSets to join with
* @param tx
* @param childId - Id of the node that was updated
* @param childBindingSet - BindingSet update
* @param siblingId - Id of the sibling node whose BindingSets will be retrieved and joined with the update
* @return Span to retrieve sibling node's BindingSets to form join results
*/
private Span getSpan(TransactionBase tx, final String childId, final VisibilityBindingSet childBindingSet, final String siblingId) {
// Get the common variable orders. These are used to build the prefix.
final VariableOrder childVarOrder = getVarOrder(tx, childId);
final VariableOrder siblingVarOrder = getVarOrder(tx, siblingId);
final List<String> commonVars = getCommonVars(childVarOrder, siblingVarOrder);
Bytes siblingScanPrefix = null;
if (!commonVars.isEmpty()) {
siblingScanPrefix = makeRowKey(siblingId, new VariableOrder(commonVars), childBindingSet);
} else {
siblingScanPrefix = makeRowKey(siblingId, siblingVarOrder, childBindingSet);
}
return Span.prefix(siblingScanPrefix);
}
Aggregations