use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class JoinObserver method parseObservation.
@Override
public Observation parseObservation(final TransactionBase tx, final Bytes row) throws Exception {
requireNonNull(tx);
requireNonNull(row);
// Read the Join metadata.
final String joinNodeId = BindingSetRow.makeFromShardedRow(Bytes.of(JOIN_PREFIX), row).getNodeId();
final JoinMetadata joinMetadata = queryDao.readJoinMetadata(tx, joinNodeId);
// Read the Visibility Binding Set from the value.
final Bytes valueBytes = tx.get(row, FluoQueryColumns.JOIN_BINDING_SET);
final VisibilityBindingSet joinBindingSet = BS_SERDE.deserialize(valueBytes);
// Figure out which node needs to handle the new metadata.
final String parentNodeId = joinMetadata.getParentNodeId();
return new Observation(joinNodeId, joinBindingSet, parentNodeId);
}
use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class BindingHashShardingFunctionTest method shardAddAndRemoveTest.
@Test
public void shardAddAndRemoveTest() {
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);
Bytes shardlessRow = BindingHashShardingFunction.removeHash(Bytes.of(SP_PREFIX), shardedRow);
Assert.assertEquals(row, shardlessRow);
}
use of org.apache.fluo.api.data.Bytes in project incubator-rya by apache.
the class TriplePrefixUtilsTest method testAddRemovePrefix.
@Test
public void testAddRemovePrefix() throws TripleRowResolverException {
byte[] expected = Bytes.of("triple").toArray();
Bytes fluoBytes = TriplePrefixUtils.addTriplePrefixAndConvertToBytes(expected);
byte[] returned = TriplePrefixUtils.removeTriplePrefixAndConvertToByteArray(fluoBytes);
Assert.assertEquals(true, Arrays.equals(expected, returned));
}
use of org.apache.fluo.api.data.Bytes 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.fluo.api.data.Bytes in project incubator-rya by apache.
the class ProjectionObserver method parseObservation.
@Override
public Observation parseObservation(final TransactionBase tx, final Bytes row) throws Exception {
requireNonNull(tx);
requireNonNull(row);
// Read the Filter metadata.
final String projectionNodeId = BindingSetRow.makeFromShardedRow(Bytes.of(PROJECTION_PREFIX), row).getNodeId();
final ProjectionMetadata projectionMetadata = queryDao.readProjectionMetadata(tx, projectionNodeId);
// Read the Visibility Binding Set from the value.
final Bytes valueBytes = tx.get(row, FluoQueryColumns.PROJECTION_BINDING_SET);
final VisibilityBindingSet projectionBindingSet = BS_SERDE.deserialize(valueBytes);
// Figure out which node needs to handle the new metadata.
final String parentNodeId = projectionMetadata.getParentNodeId();
return new Observation(projectionNodeId, projectionBindingSet, parentNodeId);
}
Aggregations