pwrliang commented on code in PR #556:
URL: https://github.com/apache/sedona-db/pull/556#discussion_r2764623864


##########
c/sedona-libgpuspatial/libgpuspatial/include/gpuspatial/gpuspatial_c.h:
##########
@@ -14,60 +14,162 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
+#include <stdbool.h>
 #include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-struct GpuSpatialJoinerConfig {
-  uint32_t concurrency;
+struct ArrowSchema;
+struct ArrowArray;
+
+// Interfaces for ray-tracing engine (OptiX)
+struct GpuSpatialRuntimeConfig {
+  /** Path to PTX files */
   const char* ptx_root;
+  /** Device ID to use, 0 is the first GPU */
+  int device_id;
+  /** Whether to use CUDA memory pool for allocations */
+  bool use_cuda_memory_pool;
+  /** Ratio of initial memory pool size to total GPU memory, between 0 and 100 
*/
+  int cuda_memory_pool_init_precent;
 };
 
-struct GpuSpatialJoinerContext {
-  const char* last_error;  // Pointer to std::string to store last error 
message
-  void* private_data;      // GPUSpatial context
-  void* build_indices;     // Pointer to std::vector<uint32_t> to store results
-  void* stream_indices;
+/** Opaque runtime for GPU spatial operations
+ * Each process should only has one instance of GpuSpatialRuntimeexactly
+ *
+ */
+struct GpuSpatialRuntime {
+  /** Initialize the runtime (OptiX) with the given configuration
+   * @return 0 on success, non-zero on failure
+   */
+  int (*init)(struct GpuSpatialRuntime* self, struct GpuSpatialRuntimeConfig* 
config);
+  void (*release)(struct GpuSpatialRuntime* self);
+  const char* (*get_last_error)(struct GpuSpatialRuntime* self);
+  void* private_data;
 };
 
-enum GpuSpatialPredicate {
-  GpuSpatialPredicateEquals = 0,
-  GpuSpatialPredicateDisjoint,
-  GpuSpatialPredicateTouches,
-  GpuSpatialPredicateContains,
-  GpuSpatialPredicateCovers,
-  GpuSpatialPredicateIntersects,
-  GpuSpatialPredicateWithin,
-  GpuSpatialPredicateCoveredBy
+/** Create an instance of GpuSpatialRuntime */
+void GpuSpatialRuntimeCreate(struct GpuSpatialRuntime* runtime);
+
+struct GpuSpatialIndexConfig {
+  /** Pointer to an initialized GpuSpatialRuntime struct */
+  struct GpuSpatialRuntime* runtime;
+  /** How many threads will concurrently call Probe method */
+  uint32_t concurrency;
+};
+
+// An opaque context for concurrent probing
+struct SedonaSpatialIndexContext {
+  void* private_data;
+};
+
+struct SedonaFloatIndex2D {
+  /** Clear the spatial index, removing all built data */
+  int (*clear)(struct SedonaFloatIndex2D* self);
+  /** Create a new context for concurrent probing */
+  void (*create_context)(struct SedonaSpatialIndexContext* context);
+  /** Destroy a previously created context */
+  void (*destroy_context)(struct SedonaSpatialIndexContext* context);
+  /** Push rectangles for building the spatial index, each rectangle is 
represented by 4
+   * floats: [min_x, min_y, max_x, max_y] Points can also be indexed by 
providing [x, y,
+   * x, y] but points and rectangles cannot be mixed
+   *
+   * @return 0 on success, non-zero on failure
+   */
+  int (*push_build)(struct SedonaFloatIndex2D* self, const float* buf, 
uint32_t n_rects);
+  /**
+   * Finish building the spatial index after all rectangles have been pushed
+   *
+   * @return 0 on success, non-zero on failure
+   */
+  int (*finish_building)(struct SedonaFloatIndex2D* self);
+  /**
+   * Probe the spatial index with the given rectangles, each rectangle is 
represented by 4
+   * floats: [min_x, min_y, max_x, max_y] Points can also be probed by 
providing [x, y, x,
+   * y] but points and rectangles cannot be mixed in one Probe call. The 
results of the
+   * probe will be stored in the context.
+   *
+   * @return 0 on success, non-zero on failure
+   */
+  int (*probe)(struct SedonaFloatIndex2D* self, struct 
SedonaSpatialIndexContext* context,
+               const float* buf, uint32_t n_rects);
+  /** Get the build indices buffer from the context
+   *
+   * @return A pointer to the buffer and its length
+   */
+  void (*get_build_indices_buffer)(struct SedonaSpatialIndexContext* context,
+                                   uint32_t** build_indices,
+                                   uint32_t* build_indices_length);
+  /** Get the probe indices buffer from the context
+   *
+   * @return A pointer to the buffer and its length
+   */
+  void (*get_probe_indices_buffer)(struct SedonaSpatialIndexContext* context,
+                                   uint32_t** probe_indices,
+                                   uint32_t* probe_indices_length);
+  const char* (*get_last_error)(struct SedonaFloatIndex2D* self);
+  const char* (*context_get_last_error)(struct SedonaSpatialIndexContext* 
context);
+  /** Release the spatial index and free all resources */
+  void (*release)(struct SedonaFloatIndex2D* self);
+  void* private_data;
 };
 
-struct GpuSpatialJoiner {
-  int (*init)(struct GpuSpatialJoiner* self, struct GpuSpatialJoinerConfig* 
config);
-  void (*clear)(struct GpuSpatialJoiner* self);
-  void (*create_context)(struct GpuSpatialJoiner* self,
-                         struct GpuSpatialJoinerContext* context);
-  void (*destroy_context)(struct GpuSpatialJoinerContext* context);
-  int (*push_build)(struct GpuSpatialJoiner* self, const struct ArrowSchema* 
schema,
-                    const struct ArrowArray* array, int64_t offset, int64_t 
length);
-  int (*finish_building)(struct GpuSpatialJoiner* self);
-  int (*push_stream)(struct GpuSpatialJoiner* self,
-                     struct GpuSpatialJoinerContext* context,
-                     const struct ArrowSchema* schema, const struct 
ArrowArray* array,
-                     int64_t offset, int64_t length, enum GpuSpatialPredicate 
predicate,
-                     int32_t array_index_offset);
-  void (*get_build_indices_buffer)(struct GpuSpatialJoinerContext* context,
-                                   void** build_indices, uint32_t* 
build_indices_length);
-  void (*get_stream_indices_buffer)(struct GpuSpatialJoinerContext* context,
-                                    void** stream_indices,
-                                    uint32_t* stream_indices_length);
-  void (*release)(struct GpuSpatialJoiner* self);
+int GpuSpatialIndexFloat2DCreate(struct SedonaFloatIndex2D* index,
+                                 const struct GpuSpatialIndexConfig* config);
+
+struct GpuSpatialRefinerConfig {
+  /** Pointer to an initialized GpuSpatialRuntime struct */
+  struct GpuSpatialRuntime* runtime;
+  /** How many threads will concurrently call Probe method */
+  uint32_t concurrency;
+  /** Whether to compress the BVH structures to save memory */
+  bool compress_bvh;
+  /** Number of batches to pipeline for parsing and refinement; setting to 1 
disables
+   * pipelining */
+  uint32_t pipeline_batches;
+};
+
+enum SedonaSpatialRelationPredicate {
+  SedonaSpatialPredicateEquals = 0,
+  SedonaSpatialPredicateDisjoint,
+  SedonaSpatialPredicateTouches,
+  SedonaSpatialPredicateContains,
+  SedonaSpatialPredicateCovers,
+  SedonaSpatialPredicateIntersects,
+  SedonaSpatialPredicateWithin,
+  SedonaSpatialPredicateCoveredBy
+};
+
+struct SedonaSpatialRefiner {
+  int (*clear)(struct SedonaSpatialRefiner* self);
+
+  int (*push_build)(struct SedonaSpatialRefiner* self,
+                    const struct ArrowSchema* build_schema,
+                    const struct ArrowArray* build_array);
+
+  int (*finish_building)(struct SedonaSpatialRefiner* self);
+
+  int (*refine_loaded)(struct SedonaSpatialRefiner* self,
+                       const struct ArrowSchema* probe_schema,
+                       const struct ArrowArray* probe_array,
+                       enum SedonaSpatialRelationPredicate predicate,
+                       uint32_t* build_indices, uint32_t* probe_indices,
+                       uint32_t indices_size, uint32_t* new_indices_size);
+
+  int (*refine)(struct SedonaSpatialRefiner* self, const struct ArrowSchema* 
schema1,
+                const struct ArrowArray* array1, const struct ArrowSchema* 
schema2,
+                const struct ArrowArray* array2,
+                enum SedonaSpatialRelationPredicate predicate, uint32_t* 
indices1,
+                uint32_t* indices2, uint32_t indices_size, uint32_t* 
new_indices_size);

Review Comment:
   This interface is currently unused, so I have removed it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to