use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class AccumuloPcjSerializerTest method basicShortMixLiteralBsTest.
@Test
public void basicShortMixLiteralBsTest() 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")));
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);
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class AccumuloPcjSerializerTest method basicShortStringLiteralBsTest.
@Test
public void basicShortStringLiteralBsTest() throws BindingSetConversionException {
final QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("X", VF.createLiteral("literal1"));
bs.addBinding("Y", VF.createLiteral("literal2"));
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);
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class BindingHashShardingFunctionTest method shardAddAndRemoveTest.
@Test
public void shardAddAndRemoveTest() {
String nodeId = NodeType.generateNewFluoIdForType(NodeType.STATEMENT_PATTERN);
QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("entity", VF.createIRI("urn:entity"));
bs.addBinding("location", VF.createLiteral("location_1"));
VisibilityBindingSet vBs = new VisibilityBindingSet(bs);
VariableOrder varOrder = new VariableOrder("entity", "location");
Bytes row = RowKeyUtil.makeRowKey(nodeId, varOrder, vBs);
Bytes shardedRow = BindingHashShardingFunction.addShard(nodeId, varOrder, vBs);
Bytes shardlessRow = BindingHashShardingFunction.removeHash(Bytes.of(SP_PREFIX), shardedRow);
Assert.assertEquals(row, shardlessRow);
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class ConstructGraphTest method testConstructGraph.
@Test
public void testConstructGraph() throws MalformedQueryException, UnsupportedEncodingException {
String query = "select ?x where { ?x <uri:talksTo> <uri:Bob>. ?y <uri:worksAt> ?z }";
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq = parser.parseQuery(query, null);
List<StatementPattern> patterns = StatementPatternCollector.process(pq.getTupleExpr());
ConstructGraph graph = new ConstructGraph(patterns);
QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("x", VF.createIRI("uri:Joe"));
bs.addBinding("y", VF.createIRI("uri:Bob"));
bs.addBinding("z", VF.createIRI("uri:BurgerShack"));
VisibilityBindingSet vBs = new VisibilityBindingSet(bs, "FOUO");
Set<RyaStatement> statements = graph.createGraphFromBindingSet(vBs);
RyaStatement statement1 = new RyaStatement(new RyaIRI("uri:Joe"), new RyaIRI("uri:talksTo"), new RyaIRI("uri:Bob"));
RyaStatement statement2 = new RyaStatement(new RyaIRI("uri:Bob"), new RyaIRI("uri:worksAt"), new RyaIRI("uri:BurgerShack"));
Set<RyaStatement> expected = Sets.newHashSet(Arrays.asList(statement1, statement2));
expected.forEach(x -> x.setColumnVisibility("FOUO".getBytes()));
ConstructGraphTestUtils.ryaStatementSetsEqualIgnoresTimestamp(expected, statements);
}
use of org.eclipse.rdf4j.query.algebra.evaluation.QueryBindingSet in project incubator-rya by apache.
the class ConstructGraphTest method testConstructGraphBNode.
@Test
public void testConstructGraphBNode() throws MalformedQueryException {
String query = "select ?x where { _:b <uri:talksTo> ?x. _:b <uri:worksAt> ?z }";
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq = parser.parseQuery(query, null);
List<StatementPattern> patterns = StatementPatternCollector.process(pq.getTupleExpr());
ConstructGraph graph = new ConstructGraph(patterns);
QueryBindingSet bs = new QueryBindingSet();
bs.addBinding("x", VF.createIRI("uri:Joe"));
bs.addBinding("z", VF.createIRI("uri:BurgerShack"));
VisibilityBindingSet vBs = new VisibilityBindingSet(bs, "FOUO");
Set<RyaStatement> statements = graph.createGraphFromBindingSet(vBs);
Set<RyaStatement> statements2 = graph.createGraphFromBindingSet(vBs);
RyaIRI subject = null;
for (RyaStatement statement : statements) {
RyaIRI subjURI = statement.getSubject();
if (subject == null) {
subject = subjURI;
} else {
assertEquals(subjURI, subject);
}
}
RyaIRI subject2 = null;
for (RyaStatement statement : statements2) {
RyaIRI subjURI = statement.getSubject();
if (subject2 == null) {
subject2 = subjURI;
} else {
assertEquals(subjURI, subject2);
}
}
assertTrue(!subject.equals(subject2));
ConstructGraphTestUtils.ryaStatementsEqualIgnoresBlankNode(statements, statements2);
}
Aggregations