本文整理汇总了Java中org.openrdf.query.algebra.Extension类的典型用法代码示例。如果您正苦于以下问题:Java Extension类的具体用法?Java Extension怎么用?Java Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Extension类属于org.openrdf.query.algebra包,在下文中一共展示了Extension类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testUnsupportedExtension
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Test
public void testUnsupportedExtension() throws Exception {
StatementPattern sp = new StatementPattern(new Var("x"), constant(TAKES), new Var("c"));
List<ExtensionElem> elements = Arrays.asList(new ExtensionElem(new Var("x"), "renamed"),
new ExtensionElem(new Not(new ValueConstant(VF.createLiteral(true))), "notTrue"),
new ExtensionElem(new ValueConstant(TAKES), "constant"));
Extension extensionNode = new Extension(sp, elements);
QueryRoot queryTree = new QueryRoot(extensionNode);
SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection);
queryTree.visit(visitor);
Assert.assertTrue(queryTree.getArg() instanceof Extension);
Assert.assertEquals(elements, ((Extension) queryTree.getArg()).getElements());
TupleExpr innerQuery = ((Extension) queryTree.getArg()).getArg();
Assert.assertTrue(innerQuery instanceof AggregationPipelineQueryNode);
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) innerQuery;
Assert.assertEquals(Sets.newHashSet("x", "c"), pipelineNode.getAssuredBindingNames());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:SparqlToPipelineTransformVisitorTest.java
示例2: make
import org.openrdf.query.algebra.Extension; //导入依赖的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: meet
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Override
public void meet(Extension node) {
Set<String> argBindings = node.getArg().getBindingNames();
if (typeRequirement != null) {
node.getElements().removeIf(elem -> {
if (varName.equals(elem.getName())) {
ValueExpr expr = elem.getExpr();
if (expr == null) {
return true;
}
else if (expr instanceof Var) {
String fromName = ((Var) expr).getName();
if (getVarValue((Var) expr) == null && !argBindings.contains(fromName)) {
return true;
}
}
}
return false;
});
meetUnaryTupleOperator(node);
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:SpinConstructRule.java
示例4: testConcreteSP
import org.openrdf.query.algebra.Extension; //导入依赖的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
示例5: meet
import org.openrdf.query.algebra.Extension; //导入依赖的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
示例6: meet
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Override
public void meet(final Extension n) {
emit(n.getArg());
if (!(n.getArg() instanceof SingletonSet)) {
newline();
}
boolean first = true;
for (final ExtensionElem e : n.getElements()) {
final ValueExpr expr = e.getExpr();
if (!(expr instanceof Var) || !((Var) expr).getName().equals(e.getName())) {
if (!first) {
newline();
}
emit("BIND (").emit(expr).emit(" AS ?").emit(e.getName()).emit(")");
first = false;
}
}
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:19,代码来源:SPARQLRenderer.java
示例7: extractExtensions
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
private static Map<String, ExtensionElem> extractExtensions(final TupleExpr rootNode) {
final Map<String, ExtensionElem> map = Maps.newHashMap();
for (final UnaryTupleOperator node : extractQueryNodes(rootNode, true)) {
if (node instanceof Extension) {
for (final ExtensionElem elem : ((Extension) node).getElements()) {
final String variable = elem.getName();
final ValueExpr expression = elem.getExpr();
if (!(expression instanceof Var)
|| !((Var) expression).getName().equals(variable)) {
map.put(variable, elem);
}
}
}
}
return map;
}
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:17,代码来源:SPARQLRenderer.java
示例8: testPropertyPattern_constantSubj
import org.openrdf.query.algebra.Extension; //导入依赖的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
示例9: testPropertyPattern_constantObj
import org.openrdf.query.algebra.Extension; //导入依赖的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
示例10: meet
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Override
public void meet(Extension extensionNode) throws Exception {
extensionNode.visitChildren(this);
if (extensionNode.getArg() instanceof AggregationPipelineQueryNode && extensionNode.getParentNode() != null) {
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) extensionNode.getArg();
if (pipelineNode.extend(extensionNode.getElements())) {
extensionNode.replaceWith(pipelineNode);
}
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:SparqlToPipelineTransformVisitor.java
示例11: testExtension
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Test
public void testExtension() throws Exception {
QueryRoot queryTree = new QueryRoot(new Extension(
new StatementPattern(new Var("x"), constant(TAKES), new Var("c")),
new ExtensionElem(new Var("x"), "renamed"),
new ExtensionElem(new ValueConstant(TAKES), "constant")));
SparqlToPipelineTransformVisitor visitor = new SparqlToPipelineTransformVisitor(collection);
queryTree.visit(visitor);
Assert.assertTrue(queryTree.getArg() instanceof AggregationPipelineQueryNode);
AggregationPipelineQueryNode pipelineNode = (AggregationPipelineQueryNode) queryTree.getArg();
Assert.assertEquals(Sets.newHashSet("x", "c", "renamed", "constant"), pipelineNode.getAssuredBindingNames());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:13,代码来源:SparqlToPipelineTransformVisitorTest.java
示例12: make
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
/**
* Make a {@link ProjectionEvaluator} that processes the logic of a {@link Projection}.
*
* @param projection - Defines the projection that will be processed. (not null)
* @return A {@link ProjectionEvaluator} for the provided {@link Projection}.
*/
public static ProjectionEvaluator make(final Projection projection) {
requireNonNull(projection);
final ProjectionElemList projectionElems = projection.getProjectionElemList();
final TupleExpr arg = projection.getArg();
final Optional<Extension> extension = arg instanceof Extension ? Optional.of((Extension)arg) : Optional.empty();
return new ProjectionEvaluator(projectionElems, extension);
}
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:ProjectionEvaluator.java
示例13: makeId
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
private String makeId(final QueryModelNode node) {
checkNotNull(node);
// Create the prefix of the id. This makes it a little bit more human readable.
String prefix;
if (node instanceof StatementPattern) {
prefix = SP_PREFIX;
} else if (node instanceof Filter) {
prefix = FILTER_PREFIX;
} else if (node instanceof Join || node instanceof LeftJoin) {
prefix = JOIN_PREFIX;
} else if (node instanceof Projection) {
prefix = PROJECTION_PREFIX;
} else if(node instanceof Extension) {
prefix = AGGREGATION_PREFIX;
} else if (node instanceof Reduced) {
prefix = CONSTRUCT_PREFIX;
} else if(node instanceof PeriodicQueryNode) {
prefix = PERIODIC_QUERY_PREFIX;
} else {
throw new IllegalArgumentException("Node must be of type {StatementPattern, Join, Filter, Extension, Projection} but was " + node.getClass());
}
final String unique = UUID.randomUUID().toString().replaceAll("-", "");
// Put them together to create the Node ID.
return prefix + "_" + unique;
}
开发者ID:apache,项目名称:incubator-rya,代码行数:28,代码来源:SparqlFluoQueryBuilder.java
示例14: meet
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Override
public void meet(Projection projection) {
if (projection.getArg() instanceof Extension) {
recordConsequent(projection.getProjectionElemList(),
((Extension) projection.getArg()).getElements());
}
else {
recordConsequent(projection.getProjectionElemList(), Arrays.asList());
}
}
开发者ID:apache,项目名称:incubator-rya,代码行数:11,代码来源:ConstructConsequentVisitor.java
示例15: testGenericSP
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Test
public void testGenericSP() {
Extension extension = new Extension(new SingletonSet(),
new ExtensionElem(new Var("z"), "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(null), p(null), o(null)));
Assert.assertEquals(expected, visitor.getConsequents());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:15,代码来源:ConstructConsequentVisitorTest.java
示例16: testMissingVariables
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Test
public void testMissingVariables() {
Extension extension = new Extension(new SingletonSet(),
new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"),
new ExtensionElem(new ValueConstant(RDF.TYPE), "y"));
Projection projection = new Projection(extension, new ProjectionElemList(
new ProjectionElem("x", "s"),
new ProjectionElem("y", "predicate"),
new ProjectionElem("z", "object")));
ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
projection.visit(visitor);
Set<StatementPattern> expected = Sets.newHashSet(
new StatementPattern(s(null), p(RDF.TYPE), o(null)));
Assert.assertEquals(expected, visitor.getConsequents());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:ConstructConsequentVisitorTest.java
示例17: testMultiProjection
import org.openrdf.query.algebra.Extension; //导入依赖的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
示例18: testBNode
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Test
public void testBNode() {
Extension extension = new Extension(new SingletonSet(),
new ExtensionElem(new Var("x"), "x"),
new ExtensionElem(new BNodeGenerator(), "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(null), p(null), anon(o(null))));
Assert.assertEquals(expected, visitor.getConsequents());
}
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:ConstructConsequentVisitorTest.java
示例19: assignPredicates
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
/**
* Creates an expression that extends a statement pattern to include
* inferred predicates.
*
* @param assign a list of predicates that could be inferred
* @param source the source statement pattern
* @param next a list of expressions that should be visited next
* @return a union of statement patterns that include inferred triples
* for a predicate variable
*/
private TupleExpr assignPredicates(
List<String> assign, StatementPattern source,
List<QueryModelNode> next) {
if (assign.isEmpty()) {
return source;
}
Var s = source.getSubjectVar();
Var p = source.getPredicateVar();
Var o = source.getObjectVar();
Var c = source.getContextVar();
Var p2;
StatementPattern sp;
ArrayList<TupleExpr> union = new ArrayList<>();
// for each possible predicate create an extension element that will
// bind the predicate to the variable, if the predicate can be inferred.
for (String a : assign) {
p2 = new ConstVar(vf.createURI(a));
sp = new StatementPattern(s, p2, o, c);
next.add(sp);
union.add(new Extension(
sp,
new ExtensionElem(
new ValueConstant(vf.createURI(a)),
p.getName())));
}
return listAsUnion(union);
}
开发者ID:niclashoyer,项目名称:neo4j-sparql-extension,代码行数:38,代码来源:PredicateVariable.java
示例20: meet
import org.openrdf.query.algebra.Extension; //导入依赖的package包/类
@Override
public void meet(Extension arg0) throws SparqlParserException
{
List<String> unknownVariables = new ArrayList<String>();
for (ExtensionElem el : arg0.getElements()) {
unknownVariables.add(el.getName());
}
throw new SparqlParserException("Unknown projection variables: " + unknownVariables); //$NON-NLS-1$
}
开发者ID:obidea,项目名称:semantika,代码行数:10,代码来源:SparqlQueryHandler.java
注:本文中的org.openrdf.query.algebra.Extension类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论