当前位置: 首页>>代码示例>>Java>>正文


Java Var.isConstant方法代码示例

本文整理汇总了Java中org.openrdf.query.algebra.Var.isConstant方法的典型用法代码示例。如果您正苦于以下问题:Java Var.isConstant方法的具体用法?Java Var.isConstant怎么用?Java Var.isConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openrdf.query.algebra.Var的用法示例。


在下文中一共展示了Var.isConstant方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matchesValue

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
 * The following table describes how a Subject, Predicate, and Object Var may be handled for a Statement and a
 * Statement Pattern:
 * <table border=1>
 *     <tr> <th>Pattern's var is constant</th> <th>Effect on resulting BS</th> </tr>
 *     <try> <td>yes</td> <td>Emit a BS if they match, no Context binding</td> </tr>
 *     <try> <td>no</td>  <td>Emit a BS with a binding for the variable</td> </tr>
 * </table>
 *
 * @param var - The statement pattern variable that is being matched. (not null)
 * @param stmtValue - The statement's value for the variable. (not null)
 * @param bs - The binding set that may be updated to include a binding for the variable. (not null)
 * @return {@code true} if he variable and the statement value match, otherwise {@code false},
 */
private boolean matchesValue(final Var var, final Value stmtValue, final QueryBindingSet bs) {
    requireNonNull(var);
    requireNonNull(stmtValue);
    requireNonNull(bs);

    // If the var is a constant, statement's value must match the var's value.
    if(var.isConstant()) {
        if(!stmtValue.equals(var.getValue())) {
            return false;
        }
    } else {
        // Otherwise it is a variable to be filled in.
        bs.addBinding(var.getName(), stmtValue);
    }

    // Either the value matched the constant or the binding set was updated.
    return true;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:33,代码来源:StatementPatternMatcher.java

示例2: meetNAryValueOperator

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meetNAryValueOperator(NAryValueOperator node) {

    List<ValueExpr> oldValues = node.getArguments();
    List<ValueExpr> newValues = Lists.newArrayList();

    for (ValueExpr v : oldValues) {
        if (v instanceof Var) {
            Var var = (Var) v;
            if (!(var.isConstant() && hMap.containsKey(var.getName()))) {
                String val = hMap.get(var.getName());
                if (val.startsWith("-const-")) {
                    newValues.add(new ValueConstant(valMap.get(val)));
                } else {
                    var.setName(val);
                    newValues.add(var);
                }
            }
        } else {
            newValues.add(v);
        }
    }
    
    node.setArguments(newValues);

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:QueryVariableNormalizer.java

示例3: meet

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meet(Var node) throws Exception {

    int count = 1;

    if (!node.isConstant()) {
        if (varMap.containsKey(node.getName())) {
            count = varMap.get(node.getName());
            count++;
            varMap.put(node.getName(), count);
        } else
            varMap.put(node.getName(), 1);

        if (!emptyVarMap.containsKey(node.getName()))
            emptyVarMap.put(node.getName(), 0);

    }
    super.meet(node);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:QueryVariableNormalizer.java

示例4: EventQueryNode

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
 * Constructs an instance of {@link EventQueryNode}.
 * @param usedFilters
 *
 * @param type - The type of {@link Event} this node matches. (not null)
 * @param patterns - The query StatementPatterns that are solved using an
 *   Event of the Type. (not null)
 * @param entities - The {@link EventStorage} that will be searched to match
 *   {@link BindingSet}s when evaluating a query. (not null)
 */
private EventQueryNode(final EventStorage eventStore, final StatementPattern geoPattern, final StatementPattern temporalPattern, final Collection<IndexingExpr> geoFilters, final Collection<IndexingExpr> temporalFilters, final Collection<FunctionCall> usedFilters) throws IllegalStateException {
    this.geoPattern = requireNonNull(geoPattern);
    this.temporalPattern = requireNonNull(temporalPattern);
    this.geoFilters = requireNonNull(geoFilters);
    this.temporalFilters = requireNonNull(temporalFilters);
    this.eventStore = requireNonNull(eventStore);
    this.usedFilters = requireNonNull(usedFilters);
    bindingNames = new HashSet<>();

    // Subject based preconditions.
    verifySameSubjects(getPatterns());
    // Predicate based preconditions.
    verifyAllPredicatesAreConstants(getPatterns());

    // The Subject may either be constant or a variable.
    final Var subject = patterns.iterator().next().getSubjectVar();
    subjectIsConstant = subject.isConstant();
    if(subjectIsConstant) {
        subjectConstant = Optional.of( subject.getValue().toString() );
        subjectVar = Optional.empty();
    } else {
        subjectConstant = Optional.empty();
        subjectVar = Optional.of( subject.getName() );
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:36,代码来源:EventQueryNode.java

示例5: canApply

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
 * Returns true if this rule is applicable to a node.
 *
 * @param node to a node
 * @return true if the rule is applicable, false otherwise
 */
@Override
public boolean canApply(StatementPattern node) {
	Var p = node.getPredicateVar();
	// check if predicate is variable
	return !(predicates.isEmpty() || p.isConstant());
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:13,代码来源:PredicateVariable.java

示例6: getURIString

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
 * Returns the URI of a constant {@link Var} object.
 *
 * @param v the {@link Var} object
 * @return URI as string if it is a URI, null otherwise
 */
protected String getURIString(Var v) {
	if (v.isConstant()) {
		Value val = v.getValue();
		if (val instanceof URI) {
			URI uri = (URI) val;
			return uri.stringValue();
		}
	}
	return null;
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:17,代码来源:AbstractRule.java

示例7: meet

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
@Override
public void meet(Var node) throws RuntimeException {

    if (node.isConstant()) {
        String key = node.getValue().toString();
        if(constantMap.containsKey(key)){
            int count = constantMap.get(key);
            count += 1;
            constantMap.put(key, count);
        } else {
            constantMap.put(key, 1);
        }
    }

}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:16,代码来源:VarConstantIndexListPruner.java

示例8: getBindingNames

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
public Set<String> getBindingNames() {
    //resource and match variable for search are already included as standard result-bindings
    Set<String> bindings = Sets.newHashSet();

    for(Var v: spConstraint.getVarList()) {
        if(!v.isConstant()) {
            bindings.add(v.getName());
        }
    }
    return bindings;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:12,代码来源:IndexingExpr.java

示例9: EntityQueryNode

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
/**
 * Constructs an instance of {@link EntityQueryNode}.
 *
 * @param type - The type of {@link Entity} this node matches. (not null)
 * @param patterns - The query StatementPatterns that are solved using an
 *   Entity of the Type. (not null)
 * @param entities - The {@link EntityStorage} that will be searched to match
 *   {@link BindingSet}s when evaluating a query. (not null)
 */
public EntityQueryNode(final Type type, final Collection<StatementPattern> patterns, final EntityStorage entities) throws IllegalStateException {
    this.type = requireNonNull(type);
    this.patterns = requireNonNull(patterns);
    this.entities = requireNonNull(entities);

    bindingNames = new HashSet<>();
    properties = new HashSet<>();
    // Subject based preconditions.
    verifySameSubjects(patterns);

    // Predicate based preconditions.
    verifyAllPredicatesAreConstants(patterns);
    verifyHasCorrectTypePattern(type, patterns);
    verifyAllPredicatesPartOfType(type, patterns);

    // The Subject may either be constant or a variable.
    final Var subject = patterns.iterator().next().getSubjectVar();
    subjectIsConstant = subject.isConstant();
    if(subjectIsConstant) {
        subjectConstant = Optional.of( subject.getValue().toString() );
        subjectVar = Optional.empty();
    } else {
        subjectConstant = Optional.empty();
        subjectVar = Optional.of( subject.getName() );
    }

    // Any constant that appears in the Object portion of the SP will be used to make sure they match.
    final Builder<RyaURI, Var> builder = ImmutableMap.<RyaURI, Var>builder();
    for(final StatementPattern sp : patterns) {
        final Var object = sp.getObjectVar();
        final Var pred = sp.getPredicateVar();
        final RyaURI predURI = new RyaURI(pred.getValue().stringValue());
        bindingNames.addAll(sp.getBindingNames());
        if(object.isConstant() && !pred.getValue().equals(RDF.TYPE)) {
            final RyaType propertyType = RdfToRyaConversions.convertValue(object.getValue());
            properties.add(new Property(predURI, propertyType));
        }
        builder.put(predURI, object);
    }
    objectVariables = builder.build();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:51,代码来源:EntityQueryNode.java

示例10: getCommonVar

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
private Var getCommonVar(final List<StatementPattern> nodes) {

        Set<Var> vars = null;
        final List<Var> tempVar;
        Set<Var> tempSet;

        int i = 0;
        for (final StatementPattern sp : nodes) {

            if (vars == null) {
                vars = Sets.newHashSet();
                vars.add(sp.getSubjectVar());
                vars.add(sp.getObjectVar());
            } else {
                tempSet = Sets.newHashSet();
                tempSet.add(sp.getSubjectVar());
                tempSet.add(sp.getObjectVar());
                vars = Sets.intersection(vars, tempSet);
            }

        }
        if (vars == null) {
            throw new NullPointerException("vars is null so the list of statement pattern nodes must be empty: nodes.size()= " + nodes.size());
        }
        if (vars.size() == 1) {
            return vars.iterator().next();
        } else if (vars.size() > 1) {
            Var first = null;

            i = 0;

            for (final Var v : vars) {
                i++;

                if (i == 1) {
                    first = v;
                } else {
                    if (v.isConstant()) {
                        return v;
                    }
                }
            }

            return first;

        } else {
            throw new IllegalStateException("No common Var!");
        }

    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:51,代码来源:StarQuery.java

示例11: isValidStarQuery

import org.openrdf.query.algebra.Var; //导入方法依赖的package包/类
public static boolean isValidStarQuery(final Collection<StatementPattern> nodes) {

        Set<String> bindings = null;
        boolean contextSet = false;
        Var context = null;

        if(nodes.size() < 2) {
            return false;
        }

        for(final StatementPattern sp: nodes) {

            final Var tempContext = sp.getContextVar();
            final Var predVar = sp.getPredicateVar();

            //does not support variable context
            if(tempContext != null && !tempContext.isConstant()) {
               return false;
            }
            if(!contextSet) {
                context = tempContext;
                contextSet = true;
            } else {

                if(context == null && tempContext != null) {
                    return false;
                } else if (context != null && !context.equals(tempContext)) {
                    return false;
                }
            }

            if(!predVar.isConstant()) {
                return false;
            }

            if(bindings == null ) {
                bindings = sp.getBindingNames();
                if(bindings.size() == 0) {
                    return false;
                }
            } else {
                bindings = Sets.intersection(bindings, sp.getBindingNames());
                if(bindings.size() == 0) {
                    return false;
                }
            }

        }


        return isBindingsetValid(bindings);
    }
 
开发者ID:apache,项目名称:incubator-rya,代码行数:53,代码来源:StarQuery.java


注:本文中的org.openrdf.query.algebra.Var.isConstant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。