Class JoinQuery

java.lang.Object
org.apache.sedona.core.spatialOperator.JoinQuery

public class JoinQuery extends Object
  • Constructor Details

    • JoinQuery

      public JoinQuery()
  • Method Details

    • SpatialJoinQuery

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,List<T>> SpatialJoinQuery(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, boolean useIndex, SpatialPredicate spatialPredicate) throws Exception
      Inner joins two sets of geometries on specified spatial predicate.

      spatialPredicate is the spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD

      If useIndex is false, the join uses nested loop algorithm to identify matching geometries.

      If useIndex is true, the join scans query windows and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicate geometries present in the input queryWindowRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries which serve as query windows
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      spatialPredicate - Spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD
      Returns:
      RDD of pairs where each pair contains a geometry and a set of matching geometries
      Throws:
      Exception - the exception
    • SpatialJoinQuery

      @Deprecated public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,List<T>> SpatialJoinQuery(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, boolean useIndex, boolean considerBoundaryIntersection) throws Exception
      Deprecated.
      Inner joins two sets of geometries on 'covers' or 'intersects' relationship.

      If considerBoundaryIntersection is true, returns pairs of geometries which intersect. Otherwise, returns pairs of geometries where first geometry covers second geometry.

      If useIndex is false, the join uses nested loop algorithm to identify matching geometries.

      If useIndex is true, the join scans query windows and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicate geometries present in the input queryWindowRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries which serve as query windows
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      considerBoundaryIntersection - Join relationship type: 'intersects' if true, 'covers' otherwise
      Returns:
      RDD of pairs where each pair contains a geometry and a set of matching geometries
      Throws:
      Exception - the exception
    • SpatialJoinQuery

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,List<T>> SpatialJoinQuery(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Throws:
      Exception
    • SpatialJoinQueryFlat

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,T> SpatialJoinQueryFlat(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, boolean useIndex, SpatialPredicate spatialPredicate) throws Exception
      Inner joins two sets of geometries on specified spatial predicate. Results are put in a flat pair format.

      spatialPredicate is the spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD.

      If useIndex is false, the join uses nested loop algorithm to identify matching geometries.

      If useIndex is true, the join scans query windows and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicates present in the input RDDs will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries which serve as query windows
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      spatialPredicate - Spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD
      Returns:
      RDD of pairs of matching geometries
      Throws:
      Exception - the exception
    • SpatialJoinQueryFlat

      @Deprecated public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,T> SpatialJoinQueryFlat(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, boolean useIndex, boolean considerBoundaryIntersection) throws Exception
      Deprecated.
      Inner joins two sets of geometries on 'covers' or 'intersects' relationship. Results are put in a flat pair format.

      If considerBoundaryIntersection is true, returns pairs of geometries which intersect. Otherwise, returns pairs of geometries where first geometry covers second geometry.

      If useIndex is false, the join uses nested loop algorithm to identify matching geometries.

      If useIndex is true, the join scans query windows and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicates present in the input RDDs will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries which serve as query windows
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      considerBoundaryIntersection - Join relationship type: 'intersects' if true, 'covers' otherwise
      Returns:
      RDD of pairs of matching geometries
      Throws:
      Exception - the exception
    • SpatialJoinQueryFlat

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,T> SpatialJoinQueryFlat(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Throws:
      Exception
    • SpatialJoinQueryCountByKey

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,Long> SpatialJoinQueryCountByKey(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, boolean useIndex, SpatialPredicate spatialPredicate) throws Exception
      SpatialJoinQueryFlat(SpatialRDD, SpatialRDD, boolean, SpatialPredicate) count by key.

      Duplicate geometries present in the input queryWindowRDD RDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD RDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries which serve as query windows
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      spatialPredicate - Spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD
      Returns:
      the result of SpatialJoinQueryFlat(SpatialRDD, SpatialRDD, boolean, SpatialPredicate), but in this pair RDD, each pair contains a geometry and the count of matching geometries
      Throws:
      Exception - the exception
    • SpatialJoinQueryCountByKey

      @Deprecated public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,Long> SpatialJoinQueryCountByKey(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, boolean useIndex, boolean considerBoundaryIntersection) throws Exception
      Deprecated.
      SpatialJoinQueryFlat(SpatialRDD, SpatialRDD, boolean, boolean) count by key.

      Duplicate geometries present in the input queryWindowRDD RDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD RDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries which serve as query windows
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      considerBoundaryIntersection - Join relationship type: 'intersects' if true, 'covers' otherwise
      Returns:
      the result of SpatialJoinQueryFlat(SpatialRDD, SpatialRDD, boolean, boolean), but in this pair RDD, each pair contains a geometry and the count of matching geometries
      Throws:
      Exception - the exception
    • SpatialJoinQueryCountByKey

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,Long> SpatialJoinQueryCountByKey(SpatialRDD<T> spatialRDD, SpatialRDD<U> queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Throws:
      Exception
    • KNNJoinQuery

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,List<T>> KNNJoinQuery(SpatialRDD<T> objectRDD, SpatialRDD<U> queryRDD, IndexType indexType, int k, DistanceMetric distanceMetric) throws Exception
      Joins two sets of geometries on specified distance metric and finds the k nearest neighbors.

      Duplicate geometries present in the input queryWindowRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input objectRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      U - Type of the geometries in queryWindowRDD set
      T - Type of the geometries in objectRDD set
      Parameters:
      objectRDD - objectRDD is the set of geometries (neighbors) to be queried
      queryRDD - queryRDD is the set of geometries which serve as query geometries (center points)
      indexType - indexType is the index type to use for the join
      k - k is the number of nearest neighbors to find
      distanceMetric - distanceMetric is the distance metric to use
      Returns:
      RDD of pairs where each pair contains a geometry and a set of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQueryFlat

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,T> DistanceJoinQueryFlat(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, boolean useIndex, SpatialPredicate spatialPredicate) throws Exception
      Inner joins two sets of geometries, where the query windows are circles (aka. distance join). Results are put in a flat pair format.

      spatialPredicate is the spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD.

      If useIndex is false, the join uses nested loop algorithm to identify matching circle/geometry.

      If useIndex is true, the join scans circles and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicates present in the input RDDs will be reflected in the join results.

      Type Parameters:
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      spatialPredicate - Spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD, should be one of INTERSECTS and COVERED_BY
      Returns:
      RDD of pairs of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQueryFlat

      @Deprecated public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,T> DistanceJoinQueryFlat(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, boolean useIndex, boolean considerBoundaryIntersection) throws Exception
      Deprecated.
      Inner joins two sets of geometries on 'coveredBy' relationship (aka. distance join). Results are put in a flat pair format.

      If considerBoundaryIntersection is true, returns pairs of circle/geometry which intersect. Otherwise, returns pairs of geometries where first circle covers second geometry.

      If useIndex is false, the join uses nested loop algorithm to identify matching circle/geometry.

      If useIndex is true, the join scans circles and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicates present in the input RDDs will be reflected in the join results.

      Type Parameters:
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      considerBoundaryIntersection - consider boundary intersection
      Returns:
      RDD of pairs of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQueryFlat

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,T> DistanceJoinQueryFlat(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Throws:
      Exception
    • DistanceJoinQuery

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,List<T>> DistanceJoinQuery(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, boolean useIndex, SpatialPredicate spatialPredicate) throws Exception
      Inner joins two sets of geometries, where the query windows are circles (aka. distance join). The query window objects are converted to circle objects. The radius is the given distance. Eventually, the original window objects are recovered and outputted.

      spatialPredicate is the spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD.

      If useIndex is false, the join uses nested loop algorithm to identify matching circle/geometry.

      If useIndex is true, the join scans circles and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicate geometries present in the input CircleRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      spatialPredicate - Spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD, should be one of INTERSECTS and COVERED_BY
      Returns:
      RDD of pairs where each pair contains a geometry and a set of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQuery

      @Deprecated public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,List<T>> DistanceJoinQuery(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, boolean useIndex, boolean considerBoundaryIntersection) throws Exception
      Deprecated.
      Inner joins two sets of geometries on 'coveredBy' relationship (aka. distance join). The query window objects are converted to circle objects. The radius is the given distance. Eventually, the original window objects are recovered and outputted.

      If considerBoundaryIntersection is true, returns pairs of circle/geometry which intersect. Otherwise, returns pairs of geometries where first circle covers second geometry.

      If useIndex is false, the join uses nested loop algorithm to identify matching circle/geometry.

      If useIndex is true, the join scans circles and uses an index of geometries built prior to invoking the join to lookup matches.

      Duplicate geometries present in the input CircleRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      considerBoundaryIntersection - consider boundary intersection
      Returns:
      RDD of pairs where each pair contains a geometry and a set of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQuery

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,List<T>> DistanceJoinQuery(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Throws:
      Exception
    • DistanceJoinQueryCountByKey

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,Long> DistanceJoinQueryCountByKey(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, boolean useIndex, SpatialPredicate spatialPredicate) throws Exception
      DistanceJoinQueryFlat(SpatialRDD, CircleRDD, boolean, boolean) count by key.

      Duplicate geometries present in the input CircleRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      spatialPredicate - Spatial predicate in join condition spatialRDD <spatialPredicate> queryRDD, should be one of INTERSECTS and COVERED_BY
      Returns:
      the result of DistanceJoinQueryFlat(SpatialRDD, CircleRDD, boolean, boolean), but in this pair RDD, each pair contains a geometry and the count of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQueryCountByKey

      @Deprecated public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,Long> DistanceJoinQueryCountByKey(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, boolean useIndex, boolean considerBoundaryIntersection) throws Exception
      Deprecated.
      DistanceJoinQueryFlat(SpatialRDD, CircleRDD, boolean, boolean) count by key.

      Duplicate geometries present in the input CircleRDD, regardless of their non-spatial attributes, will not be reflected in the join results. Duplicate geometries present in the input spatialRDD, regardless of their non-spatial attributes, will be reflected in the join results.

      Type Parameters:
      T - Type of the geometries in spatialRDD set
      Parameters:
      spatialRDD - Set of geometries
      queryRDD - Set of geometries
      useIndex - Boolean indicating whether the join should use the index from spatialRDD.indexedRDD
      considerBoundaryIntersection - consider boundary intersection
      Returns:
      the result of DistanceJoinQueryFlat(SpatialRDD, CircleRDD, boolean, boolean), but in this pair RDD, each pair contains a geometry and the count of matching geometries
      Throws:
      Exception - the exception
    • DistanceJoinQueryCountByKey

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,Long> DistanceJoinQueryCountByKey(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Throws:
      Exception
    • distanceJoin

      public static <T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<org.locationtech.jts.geom.Geometry,T> distanceJoin(SpatialRDD<T> spatialRDD, CircleRDD queryRDD, JoinQuery.JoinParams joinParams) throws Exception
      Note: INTERNAL FUNCTION. API COMPATIBILITY IS NOT GUARANTEED. DO NOT USE IF YOU DON'T KNOW WHAT IT IS.
      Throws:
      Exception
    • spatialJoin

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,T> spatialJoin(SpatialRDD<U> leftRDD, SpatialRDD<T> rightRDD, JoinQuery.JoinParams joinParams) throws Exception
      Note: INTERNAL FUNCTION. API COMPATIBILITY IS NOT GUARANTEED. DO NOT USE IF YOU DON'T KNOW WHAT IT IS.
      Throws:
      Exception
    • knnJoin

      public static <U extends org.locationtech.jts.geom.Geometry, T extends org.locationtech.jts.geom.Geometry> org.apache.spark.api.java.JavaPairRDD<U,T> knnJoin(SpatialRDD<U> queryRDD, SpatialRDD<T> objectRDD, JoinQuery.JoinParams joinParams, boolean includeTies, boolean broadcastJoin) throws Exception
      Type Parameters:
      U - Type of the geometries in queryRDD set
      T - Type of the geometries in objectRDD set
      Parameters:
      queryRDD - queryRDD is the set of geometries which serve as query geometries (center points)
      objectRDD - objectRDD is the set of geometries (neighbors) to be queried
      joinParams - joinParams is the parameters for the join
      includeTies - includeTies is a boolean indicating whether to include ties
      Returns:
      RDD of pairs where each pair contains a geometry and a set of matching geometries
      Throws:
      Exception