@Override public boolean equals(Object o) { if (o instanceof BindingSet) { return ((BindingSet)o).size() == 0; } return false; }
@Override public boolean equals(Object o) { if (o instanceof BindingSet) { return ((BindingSet)o).size() == 0; } return false; }
@Override public int size() { return set.size(); }
public SPARQLQueryBindingSet(BindingSet bindingSet) { this(bindingSet.size()); addAll(bindingSet); }
public QueryBindingSet(BindingSet bindingSet) { this(bindingSet.size()); addAll(bindingSet); }
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); }
public void optimize(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings) { if (bindings.size() > 0) { tupleExpr.visit(new VarVisitor(bindings)); } }
@Override public CloseableIteration<BindingSet, QueryEvaluationException> query( final SelectQuery query, @Nullable final BindingSet bindings, final Long timeout) throws IOException, UnsupportedOperationException { if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} - evaluating query ({} bindings, {} timeout):\n{}", this, bindings == null ? 0 : bindings.size(), timeout, query); final String name = "query result iteration"; final long ts = System.currentTimeMillis(); CloseableIteration<BindingSet, QueryEvaluationException> result; result = logClose(super.query(query, bindings, timeout), name, ts); LOGGER.debug("{} - {} obtained in {} ms", this, name, System.currentTimeMillis() - ts); return result; } else { return super.query(query, bindings, timeout); } }
@Override public BindingSet next() throws QueryEvaluationException { BindingSet next = super.next(); if (next == null) { return null; } int size = bindings.size() + next.size(); SPARQLQueryBindingSet set = new SPARQLQueryBindingSet(size); set.addAll(bindings); for (Binding binding : next) { set.setBinding(binding); } return set; }
@Override public BindingSet next() throws QueryEvaluationException { BindingSet next = super.next(); if (next == null) { return null; } int size = bindings.size() + next.size(); QueryBindingSet set = new QueryBindingSet(size); set.addAll(bindings); for (Binding binding : next) { set.setBinding(binding); } return set; }
@Override public BindingSet next() throws QueryEvaluationException { BindingSet next = super.next(); if (next == null) { return null; } int size = bindings.size() + next.size(); QueryBindingSet set = new QueryBindingSet(size); set.addAll(bindings); for (Binding binding : next) { set.setBinding(binding); } return set; }
@Override protected BindingSet getNextElement() throws QueryEvaluationException { if (currentInputBinding==null) { inputBindingsIterator = inputBindings.iterator(); if (resultIteration.hasNext()) currentInputBinding = resultIteration.next(); else return null; // no more results } if (inputBindingsIterator.hasNext()) { BindingSet next = inputBindingsIterator.next(); QueryBindingSet res = new QueryBindingSet(next.size() + currentInputBinding.size() ); res.addAll(next); res.addAll(currentInputBinding); if (!inputBindingsIterator.hasNext()) currentInputBinding = null; return res; } return null; } }
@Override public BindingSet next() throws QueryEvaluationException { BindingSet next = super.next(); QueryBindingSet result; if (next == null) { result = null; // NOPMD } else { int size = bindings.size() + next.size(); result = new QueryBindingSet(size); result.addAll(bindings); for (Binding binding : next) { result.setBinding(binding); } } return result; }
public Ruleset transform(@Nullable final BindingSet bindings) { if (bindings == null || bindings.size() == 0) { return this; } final List<Rule> transformedRules = new ArrayList<>(); for (final Rule rule : this.rules) { final TupleExpr head = Algebra.rewrite(rule.getHead(), bindings); final TupleExpr body = Algebra.rewrite(rule.getBody(), bindings); transformedRules.add(new Rule(rule.getID(), head, body)); } return new Ruleset(transformedRules, this.staticTerms); }
/** * Exports BindingSets to Kafka. The BindingSet and topic are extracted from * the indicated BindingSetRecord and the BindingSet is then exported to the topic. */ @Override public void exportNotification(final BindingSetRecord record) throws BindingSetRecordExportException { try { log.info("Exporting {} records to Kafka to topic: {}", record.getBindingSet().size(), record.getTopic()); final String bindingName = IncrementalUpdateConstants.PERIODIC_BIN_ID; final BindingSet bindingSet = record.getBindingSet(); final String topic = record.getTopic(); final long binId = ((Literal) bindingSet.getValue(bindingName)).longValue(); final Future<RecordMetadata> future = producer .send(new ProducerRecord<String, BindingSet>(topic, Long.toString(binId), bindingSet)); //wait for confirmation that results have been received future.get(5, TimeUnit.SECONDS); } catch (final Exception e) { // catch all possible exceptional behavior and throw as our checked exception. throw new BindingSetRecordExportException(e.getMessage(), e); } }
@Override public void processAggregate(BindingSet s) throws QueryEvaluationException { if (getArg() != null) { Value value = evaluate(s); if (value != null && distinctValue(value)) { count++; } } else { // wildcard count if (s.size() > 0 && distinctBindingSet(s)) { count++; } } }
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 protected BindingSet convert(BindingSet bindingSet) { MapBindingSet result = new MapBindingSet(bindingSet.size()); for (Binding binding : bindingSet) { String name = binding.getName(); Value value = binding.getValue(); if (value instanceof URI) { value = new AURI(name, (URI)value, node); } else if (value instanceof BNode) { value = new ABNode(name, (BNode)value, node); } binding = new BindingImpl(name, value); result.addBinding(binding); } return result; } }