forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ES|QL: refactor MV tests with geo (elastic#109837)
Small refactoring of MV_SLICE and MV_APPEND tests regarding random shape generation. Moving the logic to limit the size of random shapes to a helper class.
- Loading branch information
1 parent
47ad822
commit 29172b1
Showing
5 changed files
with
99 additions
and
131 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
test/framework/src/main/java/org/elasticsearch/geo/GeometryPointCountVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.geo; | ||
|
||
import org.elasticsearch.geometry.Circle; | ||
import org.elasticsearch.geometry.Geometry; | ||
import org.elasticsearch.geometry.GeometryCollection; | ||
import org.elasticsearch.geometry.GeometryVisitor; | ||
import org.elasticsearch.geometry.Line; | ||
import org.elasticsearch.geometry.LinearRing; | ||
import org.elasticsearch.geometry.MultiLine; | ||
import org.elasticsearch.geometry.MultiPoint; | ||
import org.elasticsearch.geometry.MultiPolygon; | ||
import org.elasticsearch.geometry.Point; | ||
import org.elasticsearch.geometry.Polygon; | ||
import org.elasticsearch.geometry.Rectangle; | ||
|
||
public class GeometryPointCountVisitor implements GeometryVisitor<Integer, RuntimeException> { | ||
|
||
@Override | ||
public Integer visit(Circle circle) throws RuntimeException { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public Integer visit(GeometryCollection<?> collection) throws RuntimeException { | ||
int size = 0; | ||
for (Geometry geometry : collection) { | ||
size += geometry.visit(this); | ||
} | ||
return size; | ||
} | ||
|
||
@Override | ||
public Integer visit(Line line) throws RuntimeException { | ||
return line.length(); | ||
} | ||
|
||
@Override | ||
public Integer visit(LinearRing ring) throws RuntimeException { | ||
return ring.length(); | ||
} | ||
|
||
@Override | ||
public Integer visit(MultiLine multiLine) throws RuntimeException { | ||
return visit((GeometryCollection<Line>) multiLine); | ||
} | ||
|
||
@Override | ||
public Integer visit(MultiPoint multiPoint) throws RuntimeException { | ||
return multiPoint.size(); | ||
} | ||
|
||
@Override | ||
public Integer visit(MultiPolygon multiPolygon) throws RuntimeException { | ||
return visit((GeometryCollection<Polygon>) multiPolygon); | ||
} | ||
|
||
@Override | ||
public Integer visit(Point point) throws RuntimeException { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public Integer visit(Polygon polygon) throws RuntimeException { | ||
int size = polygon.getPolygon().length(); | ||
for (int i = 0; i < polygon.getNumberOfHoles(); i++) { | ||
size += polygon.getHole(i).length(); | ||
} | ||
return size; | ||
} | ||
|
||
@Override | ||
public Integer visit(Rectangle rectangle) throws RuntimeException { | ||
return 4; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters