org.eclipse.rdf4j.query.algebra.Extension类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中org.eclipse.rdf4j.query.algebra.Extension类的一些代码示例,展示了Extension类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Extension类的具体详情如下:
包路径:org.eclipse.rdf4j.query.algebra.Extension
类名称:Extension

Extension介绍

[英]An extension operator that can be used to add bindings to solutions whose values are defined by ValueExpr.
[中]一个扩展运算符,可用于向ValueExpr定义其值的解决方案添加绑定。

代码示例

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

@Override
public boolean equals(Object other) {
  if (other instanceof Extension && super.equals(other)) {
    Extension o = (Extension)other;
    return elements.equals(o.getElements());
  }
  return false;
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

@Override
public void meet(Extension node)
  throws RDFHandlerException
{
  if (inlineBindings != null && inlineBindings.extension == node) {
    // this is the first Extension node and has already been handled
    // by meetExtension()
    // to produce inline bindings in SELECT so we can skip it here
    node.getArg().visit(this);
  }
  else {
    // any further Extension nodes produce BIND() clauses
    node.getArg().visit(this);
    for (ExtensionElem elem : node.getElements()) {
      elem.visit(this);
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

private void addSourceExpressions(UnaryTupleOperator op, Collection<ProjectionElem> elems) {
  Extension ext = null;
  for (ProjectionElem projElem : elems) {
    ExtensionElem extElem = projElem.getSourceExpression();
    if (extElem != null) {
      if (ext == null) {
        ext = new Extension(op.getArg());
        op.setArg(ext);
      }
      ext.addElement(extElem);
    }
  }
}

代码示例来源:origin: apache/incubator-rya

@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);
    }
  }
}

代码示例来源:origin: eclipse/rdf4j

@Override
  public Extension clone() {
    Extension clone = (Extension)super.clone();

    clone.elements = new ArrayList<>(getElements().size());
    for (ExtensionElem elem : getElements()) {
      clone.addElement(elem.clone());
    }

    return clone;
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

@Override
public TupleExpr visit(ASTDescribe node, Object data)
  throws VisitorException
{
  TupleExpr tupleExpr = (TupleExpr)data;
  if (tupleExpr == null) {
    tupleExpr = new SingletonSet();
  }
  Extension e = new Extension();
  ProjectionElemList projectionElements = new ProjectionElemList();
  for (int i = 0; i < node.jjtGetNumChildren(); i++) {
    ValueExpr resource = (ValueExpr)node.jjtGetChild(i).jjtAccept(this, null);
    if (resource instanceof Var) {
      projectionElements.addElement(new ProjectionElem(((Var)resource).getName()));
    }
    else {
      String alias = "_describe_" + UUID.randomUUID().toString().replaceAll("-", "_");
      ExtensionElem elem = new ExtensionElem(resource, alias);
      e.addElement(elem);
      projectionElements.addElement(new ProjectionElem(alias));
    }
  }
  if (!e.getElements().isEmpty()) {
    e.setArg(tupleExpr);
    tupleExpr = e;
  }
  Projection p = new Projection(tupleExpr, projectionElements);
  return new DescribeOperator(p);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

String alias = ((ASTVar)aliasNode).getName();
Extension extension = new Extension();
extension.addElement(new ExtensionElem(ve, alias));
  extension.setArg(((Filter)arg).getArg());
  ((Filter)arg).setArg(extension);
  extension.setArg(arg);
  result = extension;

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-sail-lucene-api

@Override
  public void updateQueryModelNodes(boolean hasResult) {
    QueryModelNode replacementNode = hasResult ? new SingletonSet() : new EmptySet();
    geoStatement.replaceWith(replacementNode);

    if (hasResult) {
      filter.replaceWith(filter.getArg());
    }
    else {
      filter.replaceWith(new EmptySet());
    }

    if (functionParent instanceof ExtensionElem) {
      Extension extension = (Extension)functionParent.getParentNode();
      List<ExtensionElem> elements = extension.getElements();
      if (elements.size() > 1) {
        elements.remove(functionParent);
      }
      else {
        extension.replaceWith(extension.getArg());
      }
    }
  }
}

代码示例来源:origin: apache/incubator-rya

@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());
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

