- java.lang.Object
-
- org.apache.lucene.document.ShapeDocValues
-
- Direct Known Subclasses:
LatLonShapeDocValues
,XYShapeDocValues
abstract class ShapeDocValues extends java.lang.Object
A binary doc values format representation forLatLonShape
andXYShape
Note that this class cannot be instantiated directly due to different encodings
XYEncodingUtils
andGeoEncodingUtils
Concrete Implementations include:
LatLonShapeDocValues
andXYShapeDocValues
ShapeDocValues also does not support Multi Geometries because the area of the original geometries must be included to compute an accurate centroid. To support multi geometries binary doc values will need to be updated to support multi values (see:
NumericDocValues
andSortedNumericDocValues
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
ShapeDocValues.Encoder
private static class
ShapeDocValues.Reader
Reads values from a ShapeDocValues Fieldprivate class
ShapeDocValues.ShapeComparator
Shape Comparator class provides tree traversal relation methodsprivate class
ShapeDocValues.TreeNode
Builds an in memory binary tree of tessellated triangles.private class
ShapeDocValues.Writer
Writes data from a ShapeDocValues field to a data output array
-
Field Summary
Fields Modifier and Type Field Description protected Geometry
boundingBox
the bounding box of the shape docvalueprotected Geometry
centroid
the centroid of the shape docvalueprivate BytesRef
data
the binary doc valueprotected ShapeDocValues.ShapeComparator
shapeComparator
the geometry comparator used to check relationsprotected static byte
VERSION
doc value format version; used to support bwc for any encoding changes
-
Constructor Summary
Constructors Constructor Description ShapeDocValues(java.util.List<ShapeField.DecodedTriangle> tessellation)
Creates a instance from a shape tessellationShapeDocValues(BytesRef binaryValue)
Creates aShapeDocValues
instance from a given serialized value
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected BytesRef
binaryValue()
returns the encoded doc values field as aBytesRef
private ShapeDocValues.TreeNode
buildTree(java.util.List<ShapeField.DecodedTriangle> tessellation, java.util.List<ShapeDocValues.TreeNode> dfsSerialized)
main entry point to build the tessellation tree *private BytesRef
computeBinaryValue(java.util.List<ShapeField.DecodedTriangle> tessellation)
protected abstract Geometry
computeBoundingBox()
protected abstract Geometry
computeCentroid()
private int
computeComponentSize(ShapeDocValues.TreeNode node, int maxX, int maxY)
private ShapeDocValues.TreeNode
createTree(ShapeDocValues.TreeNode[] triangles, int low, int high, boolean splitX, ShapeDocValues.TreeNode parent, java.util.List<ShapeDocValues.TreeNode> dfsSerialized)
creates the treeabstract Geometry
getBoundingBox()
abstract Geometry
getCentroid()
protected int
getEncodedCentroidX()
Retrieves the encoded x centroid location for the geometry(s)protected int
getEncodedCentroidY()
Retrieves the encoded y centroid location for the geometry(s)int
getEncodedMaxX()
returns the max x value for the shape's bounding boxint
getEncodedMaxY()
returns the max y value for the shape's bounding boxint
getEncodedMinX()
returns the min x value for the shape's bounding boxint
getEncodedMinY()
returns the min y value for the shape's bounding boxprotected abstract ShapeDocValues.Encoder
getEncoder()
ShapeField.DecodedTriangle.TYPE
getHighestDimension()
Retrieves the highest dimensional type (POINT, LINE, TRIANGLE) for computing the geometry(s) centroidstatic Query
newGeometryQuery(java.lang.String field, ShapeField.QueryRelation relation, java.lang.Object... geometries)
Creates a geometry query for shape docvaluesint
numberOfTerms()
Returns the number of terms (tessellated triangles) for this shapePointValues.Relation
relate(Component2D component)
protected static int
vIntSize(int i)
Computes the variable Integer size in bytesprotected static int
vLongSize(long i)
Computes the variable Long size in bytes
-
-
-
Field Detail
-
VERSION
protected static final byte VERSION
doc value format version; used to support bwc for any encoding changes- See Also:
- Constant Field Values
-
data
private final BytesRef data
the binary doc value
-
shapeComparator
protected final ShapeDocValues.ShapeComparator shapeComparator
the geometry comparator used to check relations
-
centroid
protected final Geometry centroid
the centroid of the shape docvalue
-
boundingBox
protected final Geometry boundingBox
the bounding box of the shape docvalue
-
-
Constructor Detail
-
ShapeDocValues
ShapeDocValues(java.util.List<ShapeField.DecodedTriangle> tessellation)
Creates a instance from a shape tessellation- Parameters:
tessellation
- The tessellation (must not be null)
-
ShapeDocValues
ShapeDocValues(BytesRef binaryValue)
Creates aShapeDocValues
instance from a given serialized value
-
-
Method Detail
-
numberOfTerms
public int numberOfTerms()
Returns the number of terms (tessellated triangles) for this shape
-
getEncodedMinX
public int getEncodedMinX()
returns the min x value for the shape's bounding box
-
getEncodedMinY
public int getEncodedMinY()
returns the min y value for the shape's bounding box
-
getEncodedMaxX
public int getEncodedMaxX()
returns the max x value for the shape's bounding box
-
getEncodedMaxY
public int getEncodedMaxY()
returns the max y value for the shape's bounding box
-
getEncodedCentroidX
protected int getEncodedCentroidX()
Retrieves the encoded x centroid location for the geometry(s)
-
getEncodedCentroidY
protected int getEncodedCentroidY()
Retrieves the encoded y centroid location for the geometry(s)
-
getHighestDimension
public ShapeField.DecodedTriangle.TYPE getHighestDimension()
Retrieves the highest dimensional type (POINT, LINE, TRIANGLE) for computing the geometry(s) centroid
-
computeBinaryValue
private BytesRef computeBinaryValue(java.util.List<ShapeField.DecodedTriangle> tessellation)
-
newGeometryQuery
public static Query newGeometryQuery(java.lang.String field, ShapeField.QueryRelation relation, java.lang.Object... geometries)
Creates a geometry query for shape docvalues
-
relate
public PointValues.Relation relate(Component2D component) throws java.io.IOException
- Throws:
java.io.IOException
-
getEncoder
protected abstract ShapeDocValues.Encoder getEncoder()
-
computeCentroid
protected abstract Geometry computeCentroid()
-
computeBoundingBox
protected abstract Geometry computeBoundingBox()
-
getCentroid
public abstract Geometry getCentroid()
-
getBoundingBox
public abstract Geometry getBoundingBox()
-
buildTree
private ShapeDocValues.TreeNode buildTree(java.util.List<ShapeField.DecodedTriangle> tessellation, java.util.List<ShapeDocValues.TreeNode> dfsSerialized) throws java.io.IOException
main entry point to build the tessellation tree *- Throws:
java.io.IOException
-
createTree
private ShapeDocValues.TreeNode createTree(ShapeDocValues.TreeNode[] triangles, int low, int high, boolean splitX, ShapeDocValues.TreeNode parent, java.util.List<ShapeDocValues.TreeNode> dfsSerialized)
creates the tree
-
computeComponentSize
private int computeComponentSize(ShapeDocValues.TreeNode node, int maxX, int maxY)
-
vLongSize
protected static int vLongSize(long i)
Computes the variable Long size in bytes
-
vIntSize
protected static int vIntSize(int i)
Computes the variable Integer size in bytes
-
-