Skip to content

Commit

Permalink
LUCENE-9552: make sure we don't construct Illegal rectangles due to q…
Browse files Browse the repository at this point in the history
…uantization (apache#2131)
  • Loading branch information
iverase authored and ctargett committed Dec 16, 2020
1 parent 9d24e3c commit 1d629a0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,28 @@ public void visit(QueryVisitor visitor) {

@Override
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException {
final Component2D tree = LatLonGeometry.create(geometries);

if (tree.getMinY() > tree.getMaxY()) {
// encodeLatitudeCeil may cause minY to be > maxY iff
// the delta between the longitude < the encoding resolution
return new ConstantScoreWeight(this, boost) {
@Override
public Scorer scorer(LeafReaderContext context) {
return null;
}

return new ConstantScoreWeight(this, boost) {

final Component2D tree = LatLonGeometry.create(geometries);
final GeoEncodingUtils.Component2DPredicate component2DPredicate = GeoEncodingUtils.createComponentPredicate(tree);
@Override
public boolean isCacheable(LeafReaderContext ctx) {
return false;
}
};
}

final GeoEncodingUtils.Component2DPredicate component2DPredicate = GeoEncodingUtils.createComponentPredicate(tree);

return new ConstantScoreWeight(this, boost) {

@Override
public Scorer scorer(LeafReaderContext context) throws IOException {
final SortedNumericDocValues values = context.reader().getSortedNumericDocValues(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,22 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) {

@Override
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException {

final Component2D tree = LatLonGeometry.create(geometries);
if (tree.getMinY() > tree.getMaxY()) {
// encodeLatitudeCeil may cause minY to be > maxY iff
// the delta between the longitude < the encoding resolution
return new ConstantScoreWeight(this, boost) {
@Override
public Scorer scorer(LeafReaderContext context) {
return null;
}

@Override
public boolean isCacheable(LeafReaderContext ctx) {
return false;
}
};
}
final GeoEncodingUtils.Component2DPredicate component2DPredicate = GeoEncodingUtils.createComponentPredicate(tree);
// bounding box over all geometries, this can speed up tree intersection/cheaply improve approximation for complex multi-geometries
final byte minLat[] = new byte[Integer.BYTES];
Expand Down

0 comments on commit 1d629a0

Please sign in to comment.