Search in sources :

Example 31 with TripleRow

use of org.apache.rya.api.resolver.triple.TripleRow in project incubator-rya by apache.

the class HashedSpoWholeRowTriplePatternStrategyTest method testSp.

public void testSp() throws Exception {
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = ryaTripleContext.serializeTriple(new RyaStatement(uri, uri, uri, null));
    TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO);
    Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, ByteRange> entry = strategy.defineRange(uri, uri, null, null, null);
    assertContains(entry.getValue(), tripleRow.getRow());
    entry = strategy.defineRange(uri, uri2, null, null, null);
    assertContainsFalse(entry.getValue(), tripleRow.getRow());
}
Also used : TripleRow(org.apache.rya.api.resolver.triple.TripleRow) ByteRange(org.apache.rya.api.query.strategy.ByteRange) RyaStatement(org.apache.rya.api.domain.RyaStatement) Map(java.util.Map)

Example 32 with TripleRow

use of org.apache.rya.api.resolver.triple.TripleRow in project incubator-rya by apache.

the class RyaContextTest method testHashedTripleRowSerialization.

public void testHashedTripleRowSerialization() throws Exception {
    RyaURI subj = new RyaURI("urn:test#subj");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaType obj = new RyaType("mydata");
    RyaStatement statement = new RyaStatement(subj, pred, obj);
    MockRdfCloudConfiguration config = new MockRdfCloudConfiguration();
    config.set(MockRdfCloudConfiguration.CONF_PREFIX_ROW_WITH_HASH, Boolean.TRUE.toString());
    RyaTripleContext instance = RyaTripleContext.getInstance(config);
    Map<TABLE_LAYOUT, TripleRow> map = instance.serializeTriple(statement);
    TripleRow tripleRow = map.get(TABLE_LAYOUT.SPO);
    assertEquals(statement, instance.deserializeTriple(TABLE_LAYOUT.SPO, tripleRow));
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) TABLE_LAYOUT(org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) MockRdfCloudConfiguration(org.apache.rya.api.query.strategy.wholerow.MockRdfCloudConfiguration)

Example 33 with TripleRow

use of org.apache.rya.api.resolver.triple.TripleRow in project incubator-rya by apache.

the class WholeRowTripleResolverTest method testSerializePO.

public void testSerializePO() throws Exception {
    RdfCloudTripleStoreConstants.TABLE_LAYOUT po = RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO;
    // no context
    RyaURI subj = new RyaURI("urn:test#1234");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaURI obj = new RyaURI("urn:test#obj");
    RyaURI cntxt = new RyaURI("urn:test#cntxt");
    final RyaStatement stmt = new RyaStatement(subj, pred, obj, null, null, null, null, 100l);
    final RyaStatement stmtContext = new RyaStatement(subj, pred, obj, cntxt, null, null, null, 100l);
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = tripleResolver.serialize(stmt);
    TripleRow tripleRow = serialize.get(po);
    RyaStatement deserialize = tripleResolver.deserialize(po, tripleRow);
    assertEquals(stmt, deserialize);
    // context
    serialize = tripleResolver.serialize(stmtContext);
    tripleRow = serialize.get(po);
    deserialize = tripleResolver.deserialize(po, tripleRow);
    assertEquals(stmtContext, deserialize);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) RyaStatement(org.apache.rya.api.domain.RyaStatement) RdfCloudTripleStoreConstants(org.apache.rya.api.RdfCloudTripleStoreConstants)

Example 34 with TripleRow

use of org.apache.rya.api.resolver.triple.TripleRow in project incubator-rya by apache.

the class WholeRowTripleResolverTest method testSerialize.

public void testSerialize() throws Exception {
    // no context
    RyaURI subj = new RyaURI("urn:test#1234");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaURI obj = new RyaURI("urn:test#obj");
    RyaURI cntxt = new RyaURI("urn:test#cntxt");
    final RyaStatement stmt = new RyaStatement(subj, pred, obj, null, null, null, null, 100l);
    final RyaStatement stmtContext = new RyaStatement(subj, pred, obj, cntxt, null, null, null, 100l);
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = tripleResolver.serialize(stmt);
    TripleRow tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO);
    RyaStatement deserialize = tripleResolver.deserialize(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, tripleRow);
    assertEquals(stmt, deserialize);
    // context
    serialize = tripleResolver.serialize(stmtContext);
    tripleRow = serialize.get(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO);
    deserialize = tripleResolver.deserialize(RdfCloudTripleStoreConstants.TABLE_LAYOUT.SPO, tripleRow);
    assertEquals(stmtContext, deserialize);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 35 with TripleRow

use of org.apache.rya.api.resolver.triple.TripleRow in project incubator-rya by apache.

the class HashedWholeRowTripleResolverTest method testSerializeOSP.

public void testSerializeOSP() throws Exception {
    RdfCloudTripleStoreConstants.TABLE_LAYOUT po = RdfCloudTripleStoreConstants.TABLE_LAYOUT.OSP;
    // no context
    RyaURI subj = new RyaURI("urn:test#1234");
    RyaURI pred = new RyaURI("urn:test#pred");
    RyaURI obj = new RyaURI("urn:test#obj");
    RyaURI cntxt = new RyaURI("urn:test#cntxt");
    final RyaStatement stmt = new RyaStatement(subj, pred, obj, null, null, null, null, 100l);
    final RyaStatement stmtContext = new RyaStatement(subj, pred, obj, cntxt, null, null, null, 100l);
    Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize = tripleResolver.serialize(stmt);
    TripleRow tripleRow = serialize.get(po);
    RyaStatement deserialize = tripleResolver.deserialize(po, tripleRow);
    assertEquals(stmt, deserialize);
    // context
    serialize = tripleResolver.serialize(stmtContext);
    tripleRow = serialize.get(po);
    deserialize = tripleResolver.deserialize(po, tripleRow);
    assertEquals(stmtContext, deserialize);
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) RyaStatement(org.apache.rya.api.domain.RyaStatement) RdfCloudTripleStoreConstants(org.apache.rya.api.RdfCloudTripleStoreConstants)

Aggregations

TripleRow (org.apache.rya.api.resolver.triple.TripleRow)55 RyaStatement (org.apache.rya.api.domain.RyaStatement)42 RyaURI (org.apache.rya.api.domain.RyaURI)21 Map (java.util.Map)19 TABLE_LAYOUT (org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT)17 Key (org.apache.accumulo.core.data.Key)14 Value (org.apache.accumulo.core.data.Value)13 ByteRange (org.apache.rya.api.query.strategy.ByteRange)13 TripleRowResolverException (org.apache.rya.api.resolver.triple.TripleRowResolverException)13 RyaType (org.apache.rya.api.domain.RyaType)11 RdfCloudTripleStoreConstants (org.apache.rya.api.RdfCloudTripleStoreConstants)8 Test (org.junit.Test)8 IOException (java.io.IOException)7 Text (org.apache.hadoop.io.Text)7 Mutation (org.apache.accumulo.core.data.Mutation)6 Scanner (org.apache.accumulo.core.client.Scanner)5 Authorizations (org.apache.accumulo.core.security.Authorizations)5 IntWritable (org.apache.hadoop.io.IntWritable)5 HashMap (java.util.HashMap)4 BatchWriter (org.apache.accumulo.core.client.BatchWriter)4