apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.59k stars 1.01k forks source link

LatLonPoint quantization should use same rounding mode as GeoPointField [LUCENE-7160] #8215

Open asfimport opened 8 years ago

asfimport commented 8 years ago

Both of these fields quantize doubles in a lossy way, but GeoPoint rounds towards negative infinity (because all values get shifted to positive space first), whereas LatLonPoint currently rounds towards zero.

At the same time they share the same basic logic for e.g. tree traversal and same basic tests: so it creates confusion that they round differently.

Especially since e.g. LatLonPoint does some operations in binary/integer space (some of these optimizations such as its box query are currently buggy for edge cases, and tests are lenient as TODO, another issue, may or may not impact GeoPoint, it at least tries harder).

I think LatLonPoint should round down to be more like GeoPoint here? By the way, doing this also gives more consistency, it reduces the difference between the two implementations in e.g. openstreetmaps searching (distance query benchmark now differs by only 4 hits...)

This quantization makes things complicated to reason about. I understand the advantages it brings but I think along with that comes the responsibility of us handling edge cases better. I don't think we do well at this today...


Migrated from LUCENE-7160 by Robert Muir (@rmuir) Attachments: LUCENE-7160.patch

asfimport commented 8 years ago

Robert Muir (@rmuir) (migrated from JIRA)

Here's a patch. I think its a first step towards e.g. removing test leniency, testing and fixing edge cases to at least be consistent.

asfimport commented 8 years ago

Michael McCandless (@mikemccand) (migrated from JIRA)

+1

asfimport commented 8 years ago

ASF subversion and git services (migrated from JIRA)

Commit c071a3a8b57f9a46ef1d236bd70233c0ae4224c7 in lucene-solr's branch refs/heads/master from @rmuir https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=c071a3a

LUCENE-7160: LatLonPoint quantization should use the same rounding mode as GeoPointField

asfimport commented 8 years ago

ASF subversion and git services (migrated from JIRA)

Commit d9d88b8941108bf9d30c1e47ab881e94e6faabf2 in lucene-solr's branch refs/heads/branch_6x from @rmuir https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=d9d88b8

LUCENE-7160: LatLonPoint quantization should use the same rounding mode as GeoPointField