}
@Override
protected boolean checkPrecondition(final Map<String, BasicOperator> mso) {
BasicOperator operator = mso.get("operator");
final Filter filter = (Filter) mso.get("filter");
while (operator instanceof Filter) {
if (operator.getPrecedingOperators().size() > 1
|| operator.getSucceedingOperators().size() > 1)
return false;
operator = operator.getPrecedingOperators().get(0);
}
if (operator.getSucceedingOperators().size() > 1)
return false;
if (operator instanceof TriplePattern
|| operator instanceof lupos.engine.operators.index.BasicIndexScan
|| operator instanceof lupos.engine.operators.index.Root)
return false;
if (operator instanceof Union) {
for (final BasicOperator o : operator.getPrecedingOperators())
if (o.getSucceedingOperators().size() > 1
|| !(o.getUnionVariables().containsAll(
filter.getUsedVariables()) && !(o instanceof Filter && filter
.equalFilterExpression((Filter) o))))
return false;
return true;
}
if (operator instanceof Optional) {
if (operator.getPrecedingOperators().size() == 2) {
BasicOperator o = operator.getPrecedingOperators().get(0);
if (// o.getSucceedingOperators().size() == 1 &&
o.getUnionVariables().containsAll(filter.getUsedVariables())
&& !(o instanceof Filter && filter
.equalFilterExpression((Filter) o))) {
o = operator.getPrecedingOperators().get(1);
if (// o.getSucceedingOperators().size() == 1 &&
o.getUnionVariables()
.containsAll(filter.getUsedVariables())
&& !(o instanceof Filter && filter
.equalFilterExpression((Filter) o)))
return true;
}
}
return false;
}
if (operator instanceof Join) {
// check if the join has preceding operators in a loop
if (operator.getCycleOperands() != null
&& operator.getCycleOperands().size() > 0)
return false;
}
for (final BasicOperator o : operator.getPrecedingOperators()) {
if (o.getSucceedingOperators().size() == 1
&& o.getUnionVariables().containsAll(
filter.getUsedVariables())
&& !(o instanceof Filter && filter
.equalFilterExpression((Filter) o)))
return true;
}
return false;
}