Search in sources :

Example 6 with AccumuloPcjSerializer

use of org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer in project incubator-rya by apache.

the class AccumuloPcjSerializerTest method basicMixUriLiteralBsTest.

@Test
public void basicMixUriLiteralBsTest() throws BindingSetConversionException {
    final QueryBindingSet bs = new QueryBindingSet();
    bs.addBinding("X", new LiteralImpl("literal1"));
    bs.addBinding("Y", new LiteralImpl("5", new URIImpl("http://www.w3.org/2001/XMLSchema#integer")));
    bs.addBinding("Z", new LiteralImpl("5.0", new URIImpl("http://www.w3.org/2001/XMLSchema#double")));
    bs.addBinding("W", new LiteralImpl("1000", new URIImpl("http://www.w3.org/2001/XMLSchema#long")));
    bs.addBinding("A", new URIImpl("http://uri1"));
    bs.addBinding("B", new URIImpl("http://uri2"));
    bs.addBinding("C", new URIImpl("http://uri3"));
    final VariableOrder varOrder = new VariableOrder("A", "W", "X", "Y", "Z", "B", "C");
    BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
    final byte[] byteVal = converter.convert(bs, varOrder);
    final BindingSet newBs = converter.convert(byteVal, varOrder);
    assertEquals(bs, newBs);
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) BindingSet(org.openrdf.query.BindingSet) MapBindingSet(org.openrdf.query.impl.MapBindingSet) AccumuloPcjSerializer(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) URIImpl(org.openrdf.model.impl.URIImpl) QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) Test(org.junit.Test)

Example 7 with AccumuloPcjSerializer

use of org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer in project incubator-rya by apache.

the class AccumuloIndexSet method getRange.

private Range getRange(final String commonVarOrder, final BindingSet bs) throws BindingSetConversionException {
    final AccumuloPcjSerializer converter = new AccumuloPcjSerializer();
    byte[] rangePrefix = new byte[0];
    rangePrefix = converter.convert(bs, new VariableOrder(commonVarOrder));
    return Range.prefix(new Text(rangePrefix));
}
Also used : AccumuloPcjSerializer(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) Text(org.apache.hadoop.io.Text)

Example 8 with AccumuloPcjSerializer

use of org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer in project incubator-rya by apache.

the class AccumuloPcjSerializerTest method serialize_bindingsSubsetOfVarOrder.

/**
 * The BindingSet has fewer Bindings than there are variables in the variable
 * order, but they are all in the variable order. This is the case where
 * the missing bindings were optional.
 */
@Test
public void serialize_bindingsSubsetOfVarOrder() throws BindingSetConversionException {
    // Setup the Binding Set.
    final MapBindingSet originalBindingSet = new MapBindingSet();
    originalBindingSet.addBinding("x", new URIImpl("http://a"));
    originalBindingSet.addBinding("y", new URIImpl("http://b"));
    // Setup the variable order.
    final VariableOrder varOrder = new VariableOrder("x", "a", "y", "b");
    // Create the byte[] representation of the BindingSet.
    BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
    byte[] serialized = converter.convert(originalBindingSet, varOrder);
    // Deserialize the byte[] back into the binding set.
    BindingSet deserialized = converter.convert(serialized, varOrder);
    // Ensure the deserialized value matches the original.
    assertEquals(originalBindingSet, deserialized);
}
Also used : QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) BindingSet(org.openrdf.query.BindingSet) MapBindingSet(org.openrdf.query.impl.MapBindingSet) AccumuloPcjSerializer(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) URIImpl(org.openrdf.model.impl.URIImpl) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Test(org.junit.Test)

Example 9 with AccumuloPcjSerializer

use of org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer in project incubator-rya by apache.

the class AccumuloPcjSerializerTest method basicLongMixLiteralBsTest.

@Test
public void basicLongMixLiteralBsTest() throws BindingSetConversionException {
    final QueryBindingSet bs = new QueryBindingSet();
    bs.addBinding("X", new LiteralImpl("literal1"));
    bs.addBinding("Y", new LiteralImpl("5", new URIImpl("http://www.w3.org/2001/XMLSchema#integer")));
    bs.addBinding("Z", new LiteralImpl("5.0", new URIImpl("http://www.w3.org/2001/XMLSchema#double")));
    bs.addBinding("W", new LiteralImpl("1000", new URIImpl("http://www.w3.org/2001/XMLSchema#long")));
    final VariableOrder varOrder = new VariableOrder("W", "X", "Y", "Z");
    BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
    final byte[] byteVal = converter.convert(bs, varOrder);
    final BindingSet newBs = converter.convert(byteVal, varOrder);
    assertEquals(bs, newBs);
}
Also used : LiteralImpl(org.openrdf.model.impl.LiteralImpl) QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) BindingSet(org.openrdf.query.BindingSet) MapBindingSet(org.openrdf.query.impl.MapBindingSet) AccumuloPcjSerializer(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer) VariableOrder(org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder) URIImpl(org.openrdf.model.impl.URIImpl) QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) Test(org.junit.Test)

Aggregations

AccumuloPcjSerializer (org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjSerializer)9 VariableOrder (org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder)9 Test (org.junit.Test)8 BindingSet (org.openrdf.query.BindingSet)8 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)8 MapBindingSet (org.openrdf.query.impl.MapBindingSet)8 URIImpl (org.openrdf.model.impl.URIImpl)7 LiteralImpl (org.openrdf.model.impl.LiteralImpl)4 Text (org.apache.hadoop.io.Text)1