• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Projection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openrdf.query.algebra.Projection的典型用法代码示例。如果您正苦于以下问题:Java Projection类的具体用法?Java Projection怎么用?Java Projection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Projection类属于org.openrdf.query.algebra包,在下文中一共展示了Projection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testReflexiveProperty

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testReflexiveProperty() throws Exception {
    // Define a reflexive property
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    when(inferenceEngine.isReflexiveProperty(HAS_FAMILY)).thenReturn(true);
    // Construct a query, then visit it
    final StatementPattern sp = new StatementPattern(new Var("s", ALICE), new Var("p", HAS_FAMILY), new Var("o"));
    final Projection query = new Projection(sp, new ProjectionElemList(new ProjectionElem("o", "member")));
    query.visit(new ReflexivePropertyVisitor(conf, inferenceEngine));
    // Expected structure after rewriting SP(:Alice :hasFamilyMember ?member):
    //
    // Union(
    //     originalSP(:Alice :hasFamilyMember ?member),
    //     ZeroLengthPath(:Alice, ?member)
    // )
    Assert.assertTrue(query.getArg() instanceof Union);
    final TupleExpr left = ((Union) query.getArg()).getLeftArg();
    final TupleExpr right = ((Union) query.getArg()).getRightArg();
    Assert.assertEquals(sp, left);
    Assert.assertTrue(right instanceof ZeroLengthPath);
    Assert.assertEquals(sp.getSubjectVar(), ((ZeroLengthPath) right).getSubjectVar());
    Assert.assertEquals(sp.getObjectVar(), ((ZeroLengthPath) right).getObjectVar());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:ReflexivePropertyVisitorTest.java


示例2: testReflexivePropertyDisabled

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testReflexivePropertyDisabled() throws Exception {
    // Disable inference
    final RdfCloudTripleStoreConfiguration disabledConf = conf.clone();
    disabledConf.setInferReflexiveProperty(false);
    // Define a reflexive property
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    when(inferenceEngine.isReflexiveProperty(HAS_FAMILY)).thenReturn(true);
    // Construct a query, then make a copy and visit the copy
    final Projection query = new Projection(
            new StatementPattern(new Var("s", ALICE), new Var("p", HAS_FAMILY), new Var("o")),
            new ProjectionElemList(new ProjectionElem("s", "subject")));
    final Projection modifiedQuery = query.clone();
    modifiedQuery.visit(new ReflexivePropertyVisitor(disabledConf, inferenceEngine));
    // There should be no difference
    Assert.assertEquals(query, modifiedQuery);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:ReflexivePropertyVisitorTest.java


示例3: testTypePattern

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testTypePattern() throws Exception {
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    final Set<URI> narcissistProps = new HashSet<>();
    narcissistProps.add(love);
    when(inferenceEngine.getHasSelfImplyingType(narcissist)).thenReturn(narcissistProps);
    final Var subj = new Var("s");
    final Var obj = new Var("o", narcissist);
    obj.setConstant(true);
    final Var pred = new Var("p", RDF.TYPE);
    pred.setConstant(true);

    final Projection query = new Projection(new StatementPattern(subj, pred, obj),
            new ProjectionElemList(new ProjectionElem("s", "subject")));
    query.visit(new HasSelfVisitor(conf, inferenceEngine));

    Assert.assertTrue(query.getArg() instanceof Union);
    final Union union = (Union) query.getArg();
    Assert.assertTrue(union.getRightArg() instanceof StatementPattern);
    Assert.assertTrue(union.getLeftArg() instanceof StatementPattern);
    final StatementPattern expectedLeft = new StatementPattern(subj, pred, obj);
    final StatementPattern expectedRight = new StatementPattern(subj, new Var("urn:love", love), subj);
    Assert.assertEquals(expectedLeft, union.getLeftArg());
    Assert.assertEquals(expectedRight, union.getRightArg());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:HasSelfVisitorTest.java


示例4: testOneOfDisabled

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testOneOfDisabled() throws Exception {
    // Configure a mock instance engine with an ontology:
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true);
    when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION);
    when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true);
    when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION);

    // Query for a Suits and rewrite using the visitor:
    final Projection query = new Projection(
            new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)),
            new ProjectionElemList(new ProjectionElem("s", "subject")));

    final AccumuloRdfConfiguration disabledConf = conf.clone();
    disabledConf.setInferOneOf(false);

    query.visit(new OneOfVisitor(disabledConf, inferenceEngine));

    // Expected structure: the original statement:
    assertTrue(query.getArg() instanceof StatementPattern);
    final StatementPattern actualCardSuitSp = (StatementPattern) query.getArg();
    final StatementPattern expectedCardSuitSp = new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS));
    assertEquals(expectedCardSuitSp, actualCardSuitSp);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:OneOfVisitorTest.java


