org.eclipse.rdf4j.query.algebra.Extension.getElements()方法的使用及代码示例

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

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

Extension.getElements介绍

暂无

代码示例

代码示例来源: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: eclipse/rdf4j

@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: 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: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-spin

@Override
public void meet(Extension node) {
  extension = node;
  List<ExtensionElem> elements = node.getElements();
  // NB: preserve ExtensionElem order
  extensionExprs = new LinkedHashMap<String, ValueExpr>(elements.size());
  for (ExtensionElem elem : elements) {
    extensionExprs.put(elem.getName(), elem.getExpr());
  }
}

代码示例来源: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;
  }
}

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

@Override
public void meet(Extension e) {
  super.meet(e);
  for (ExtensionElem elem: e.getElements()) {
    res.add(elem.getName());
  }
}
// TODO maybe stop tree traversal in nested SERVICE?

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

@Override
public void meet(Extension e) {
  super.meet(e);
  for (ExtensionElem elem: e.getElements()) {
    res.add(elem.getName());
  }
}
// TODO maybe stop tree traversal in nested SERVICE?

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

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

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

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

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

@Override
public void meet(Projection projection) {
  if (projection.getArg() instanceof Extension) {
    recordConsequent(projection.getProjectionElemList(),
        ((Extension) projection.getArg()).getElements());
  }
  else {
    recordConsequent(projection.getProjectionElemList(), Arrays.asList());
  }
}

代码示例来源:origin: ontop/ontop

public DefaultSimpleGraphResultSet(TupleResultSet tupleResultSet, ConstructTemplate constructTemplate,
                  boolean storeResults, TermFactory termFactory,
                  org.apache.commons.rdf.api.RDF rdfFactory) throws OntopResultConversionException, OntopConnectionException {
  this.tupleResultSet = tupleResultSet;
  this.constructTemplate = constructTemplate;
  this.termFactory = termFactory;
  this.rdfFactory = rdfFactory;
  Extension ex = constructTemplate.getExtension();
  if (ex != null) {
    extMap = ex.getElements().stream()
        .collect(ImmutableCollectors.toMap(e -> e.getName(), e -> e.getExpr()));
  }
  else
    extMap = null;
  this.storeResults = storeResults;
  if (storeResults) {
    //process current result set into local buffer,
    //since additional results will be collected
    while (tupleResultSet.hasNext()) {
      results.addAll(processResults(tupleResultSet.next()));
    }
  }
}

代码示例来源: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: 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: 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: 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: 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-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: eclipse/rdf4j

@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-queryalgebra-evaluation

for (ExtensionElem extElem : extension.getElements()) {
  ValueExpr expr = extElem.getExpr();
  if (!(expr instanceof AggregateOperator)) {

代码示例来源: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());
  }
}

相关文章