return minCost;
}
LOOP: for( int i = 0; i < atoms.size(); i++ ) {
QueryAtom atom = atoms.get( i );
boolean newNonOptimal = notOptimal;
Set<ATermAppl> newBoundVars = new HashSet<ATermAppl>( boundVars );
// TODO reorder UV atoms after all class and property variables are
// bound.
if( !atom.isGround() ) {
int boundCount = 0;
int unboundCount = 0;
for( ATermAppl a : atom.getArguments() ) {
if( ATermUtils.isVar( a ) ) {
if( newBoundVars.add( a ) ) {
unboundCount++;
/*
* It is not valid to have an ordering like
* NotKnown(ClassAtom(?x, A)), ClassAtom(?x, B).
* This is because variables in negation atom will
* not be bound by the query evaluation. However, if
* an atom in the query later binds the variable to
* a value the result will be incorrect because
* earlier evaluation of negation was not evaluated
* with that binding.
*/
if( atom.getPredicate().equals( QueryPredicate.NotKnown ) ) {
for( int j = 0; j < atoms.size(); j++ ) {
QueryAtom nextAtom = atoms.get( j );
if( i == j
|| nextAtom.getPredicate().equals(
QueryPredicate.NotKnown ) ) {
continue;
}
if( nextAtom.getArguments().contains( a ) ) {
if( log.isLoggable( Level.FINE ) )
log.fine( "Unbound vars for not" );
continue LOOP;
}
}