question: public boolean varUsedInFilterOrAssignment ( IVariable < ? > var ) { if ( ! usageMap . containsKey ( var ) ) { return false ; } final List < IQueryNode > varOccurrences = usageMap . get ( var ) ; for ( int i = 0 ; i < varOccurrences . size ( ) ; i ++ ) { final IQueryNode n = varOccurrences . get ( i ) ; if ( n instanceof FilterNode || n instanceof AssignmentNode ) { return true ; } } return false ; }
target:  Returns true if a usage record for the given variable inside a FILTER or BIND/VALUES node has been recorded. The rationale of this check is as follows: if a variable used inside a static binding is queries in such an ancestor filter, the binding must not be considered global. As an example, consider the following query: <pre> SELECT * WHERE { FILTER(!bound(?x)) { BIND(1 AS ?x) } }  Expected result is the empty set, according to bottom-up semantics. We must *not* rewrite this query as  SELECT * WHERE { FILTER(!bound(?x)) } VALUES ?x { 1 } The reason is that in this case the FILTER will pass, while ?x in the original query the BIND(1 AS ?x) is in scope and the filter fails. The same holds for queries where the FILTER is at the same level as the BIND/VALUES clause, such as: SELECT * WHERE { FILTER(!bound(?x)) { BIND(1 AS ?x) } } 