Skip to content

Commit

Permalink
Merge pull request #53 from citusdata/major-restructuring
Browse files Browse the repository at this point in the history
Restructure the codebase according to Citus and PGXS guidelines
  • Loading branch information
Burak Yücesoy authored Jun 18, 2018
2 parents a53cea8 + 6d7d03c commit d89a3fb
Show file tree
Hide file tree
Showing 100 changed files with 954 additions and 406 deletions.
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.gitignore
*.o
*.so
*.out
*.diff
regress/binary.dat
regress/failures
binary.dat
regression.out
regression.diffs
results

hll--?.?.sql
hll--?.?-*.sql
!hll--?.?-*--?.?-*.sql
37 changes: 20 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
sudo: required
dist: trusty
language: c
env:
- PGVERSION=9.2
- PGVERSION=9.3
- PGVERSION=9.4
- PGVERSION=9.5
- PGVERSION=9.6
matrix:
fast_finish: true
include:
- env: PGVERSION=9.4
- env: PGVERSION=9.5
- env: PGVERSION=9.6
- env: PGVERSION=10
- env: PGVERSION=11
allow_failures:
- env: PGVERSION=11
before_install:
- git clone -b v0.7.5 --depth 1 https://github.com/citusdata/tools.git
- sudo make -C tools install
- setup_apt
- nuke_pg
install:
- install_uncrustify
- install_pg
before_script:
- export PATH=/usr/lib/postgresql/$PGVERSION/bin:$PATH # Add our chosen PG version to the path
- sudo /etc/init.d/postgresql stop # Stop whichever version of PG that travis started
- sudo /etc/init.d/postgresql start $PGVERSION # Start the version of PG that we want to test
- sudo apt-get update -qq # Retrieves new list of packages
- sudo apt-get install postgresql-server-dev-$PGVERSION # Required for PGXS
- sudo apt-get install postgresql-common # Required for extension support files
- createdb hll_regress # Create the test database
script:
- make && sudo make install
- psql -c "create extension hll" hll_regress
- make -C regress
- config_and_start_cluster
script: pg_travis_test
File renamed without changes.
File renamed without changes.
39 changes: 15 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,26 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

MODULE_big = hll
OBJS = \
hll.o \
MurmurHash3.o \
$(NULL)

EXTENSION = hll
DATA = \
hll--2.10.sql \
$(NULL)

EXTRA_CLEAN += -r $(RPM_BUILD_ROOT)
EXTVERSION = 2.10

PG_CPPFLAGS += -fPIC
hll.o: override CFLAGS += -std=c99
MurmurHash3.o: override CC = $(CXX)
DATA_built = $(EXTENSION)--$(EXTVERSION).sql
DATA = $(wildcard $(EXTENSION)--*--*.sql)

ifdef DEBUG
COPT += -O0
CXXFLAGS += -g -O0
endif
MODULE_big = $(EXTENSION)
OBJS = src/hll.o \
src/MurmurHash3.o

SHLIB_LINK += -lstdc++
PG_CPPFLAGS = -fPIC -Wall -Wextra -Werror -Wno-unused-parameter -Wno-implicit-fallthrough -Iinclude -I$(libpq_srcdir)

