pwrliang commented on code in PR #556:
URL: https://github.com/apache/sedona-db/pull/556#discussion_r2784247943
##########
c/sedona-libgpuspatial/libgpuspatial/include/gpuspatial/gpuspatial_c.h:
##########
@@ -14,60 +14,199 @@
// 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 GpuSpatialRuntime exactly
+ */
+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);
Review Comment:
It is not possible for the index because the result buffer size is unknown
to the caller.
--
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]