T
- extends Geometry - the type of geometries in the left setU
- extends Geometry - the type of geometries in the right setpublic class KnnJoinIndexJudgement<T extends org.locationtech.jts.geom.Geometry,U extends org.locationtech.jts.geom.Geometry> extends Object implements org.apache.spark.api.java.function.FlatMapFunction2<Iterator<T>,Iterator<org.locationtech.jts.index.SpatialIndex>,org.apache.commons.lang3.tuple.Pair<U,T>>, Serializable
Modifier and Type | Field and Description |
---|---|
protected org.apache.spark.util.LongAccumulator |
buildCount |
protected org.apache.spark.util.LongAccumulator |
candidateCount |
protected org.apache.spark.util.LongAccumulator |
resultCount |
protected org.apache.spark.util.LongAccumulator |
streamCount |
Constructor and Description |
---|
KnnJoinIndexJudgement(int k,
Double searchRadius,
DistanceMetric distanceMetric,
boolean includeTies,
org.apache.spark.broadcast.Broadcast<List> broadcastQueryObjects,
org.apache.spark.broadcast.Broadcast<STRtree> broadcastObjectsTreeIndex,
org.apache.spark.util.LongAccumulator buildCount,
org.apache.spark.util.LongAccumulator streamCount,
org.apache.spark.util.LongAccumulator resultCount,
org.apache.spark.util.LongAccumulator candidateCount)
Constructor for the KnnJoinIndexJudgement class.
|
Modifier and Type | Method and Description |
---|---|
Iterator<org.apache.commons.lang3.tuple.Pair<U,T>> |
call(Iterator<T> streamShapes,
Iterator<org.locationtech.jts.index.SpatialIndex> treeIndexes)
This method performs the KNN join operation.
|
static <U extends org.locationtech.jts.geom.Geometry,T extends org.locationtech.jts.geom.Geometry> |
distance(U key,
T value,
DistanceMetric distanceMetric) |
static double |
distanceByMetric(org.locationtech.jts.geom.Geometry queryGeom,
org.locationtech.jts.geom.Geometry candidateGeom,
DistanceMetric distanceMetric)
This method calculates the distance between two geometries using the specified distance metric.
|
static ItemDistance |
getItemDistanceByMetric(DistanceMetric distanceMetric)
This method returns the ItemDistance object based on the specified distance metric.
|
protected boolean |
hasNextBase(List<? extends org.locationtech.jts.geom.Geometry> buildShapes,
Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes)
Iterator model for the nest loop join.
|
protected boolean |
hasNextBase(org.locationtech.jts.index.SpatialIndex spatialIndex,
Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes,
boolean buildLeft)
Iterator model for the index-based join.
|
protected void |
initPartition()
Looks up the extent of the current partition.
|
protected void |
log(String message,
Object... params) |
protected org.apache.commons.lang3.tuple.Pair<U,T> |
nextBase(List<? extends org.locationtech.jts.geom.Geometry> buildShapes,
Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes)
Iterator model for the nest loop join.
|
protected org.apache.commons.lang3.tuple.Pair<U,T> |
nextBase(org.locationtech.jts.index.SpatialIndex spatialIndex,
Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes,
boolean buildLeft)
Iterator model for the index-based join.
|
protected final org.apache.spark.util.LongAccumulator buildCount
protected final org.apache.spark.util.LongAccumulator streamCount
protected final org.apache.spark.util.LongAccumulator resultCount
protected final org.apache.spark.util.LongAccumulator candidateCount
public KnnJoinIndexJudgement(int k, Double searchRadius, DistanceMetric distanceMetric, boolean includeTies, org.apache.spark.broadcast.Broadcast<List> broadcastQueryObjects, org.apache.spark.broadcast.Broadcast<STRtree> broadcastObjectsTreeIndex, org.apache.spark.util.LongAccumulator buildCount, org.apache.spark.util.LongAccumulator streamCount, org.apache.spark.util.LongAccumulator resultCount, org.apache.spark.util.LongAccumulator candidateCount)
k
- the number of nearest neighbors to findsearchRadius
- distanceMetric
- the distance metric to usebroadcastQueryObjects
- the broadcast geometries on queriesbroadcastObjectsTreeIndex
- the broadcast spatial index on objectsbuildCount
- accumulator for the number of geometries processed from the build sidestreamCount
- accumulator for the number of geometries processed from the stream sideresultCount
- accumulator for the number of join resultscandidateCount
- accumulator for the number of candidate matchespublic Iterator<org.apache.commons.lang3.tuple.Pair<U,T>> call(Iterator<T> streamShapes, Iterator<org.locationtech.jts.index.SpatialIndex> treeIndexes) throws Exception
call
in interface org.apache.spark.api.java.function.FlatMapFunction2<Iterator<T extends org.locationtech.jts.geom.Geometry>,Iterator<org.locationtech.jts.index.SpatialIndex>,org.apache.commons.lang3.tuple.Pair<U extends org.locationtech.jts.geom.Geometry,T extends org.locationtech.jts.geom.Geometry>>
streamShapes
- iterator over the geometries in the stream sidetreeIndexes
- iterator over the spatial indexesException
- if the spatial index is not of type STRtreepublic static double distanceByMetric(org.locationtech.jts.geom.Geometry queryGeom, org.locationtech.jts.geom.Geometry candidateGeom, DistanceMetric distanceMetric)
queryGeom
- the query geometrycandidateGeom
- the candidate geometrydistanceMetric
- the distance metric to usepublic static ItemDistance getItemDistanceByMetric(DistanceMetric distanceMetric)
distanceMetric
- the distance metric to usepublic static <U extends org.locationtech.jts.geom.Geometry,T extends org.locationtech.jts.geom.Geometry> double distance(U key, T value, DistanceMetric distanceMetric)
protected void initPartition()
Must be called before processing a partition. Must be called from the same instance that will be used to process the partition.
protected boolean hasNextBase(org.locationtech.jts.index.SpatialIndex spatialIndex, Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes, boolean buildLeft)
spatialIndex
- streamShapes
- buildLeft
- protected boolean hasNextBase(List<? extends org.locationtech.jts.geom.Geometry> buildShapes, Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes)
buildShapes
- streamShapes
- protected org.apache.commons.lang3.tuple.Pair<U,T> nextBase(org.locationtech.jts.index.SpatialIndex spatialIndex, Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes, boolean buildLeft)
spatialIndex
- streamShapes
- buildLeft
- protected org.apache.commons.lang3.tuple.Pair<U,T> nextBase(List<? extends org.locationtech.jts.geom.Geometry> buildShapes, Iterator<? extends org.locationtech.jts.geom.Geometry> streamShapes)
buildShapes
- streamShapes
- Copyright © 2025 The Apache Software Foundation. All rights reserved.