I'm puzzled by the following code fragment in this method:
// if the filter is positional, try changing f[a and b] to f[a][b] to
increase
// the chances of finishing early.
if (filterIsPositional &&
filter instanceof BooleanExpression &&
((BooleanExpression)filter).operator == Tokenizer.AND) {
BooleanExpression bf = (BooleanExpression)filter;
if (isPositionalFilter(bf.operands[0]) &&
bf.operands[1].getItemType()==Type.BOOLEAN &&
!isPositionalFilter(bf.operands[1])) {
FilterExpression f1 = new FilterExpression(start,
bf.operands[0]);
FilterExpression f2 = new FilterExpression(f1, bf.operands[1]);
//System.err.println("Simplified to: ");
//f2.display(10);
return f2.analyze(env);
}
if (isPositionalFilter(bf.operands[1]) &&
bf.operands[1].getItemType()==Type.BOOLEAN &&
!isPositionalFilter(bf.operands[0])) {
FilterExpression f1 = new FilterExpression(start,
bf.operands[1]);
FilterExpression f2 = new FilterExpression(f1, bf.operands[0]);
return f2.analyze(env);
}
}
Translating the tests into words it reads:
If f is a positional filter of form "a and b" then
If a is a positional filter and b is not a positional filter, but IS
a BOOLEAN then rewrite
Otherwise if b is a positional filter and a is not a positional
filter, but B IS a BOOLEAN then rewrite
^
|
I'm strugling to understand this, but the fact that the logic of the
two cases is not symmetrical (i.e. the same operand is testes for
being a boolean expression) worries me.
--
Colin Paul Adams
Preston Lancashire
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|