本文整理了Java中org.openrdf.query.algebra.Extension.getElements()
方法的一些代码示例,展示了Extension.getElements()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Extension.getElements()
方法的具体详情如下:
包路径:org.openrdf.query.algebra.Extension
类名称:Extension
方法名:getElements
暂无
代码示例来源:origin: org.openrdf.sesame/sesame-queryalgebra-model
@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: org.openrdf.sesame/sesame-queryalgebra-model
@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.openrdf.sesame/sesame-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: eu.fbk.rdfpro/rdfpro-rules
public static ValueExpr parseValueExpr(final String string, @Nullable final String baseURI,
@Nullable final Map<String, String> namespaces) throws MalformedQueryException {
Objects.requireNonNull(string);
final TupleExpr expr = parseQuery("SELECT ((" + string + ") AS ?dummy) WHERE {}", baseURI,
namespaces).getTupleExpr();
return ((Extension) ((Projection) expr).getArg()).getElements().get(0).getExpr();
}
代码示例来源:origin: eu.fbk.knowledgestore/ks-server
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;
}
代码示例来源:origin: eu.fbk.rdfpro/rdfpro-rules
private static Map<String, ExtensionElem> extractExtensions(final TupleExpr rootNode) {
final Map<String, ExtensionElem> map = new HashMap<>();
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;
}
代码示例来源:origin: org.apache.rya/rya.api.evaluation
/**
* Constructs an instance of {@link ProjectionEvaluator}.
*
* @param projectionElems - Defines the structure of the resulting value. (not null)
* @param extensions - Extra information about the projection elements when there are anonymous constants or blank
* nodes within the projection elements. (not null)
*/
public ProjectionEvaluator(final ProjectionElemList projectionElems, final Optional<Extension> extensions) {
this.projectionElems = requireNonNull(projectionElems);
requireNonNull(extensions);
// Find all extensions that represent constant insertions.
if(extensions.isPresent()) {
for(final ExtensionElem extensionElem : extensions.get().getElements()) {
final ValueExpr valueExpr = extensionElem.getExpr();
// If the extension is a ValueConstant, store it so that they may be added to the binding sets.
if(valueExpr instanceof ValueConstant) {
final String sourceName = extensionElem.getName();
final Value targetValue = ((ValueConstant) valueExpr).getValue();
constantSources.put(sourceName, targetValue);
}
// If the extension is a BNodeGenerator, keep track of the name so that we know we have to generate an ID for it.
else if(valueExpr instanceof BNodeGenerator) {
final String sourceName = extensionElem.getName();
anonymousSources.add( sourceName );
}
}
}
}
代码示例来源:origin: apache/marmotta
@Override
public void meet(Extension node) throws RuntimeException {
// visit children before, as there might be dependencies
super.meet(node);
for(ExtensionElem elem : node.getElements()) {
if(elem.getExpr() instanceof Var && ((Var) elem.getExpr()).getName().equals(elem.getName())) {
log.debug("ignoring self-aliasing of variable {}", elem.getName());
} else {
elements.add(elem);
}
}
}
代码示例来源:origin: org.openrdf.elmo/elmo-repository
@Override
public void meet(Extension node) {
handleType(SeRQO.EXTENSION);
handleChildList(SeRQO.ELEMENTS, node.getElements());
super.meet(node);
}
代码示例来源:origin: org.apache.rya/rya.api.evaluation
/**
* 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);
}
代码示例来源:origin: org.apache.rya/mongodb.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: org.openrdf.sesame/sesame-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.openrdf.sesame/sesame-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.openrdf.sesame/sesame-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: eu.fbk.rdfpro/rdfpro-rules
for (final ExtensionElem elem : new ArrayList<>(extension.getElements())) {
final Set<String> elemVars = extractVariables(elem.getExpr());
Extension newArg = null;
extension.getElements().remove(elem);
dirty = true;
if (extension.getElements().isEmpty()) {
expr = (TupleExpr) replaceNode(expr, extension, extension.getArg());
代码示例来源:origin: org.openrdf.sesame/sesame-queryalgebra-evaluation
@Override
public BindingSet convert(BindingSet sourceBindings)
throws QueryEvaluationException
{
QueryBindingSet targetBindings = new QueryBindingSet(sourceBindings);
for (ExtensionElem extElem : extension.getElements()) {
ValueExpr expr = extElem.getExpr();
if (!(expr instanceof AggregateOperator)) {
try {
// we evaluate each extension element over the targetbindings, so that bindings from
// a previous extension element in this same extension can be used by other extension elements.
// e.g. if a projection contains (?a + ?b as ?c) (?c * 2 as ?d)
Value targetValue = strategy.evaluate(extElem.getExpr(), targetBindings);
if (targetValue != null) {
// Potentially overwrites bindings from super
targetBindings.setBinding(extElem.getName(), targetValue);
}
}
catch (ValueExprEvaluationException e) {
// silently ignore type errors in extension arguments. They should not cause the
// query to fail but just result in no additional binding.
}
}
}
return targetBindings;
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-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: eu.fbk.knowledgestore/ks-server
@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;
}
}
}
代码示例来源:origin: eu.fbk.rdfpro/rdfpro-rules
@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;
}
}
}
代码示例来源:origin: org.openrdf.sesame/sesame-queryparser-serql
if (!extension.getElements().isEmpty()) {
extension.setArg(result);
result = extension;
内容来源于网络,如有侵权,请联系作者删除!