本文整理汇总了Java中org.openrdf.query.algebra.MultiProjection类的典型用法代码示例。如果您正苦于以下问题:Java MultiProjection类的具体用法?Java MultiProjection怎么用?Java MultiProjection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultiProjection类属于org.openrdf.query.algebra包,在下文中一共展示了MultiProjection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testMultiProjection
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Test
public void testMultiProjection() 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 courseHasRelation = new ProjectionElemList(
new ProjectionElem("p", "relation"),
new ProjectionElem("course"));
ProjectionElemList studentHasRelation = new ProjectionElemList(
new ProjectionElem("p", "relation"),
new ProjectionElem("x", "student"));
QueryRoot queryTree = new QueryRoot(new MultiProjection(
new Join(new Join(isCourse, hasEdge), isUndergrad),
Arrays.asList(courseHasRelation, studentHasRelation)));
SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection);
queryTree.visit(visitor);
Assert.assertTrue(queryTree.getArg() instanceof AggregationPipelineQueryNode);
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) queryTree.getArg();
Assert.assertEquals(Sets.newHashSet("relation"), pipelineNode.getAssuredBindingNames());
Assert.assertEquals(Sets.newHashSet("relation", "course", "student"), pipelineNode.getBindingNames());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:SparqlToPipelineTransformVisitorTest.java
示例2: make
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
/**
* Make a {@link MultiProjectionEvaluator} that processes the logic of a {@link MultiProjection}.
*
* @param multiProjection - Defines the projections that will be processed. (not null)
* @param bNodeIdFactory - Creates the IDs for Blank Nodes. (not null)
* @return A {@link MultiProjectionEvaluator} for the provided {@link MultiProjection}.
*/
public static MultiProjectionEvaluator make(final MultiProjection multiProjection, final BNodeIdFactory bNodeIdFactory) {
requireNonNull(multiProjection);
// Figure out if there are extensions.
final TupleExpr arg = multiProjection.getArg();
final Optional<Extension> extension = (arg instanceof Extension) ? Optional.of((Extension)arg): Optional.empty();
// If there are, iterate through them and find any blank node source names.
final Set<String> blankNodeSourceNames = new HashSet<>();
if(extension.isPresent()) {
for(final ExtensionElem elem : extension.get().getElements()) {
if(elem.getExpr() instanceof BNodeGenerator) {
blankNodeSourceNames.add( elem.getName() );
}
}
}
// Create a ProjectionEvaluator for each projection that is part of the multi.
final Set<ProjectionEvaluator> projections = new HashSet<>();
for(final ProjectionElemList projectionElemList : multiProjection.getProjections()) {
projections.add( new ProjectionEvaluator(projectionElemList, extension) );
}
return new MultiProjectionEvaluator(projections, blankNodeSourceNames, bNodeIdFactory);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:33,代码来源:MultiProjectionEvaluator.java
示例3: getConstructGraphVarOrder
import org.openrdf.query.algebra.MultiProjection; //导入依赖的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
示例4: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(final MultiProjection node) throws TopologyBuilderException {
final String id = PROJECTION_PREFIX + UUID.randomUUID();
final Optional<Side> side = getSide(node);
final MultiProjectionProcessorSupplier supplier = new MultiProjectionProcessorSupplier(
MultiProjectionEvaluator.make(node, bNodeIdFactory),
result -> getResult(side, result));
// If the arg is an Extension, then this node's grandchild is the next processing node.
TupleExpr downstreamNode = node.getArg();
if (downstreamNode instanceof Extension) {
downstreamNode = ((Extension) downstreamNode).getArg();
}
entries.add(new ProcessorEntry(node, id, side, supplier, Lists.newArrayList(downstreamNode)));
idMap.put(node, id);
super.meet(node);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:TopologyFactory.java
示例5: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(MultiProjection projectionNode) throws Exception {
projectionNode.visitChildren(this);
if (projectionNode.getArg() instanceof AggregationPipelineQueryNode && projectionNode.getParentNode() != null) {
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) projectionNode.getArg();
if (pipelineNode.project(projectionNode.getProjections())) {
projectionNode.replaceWith(pipelineNode);
}
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:SparqlToPipelineTransformVisitor.java
示例6: getMultiProjection
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
/**
* Get the first {@link MultiProjection} node from a SPARQL query.
*
* @param sparql - The query that contains a single Projection node.
* @return The first {@link MultiProjection} that is encountered.
* @throws Exception The query could not be parsed.
*/
public static @Nullable MultiProjection getMultiProjection(final String sparql) throws Exception {
requireNonNull(sparql);
final AtomicReference<MultiProjection> multiProjection = new AtomicReference<>();
final ParsedQuery parsed = new SPARQLParser().parseQuery(sparql, null);
parsed.getTupleExpr().visit(new QueryModelVisitorBase<Exception>() {
@Override
public void meet(final MultiProjection node) throws Exception {
multiProjection.set(node);
}
});
return multiProjection.get();
}
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:MultiProjectionEvaluatorTest.java
示例7: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(MultiProjection projection) {
List<ExtensionElem> bindings;
if (projection.getArg() instanceof Extension) {
bindings = ((Extension) projection.getArg()).getElements();
}
else {
bindings = Arrays.asList();
}
for (ProjectionElemList template : projection.getProjections()) {
recordConsequent(template, bindings);
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:14,代码来源:ConstructConsequentVisitor.java
示例8: testMultiProjection
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Test
public void testMultiProjection() {
Extension extension = new Extension(new SingletonSet(),
new ExtensionElem(new ValueConstant(RDF.TYPE), "rdftype"),
new ExtensionElem(new ValueConstant(OWL.OBJECTPROPERTY), "owlprop"),
new ExtensionElem(new ValueConstant(OWL.EQUIVALENTCLASS), "owleqcls"),
new ExtensionElem(new ValueConstant(OWL.CLASS), "owlclass"));
MultiProjection projection = new MultiProjection(extension, Arrays.asList(
new ProjectionElemList(
new ProjectionElem("cls", "subject"),
new ProjectionElem("rdftype", "predicate"),
new ProjectionElem("owlclass", "object")),
new ProjectionElemList(
new ProjectionElem("prop", "subject"),
new ProjectionElem("rdftype", "predicate"),
new ProjectionElem("owlprop", "object")),
new ProjectionElemList(
new ProjectionElem("owleqcls", "predicate"),
new ProjectionElem("cls", "object"))));
ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
projection.visit(visitor);
Set<StatementPattern> expected = Sets.newHashSet(
new StatementPattern(s(null), p(RDF.TYPE), o(OWL.CLASS)),
new StatementPattern(s(null), p(RDF.TYPE), o(OWL.OBJECTPROPERTY)),
new StatementPattern(s(null), p(OWL.EQUIVALENTCLASS), o(null)));
Assert.assertEquals(expected, visitor.getConsequents());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:28,代码来源:ConstructConsequentVisitorTest.java
示例9: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(MultiProjection node) throws RuntimeException {
setSeen(node);
super.meet(node);
}
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:6,代码来源:SeenVisitor.java
示例10: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(MultiProjection node) throws RuntimeException {
check(node);
super.meet(node);
}
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:6,代码来源:ConsistencyVisitor.java
示例11: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(final Reduced node) {
//create id, initialize ConstructQueryMetadata builder, register ConstructQueryMetadata
//builder with FluoQueryBuilder, and add metadata that we currently have
final String constructId = nodeIds.getOrMakeId(node);
ConstructQueryMetadata.Builder constructBuilder = fluoQueryBuilder.getConstructQueryBuilder().orNull();
if(constructBuilder == null) {
constructBuilder = ConstructQueryMetadata.builder();
constructBuilder.setNodeId(constructId);
fluoQueryBuilder.setConstructQueryMetadata(constructBuilder);
}
//get child node
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());
}
//get ExtensionElems to build ConstructGraph
final QueryModelNode grandChild = unary.getArg();
Preconditions.checkArgument(grandChild instanceof Extension);
final Extension extension = (Extension) grandChild;
final List<ExtensionElem> extensionElems = extension.getElements();
final ConstructGraph graph = getConstructGraph(projections, extensionElems);
constructBuilder.setConstructGraph(graph);
//set child to the next node we care about in Fluo
//if Extension's arg is a Group node, then it is an Aggregation, so set child to Extension
//otherwise set child to Extension's child (only care about Extensions if they are Aggregations)
if(extension.getArg() instanceof Group) {
child = extension;
} else {
child = extension.getArg();
}
//Set the child node in the ConstructQueryMetadataBuilder
final String childNodeId = nodeIds.getOrMakeId(child);
constructBuilder.setChildNodeId(childNodeId);
// Update the child node's metadata.
final Set<String> childVars = getVars((TupleExpr)child);
final VariableOrder childVarOrder = new VariableOrder(childVars);
setChildMetadata(fluoQueryBuilder, childNodeId, childVarOrder, constructId);
//fast forward visitor to next node we care about
child.visit(this);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:56,代码来源:SparqlFluoQueryBuilder.java
示例12: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(final MultiProjection n) {
emit(Query.create(n, null, SPARQLRenderer.this.forceSelect));
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:5,代码来源:SPARQLRenderer.java
示例13: extractQueryNodes
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
private static List<UnaryTupleOperator> extractQueryNodes(final TupleExpr rootNode,
final boolean haltOnGroup) {
final List<UnaryTupleOperator> nodes = Lists.newArrayList();
TupleExpr queryNode = rootNode;
while (queryNode instanceof UnaryTupleOperator) {
nodes.add((UnaryTupleOperator) queryNode);
queryNode = ((UnaryTupleOperator) queryNode).getArg();
}
boolean describeFound = false;
boolean modifierFound = false;
boolean projectionFound = false;
boolean groupFound = false;
boolean orderFound = false;
boolean sliceFound = false;
boolean extensionFound = false;
int index = 0;
while (index < nodes.size()) {
final UnaryTupleOperator node = nodes.get(index);
if (node instanceof DescribeOperator && !describeFound) {
describeFound = true;
} else if ((node instanceof Distinct || node instanceof Reduced) && !modifierFound
&& !projectionFound) {
modifierFound = true;
} else if ((node instanceof Projection || node instanceof MultiProjection)
&& !projectionFound) {
projectionFound = true;
} else if (node instanceof Group && !groupFound && !haltOnGroup) {
groupFound = true;
} else if (node instanceof Order && !orderFound) {
orderFound = true;
} else if (node instanceof Slice && !sliceFound) {
sliceFound = true;
} else if (node instanceof Filter && !groupFound && !haltOnGroup) {
int i = index + 1;
for (; i < nodes.size() && nodes.get(i) instanceof Extension;) {
++i;
}
if (i < nodes.size() && nodes.get(i) instanceof Group) {
groupFound = true;
index = i;
} else {
break;
}
} else if (node instanceof Extension && !extensionFound) {
extensionFound = true;
} else if (!(node instanceof QueryRoot) || index > 0) {
break;
}
++index;
}
return nodes.subList(0, index);
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:65,代码来源:SPARQLRenderer.java
示例14: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(MultiProjection arg0) throws Exception {
arg0.visitChildren(this);
}
开发者ID:markusstocker,项目名称:emrooz,代码行数:5,代码来源:SparqlQueryModelVisitor.java
示例15: meet
import org.openrdf.query.algebra.MultiProjection; //导入依赖的package包/类
@Override
public void meet(MultiProjection arg0) throws SparqlParserException
{
// NO-OP
}
开发者ID:obidea,项目名称:semantika,代码行数:6,代码来源:SparqlQueryHandler.java
注:本文中的org.openrdf.query.algebra.MultiProjection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论