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);
}
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));
}
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);
}
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);
}
Aggregations