/** Merge two bindings, assuming they are compatible. */ public static Binding merge(Binding bind1, Binding bind2) { //Create binding from LHS BindingMap b2 = BindingFactory.create(bind1) ; Iterator<Var> vIter = bind2.vars() ; // Add any variables from the RHS for ( ; vIter.hasNext() ; ) { Var v = vIter.next() ; if ( ! b2.contains(v) ) b2.add(v, bind2.get(v)) ; else { // Checking! Node n1 = bind1.get(v) ; Node n2 = bind2.get(v) ; if ( ! n1.equals(n2) ) Log.warn(BindingUtils.class, "merge: Mismatch : "+n1+" != "+n2); } } return b2 ; }
Var var = Var.alloc( varName ); if( !result.contains( var ) ) result.add( var, JenaUtils.makeGraphNode( entry.getValue() ) );
public Binding convert(Binding b) { if ( parentBinding == null || parentBinding.isEmpty() ) return b ; // This is the result. Could have BindingBase.setParent etc. BindingMap b2 = new BindingMap(parentBinding) ; // Copy the resultSet bindings to the combined result binding with checking. for ( Iterator<Var> iter = b.vars() ; iter.hasNext(); ) { Var v = iter.next(); Node n = b.get(v) ; if ( b2.contains(v) ) { Node n2 = b2.get(v) ; if ( n2.equals(n) ) Log.warn(this, "Binding already for "+v+" (same value)" ) ; else { Log.fatal(this, "Binding already for "+v+" (different values)" ) ; throw new ARQInternalErrorException("QueryIteratorResultSet: Incompatible bindings for "+v) ; } } b2.add(v, n) ; } return b2 ; } }
@Override public Binding convert(Binding b) { if ( parentBinding == null || parentBinding.isEmpty() ) return b ; // This is the result. Could have BindingBase.setParent etc. BindingMap b2 = BindingFactory.create(parentBinding) ; // Copy the resultSet bindings to the combined result binding with checking. for ( Iterator<Var> iter = b.vars() ; iter.hasNext(); ) { Var v = iter.next(); Node n = b.get(v) ; if ( b2.contains(v) ) { Node n2 = b2.get(v) ; if ( n2.equals(n) ) Log.warn(this, "Binding already for "+v+" (same value)" ) ; else { Log.fatal(this, "Binding already for "+v+" (different values)" ) ; throw new ARQInternalErrorException("Incompatible bindings for "+v) ; } } b2.add(v, n) ; } return b2 ; } }