Search in sources :

Example 21 with Bytes

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);
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) JoinMetadata(org.apache.rya.indexing.pcj.fluo.app.query.JoinMetadata)

Example 22 with Bytes

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);
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) Test(org.junit.Test)

Example 23 with Bytes

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));
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) Test(org.junit.Test)

Example 24 with Bytes

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);
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) NodeType(org.apache.rya.indexing.pcj.fluo.app.NodeType) BindingSetRow(org.apache.rya.indexing.pcj.fluo.app.BindingSetRow)

Example 25 with 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);
}
Also used : Bytes(org.apache.fluo.api.data.Bytes) VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) ProjectionMetadata(org.apache.rya.indexing.pcj.fluo.app.query.ProjectionMetadata)

Aggregations

Bytes (org.apache.fluo.api.data.Bytes)43 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)16 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)14 Column (org.apache.fluo.api.data.Column)9 Test (org.junit.Test)9 ColumnScanner (org.apache.fluo.api.client.scanner.ColumnScanner)8 RowScanner (org.apache.fluo.api.client.scanner.RowScanner)8 NodeType (org.apache.rya.indexing.pcj.fluo.app.NodeType)8 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)6 FluoClient (org.apache.fluo.api.client.FluoClient)5 ColumnValue (org.apache.fluo.api.data.ColumnValue)5 RowColumn (org.apache.fluo.api.data.RowColumn)5 Span (org.apache.fluo.api.data.Span)5 Transaction (org.apache.fluo.api.client.Transaction)4 RyaStatement (org.apache.rya.api.domain.RyaStatement)4 HashSet (java.util.HashSet)3 Snapshot (org.apache.fluo.api.client.Snapshot)3 RyaURI (org.apache.rya.api.domain.RyaURI)3 JoinBatchInformation (org.apache.rya.indexing.pcj.fluo.app.batch.JoinBatchInformation)3 SpanBatchDeleteInformation (org.apache.rya.indexing.pcj.fluo.app.batch.SpanBatchDeleteInformation)3