Skip to content

Commit

Permalink
Rebase and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme committed Jan 3, 2025
1 parent 0f6fd8c commit 80409b9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 193 deletions.
2 changes: 1 addition & 1 deletion h3/sql/install/14-opclass_spgist.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 Bytes & Brains
* Copyright 2024 Zacharias Knudsen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
1 change: 0 additions & 1 deletion h3/sql/updates/h3--4.1.4--unreleased.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ CREATE OPERATOR CLASS spgist_h3index_ops DEFAULT FOR TYPE h3index USING spgist A
FUNCTION 3 h3index_spgist_picksplit(internal, internal),
FUNCTION 4 h3index_spgist_inner_consistent(internal, internal),
FUNCTION 5 h3index_spgist_leaf_consistent(internal, internal);
>>>>>>> e8aae9e (Initial SP-GiST experimentation):h3/sql/updates/h3--4.1.3--unreleased.sql
8 changes: 4 additions & 4 deletions h3/src/opclass_spgist.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020 Bytes & Brains
* Copyright 2024 Zacharias Knudsen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@

#include "inttypes.h"

#include "upstream.h" // Copied from upstream
#include "h3Index.h" // Copied from upstream

PG_FUNCTION_INFO_V1(h3index_spgist_config);
PG_FUNCTION_INFO_V1(h3index_spgist_choose);
Expand Down Expand Up @@ -283,7 +283,7 @@ h3index_spgist_inner_consistent(PG_FUNCTION_ARGS)
{
spgInnerConsistentIn *in = (spgInnerConsistentIn *) PG_GETARG_POINTER(0);
spgInnerConsistentOut *out = (spgInnerConsistentOut *) PG_GETARG_POINTER(1);
H3Index parent = NULL;
H3Index parent = H3_NULL;
int bc,
i;
bool stop;
Expand Down Expand Up @@ -323,7 +323,7 @@ h3index_spgist_inner_consistent(PG_FUNCTION_ARGS)
StrategyNumber strategy = in->scankeys[i].sk_strategy;
H3Index query = DatumGetH3Index(in->scankeys[i].sk_argument);

if (parent == NULL)
if (parent == H3_NULL)
{
if (bc > -1)
{
Expand Down
187 changes: 0 additions & 187 deletions h3/src/upstream.h

This file was deleted.

22 changes: 22 additions & 0 deletions h3/test/expected/opclass_spgist.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
\pset tuples_only on
\set hexagon '\'831c02fffffffff\'::h3index'
CREATE TABLE h3_test_spgist (hex h3index);
CREATE INDEX SPGIST_IDX ON h3_test_spgist USING spgist(hex);
INSERT INTO h3_test_spgist (hex) SELECT h3_cell_to_parent(:hexagon);
INSERT INTO h3_test_spgist (hex) SELECT h3_cell_to_children(:hexagon);
INSERT INTO h3_test_spgist (hex) SELECT h3_cell_to_center_child(:hexagon, 15);
--
-- TEST SP-GiST
--
SELECT COUNT(*) = 1 FROM h3_test_spgist WHERE hex @> :hexagon;
t

SELECT COUNT(*) = 8 FROM h3_test_spgist WHERE hex <@ :hexagon;
t

--
TRUNCATE TABLE h3_test_spgist;
INSERT INTO h3_test_spgist (hex) SELECT h3_cell_to_children(h3_cell_to_center_child(:hexagon, 10), 15);
SELECT COUNT(*) = 16807 FROM h3_test_spgist WHERE hex <@ :hexagon;
t

0 comments on commit 80409b9

Please sign in to comment.