示例5: testProjection

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testProjection() throws Exception {
    StatementPattern isUndergrad = new StatementPattern(new Var("x"), constant(RDF.TYPE), constant(UNDERGRAD));
    StatementPattern isCourse = new StatementPattern(new Var("course"), constant(RDF.TYPE), constant(COURSE));
    StatementPattern hasEdge = new StatementPattern(new Var("x"), new Var("p"), new Var("course"));
    ProjectionElemList projectionElements = new ProjectionElemList(
            new ProjectionElem("p", "relation"),
            new ProjectionElem("course"));
    QueryRoot queryTree = new QueryRoot(new Projection(
            new Join(new Join(isCourse, hasEdge), isUndergrad),
            projectionElements));
    SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection);
    queryTree.visit(visitor);
    Assert.assertTrue(queryTree.getArg() instanceof AggregationPipelineQueryNode);
    AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) queryTree.getArg();
    Assert.assertEquals(Sets.newHashSet("relation", "course"), pipelineNode.getAssuredBindingNames());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:SparqlToPipelineTransformVisitorTest.java


示例6: changesNothing

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
/**
 * This Projection enumerates all of the variables that were in the query, none of them are anonymous, and
 * none of them insert constants.
 */
@Test
public void changesNothing() throws Exception {
    // Read the projection object from a SPARQL query.
    final Projection projection = getProjection(
            "SELECT ?person ?employee ?business " +
            "WHERE { " +
                "?person <urn:talksTo> ?employee . " +
                "?employee <urn:worksAt> ?business . " +
            "}");

    // Create a Binding Set that contains the result of the WHERE clause.
    final ValueFactory vf = new ValueFactoryImpl();
    final MapBindingSet bs = new MapBindingSet();
    bs.addBinding("person", vf.createURI("urn:Alice"));
    bs.addBinding("employee", vf.createURI("urn:Bob"));
    bs.addBinding("business", vf.createURI("urn:TacoJoint"));
    final VisibilityBindingSet original = new VisibilityBindingSet(bs, "a|b");

    // Execute the projection.
    final VisibilityBindingSet result = ProjectionEvaluator.make(projection).project(original);
    assertEquals(original, result);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:ProjectionEvaluatorTest.java


示例7: getConstructGraphVarOrder

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
private static VariableOrder getConstructGraphVarOrder(final Reduced node) {

        //get child node
          final QueryModelNode child = node.getArg();
          Preconditions.checkArgument(child instanceof Projection || child instanceof MultiProjection);
          final UnaryTupleOperator unary = (UnaryTupleOperator) child;

          //get ProjectionElemList to build ConstructGraph
          final List<ProjectionElemList> projections = new ArrayList<>();
          if(unary instanceof Projection) {
              projections.add(((Projection) unary).getProjectionElemList());
          } else {
              projections.addAll(((MultiProjection)unary).getProjections());
          }

          return getConstructGraphVarOrder(projections);
      }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:SparqlFluoQueryBuilder.java


示例8: meet

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Override
public void meet(final Projection node) throws TopologyBuilderException {
    final String id = PROJECTION_PREFIX + UUID.randomUUID();
    final Optional<Side> side = getSide(node);

    // If the arg is an Extension, there are rebindings that need to be
    // ignored since they do not have a processor node.
    TupleExpr downstreamNode = node.getArg();
    if (downstreamNode instanceof Extension) {
        downstreamNode = ((Extension) downstreamNode).getArg();
    }

    final ProjectionProcessorSupplier supplier = new ProjectionProcessorSupplier(
            ProjectionEvaluator.make(node),
            result -> getResult(side, result));

    entries.add(new ProcessorEntry(node, id, side, supplier, Lists.newArrayList(downstreamNode)));
    idMap.put(node, id);
    super.meet(node);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:TopologyFactory.java


示例9: getPlans

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
private List<TupleExpr> getPlans(final TupleExpr te) {


        final NodeCollector nc = new NodeCollector();
        te.visit(nc);

        final Set<QueryModelNode> nodeSet = nc.getNodeSet();
        final List<Filter> filterList = nc.getFilterSet();
        final Projection projection = nc.getProjection().clone();

        final List<TupleExpr> queryPlans = Lists.newArrayList();

        final Collection<List<QueryModelNode>> plans = Collections2.permutations(nodeSet);

        for (final List<QueryModelNode> p : plans) {
            if (p.size() == 0) {
                throw new IllegalArgumentException("Tuple must contain at least one node!");
            } else if (p.size() == 1) {
                queryPlans.add(te);
            } else {
                queryPlans.add(buildTuple(p, filterList, projection));
            }
        }

        return queryPlans;
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:TupleExecutionPlanGenerator.java


示例10: getNormalizedIndices

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
private List<ExternalTupleSet> getNormalizedIndices(List<ExternalTupleSet> indexSet) {

        ExternalTupleSet tempIndex;
        final List<ExternalTupleSet> normalizedIndexSet = Lists.newArrayList();
        for (final ExternalTupleSet e : indexSet) {
            List<TupleExpr> tupList = null;
            try {
                tupList = QueryVariableNormalizer.getNormalizedIndex(query, e.getTupleExpr());
            } catch (final Exception e1) {
                e1.printStackTrace();
                throw new Error(e1);
            }

            for (final TupleExpr te : tupList) {
                tempIndex = (ExternalTupleSet) e.clone();
                tempIndex.setProjectionExpr((Projection) te);
                normalizedIndexSet.add(tempIndex);
            }
        }
        return normalizedIndexSet;
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:IndexedExecutionPlanGenerator.java


示例11: testConcreteSP

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testConcreteSP() {
    Extension extension = new Extension(new SingletonSet(),
            new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"),
            new ExtensionElem(new ValueConstant(RDF.TYPE), "y"),
            new ExtensionElem(new ValueConstant(OWL.CLASS), "z"));
    Projection projection = new Projection(extension, new ProjectionElemList(
            new ProjectionElem("x", "subject"),
            new ProjectionElem("y", "predicate"),
            new ProjectionElem("z", "object")));
    ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
    projection.visit(visitor);
    Set<StatementPattern> expected = Sets.newHashSet(
            new StatementPattern(s(FOAF.PERSON), p(RDF.TYPE), o(OWL.CLASS)));
    Assert.assertEquals(expected, visitor.getConsequents());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:ConstructConsequentVisitorTest.java


示例12: AccumuloIndexSet

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
/**
    *
    * @param accCon
    *            - connection to a valid Accumulo instance
    * @param tablename
    *            - name of an existing PCJ table
    * @throws MalformedQueryException
    * @throws SailException
    * @throws QueryEvaluationException
    * @throws TableNotFoundException
    * @throws AccumuloSecurityException
    * @throws AccumuloException
    * @throws PCJStorageException
    */
public AccumuloIndexSet(final Configuration conf, final String tablename)
		throws MalformedQueryException, SailException,
                   QueryEvaluationException, TableNotFoundException, AccumuloException, AccumuloSecurityException, PCJStorageException {
       this.tablename = tablename;
	this.accCon = ConfigUtils.getConnector(conf);
	this.auths = getAuthorizations(conf);
       PcjMetadata meta = pcj.getPcjMetadata(accCon, tablename);
	final SPARQLParser sp = new SPARQLParser();
	final ParsedTupleQuery pq = (ParsedTupleQuery) sp.parseQuery(meta.getSparql(), null);

	setProjectionExpr((Projection) pq.getTupleExpr());
	final Set<VariableOrder> orders = meta.getVarOrders();

	varOrder = Lists.newArrayList();
	for (final VariableOrder var : orders) {
		varOrder.add(var.toString());
	}
	setLocalityGroups(tablename, accCon, varOrder);
	this.setSupportedVariableOrderMap(varOrder);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:35,代码来源:AccumuloIndexSet.java


示例13: findProjection

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
/**
 * Finds the first {@link Projection} node within a {@link ParsedQuery}.
 *
 * @param query - The query that will be searched. (not null)
 * @return The first projection encountered if the query has one; otherwise absent.
 */
public Optional<Projection> findProjection(final ParsedQuery query) {
    checkNotNull(query);

    // When a projection is encountered for the requested index, store it in atomic reference and quit searching.
    final AtomicReference<Projection> projectionRef = new AtomicReference<>();

    query.getTupleExpr().visit(new QueryModelVisitorBase<RuntimeException>() {
        @Override
        public void meet(Projection projection) {
            projectionRef.set(projection);
        }
    });

    return Optional.fromNullable( projectionRef.get() );
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:ParsedQueryUtil.java


示例14: MongoPcjQueryNode

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
/**
 * Creates a new {@link MongoPcjQueryNode}.
 *
 * @param sparql - sparql query whose results will be stored in PCJ document. (not empty of null)
 * @param pcjId - name of an existing PCJ. (not empty or null)
 * @param pcjDocs - {@link MongoPcjDocuments} used to maintain PCJs in mongo. (not null)
 *
 * @throws MalformedQueryException - The SPARQL query needs to contain a projection.
 */
public MongoPcjQueryNode(final String sparql, final String pcjId, final MongoPcjDocuments pcjDocs) throws MalformedQueryException {
    checkArgument(!Strings.isNullOrEmpty(sparql));
    checkArgument(!Strings.isNullOrEmpty(pcjId));
    this.pcjDocs = checkNotNull(pcjDocs);
    this.pcjId = pcjId;
    final SPARQLParser sp = new SPARQLParser();
    final ParsedTupleQuery pq = (ParsedTupleQuery) sp.parseQuery(sparql, null);
    final TupleExpr te = pq.getTupleExpr();
    Preconditions.checkArgument(PCJOptimizerUtilities.isPCJValid(te), "TupleExpr is an invalid PCJ.");

    final Optional<Projection> projection = new ParsedQueryUtil().findProjection(pq);
    if (!projection.isPresent()) {
        throw new MalformedQueryException("SPARQL query '" + sparql + "' does not contain a Projection.");
    }
    setProjectionExpr(projection.get());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:MongoPcjQueryNode.java


示例15: equals_equals

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void equals_equals() 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, identicalTestSet);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:SimpleExternalTupleSetTest.java


示例16: meetUnaryTupleOperator

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Override
protected void meetUnaryTupleOperator(final UnaryTupleOperator node) {
    if (node instanceof Projection) {
        cardinality += -1.0;
    }
    super.meetUnaryTupleOperator(node);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:8,代码来源:RdfCloudTripleStoreEvaluationStatistics.java


示例17: getSupportedVariableOrderMap

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void getSupportedVariableOrderMap() throws MalformedQueryException {
    // Create the 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 the object that is being tested.
    final SimpleExternalTupleSet testSet = new SimpleExternalTupleSet(pcjExpression);

    // Verify the correct Supported Variable Order Map is created.
    final Map<String, Set<String>> expected = new HashMap<>();

    String varOrder = "f";
    Set<String> vars = new HashSet<>();
    vars.add("f");
    expected.put(varOrder, vars);

    varOrder = "f;m";
    vars = new HashSet<>();
    vars.add("f");
    vars.add("m");
    expected.put(varOrder, vars);

    varOrder = "f;m;d";
    vars = new HashSet<>();
    vars.add("f");
    vars.add("m");
    vars.add("d");
    expected.put(varOrder, vars);

    assertEquals(expected, testSet.getSupportedVariableOrderMap());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:39,代码来源:SimpleExternalTupleSetTest.java


示例18: testPropertyPattern_constantSubj

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testPropertyPattern_constantSubj() throws Exception {
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    final Set<Resource> loveTypes = new HashSet<>();
    loveTypes.add(narcissist);
    when(inferenceEngine.getHasSelfImplyingProperty(love)).thenReturn(loveTypes);
    final Var subj = new Var("s", self);
    subj.setConstant(true);
    final Var obj = new Var("o");
    final Var pred = new Var("p", love);
    pred.setConstant(true);

    final Projection query = new Projection(new StatementPattern(subj, pred, obj),
            new ProjectionElemList(new ProjectionElem("s", "subject")));
    query.visit(new HasSelfVisitor(conf, inferenceEngine));

    Assert.assertTrue(query.getArg() instanceof Union);
    final Union union = (Union) query.getArg();
    Assert.assertTrue(union.getRightArg() instanceof StatementPattern);
    Assert.assertTrue(union.getLeftArg() instanceof Extension);
    final StatementPattern expectedRight = new StatementPattern(subj, pred, obj);
    final Extension expectedLeft = new Extension(
            new StatementPattern(subj, new Var(RDF.TYPE.stringValue(), RDF.TYPE), new Var("urn:Narcissist", narcissist)),
            new ExtensionElem(subj, "o"));
    Assert.assertEquals(expectedLeft, union.getLeftArg());
    Assert.assertEquals(expectedRight, union.getRightArg());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:28,代码来源:HasSelfVisitorTest.java


示例19: testPropertyPattern_constantObj

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testPropertyPattern_constantObj() throws Exception {
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    final Set<Resource> loveTypes = new HashSet<>();
    loveTypes.add(narcissist);
    when(inferenceEngine.getHasSelfImplyingProperty(love)).thenReturn(loveTypes);
    final Var subj = new Var("s");
    final Var obj = new Var("o", self);
    obj.setConstant(true);
    final Var pred = new Var("p", love);
    pred.setConstant(true);

    final Projection query = new Projection(new StatementPattern(subj, pred, obj),
            new ProjectionElemList(new ProjectionElem("s", "subject")));
    query.visit(new HasSelfVisitor(conf, inferenceEngine));

    Assert.assertTrue(query.getArg() instanceof Union);
    final Union union = (Union) query.getArg();
    Assert.assertTrue(union.getRightArg() instanceof StatementPattern);
    Assert.assertTrue(union.getLeftArg() instanceof Extension);
    final StatementPattern expectedRight = new StatementPattern(subj, pred, obj);
    final Extension expectedLeft = new Extension(
            new StatementPattern(obj, new Var(RDF.TYPE.stringValue(), RDF.TYPE), new Var("urn:Narcissist", narcissist)),
            new ExtensionElem(obj, "s"));
    Assert.assertEquals(expectedLeft, union.getLeftArg());
    Assert.assertEquals(expectedRight, union.getRightArg());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:28,代码来源:HasSelfVisitorTest.java


示例20: testOneOf

import org.openrdf.query.algebra.Projection; //导入依赖的package包/类
@Test
public void testOneOf() throws Exception {
    // Configure a mock instance engine with an ontology:
    final InferenceEngine inferenceEngine = mock(InferenceEngine.class);
    when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true);
    when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION);
    when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true);
    when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION);
    // Query for a  Suits and rewrite using the visitor:
    final Projection query = new Projection(
            new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)),
            new ProjectionElemList(new ProjectionElem("s", "subject")));
    query.visit(new OneOfVisitor(conf, inferenceEngine));
    // Expected structure: BindingSetAssignment containing the enumeration:
    // BindingSetAssignment(CLUBS, DIAMONDS, HEARTS, SPADES)
    // Collect the arguments to the BindingSetAssignment:
    assertTrue(query.getArg() instanceof BindingSetAssignment);
    final BindingSetAssignment bsa = (BindingSetAssignment) query.getArg();
    final Iterable<BindingSet> iterable = bsa.getBindingSets();
    final Iterator<BindingSet> iter = iterable.iterator();

    assertBindingSet(iter, CARD_SUIT_ENUMERATION.iterator());

    // Query for a Ranks and rewrite using the visitor:
    final Projection query2 = new Projection(
            new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", RANKS)),
            new ProjectionElemList(new ProjectionElem("s", "subject")));
    query2.visit(new OneOfVisitor(conf, inferenceEngine));
    // Expected structure: BindingSetAssignment containing the enumeration:
    // BindingSetAssignment(ACE, 2, 3, 4, 5, 6, 7, 8, 9, 10, JACK, QUEEN, KING)
    // Collect the arguments to the BindingSetAssignment:
    assertTrue(query2.getArg() instanceof BindingSetAssignment);
    final BindingSetAssignment bsa2 = (BindingSetAssignment) query2.getArg();
    final Iterable<BindingSet> iterable2 = bsa2.getBindingSets();
    final Iterator<BindingSet> iter2 = iterable2.iterator();

    assertBindingSet(iter2, CARD_RANK_ENUMERATION.iterator());
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:39,代码来源:OneOfVisitorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TrustedAuthorities类代码示例发布时间:2022-05-23
下一篇:
Java XMLEntityStorage类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap