@Override public Set<String> getBindingNames() { return set.getBindingNames(); }
@Override public Iterator<String> varNames() { return bs.getBindingNames().iterator(); }
private Set<String> findBindingNames() { Set<String> result = new HashSet<>(); if (bindingSets != null) { for (BindingSet set : bindingSets) { result.addAll(set.getBindingNames()); } } return result; }
private Set<String> findBindingNames() { Set<String> result = new HashSet<String>(); if (bindingSets != null) { for (BindingSet set : bindingSets) { result.addAll(set.getBindingNames()); } } return result; }
public Tuple(BindingSet bindingset) { bindingset .getBindingNames() .stream() .sorted() .forEach(name -> line.add(bindingset.getValue(name))); }
public Tuple(BindingSet bindingset) { bindingset .getBindingNames() .stream() .sorted() .forEach(name -> line.add(bindingset.getValue(name))); }
private boolean bindingSetsIntersect(BindingSet bs1, BindingSet bs2) { for(String s: bs1.getBindingNames()) { if(bs2.getValue(s) != null && !unAssuredVariables.contains(s)) { return true; } } return false; }
/** * Compute the relevant binding names using the variables occuring in the service expression and the input * bindings. The idea is find all variables which need to be projected in the subquery, i.e. those that * will not be bound by an input binding. * <p> * If the resulting list is empty, the cross product needs to be formed. * * @param bindings * @param serviceVars * @return the list of relevant bindings (if empty: the cross product needs to be formed) */ private List<String> getRelevantBindingNames(List<BindingSet> bindings, Set<String> serviceVars) { // get the bindings variables // TODO CHECK: does the first bindingset give all relevant names List<String> relevantBindingNames = new ArrayList<>(5); for (String bName : bindings.get(0).getBindingNames()) { if (serviceVars.contains(bName)) relevantBindingNames.add(bName); } return relevantBindingNames; }
/** * Compute the relevant binding names using the variables occuring in the service expression and the input * bindings. The idea is find all variables which need to be projected in the subquery, i.e. those that * will not be bound by an input binding. * <p> * If the resulting list is empty, the cross product needs to be formed. * * @param bindings * @param serviceVars * @return the list of relevant bindings (if empty: the cross product needs to be formed) */ private List<String> getRelevantBindingNames(List<BindingSet> bindings, Set<String> serviceVars) { // get the bindings variables // TODO CHECK: does the first bindingset give all relevant names List<String> relevantBindingNames = new ArrayList<String>(5); for (String bName : bindings.get(0).getBindingNames()) { if (serviceVars.contains(bName)) relevantBindingNames.add(bName); } return relevantBindingNames; }
/** * Compute the relevant binding names using the variables occuring in the service expression and the input * bindings. The idea is find all variables which need to be projected in the subquery, i.e. those that * will not be bound by an input binding. * <p> * If the resulting list is empty, the cross product needs to be formed. * * @param bindings * @param serviceVars * @return the list of relevant bindings (if empty: the cross product needs to be formed) */ private List<String> getRelevantBindingNames(List<BindingSet> bindings, Set<String> serviceVars) { // get the bindings variables // TODO CHECK: does the first bindingset give all relevant names List<String> relevantBindingNames = new ArrayList<String>(5); for (String bName : bindings.get(0).getBindingNames()) { if (serviceVars.contains(bName)) relevantBindingNames.add(bName); } return relevantBindingNames; }
private VariableOrder getVarOrder(final BindingSet bs) { return new VariableOrder(bs.getBindingNames()); }
/** * Check whether two {@link BindingSet}s are compatible. Two binding sets are compatible if they have * equal values for each binding name that occurs in both binding sets. */ public static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2) { Set<String> sharedBindings = new HashSet<>(bs1.getBindingNames()); sharedBindings.retainAll(bs2.getBindingNames()); for (String bindingName : sharedBindings) { Value value1 = bs1.getValue(bindingName); Value value2 = bs2.getValue(bindingName); if (!value1.equals(value2)) { return false; } } return true; }
/** * Check whether two {@link BindingSet}s are compatible. Two binding sets are compatible if they have * equal values for each binding name that occurs in both binding sets. */ public static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2) { Set<String> sharedBindings = new HashSet<String>(bs1.getBindingNames()); sharedBindings.retainAll(bs2.getBindingNames()); for (String bindingName : sharedBindings) { Value value1 = bs1.getValue(bindingName); Value value2 = bs2.getValue(bindingName); if (!value1.equals(value2)) { return false; } } return true; }
/** * Check whether two {@link BindingSet}s are compatible. Two binding sets are compatible if they have * equal values for each binding name that occurs in both binding sets. */ public static boolean bindingSetsCompatible(BindingSet bs1, BindingSet bs2) { Set<String> sharedBindings = new HashSet<String>(bs1.getBindingNames()); sharedBindings.retainAll(bs2.getBindingNames()); for (String bindingName : sharedBindings) { Value value1 = bs1.getValue(bindingName); Value value2 = bs2.getValue(bindingName); if (!value1.equals(value2)) { return false; } } return true; }
public static Set<String> getCommonVars(final StarQuery query, final BindingSet bs) { final Set<String> starQueryVarNames = Sets.newHashSet(); if(bs == null || bs.size() == 0) { return Sets.newHashSet(); } final Set<String> bindingNames = bs.getBindingNames(); starQueryVarNames.addAll(query.getUnCommonVars()); if(!query.commonVarConstant()) { starQueryVarNames.add(query.getCommonVarName()); } return Sets.intersection(bindingNames, starQueryVarNames); }
/** * Retrieve a modified queryString into which all bindings of the given argument are replaced with their * value. * * @param queryString * @param bindings * @return the modified queryString */ public static String getGraphQueryString(String queryString, BindingSet bindings) { if (bindings.size() == 0) { return queryString; } String qry = queryString; for (String name : bindings.getBindingNames()) { String replacement = valueToString(bindings.getValue(name)); if (replacement != null) { String pattern = "[\\?\\$]" + name + "(?=\\W)"; // we use Matcher.quoteReplacement to make sure things like newlines // in literal values are preserved qry = qry.replaceAll(pattern, Matcher.quoteReplacement(replacement)); } } return qry; }
@Override public void handleSolution(BindingSet arg0) throws TupleQueryResultHandlerException { Set<String> names = arg0.getBindingNames(); MapBindingSet sol = new MapBindingSet(names.size()); for (String n : names) { Value v = AGHttpRepoClient.getApplicationValue(arg0.getValue(n), vf); if (v != null) { sol.addBinding(n, v); } } handler.handleSolution(sol); }
private BindingSet removeConstants(BindingSet bs) { QueryBindingSet bSet = new QueryBindingSet(); for (String s : bs.getBindingNames()) { if (!VarNameUtils.isConstant(s)) { bSet.addBinding(bs.getBinding(s)); } } return bSet; }
public static StarQuery getConstrainedStarQuery(final StarQuery query, final BindingSet bs) { if(bs.size() == 0) { return query; } final Set<String> bindingNames = bs.getBindingNames(); final Set<String> unCommonVarNames = query.getUnCommonVars(); final Set<String> intersectVar = Sets.intersection(bindingNames, unCommonVarNames); if (!query.commonVarConstant()) { final Value v = bs.getValue(query.getCommonVarName()); if (v != null) { query.commonVar.setValue(v); } } for(final String s: intersectVar) { try { query.nodeColumnCond[query.varPos.get(s)] = query.setValue(query.nodeColumnCond[query.varPos.get(s)], bs.getValue(s)); } catch (final RyaTypeResolverException e) { e.printStackTrace(); } } return query; }
@Override public BindingSet next() throws QueryEvaluationException { if (!hasNext() || isClosed) { throw new NoSuchElementException(); } Statement statment = statementIt.next(); MapBindingSet bset = new MapBindingSet(); if (!subjectBinding.startsWith("-const")) bset.addBinding(subjectBinding, statment.getSubject()); if (!predicateBinding.startsWith("-const")) bset.addBinding(predicateBinding, statment.getPredicate()); if (!objectBinding.startsWith("-const")) bset.addBinding(objectBinding, statment.getObject()); if (contextBinding != null && !contextBinding.startsWith("-const")) bset.addBinding(contextBinding, statment.getContext()); // merge with other bindings. for (String name : bindings.getBindingNames()) { bset.addBinding(name, bindings.getValue(name)); } return bset; }