use of org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider in project incubator-rya by apache.
the class StatementMetadataOptimizerTest method getExpected.
private static Set<StatementMetadataNode<?>> getExpected(String query) throws MalformedQueryException {
ParsedQuery pq = parser.parseQuery(query, null);
StatementMetadataExternalSetProvider provider = new StatementMetadataExternalSetProvider(getConf(false));
List<StatementPattern> patterns = StatementPatternCollector.process(pq.getTupleExpr());
JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>(new HashSet<QueryModelNode>(patterns), new ArrayList<QueryModelNode>(patterns), new HashMap<ValueExpr, Filter>());
return new HashSet<>(provider.getExternalSets(segment));
}
use of org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider in project incubator-rya by apache.
the class StatementMetadataExternalSetProviderTest method createSingleAccumuloMetadataNode.
@Test
public void createSingleAccumuloMetadataNode() throws MalformedQueryException {
AccumuloRdfConfiguration conf = (AccumuloRdfConfiguration) getConf(false);
Set<RyaURI> propertySet = new HashSet<>();
propertySet.add(new RyaURI("http://createdBy"));
conf.setStatementMetadataProperties(propertySet);
StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf);
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq = parser.parseQuery(query, null);
List<QueryModelNode> patterns = new ArrayList<>();
List<StatementMetadataNode<?>> expected = new ArrayList<>();
Set<StatementPattern> sp = StatementMetadataTestUtils.getMetadataStatementPatterns(pq.getTupleExpr(), propertySet);
patterns.addAll(StatementPatternCollector.process(pq.getTupleExpr()));
JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>(new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>());
List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment);
expected.add(new StatementMetadataNode<>(sp, conf));
Assert.assertEquals(expected, extSets);
}
use of org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider in project incubator-rya by apache.
the class StatementMetadataExternalSetProviderTest method createMultipleMetadataNode.
@Test
public void createMultipleMetadataNode() throws MalformedQueryException {
MongoDBRdfConfiguration conf = (MongoDBRdfConfiguration) getConf(true);
Set<RyaURI> propertySet = new HashSet<>();
propertySet.add(new RyaURI("http://createdBy"));
propertySet.add(new RyaURI("http://createdOn"));
conf.setStatementMetadataProperties(propertySet);
StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf);
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq2 = parser.parseQuery(query2, null);
ParsedQuery pq3 = parser.parseQuery(query3, null);
ParsedQuery pq1 = parser.parseQuery(query, null);
List<QueryModelNode> patterns = new ArrayList<>();
List<StatementMetadataNode<?>> expected = new ArrayList<>();
Set<StatementPattern> sp1 = StatementMetadataTestUtils.getMetadataStatementPatterns(pq1.getTupleExpr(), propertySet);
Set<StatementPattern> sp3 = StatementMetadataTestUtils.getMetadataStatementPatterns(pq3.getTupleExpr(), propertySet);
// added extra blankNode into query3 to make blankNode names line up with query2. Need to remove it now so that
// StatementMetadataNode doesn't blow up because all subjects aren't the same.
removePatternWithGivenSubject("-anon-1", sp3);
patterns.addAll(StatementPatternCollector.process(pq2.getTupleExpr()));
JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>(new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>());
List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment);
expected.add(new StatementMetadataNode<>(sp1, conf));
expected.add(new StatementMetadataNode<>(sp3, conf));
Assert.assertEquals(expected, extSets);
}
use of org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider in project incubator-rya by apache.
the class StatementMetadataExternalSetProviderTest method createSingleMongoMetadataNode.
@Test
public void createSingleMongoMetadataNode() throws MalformedQueryException {
MongoDBRdfConfiguration conf = (MongoDBRdfConfiguration) getConf(true);
Set<RyaURI> propertySet = new HashSet<>();
propertySet.add(new RyaURI("http://createdBy"));
conf.setStatementMetadataProperties(propertySet);
StatementMetadataExternalSetProvider metaProvider = new StatementMetadataExternalSetProvider(conf);
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq = parser.parseQuery(query, null);
List<QueryModelNode> patterns = new ArrayList<>();
List<StatementMetadataNode<?>> expected = new ArrayList<>();
Set<StatementPattern> sp = StatementMetadataTestUtils.getMetadataStatementPatterns(pq.getTupleExpr(), propertySet);
patterns.addAll(StatementPatternCollector.process(pq.getTupleExpr()));
JoinSegment<StatementMetadataNode<?>> segment = new JoinSegment<>(new HashSet<>(patterns), patterns, new HashMap<ValueExpr, Filter>());
List<StatementMetadataNode<?>> extSets = metaProvider.getExternalSets(segment);
expected.add(new StatementMetadataNode<>(sp, conf));
Assert.assertEquals(expected, extSets);
}
Aggregations