private void visitBind(Resource r)
  throws RDF4JException
{
  Value expr = TripleSources.singleValue(r, SP.EXPRESSION_PROPERTY, store);
  ValueExpr valueExpr = visitExpression(expr);
  Value varValue = TripleSources.singleValue(r, SP.VARIABLE_PROPERTY, store);
  if (!(varValue instanceof Resource)) {
    throw new MalformedSpinException(
        String.format("Value of %s is not a resource", SP.VARIABLE_PROPERTY));
  }
  String varName = getVarName((Resource)varValue);
  tupleNode = new Extension(tupleNode, new ExtensionElem(valueExpr, varName));
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

@Override
public void meet(Extension node)
  throws RDFHandlerException
{
  node.getArg().visit(this);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

aExt = new Extension();
aExt.addElements(new ExtensionElem(new ValueConstant(aPattern.getSubjectVar().getValue()),
    aPattern.getSubjectVar().getName()));
  aExt = new Extension();
aExt.addElements(new ExtensionElem(new ValueConstant(aPattern.getPredicateVar().getValue()),
    aPattern.getPredicateVar().getName()));
  aExt = new Extension();
aExt.addElements(new ExtensionElem(new ValueConstant(aPattern.getObjectVar().getValue()),
    aPattern.getObjectVar().getName()));

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

public void addElements(Iterable<ExtensionElem> elements) {
  for (ExtensionElem pe : elements) {
    addElement(pe);
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

public Extension(TupleExpr arg, ExtensionElem... elements) {
  this(arg);
  addElements(elements);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryparser-sparql

@Override
public TupleExpr visit(ASTDescribe node, Object data)
  throws VisitorException
{
  TupleExpr tupleExpr = (TupleExpr)data;
  if (tupleExpr == null) {
    tupleExpr = new SingletonSet();
  }
  Extension e = new Extension();
  ProjectionElemList projectionElements = new ProjectionElemList();
  for (int i = 0; i < node.jjtGetNumChildren(); i++) {
    ValueExpr resource = (ValueExpr)node.jjtGetChild(i).jjtAccept(this, null);
    if (resource instanceof Var) {
      projectionElements.addElement(new ProjectionElem(((Var)resource).getName()));
    }
    else {
      String alias = "_describe_" + UUID.randomUUID().toString().replaceAll("-", "_");
      ExtensionElem elem = new ExtensionElem(resource, alias);
      e.addElement(elem);
      projectionElements.addElement(new ProjectionElem(alias));
    }
  }
  if (!e.getElements().isEmpty()) {
    e.setArg(tupleExpr);
    tupleExpr = e;
  }
  Projection p = new Projection(tupleExpr, projectionElements);
  return new DescribeOperator(p);
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryparser-sparql

String alias = ((ASTVar)aliasNode).getName();
Extension extension = new Extension();
extension.addElement(new ExtensionElem(ve, alias));
  extension.setArg(((Filter)arg).getArg());
  ((Filter)arg).setArg(extension);
  extension.setArg(arg);
  result = extension;

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-sail-lucene-api

@Override
public void updateQueryModelNodes(boolean hasResult) {
  QueryModelNode replacementNode = hasResult ? new SingletonSet() : new EmptySet();
  geoStatement.replaceWith(replacementNode);
  if (hasResult) {
    filter.replaceWith(filter.getArg());
  }
  else {
    filter.replaceWith(new EmptySet());
  }
  QueryModelNode functionParent = distanceFunction.getParentNode();
  if (functionParent instanceof ExtensionElem) {
    Extension extension = (Extension)functionParent.getParentNode();
    List<ExtensionElem> elements = extension.getElements();
    if (elements.size() > 1) {
      elements.remove(functionParent);
    }
    else {
      extension.replaceWith(extension.getArg());
    }
  }
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

private TupleExpr visitHaving(Resource having)
  throws RDF4JException
{
  UnaryTupleOperator op = (UnaryTupleOperator)group.getParentNode();
  op.setArg(new Extension(group));
  Iteration<? extends Resource, QueryEvaluationException> iter = TripleSources.listResources(having,
      store);
  while (iter.hasNext()) {
    Resource r = iter.next();
    ValueExpr havingExpr = visitExpression(r);
    Filter filter = new Filter(op.getArg(), havingExpr);
    op.setArg(filter);
    op = filter;
  }
  return op;
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-queryalgebra-evaluation

@Override
public void meet(Extension node) {
  if (node.getArg().getBindingNames().containsAll(filterVars)) {
    node.getArg().visit(this);
  }
  else {
    relocate(filter, node);
  }
}

代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client

@Override
  public Extension clone() {
    Extension clone = (Extension)super.clone();

    clone.elements = new ArrayList<ExtensionElem>(getElements().size());
    for (ExtensionElem elem : getElements()) {
      clone.addElement(elem.clone());
    }

    return clone;
  }
}

相关文章