当前位置: 首页>>代码示例>>Java>>正文


Java ParsedQuery.getTupleExpr方法代码示例

本文整理汇总了Java中org.openrdf.query.parser.ParsedQuery.getTupleExpr方法的典型用法代码示例。如果您正苦于以下问题:Java ParsedQuery.getTupleExpr方法的具体用法?Java ParsedQuery.getTupleExpr怎么用?Java ParsedQuery.getTupleExpr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.query.parser.ParsedQuery的用法示例。


在下文中一共展示了ParsedQuery.getTupleExpr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rewrite

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
/**
 * Rewrite a given query to add inference.
 *
 * @param ql the query language used for the query
 * @param query the query to rewrite
 * @param baseuri a base URI to use for the query
 * @return rewritten query that includes inference
 * @throws MalformedQueryException if the query is malformed
 * @throws RepositoryException if there was a problem while rewriting
 */
public Query rewrite(QueryLanguage ql, String query, String baseuri)
		throws MalformedQueryException, RepositoryException {
	// parse query using Sesame
	QueryParserFactory f = QueryParserRegistry.getInstance().get(ql);
	QueryParser parser = f.getParser();
	ParsedQuery parsed = parser.parseQuery(query, baseuri);
	// get SPARQL algebra expression from parsed query
	TupleExpr expr = parsed.getTupleExpr();
	// rewrite query using visitor pattern
	RuleTransformationVisitor visitor
			= new RuleTransformationVisitor(rules);
	expr.visit(visitor);
	// return new query based on rewritten algebra expression
	return getExprQuery(parsed, expr);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:26,代码来源:QueryRewriter.java

示例2: hashCode_same

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void hashCode_same() throws MalformedQueryException {
    // The common PCJ expression.
    final String sparql =
            "SELECT ?f ?m ?d { " +
                "?f <urn:talksTo> ?m . " +
                "?m <uri:associatesWith> ?d . " +
            "}";

    final ParsedQuery query = new SPARQLParser().parseQuery(sparql, null);
    final Projection pcjExpression = (Projection) query.getTupleExpr();

    // Create two SimpleExternalTupleSet pbjects using the same expression.
    final SimpleExternalTupleSet testSet = new SimpleExternalTupleSet(pcjExpression);
    final SimpleExternalTupleSet identicalTestSet = new SimpleExternalTupleSet(pcjExpression);

    // Show that they are equal.
    assertEquals(testSet.hashCode(), identicalTestSet.hashCode());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:SimpleExternalTupleSetTest.java

示例3: testCross

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
public void testCross() throws Exception {
        String query = "select * where {\n" +
                "?subj0 <urn:lubm:rdfts#name> 'Department0'.\n" +
                "?subj1 <urn:lubm:rdfts#name> 'Department1'.\n" +
                "?subj0 <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" +
                "?subj1 <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" +
                "}";
//        System.out.println(query);
        QueryParser parser = new SPARQLParser();
        ParsedQuery parsedQuery = parser.parseQuery(query, null);
        QueryRoot tupleExpr = new QueryRoot(parsedQuery.getTupleExpr());

        SimilarVarJoinOptimizer similarVarJoinOptimizer = new SimilarVarJoinOptimizer();
        similarVarJoinOptimizer.optimize(tupleExpr, null, null);

//        System.out.println(tupleExpr);

        SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
        visitor.setTablePrefix(tablePrefix);
        visitor.setInstance(instance);
        visitor.setZk(zk);
        visitor.setUser(user);
        visitor.setPassword(password);
        visitor.meet(tupleExpr);
//        System.out.println(visitor.getPigScript());
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:SparqlToPigTransformVisitorTest.java

示例4: testPeriodicNodePlacement

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testPeriodicNodePlacement() throws MalformedQueryException {
     String query = "prefix function: <http://org.apache.rya/function#> " //n
            + "prefix time: <http://www.w3.org/2006/time#> " //n
            + "prefix fn: <http://www.w3.org/2006/fn#> " //n
            + "select ?obs ?time ?lat where {" //n
            + "Filter(function:periodic(?time, 12.0, 6.0,time:hours)) " //n
            + "Filter(fn:test(?lat, 25)) " //n
            + "?obs <uri:hasTime> ?time. " //n
            + "?obs <uri:hasLattitude> ?lat }"; //n
     
     SPARQLParser parser = new SPARQLParser();
     ParsedQuery pq = parser.parseQuery(query, null);
     TupleExpr te = pq.getTupleExpr();
     te.visit(new PeriodicQueryNodeVisitor());
     
     PeriodicNodeCollector collector = new PeriodicNodeCollector();
     te.visit(collector);
     
     PeriodicQueryNode node2 = new PeriodicQueryNode(12*60*60*1000L, 6*3600*1000L, TimeUnit.MILLISECONDS, "time", new Join());

     Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node2, collector.getPeriodicQueryNode()));
     
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:25,代码来源:PeriodicQueryUtilTest.java

示例5: testPeriodicNodeLocation

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testPeriodicNodeLocation() throws MalformedQueryException {
     String query = "prefix function: <http://org.apache.rya/function#> " //n
            + "prefix time: <http://www.w3.org/2006/time#> " //n
            + "prefix fn: <http://www.w3.org/2006/fn#> " //n
            + "select ?obs ?time ?lat where {" //n
            + "Filter(function:periodic(?time, 1,.5,time:hours)) " //n
            + "Filter(fn:test(?lat, 25)) " //n
            + "?obs <uri:hasTime> ?time. " //n
            + "?obs <uri:hasLattitude> ?lat }"; //n
     
     SPARQLParser parser = new SPARQLParser();
     ParsedQuery pq = parser.parseQuery(query, null);
     TupleExpr te = pq.getTupleExpr();
     te.visit(new PeriodicQueryNodeVisitor());
    
     PeriodicNodeCollector collector = new PeriodicNodeCollector();
     te.visit(collector);
     Assert.assertEquals(2, collector.getPos());
     
     te.visit(new PeriodicQueryNodeRelocator());
     collector.resetCount();
     te.visit(collector);
     Assert.assertEquals(1, collector.getPos());
     
     double window = 1*60*60*1000;
     double period = .5*3600*1000;
     PeriodicQueryNode node2 = new PeriodicQueryNode((long) window, (long) period, TimeUnit.MILLISECONDS, "time", new Join());
     Assert.assertEquals(true, periodicNodesEqualIgnoreArg(node2, collector.getPeriodicQueryNode()));
     
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:32,代码来源:PeriodicQueryUtilTest.java

示例6: testMongoMatchQuery

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testMongoMatchQuery() throws MalformedQueryException {
    SPARQLParser parser = new SPARQLParser();
    ParsedQuery pq = parser.parseQuery(query, null);
    TupleExpr te = pq.getTupleExpr();
    System.out.println("Parametrized query is : " + te);
    mongoOptimizer.optimize(te, null, null);
    System.out.println("Result of optimization is : " + te);
    assertEquals(expected, StatementMetadataTestUtils.getMetadataNodes(te));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:StatementMetadataOptimizerTest.java

示例7: testISNUMERIC

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testISNUMERIC() throws Exception {

    final SPARQLParser parser1 = new SPARQLParser();
    final SPARQLParser parser2 = new SPARQLParser();

    final ParsedQuery pq1 = parser1.parseQuery(q29, null);
    final ParsedQuery pq2 = parser2.parseQuery(q30, null);

    final SimpleExternalTupleSet extTup = new SimpleExternalTupleSet(
            new Projection(pq2.getTupleExpr()));

    final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
    list.add(extTup);

    final TupleExpr tup = pq1.getTupleExpr().clone();
    provider.setIndices(list);
    final PCJOptimizer pcj = new PCJOptimizer(list, false, provider);
    pcj.optimize(tup, null, null);

    final Set<StatementPattern> qSet = Sets.newHashSet(StatementPatternCollector
            .process(pq1.getTupleExpr()));
    final Set<QueryModelNode> eTupSet = PcjIntegrationTestingUtil
            .getTupleSets(tup);

    final Set<StatementPattern> set = Sets.newHashSet();
    for (final QueryModelNode s : eTupSet) {
        set.addAll(StatementPatternCollector.process(((ExternalTupleSet) s)
                .getTupleExpr()));
    }

    Assert.assertTrue(set.equals(qSet) && eTupSet.size() == 1);

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:35,代码来源:PrecompJoinOptimizerTest2.java

示例8: testTwoIndexLargeQuery

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testTwoIndexLargeQuery() throws Exception {

	SPARQLParser parser = new SPARQLParser();

	ParsedQuery pq1 = parser.parseQuery(q15, null);
	ParsedQuery pq2 = parser.parseQuery(q7, null);
	ParsedQuery pq3 = parser.parseQuery(q12, null);

	System.out.println("Query is " + pq1.getTupleExpr());

	SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet(
			new Projection(pq2.getTupleExpr()));
	SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet(
			new Projection(pq3.getTupleExpr()));

	List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();

	list.add(extTup2);
	list.add(extTup1);

	IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(
			pq1.getTupleExpr(), list);
	List<ExternalTupleSet> indexSet = iep.getNormalizedIndices();
	Assert.assertEquals(4, indexSet.size());

	Set<TupleExpr> processedTups = Sets.newHashSet(iep.getIndexedTuples());
	Assert.assertEquals(5, processedTups.size());

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:31,代码来源:GeneralizedExternalProcessorTest.java

示例9: testGeoIndexFunction

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testGeoIndexFunction() throws Exception {

    final SPARQLParser parser1 = new SPARQLParser();
    final SPARQLParser parser2 = new SPARQLParser();

    final ParsedQuery pq1 = parser1.parseQuery(q21, null);
    final ParsedQuery pq2 = parser2.parseQuery(q23, null);
    System.out.println("Query is " + pq1.getTupleExpr());
    System.out.println("Index is " + pq2.getTupleExpr());

    final SimpleExternalTupleSet extTup = new SimpleExternalTupleSet(new Projection(pq2.getTupleExpr()));

    final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
    list.add(extTup);

    final TupleExpr tup = pq1.getTupleExpr().clone();
    final PCJOptimizer pcj = new PCJOptimizer(list, false, new AccumuloIndexSetProvider(new Configuration(), list));
    pcj.optimize(tup, null, null);

    System.out.println("Processed query is " + tup);

    final Set<StatementPattern> qSet = Sets.newHashSet(StatementPatternCollector.process(pq1.getTupleExpr()));
    final Set<QueryModelNode> eTupSet =  PcjIntegrationTestingUtil.getTupleSets(tup);
    final Set<StatementPattern> set = Sets.newHashSet();

    Assert.assertEquals(1, eTupSet.size());

    for (final QueryModelNode s : eTupSet) {
        final Set<StatementPattern> tempSet = Sets.newHashSet(StatementPatternCollector.process(((ExternalTupleSet) s)
                .getTupleExpr()));
        set.addAll(tempSet);

    }

    Assert.assertTrue(qSet.containsAll(set));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:38,代码来源:PrecompJoinOptimizerVarToConstTest.java

示例10: testTwoIndexFilter1

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testTwoIndexFilter1() throws Exception {

	SPARQLParser parser = new SPARQLParser();

	ParsedQuery pq1 = parser.parseQuery(q15, null);
	ParsedQuery pq2 = parser.parseQuery(q16, null);
	ParsedQuery pq3 = parser.parseQuery(q17, null);

	System.out.println("Query is " + pq1.getTupleExpr());

	SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet(
			(Projection) pq2.getTupleExpr());
	SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet(
			(Projection) pq3.getTupleExpr());

	List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
	list.add(extTup1);
	list.add(extTup2);

	VarConstantIndexListPruner vci = new VarConstantIndexListPruner(
			pq1.getTupleExpr());
	List<ExternalTupleSet> processedIndexSet = vci.getRelevantIndices(list);

	System.out.println("Relevant indexes are: ");
	for (ExternalTupleSet e : processedIndexSet) {
		System.out.println(e);
	}

	Set<ExternalTupleSet> indexSet = Sets.newHashSet();
	indexSet.add(extTup2);

	Assert.assertTrue(Sets.intersection(indexSet,
			Sets.<ExternalTupleSet> newHashSet(processedIndexSet)).equals(
					Sets.<ExternalTupleSet> newHashSet(processedIndexSet)));

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:38,代码来源:VarConstantIndexListPrunerTest.java

示例11: testBasicSegment

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testBasicSegment() throws MalformedQueryException {

	String query1 = ""//
			+ "SELECT ?e ?c ?l" //
			+ "{" //
			+ "  ?e a ?c . "//
			+ "  OPTIONAL {?e <uri:talksTo> ?l}  . "//
			+ "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "//
			+ "}";//

	String query2 = ""//
			+ "SELECT ?e ?c ?l" //
			+ "{" //
			+ "  ?e a ?c . "//
			+ "  OPTIONAL {?e <uri:talksTo> ?l}  . "//
			+ "}";//

	SPARQLParser parser = new SPARQLParser();
	ParsedQuery pq1 = parser.parseQuery(query1, null);
	ParsedQuery pq2 = parser.parseQuery(query2, null);
	TupleExpr te1 = pq1.getTupleExpr();
	TupleExpr te2 = pq2.getTupleExpr();
	Projection proj = (Projection) te1;
	Join join = (Join) proj.getArg();

	
	ExternalSetMatcher<ExternalTupleSet> jsm = pcjFactory.getMatcher(qFactory.getQuerySegment(join));
	SimpleExternalTupleSet pcj = new SimpleExternalTupleSet((Projection)te2);
	Assert.assertEquals(true, jsm.match(pcj));
	TupleExpr te = jsm.getQuery();
	Assert.assertEquals(new HashSet<QueryModelNode>(), jsm.getUnmatchedArgNodes());

	Set<QueryModelNode> qNodes = LeftJoinQueryNodeGatherer.getNodes(te);
	List<QueryModelNode> nodes = jsm.getOrderedNodes();
	Set<QueryModelNode> nodeSet = new HashSet<>();
	nodeSet.add(nodes.get(0));
	nodeSet.add(pcj);

	Assert.assertEquals(nodeSet, new HashSet<QueryModelNode>(nodes));
	Assert.assertEquals(nodeSet, qNodes);

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:44,代码来源:OptionalJoinSegmentPCJMatcherTest.java

示例12: testBasicMatchWithFilter

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testBasicMatchWithFilter() throws Exception {

	String query1 = ""//
			+ "SELECT ?e ?c ?l" //
			+ "{" //
			+ " Filter(?e = <uri:Bob>)" //
			+ " Filter(?c = <uri:Lawyer>)" //
			+ "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
			+ "  ?e a ?c . "//
			+ "  OPTIONAL {?e <uri:talksTo> ?l}  . "//
			+ "}";//

	String query2 = ""//
			+ "SELECT ?e ?c ?l" //
			+ "{" //
			+ " Filter(?e = <uri:Bob>)" //
			+ " ?e a ?c . "//
			+ " OPTIONAL {?e <uri:talksTo> ?l} . "//
			+ "}";//

	SPARQLParser parser = new SPARQLParser();
	ParsedQuery pq1 = parser.parseQuery(query1, null);
	ParsedQuery pq2 = parser.parseQuery(query2, null);
	TupleExpr te1 = pq1.getTupleExpr();
	TupleExpr te2 = pq2.getTupleExpr();
	Projection proj = (Projection) te1;
	Filter filter = (Filter) proj.getArg();

	ExternalSetMatcher<ExternalTupleSet> jsm = pcjFactory.getMatcher(qFactory.getQuerySegment(filter));
	SimpleExternalTupleSet pcj = new SimpleExternalTupleSet((Projection)te2);
	Assert.assertEquals(true, jsm.match(pcj));
	TupleExpr te = jsm.getQuery();
	Assert.assertEquals(new HashSet<QueryModelNode>(), jsm.getUnmatchedArgNodes());

	Set<QueryModelNode> qNodes = LeftJoinQueryNodeGatherer.getNodes(te);
	List<QueryModelNode> nodes = jsm.getOrderedNodes();
	Set<QueryModelNode> nodeSet = new HashSet<>();
	nodeSet.add(nodes.get(0));
	nodeSet.add(pcj);
	nodeSet.add(nodes.get(2));

	Assert.assertEquals(nodeSet, new HashSet<QueryModelNode>(nodes));
	Assert.assertEquals(nodeSet, qNodes);

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:47,代码来源:OptionalJoinSegmentPCJMatcherTest.java

示例13: testEvaluateTwoIndexTwoVarOrder1

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testEvaluateTwoIndexTwoVarOrder1()
        throws Exception {


    final String indexSparqlString = ""//
            + "SELECT ?c ?e ?l  " //
            + "{" //
            + "  ?e a ?c . "//
            + "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l "//
            + "}";//

    final String indexSparqlString2 = ""//
            + "SELECT ?e ?o ?l " //
            + "{" //
            + "  ?e <uri:talksTo> ?o . "//
            + "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "//
            + "}";//

    final String queryString = ""//
            + "SELECT ?e ?c ?l ?o " //
            + "{" //
            + "  ?e a ?c . "//
            + "  ?e <http://www.w3.org/2000/01/rdf-schema#label> ?l . "//
            + "  ?e <uri:talksTo> ?o . "//
            + "  ?o <http://www.w3.org/2000/01/rdf-schema#label> ?l "//
            + "}";//

    final SPARQLParser sp = new SPARQLParser();
    final ParsedQuery index1 = sp.parseQuery(indexSparqlString, null);
    final ParsedQuery index2 = sp.parseQuery(indexSparqlString2, null);
    final List<ExternalTupleSet> index = Lists.newArrayList();

    final SimpleExternalTupleSet ais1 = new SimpleExternalTupleSet(
            (Projection) index1.getTupleExpr());
    final SimpleExternalTupleSet ais2 = new SimpleExternalTupleSet(
            (Projection) index2.getTupleExpr());

    index.add(ais1);
    index.add(ais2);

    final ParsedQuery pq = sp.parseQuery(queryString, null);
    final TupleExpr tup = pq.getTupleExpr().clone();
    provider.setIndices(index);
    final PCJOptimizer pcj = new PCJOptimizer(index, false, provider);
    pcj.optimize(tup, null, null);


    final IndexPlanValidator ipv = new IndexPlanValidator(false);
    Assert.assertEquals(false, ipv.isValid(tup));

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:53,代码来源:IndexPlanValidatorTest.java

示例14: testValidPCJ

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testValidPCJ() throws MalformedQueryException {

	String query1 = ""//
			+ "SELECT ?e ?c " //
			+ "{" //
			+ "  ?e a ?c . "//
			+ "}";//

	String query2 = ""//
			+ "SELECT ?a ?b ?m" //
			+ "{" //
			+ "  ?a a ?b . "//
			+ "  OPTIONAL {?a <uri:talksTo> ?m}  . "//
			+ "}";//

	String query3 = ""//
			+ "SELECT ?a ?b ?m" //
			+ "{" //
			+ "  ?a a ?b . "//
			+ "  ?a <uri:talksTo> ?m  . "//
			+ "}";//

	String query4 = ""//
			+ "SELECT ?a ?b ?m ?n" //
			+ "{" //
			+ "  ?a a ?b . "//
			+ "  OPTIONAL {?a <uri:talksTo> ?m}  . "//
			+ "}";//

	String query5 = ""//
			+ "SELECT ?e ?c " //
			+ "{" //
			+ "Filter(?e = <uri:s1>) " //
			+ "  ?e a ?c . "//
			+ "}";//

	String query6 = ""//
			+ "SELECT ?e ?c " //
			+ "{" //
			+ "Filter(?f = <uri:s1>) " //
			+ "  ?e a ?c . "//
			+ "  ?c <uri:p1> <uri:o1> " //
			+ "}";//

	SPARQLParser parser = new SPARQLParser();
	ParsedQuery pq1 = parser.parseQuery(query1, null);
	ParsedQuery pq2 = parser.parseQuery(query2, null);
	ParsedQuery pq3 = parser.parseQuery(query3, null);
	ParsedQuery pq4 = parser.parseQuery(query4, null);
	ParsedQuery pq5 = parser.parseQuery(query5, null);
	ParsedQuery pq6 = parser.parseQuery(query6, null);
	TupleExpr te1 = pq1.getTupleExpr();
	TupleExpr te2 = pq2.getTupleExpr();
	TupleExpr te3 = pq3.getTupleExpr();
	TupleExpr te4 = pq4.getTupleExpr();
	TupleExpr te5 = pq5.getTupleExpr();
	TupleExpr te6 = pq6.getTupleExpr();

	SimpleExternalTupleSet pcj1 = new SimpleExternalTupleSet(
			(Projection) te1);
	SimpleExternalTupleSet pcj2 = new SimpleExternalTupleSet(
			(Projection) te2);
	SimpleExternalTupleSet pcj3 = new SimpleExternalTupleSet(
			(Projection) te3);
	SimpleExternalTupleSet pcj4 = new SimpleExternalTupleSet(
			(Projection) te4);
	SimpleExternalTupleSet pcj5 = new SimpleExternalTupleSet(
			(Projection) te5);
	SimpleExternalTupleSet pcj6 = new SimpleExternalTupleSet(
			(Projection) te6);

	Assert.assertEquals(false , PCJOptimizerUtilities.isPCJValid(pcj1));
	Assert.assertEquals(true , PCJOptimizerUtilities.isPCJValid(pcj2));
	Assert.assertEquals(true , PCJOptimizerUtilities.isPCJValid(pcj3));
	Assert.assertEquals(false , PCJOptimizerUtilities.isPCJValid(pcj4));
	Assert.assertEquals(true , PCJOptimizerUtilities.isPCJValid(pcj5));
	Assert.assertEquals(false , PCJOptimizerUtilities.isPCJValid(pcj6));

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:81,代码来源:PCJOptimizerUtilitesTest.java

示例15: testGetContrainedQuery

import org.openrdf.query.parser.ParsedQuery; //导入方法依赖的package包/类
@Test
public void testGetContrainedQuery() throws RyaTypeResolverException, MalformedQueryException {
  
    String q1 = "" //
            + "SELECT ?X ?Y1 ?Y2 " //
            + "{"//
            + "GRAPH <http://joe> { " //
            +  "?X <uri:cf1> ?Y1 ."//
            +  "?X <uri:cf2> ?Y2 ."//
            +  "?X <uri:cf3> ?Y3 ."//
            +  "}" //
            +  "}";
    
    
    SPARQLParser parser = new SPARQLParser();
    
    ParsedQuery pq1 = null;
    pq1 = parser.parseQuery(q1, null);

    TupleExpr te1 = pq1.getTupleExpr();
    
    System.out.println(te1);
    List<StatementPattern> spList1 = StatementPatternCollector.process(te1);
    
    StarQuery sq1 = new StarQuery(spList1);
    
    QueryBindingSet bs1 = new QueryBindingSet();
    QueryBindingSet bs2 = new QueryBindingSet();
    
    Value v1 = vf.createURI("uri:hank");
    Value v2 = vf.createURI("uri:bob");
    
    bs1.addBinding("X",v1);
    bs2.addBinding("X", v1);
    bs2.addBinding("Y3", v2);
    
   StarQuery sq2 = StarQuery.getConstrainedStarQuery(sq1, bs1);
   StarQuery sq3 = StarQuery.getConstrainedStarQuery(sq1, bs2);
   
   Assert.assertTrue(sq2.commonVarHasValue());
   Assert.assertEquals(sq2.getCommonVarValue(), "uri:hank");
   
   Assert.assertTrue(sq3.commonVarHasValue());
   Assert.assertEquals(sq3.getCommonVarValue(), "uri:hank");
   
   
   TextColumn[] tc1 = sq1.getColumnCond();
   TextColumn[] tc2 = sq2.getColumnCond();
   TextColumn[] tc3 = sq3.getColumnCond();
   
   for(int i = 0; i < tc1.length; i++) {
       
       Assert.assertTrue(tc1[i].equals(tc2[i]));
       if(i != 2) {
           Assert.assertTrue(tc1[i].equals(tc3[i]));
       } else {
           Assert.assertEquals(tc3[i].getColumnFamily(), new Text("uri:cf3"));
           RyaType objType = RdfToRyaConversions.convertValue(v2);
           byte[][] b1 = null;
            b1 = RyaContext.getInstance().serializeType(objType);
           byte[] b2 = Bytes.concat("object".getBytes(),
                   "\u0000".getBytes(), b1[0], b1[1]);
           Assert.assertEquals(tc3[i].getColumnQualifier(), new Text(b2));
           Assert.assertTrue(!tc3[i].isPrefix());
       }
   }
    
    
    
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:71,代码来源:StarQueryTest.java


注:本文中的org.openrdf.query.parser.ParsedQuery.getTupleExpr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。