ifndef PG_CONFIG
PG_CONFIG = pg_config
endif
REGRESS = setup $(filter-out setup,$(patsubst sql/%.sql,%,$(sort $(wildcard sql/*.sql))))

PGXS := $(shell $(PG_CONFIG) --pgxs)
PG_CONFIG ?= pg_config
PGXS = $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

src/hll.o: override CFLAGS += -std=c99

$(EXTENSION)--2.10.sql: $(EXTENSION).sql
cat $^ > $@

File renamed without changes.
File renamed without changes.
21 changes: 9 additions & 12 deletions regress/add_agg.ref → expected/add_agg.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ SELECT hll_set_output_version(1);
(1 row)

DROP TABLE IF EXISTS test_khvengxf;
DROP TABLE
NOTICE: table "test_khvengxf" does not exist, skipping
CREATE TABLE test_khvengxf (
val integer
);
CREATE TABLE
insert into test_khvengxf(val) values (1), (2), (3);
INSERT 0 3
-- Check default and explicit signatures.
select hll_print(hll_add_agg(hll_hash_integer(val)))
from test_khvengxf;
Expand Down Expand Up @@ -79,28 +77,28 @@ select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, 0))
-- Check range checking.
select hll_print(hll_add_agg(hll_hash_integer(val), -1))
from test_khvengxf;
psql:add_agg.sql:38: ERROR: log2m modifier must be between 0 and 31
ERROR: log2m modifier must be between 0 and 31
select hll_print(hll_add_agg(hll_hash_integer(val), 32))
from test_khvengxf;
psql:add_agg.sql:41: ERROR: log2m modifier must be between 0 and 31
ERROR: log2m modifier must be between 0 and 31
select hll_print(hll_add_agg(hll_hash_integer(val), 10, -1))
from test_khvengxf;
psql:add_agg.sql:44: ERROR: regwidth modifier must be between 0 and 7
ERROR: regwidth modifier must be between 0 and 7
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 8))
from test_khvengxf;
psql:add_agg.sql:47: ERROR: regwidth modifier must be between 0 and 7
ERROR: regwidth modifier must be between 0 and 7
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, -2))
from test_khvengxf;
psql:add_agg.sql:50: ERROR: expthresh modifier must be between -1 and 2^32
ERROR: expthresh modifier must be between -1 and 2^32
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 8589934592))
from test_khvengxf;
psql:add_agg.sql:53: ERROR: expthresh modifier must be between -1 and 2^32
ERROR: expthresh modifier must be between -1 and 2^32
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, -1))
from test_khvengxf;
psql:add_agg.sql:56: ERROR: sparseon modifier must be 0 or 1
ERROR: sparseon modifier must be 0 or 1
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, 2))
from test_khvengxf;
psql:add_agg.sql:59: ERROR: sparseon modifier must be 0 or 1
ERROR: sparseon modifier must be 0 or 1
-- Check that we return hll_empty on null input.
select hll_print(hll_add_agg(NULL));
hll_print
Expand Down Expand Up @@ -139,4 +137,3 @@ select hll_print(hll_add_agg(NULL, 10, 4, 512, 0));
(1 row)

DROP TABLE test_khvengxf;
DROP TABLE
37 changes: 17 additions & 20 deletions regress/agg_oob.ref → expected/agg_oob.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ SELECT hll_set_output_version(1);
(1 row)

DROP TABLE IF EXISTS test_wdflbzfx;
DROP TABLE
NOTICE: table "test_wdflbzfx" does not exist, skipping
CREATE TABLE test_wdflbzfx (
recno SERIAL,
v1 hll
);
CREATE TABLE
INSERT INTO test_wdflbzfx (recno, v1) VALUES
-- NULL --
(0, NULL),
Expand All @@ -42,22 +41,21 @@ INSERT INTO test_wdflbzfx (recno, v1) VALUES
(17, E'\\x138b7f0022'),
(18, E'\\x138b7f0041'),
(19, E'\\x138b7f0061');
INSERT 0 20
-- ----------------------------------------------------------------
-- Aggregate Union
-- ----------------------------------------------------------------
-- No rows selected
SELECT hll_union_agg(v1) FROM test_wdflbzfx WHERE recno > 100;
hll_union_agg
---------------
NULL

(1 row)

-- NULLs
SELECT hll_union_agg(v1) FROM test_wdflbzfx WHERE recno IN (0, 1, 2, 3);
hll_union_agg
---------------
NULL

(1 row)

-- UNDEFINED
Expand Down Expand Up @@ -253,23 +251,23 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
FROM test_wdflbzfx WHERE recno > 100;
ceiling
---------
NULL
(1 row)

-- NULLs
SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
FROM test_wdflbzfx WHERE recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

-- UNDEFINED
SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
FROM test_wdflbzfx WHERE recno IN (4, 5, 6, 7);
ceiling
---------
NULL
(1 row)

-- UNDEFINED and NULL
Expand All @@ -278,7 +276,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

-- EMPTY
Expand All @@ -304,7 +302,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (4, 5, 6, 7);
ceiling
---------
NULL
(1 row)

-- EMPTY, UNDEFINED and NULL
Expand All @@ -314,7 +312,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

-- EXPLICIT
Expand All @@ -340,7 +338,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (4, 5, 6, 7);
ceiling
---------
NULL
(1 row)

-- EXPLICIT, UNDEFINED and NULL
Expand All @@ -350,7 +348,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

-- EXPLICIT and EMPTY
Expand Down Expand Up @@ -379,7 +377,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (4, 5, 6, 7);
ceiling
---------
NULL
(1 row)

-- EXPLICIT, EMPTY, UNDEFINED and NULL
Expand All @@ -390,7 +388,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

-- Don't feel like a full sparse/explicit permuatation is adding
Expand Down Expand Up @@ -418,7 +416,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (4, 5, 6, 7);
ceiling
---------
NULL
(1 row)

-- SPARSE, UNDEFINED and NULL
Expand All @@ -428,7 +426,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

-- SPARSE and EMPTY
Expand Down Expand Up @@ -457,7 +455,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (4, 5, 6, 7);
ceiling
---------
NULL
(1 row)

-- SPARSE, EMPTY, UNDEFINED and NULL
Expand All @@ -468,8 +466,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
OR recno IN (0, 1, 2, 3);
ceiling
---------
NULL
(1 row)

DROP TABLE IF EXISTS test_wdflbzfx;
DROP TABLE
File renamed without changes.
63 changes: 63 additions & 0 deletions expected/card_op.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
-- ----------------------------------------------------------------
-- Regression tests for cardinality operator.
-- ----------------------------------------------------------------
SELECT hll_set_output_version(1);
hll_set_output_version
------------------------
1
(1 row)

SELECT #E'\\x108b49'::hll;
?column?
----------

(1 row)

SELECT #hll_empty(11,5,256,1);
?column?
----------
0
(1 row)

-- # gets evaluated first so || hll_union(double, bigint) fails
SELECT #hll_empty(11,5,256,1) || hll_hash_integer(1,0);
ERROR: operator does not exist: double precision || hll_hashval
LINE 1: SELECT #hll_empty(11,5,256,1) || hll_hash_integer(1,0);
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
SELECT #(hll_empty(11,5,256,1) || hll_hash_integer(1,0));
?column?
----------
1
(1 row)

SELECT #E'\\x128b498895a3f5af28cafe'::hll;
?column?
----------
1
(1 row)

SELECT #E'\\x128b498895a3f5af28cafeda0ce907e4355b60'::hll;
?column?
----------
2
(1 row)

SELECT #E'\\x138b4f0061'::hll;
?column?
------------------
1.00024422012692
(1 row)

SELECT #E'\\x148B480800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'::hll;
?column?
------------------
1.00024422012692
(1 row)

SELECT #E'\\x148B480842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'::hll;
?column?
------------------
545.638878057197
(1 row)

Loading

0 comments on commit d89a3fb

Please sign in to comment.