Search in sources :

Example 56 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjSerializerTest method serialize_bindingNotInVariableOrder.

/**
 * The BindingSet has more Bindings than there are variables in the variable order.
 * This is the case where a Group By clause does not include all of the Bindings that
 * are in the Binding Set.
 */
@Test
public void serialize_bindingNotInVariableOrder() throws RyaTypeResolverException, BindingSetConversionException {
    // Setup the Binding Set.
    final MapBindingSet originalBindingSet = new MapBindingSet();
    originalBindingSet.addBinding("x", new URIImpl("http://a"));
    originalBindingSet.addBinding("y", new URIImpl("http://b"));
    originalBindingSet.addBinding("z", new URIImpl("http://d"));
    // Setup the variable order.
    final VariableOrder varOrder = new VariableOrder("x", "y");
    // Serialize the Binding Set.
    BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
    byte[] serialized = converter.convert(originalBindingSet, varOrder);
    // Deserialize it again.
    BindingSet deserialized = converter.convert(serialized, varOrder);
    // Show that it only contains the bindings that were part of the Variable Order.
    MapBindingSet expected = new MapBindingSet();
    expected.addBinding("x", new URIImpl("http://a"));
    expected.addBinding("y", new URIImpl("http://b"));
    assertEquals(expected, 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 57 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class AccumuloPcjSerializerTest method basicLongUriBsTest.

@Test
public void basicLongUriBsTest() throws BindingSetConversionException {
    final QueryBindingSet bs = new QueryBindingSet();
    bs.addBinding("X", new URIImpl("http://uri1"));
    bs.addBinding("Y", new URIImpl("http://uri2"));
    bs.addBinding("Z", new URIImpl("http://uri3"));
    bs.addBinding("A", new URIImpl("http://uri4"));
    bs.addBinding("B", new URIImpl("http://uri5"));
    final VariableOrder varOrder = new VariableOrder("X", "Y", "Z", "A", "B");
    BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
    final byte[] byteVal = converter.convert(bs, varOrder);
    final BindingSet newBs = converter.convert(byteVal, varOrder);
    assertEquals(bs, newBs);
}
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) QueryBindingSet(org.openrdf.query.algebra.evaluation.QueryBindingSet) Test(org.junit.Test)

Example 58 with URIImpl

use of org.openrdf.model.impl.URIImpl 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 59 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class VisibilityBindingSetStringConverterTest method fromString.

@Test
public void fromString() throws BindingSetConversionException {
    // Setup the String that will be converted.
    final String bindingSetString = "http://b<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::" + "http://c<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::" + "http://a<<~>>http://www.w3.org/2001/XMLSchema#anyURI" + VISIBILITY_DELIM + "A&B";
    // Convert it to a BindingSet
    final VariableOrder varOrder = new VariableOrder("y", "z", "x");
    final VisibilityBindingSetStringConverter converter = new VisibilityBindingSetStringConverter();
    final BindingSet bindingSet = converter.convert(bindingSetString, varOrder);
    // Ensure it converted to the expected result.
    final MapBindingSet expected = new MapBindingSet();
    expected.addBinding("z", new URIImpl("http://c"));
    expected.addBinding("y", new URIImpl("http://b"));
    expected.addBinding("x", new URIImpl("http://a"));
    final VisibilityBindingSet visiSet = new VisibilityBindingSet(expected, "A&B");
    assertEquals(visiSet, bindingSet);
}
Also used : VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) BindingSet(org.openrdf.query.BindingSet) MapBindingSet(org.openrdf.query.impl.MapBindingSet) VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) URIImpl(org.openrdf.model.impl.URIImpl) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Test(org.junit.Test)

Example 60 with URIImpl

use of org.openrdf.model.impl.URIImpl in project incubator-rya by apache.

the class VisibilityBindingSetStringConverterTest method toString_URIs.

@Test
public void toString_URIs() throws BindingSetConversionException {
    // Setup the binding set that will be converted.
    final MapBindingSet originalBindingSet = new MapBindingSet();
    originalBindingSet.addBinding("x", new URIImpl("http://a"));
    originalBindingSet.addBinding("y", new URIImpl("http://b"));
    originalBindingSet.addBinding("z", new URIImpl("http://c"));
    final VisibilityBindingSet visiSet = new VisibilityBindingSet(originalBindingSet, "A&B&C");
    // Convert it to a String.
    final VariableOrder varOrder = new VariableOrder("y", "z", "x");
    final VisibilityBindingSetStringConverter converter = new VisibilityBindingSetStringConverter();
    final String bindingSetString = converter.convert(visiSet, varOrder);
    // Ensure it converted to the expected result.l
    final String expected = "http://b<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::" + "http://c<<~>>http://www.w3.org/2001/XMLSchema#anyURI:::" + "http://a<<~>>http://www.w3.org/2001/XMLSchema#anyURI" + VISIBILITY_DELIM + "A&B&C";
    assertEquals(expected, bindingSetString);
}
Also used : VisibilityBindingSet(org.apache.rya.api.model.VisibilityBindingSet) URIImpl(org.openrdf.model.impl.URIImpl) MapBindingSet(org.openrdf.query.impl.MapBindingSet) Test(org.junit.Test)

Aggregations

URIImpl (org.openrdf.model.impl.URIImpl)170 Test (org.junit.Test)120 LiteralImpl (org.openrdf.model.impl.LiteralImpl)62 URI (org.openrdf.model.URI)58 BindingSet (org.openrdf.query.BindingSet)50 MapBindingSet (org.openrdf.query.impl.MapBindingSet)36 RyaURI (org.apache.rya.api.domain.RyaURI)33 HashSet (java.util.HashSet)31 Statement (org.openrdf.model.Statement)30 QueryBindingSet (org.openrdf.query.algebra.evaluation.QueryBindingSet)30 ArrayList (java.util.ArrayList)29 RyaType (org.apache.rya.api.domain.RyaType)25 VisibilityBindingSet (org.apache.rya.api.model.VisibilityBindingSet)24 RyaStatement (org.apache.rya.api.domain.RyaStatement)23 Value (org.openrdf.model.Value)22 NumericLiteralImpl (org.openrdf.model.impl.NumericLiteralImpl)22 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)21 StatementPattern (org.openrdf.query.algebra.StatementPattern)20 StatementImpl (org.openrdf.model.impl.StatementImpl)19 PcjMetadata (org.apache.rya.indexing.pcj.storage.PcjMetadata)16