use of org.apache.rya.indexing.pcj.fluo.app.NodeType in project incubator-rya by apache.
the class FluoBinPruner method pruneBindingSetBin.
/**
* This method deletes BindingSets in the specified bin from the BindingSet
* Column of the indicated Fluo nodeId
*
* @param id
* - Fluo nodeId
* @param bin
* - bin id
*/
@Override
public void pruneBindingSetBin(final NodeBin nodeBin) {
final String id = nodeBin.getNodeId();
final long bin = nodeBin.getBin();
try (Transaction tx = client.newTransaction()) {
final Optional<NodeType> type = NodeType.fromNodeId(id);
if (!type.isPresent()) {
log.trace("Unable to determine NodeType from id: " + id);
throw new RuntimeException();
}
final Column batchInfoColumn = type.get().getResultColumn();
final Bytes batchInfoSpanPrefix = BindingHashShardingFunction.getShardedScanPrefix(id, vf.createLiteral(bin));
final SpanBatchDeleteInformation batchInfo = SpanBatchDeleteInformation.builder().setColumn(batchInfoColumn).setSpan(Span.prefix(batchInfoSpanPrefix)).build();
BatchInformationDAO.addBatch(tx, id, batchInfo);
tx.commit();
}
}
use of org.apache.rya.indexing.pcj.fluo.app.NodeType in project incubator-rya by apache.
the class GetQueryReport method countBindingSets.
private BigInteger countBindingSets(final SnapshotBase sx, final String nodeId, final Column bindingSetColumn) {
checkNotNull(sx);
checkNotNull(nodeId);
checkNotNull(bindingSetColumn);
NodeType type = NodeType.fromNodeId(nodeId).get();
Bytes prefixBytes = Bytes.of(type.getNodeTypePrefix());
// Limit the scan to the binding set column and node id.
final RowScanner rows = sx.scanner().over(Span.prefix(prefixBytes)).fetch(bindingSetColumn).byRow().build();
BigInteger count = BigInteger.valueOf(0L);
for (ColumnScanner columns : rows) {
String row = BindingSetRow.makeFromShardedRow(prefixBytes, columns.getRow()).getNodeId();
if (row.equals(nodeId)) {
count = count.add(BigInteger.ONE);
}
}
return count;
}
use of org.apache.rya.indexing.pcj.fluo.app.NodeType in project incubator-rya by apache.
the class PeriodicNotificationProvider method getQueryIdFromPeriodicId.
private String getQueryIdFromPeriodicId(Snapshot sx, String nodeId) {
NodeType nodeType = NodeType.fromNodeId(nodeId).orNull();
String id = null;
switch(nodeType) {
case FILTER:
id = getQueryIdFromPeriodicId(sx, sx.get(Bytes.of(nodeId), FluoQueryColumns.FILTER_PARENT_NODE_ID).toString());
break;
case PERIODIC_QUERY:
id = getQueryIdFromPeriodicId(sx, sx.get(Bytes.of(nodeId), FluoQueryColumns.PERIODIC_QUERY_PARENT_NODE_ID).toString());
break;
case QUERY:
id = FluoQueryUtils.convertFluoQueryIdToPcjId(nodeId);
break;
case AGGREGATION:
id = getQueryIdFromPeriodicId(sx, sx.get(Bytes.of(nodeId), FluoQueryColumns.AGGREGATION_PARENT_NODE_ID).toString());
break;
case CONSTRUCT:
id = getQueryIdFromPeriodicId(sx, sx.get(Bytes.of(nodeId), FluoQueryColumns.CONSTRUCT_PARENT_NODE_ID).toString());
break;
case PROJECTION:
id = getQueryIdFromPeriodicId(sx, sx.get(Bytes.of(nodeId), FluoQueryColumns.PROJECTION_PARENT_NODE_ID).toString());
break;
default:
throw new IllegalArgumentException("Invalid node type");
}
return id;
}
use of org.apache.rya.indexing.pcj.fluo.app.NodeType in project incubator-rya by apache.
the class BatchIT method createSpanBatches.
private void createSpanBatches(FluoClient fluoClient, List<String> ids, List<String> prefixes, int batchSize) {
Preconditions.checkArgument(ids.size() == prefixes.size());
try (Transaction tx = fluoClient.newTransaction()) {
for (int i = 0; i < ids.size(); i++) {
String id = ids.get(i);
String bsPrefix = prefixes.get(i);
URI uri = vf.createURI(bsPrefix);
Bytes prefixBytes = BindingHashShardingFunction.getShardedScanPrefix(id, uri);
NodeType type = NodeType.fromNodeId(id).get();
Column bsCol = type.getResultColumn();
SpanBatchDeleteInformation.Builder builder = SpanBatchDeleteInformation.builder().setBatchSize(batchSize).setColumn(bsCol);
if (type == NodeType.JOIN) {
builder.setSpan(Span.prefix(type.getNodeTypePrefix()));
builder.setNodeId(java.util.Optional.of(id));
} else {
builder.setSpan(Span.prefix(prefixBytes));
}
BatchInformationDAO.addBatch(tx, id, builder.build());
}
tx.commit();
}
}
use of org.apache.rya.indexing.pcj.fluo.app.NodeType in project incubator-rya by apache.
the class BatchIT method countResults.
private int countResults(FluoClient fluoClient, String nodeId, Column bsColumn) {
try (Transaction tx = fluoClient.newTransaction()) {
int count = 0;
Optional<NodeType> type = NodeType.fromNodeId(nodeId);
Bytes prefixBytes = Bytes.of(type.get().getNodeTypePrefix());
RowScanner scanner = tx.scanner().over(Span.prefix(prefixBytes)).fetch(bsColumn).byRow().build();
Iterator<ColumnScanner> colScanners = scanner.iterator();
while (colScanners.hasNext()) {
ColumnScanner colScanner = colScanners.next();
BindingSetRow bsRow = BindingSetRow.makeFromShardedRow(prefixBytes, colScanner.getRow());
if (bsRow.getNodeId().equals(nodeId)) {
Iterator<ColumnValue> vals = colScanner.iterator();
while (vals.hasNext()) {
vals.next();
count++;
}
}
}
tx.commit();
return count;
}
}
Aggregations