On Mon, Feb 3, 2014 at 9:45 PM, Andrea Aime <andrea.a...@geo-solutions.it>wrote:

> Also, I still have to verify that what we discussed so far actually brings
> the database
> 3 state logic back to our 2 state one in a fully equivalent manner: think
> nested filters
> or combinations, I believe that once even one bit is unknown, everything
> just flips
> into that state, and that the only way to get out of it is to have
> explicit "is null", "is not null"
> statements...
> Have to check.
>

Ok, checked, found a case where I'm not sure there is an equivalent
translation, it's the handling
of not with an unknown.

Take this case:
create table abc(a integer, b integer, c integer);
insert into abc values(null, null, null);

And then let's evaluate in memory  not(a > 3 or b = 5 or c <= 10). The
result is not(false or false or false)
-> true. So in memory we would return the feature with a, b and c all nulls.

However, here is the evaluation against a database, with either the direct
query, or when we apply
the de-morgan rules:

gttest=# select * from abc where not(a > 3 or b = 5 or c <= 10);
 a | b | c
---+---+---
(0 rows)

gttest=# select * from abc where a <= 3 and (b < 5 or b > 5) and c > 10;
 a | b | c
---+---+---
(0 rows)

The first one is evaluated as the database as not(unknown or uknown or
unknown) -> not(unknown) -> unknown
(which is "false" for us, as it does not return any rule).
the second one is evaluated as unknown and (unknown or unknown) and unknown
-> unknown (which is again false for us)

If we instead we do the translation I was suggesting at the beginning:
gttest=# select * from abc where not((a > 3 and a is not null) or (b = 5
and b is not null) or(c <= 10 and c is not null));
 a | b | c
---+---+---
   |   |
(1 row)

Which is longer, but also equivalent to the result we would have got in
memory.

So, I'm going to implement this one, and will make sure redundant "is not
null" checks are stripped before encoding
in sql (going to make the simplifying filter visitor eliminate repeated
filters in a AND or OR chain)

Cheers
Andrea

-- 
== Our support, Your Success! Visit http://opensdi.geo-solutions.it for
more information ==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39  339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to