Search in sources :

Example 1 with JoinSegment

use of org.apache.rya.indexing.external.matching.JoinSegment 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));
}
Also used : ValueExpr(org.openrdf.query.algebra.ValueExpr) ParsedQuery(org.openrdf.query.parser.ParsedQuery) QueryModelNode(org.openrdf.query.algebra.QueryModelNode) JoinSegment(org.apache.rya.indexing.external.matching.JoinSegment) StatementMetadataExternalSetProvider(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider) StatementPattern(org.openrdf.query.algebra.StatementPattern) StatementMetadataNode(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataNode) Filter(org.openrdf.query.algebra.Filter) HashSet(java.util.HashSet)

Example 2 with JoinSegment

use of org.apache.rya.indexing.external.matching.JoinSegment 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);
}
Also used : ValueExpr(org.openrdf.query.algebra.ValueExpr) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) ArrayList(java.util.ArrayList) QueryModelNode(org.openrdf.query.algebra.QueryModelNode) JoinSegment(org.apache.rya.indexing.external.matching.JoinSegment) StatementMetadataExternalSetProvider(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) RyaURI(org.apache.rya.api.domain.RyaURI) StatementMetadataNode(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataNode) StatementPattern(org.openrdf.query.algebra.StatementPattern) Filter(org.openrdf.query.algebra.Filter) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with JoinSegment

use of org.apache.rya.indexing.external.matching.JoinSegment 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);
}
Also used : ValueExpr(org.openrdf.query.algebra.ValueExpr) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) ArrayList(java.util.ArrayList) QueryModelNode(org.openrdf.query.algebra.QueryModelNode) JoinSegment(org.apache.rya.indexing.external.matching.JoinSegment) StatementMetadataExternalSetProvider(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider) RyaURI(org.apache.rya.api.domain.RyaURI) StatementMetadataNode(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataNode) StatementPattern(org.openrdf.query.algebra.StatementPattern) Filter(org.openrdf.query.algebra.Filter) MongoDBRdfConfiguration(org.apache.rya.mongodb.MongoDBRdfConfiguration) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with JoinSegment

use of org.apache.rya.indexing.external.matching.JoinSegment 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);
}
Also used : ValueExpr(org.openrdf.query.algebra.ValueExpr) SPARQLParser(org.openrdf.query.parser.sparql.SPARQLParser) ParsedQuery(org.openrdf.query.parser.ParsedQuery) ArrayList(java.util.ArrayList) QueryModelNode(org.openrdf.query.algebra.QueryModelNode) JoinSegment(org.apache.rya.indexing.external.matching.JoinSegment) StatementMetadataExternalSetProvider(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider) RyaURI(org.apache.rya.api.domain.RyaURI) StatementMetadataNode(org.apache.rya.indexing.statement.metadata.matching.StatementMetadataNode) StatementPattern(org.openrdf.query.algebra.StatementPattern) Filter(org.openrdf.query.algebra.Filter) MongoDBRdfConfiguration(org.apache.rya.mongodb.MongoDBRdfConfiguration) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)4 JoinSegment (org.apache.rya.indexing.external.matching.JoinSegment)4 StatementMetadataExternalSetProvider (org.apache.rya.indexing.statement.metadata.matching.StatementMetadataExternalSetProvider)4 StatementMetadataNode (org.apache.rya.indexing.statement.metadata.matching.StatementMetadataNode)4 Filter (org.openrdf.query.algebra.Filter)4 QueryModelNode (org.openrdf.query.algebra.QueryModelNode)4 StatementPattern (org.openrdf.query.algebra.StatementPattern)4 ValueExpr (org.openrdf.query.algebra.ValueExpr)4 ParsedQuery (org.openrdf.query.parser.ParsedQuery)4 ArrayList (java.util.ArrayList)3 RyaURI (org.apache.rya.api.domain.RyaURI)3 Test (org.junit.Test)3 SPARQLParser (org.openrdf.query.parser.sparql.SPARQLParser)3 MongoDBRdfConfiguration (org.apache.rya.mongodb.MongoDBRdfConfiguration)2 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)1