use of org.apache.rya.indexing.pcj.fluo.app.BindingSetRow 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;
}
}
use of org.apache.rya.indexing.pcj.fluo.app.BindingSetRow in project incubator-rya by apache.
the class ConstructQueryResultObserver method process.
@Override
public void process(TransactionBase tx, Bytes row, Column col) throws Exception {
// Build row for parent that result will be written to
BindingSetRow bsRow = BindingSetRow.makeFromShardedRow(Bytes.of(CONSTRUCT_PREFIX), row);
String constructNodeId = bsRow.getNodeId();
String bsString = bsRow.getBindingSetString();
String parentNodeId = queryDao.readMetadadataEntry(tx, constructNodeId, FluoQueryColumns.CONSTRUCT_PARENT_NODE_ID).toString();
Bytes rowBytes = BindingHashShardingFunction.getShardedScanPrefix(parentNodeId, bsString);
// Get NodeType of the parent node
NodeType parentType = NodeType.fromNodeId(parentNodeId).get();
// Get data for the ConstructQuery result
Bytes bytes = tx.get(row, col);
// Write result to parent
tx.set(rowBytes, parentType.getResultColumn(), bytes);
}
use of org.apache.rya.indexing.pcj.fluo.app.BindingSetRow in project incubator-rya by apache.
the class BindingHashShardingFunctionTest method bindingSetRowTest.
@Test
public void bindingSetRowTest() {
String nodeId = NodeType.generateNewFluoIdForType(NodeType.STATEMENT_PATTERN);
QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("entity", vf.createURI("urn:entity"));
bs.addBinding("location", vf.createLiteral("location_1"));
VisibilityBindingSet vBs = new VisibilityBindingSet(bs);
VariableOrder varOrder = new VariableOrder("entity", "location");
Bytes row = RowKeyUtil.makeRowKey(nodeId, varOrder, vBs);
Bytes shardedRow = BindingHashShardingFunction.addShard(nodeId, varOrder, vBs);
BindingSetRow expected = BindingSetRow.make(row);
BindingSetRow actual = BindingSetRow.makeFromShardedRow(Bytes.of(SP_PREFIX), shardedRow);
Assert.assertEquals(expected, actual);
}
Aggregations