use of org.apache.jena.sparql.engine.binding.BindingBuilder in project jena by apache.
the class QueryIteratorMapped method moveToNextBinding.
@Override
protected Binding moveToNextBinding() {
Binding b = super.moveToNextBinding();
if (this.varMapping == null)
return b;
// Apply remapping
BindingBuilder builder = Binding.builder();
Iterator<Var> vs = b.vars();
while (vs.hasNext()) {
Var v = vs.next();
Node value = b.get(v);
// Only remap non-null variables for which there is a mapping
if (value == null)
continue;
if (this.varMapping.containsKey(v)) {
builder.add(this.varMapping.get(v), value);
}
}
return builder.build();
}
use of org.apache.jena.sparql.engine.binding.BindingBuilder in project jena by apache.
the class TransformFilterInequality method buildTable.
private static Table buildTable(Map<Var, Set<NodeValue>> possibleValues) {
if (possibleValues.size() == 0)
return TableFactory.createEmpty();
Table table = TableFactory.create();
// Although each filter condition must apply for a row to be accepted
// they are actually independent since only one condition needs to fail
// for the filter to reject the row. Thus for each unique variable/value
// combination a single row must be produced
BindingBuilder builder = Binding.builder();
for (Var v : possibleValues.keySet()) {
for (NodeValue value : possibleValues.get(v)) {
Binding b = builder.reset().add(v, value.asNode()).build();
table.addBinding(b);
}
}
return table;
}
use of org.apache.jena.sparql.engine.binding.BindingBuilder in project jena by apache.
the class SolverLibTDB method convToBinding.
static Binding convToBinding(BindingNodeId bindingNodeIds, NodeTable nodeTable) {
if (true)
return new BindingTDB(bindingNodeIds, nodeTable);
else {
// Makes nodes immediately. Causing unnecessary NodeTable accesses
// (e.g. project)
BindingBuilder builder = Binding.builder();
for (Var v : bindingNodeIds) {
NodeId id = bindingNodeIds.get(v);
Node n = nodeTable.getNodeForNodeId(id);
builder.add(v, n);
}
return builder.build();
}
}
use of org.apache.jena.sparql.engine.binding.BindingBuilder in project jena by apache.
the class NodeTransformLib method transform.
public static Binding transform(Binding b, NodeTransform transform) {
BindingBuilder b2 = Binding.builder();
List<Var> vars = Iter.toList(b.vars());
for (Var v : vars) {
Var v2 = (Var) transform.apply(v);
b2.add(v2, b.get(v));
}
return b2.build();
}
use of org.apache.jena.sparql.engine.binding.BindingBuilder in project jena by apache.
the class AbstractRewriter method rewrite.
/**
* Rewrite a binding.
*
* @param binding The binding to rewrite
* @return The rewritten binding.
*/
protected final Binding rewrite(Binding binding) {
BindingBuilder builder = Binding.builder();
Iterator<Var> iter = binding.vars();
while (iter.hasNext()) {
Var v = iter.next();
Node n = changeNode(binding.get(v));
n = n.equals(v) ? binding.get(v) : n;
builder.add(v, n);
}
return builder.build();
}
Aggregations