private Table minusWorker(Table tableLeft, Table tableRight)
{
// Minus(Ω1, Ω2) = { μ | μ in Ω1 such that for all μ' in Ω2, either μ and μ' are not compatible or dom(μ) and dom(μ') are disjoint }
TableN results = new TableN() ;
QueryIterator iterLeft = tableLeft.iterator(execCxt) ;
for ( ; iterLeft.hasNext() ; )
{
Binding bindingLeft = iterLeft.nextBinding() ;
boolean includeThisRow = true ;
// Find a reason not to include the row.
// That's is not disjoint and not compatible.
QueryIterator iterRight = tableRight.iterator(execCxt) ;
for ( ; iterRight.hasNext() ; )
{
Binding bindingRight = iterRight.nextBinding() ;
if ( Algebra.disjoint(bindingLeft, bindingRight) )
// Disjoint - not a reason to exclude
continue ;
if ( ! Algebra.compatible(bindingLeft, bindingRight) )
// Compatible - not a reason to exclude.
continue ;
includeThisRow = false ;
break ;
}
iterRight.close();
if ( includeThisRow )
results.addBinding(bindingLeft) ;
}
iterLeft.close();