use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class BindingSetStringConverter method convert.
@Override
public BindingSet convert(final String bindingSetString, final VariableOrder varOrder) {
requireNonNull(bindingSetString);
requireNonNull(varOrder);
// If both are empty, return an empty binding set.
if (bindingSetString.isEmpty() && varOrder.toString().isEmpty()) {
return new MapBindingSet();
}
// Otherwise parse it.
final String[] bindingStrings = bindingSetString.split(BINDING_DELIM);
final String[] varOrderArr = varOrder.toArray();
checkArgument(varOrderArr.length == bindingStrings.length, "The number of Bindings must match the length of the VariableOrder.");
final QueryBindingSet bindingSet = new QueryBindingSet();
for (int i = 0; i < bindingStrings.length; i++) {
final String bindingString = bindingStrings[i];
if (!NULL_VALUE_STRING.equals(bindingString)) {
final String name = varOrderArr[i];
final Value value = toValue(bindingStrings[i]);
bindingSet.addBinding(name, value);
}
}
return bindingSet;
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class AccumuloPeriodicQueryResultStorage method getRowPrefix.
private Text getRowPrefix(final long binId) throws BindingSetConversionException {
final ValueFactory vf = SimpleValueFactory.getInstance();
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding(PeriodicQueryResultStorage.PeriodicBinId, vf.createLiteral(Long.toString(binId), XMLSchema.LONG));
return new Text(converter.convert(bs, new VariableOrder(PeriodicQueryResultStorage.PeriodicBinId)));
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet 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", VF.createIRI("http://uri1"));
bs.addBinding("Y", VF.createIRI("http://uri2"));
bs.addBinding("Z", VF.createIRI("http://uri3"));
bs.addBinding("A", VF.createIRI("http://uri4"));
bs.addBinding("B", VF.createIRI("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);
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet 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", VF.createLiteral("literal1"));
bs.addBinding("Y", VF.createLiteral("5", VF.createIRI("http://www.w3.org/2001/XMLSchema#integer")));
bs.addBinding("Z", VF.createLiteral("5.0", VF.createIRI("http://www.w3.org/2001/XMLSchema#double")));
bs.addBinding("W", VF.createLiteral("1000", VF.createIRI("http://www.w3.org/2001/XMLSchema#long")));
bs.addBinding("A", VF.createIRI("http://uri1"));
bs.addBinding("B", VF.createIRI("http://uri2"));
bs.addBinding("C", VF.createIRI("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.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class AccumuloPcjSerializerTest method basicShortUriBsTest.
@Test
public void basicShortUriBsTest() throws BindingSetConversionException {
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("X", VF.createIRI("http://uri1"));
bs.addBinding("Y", VF.createIRI("http://uri2"));
final VariableOrder varOrder = new VariableOrder("X", "Y");
BindingSetConverter<byte[]> converter = new AccumuloPcjSerializer();
final byte[] byteVal = converter.convert(bs, varOrder);
final BindingSet newBs = converter.convert(byteVal, varOrder);
assertEquals(bs, newBs);
}
Aggregations