Skip to content

Commit d89a3fb

Browse files
author
Burak Yücesoy
authored
Merge pull request citusdata#53 from citusdata/major-restructuring
Restructure the codebase according to Citus and PGXS guidelines
2 parents a53cea8 + 6d7d03c commit d89a3fb

File tree

100 files changed

+954
-406
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+954
-406
lines changed

.gitignore

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
.gitignore
21
*.o
32
*.so
4-
*.out
5-
*.diff
6-
regress/binary.dat
7-
regress/failures
3+
binary.dat
4+
regression.out
5+
regression.diffs
6+
results
7+
8+
hll--?.?.sql
9+
hll--?.?-*.sql
10+
!hll--?.?-*--?.?-*.sql

.travis.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
sudo: required
22
dist: trusty
33
language: c
4-
env:
5-
- PGVERSION=9.2
6-
- PGVERSION=9.3
7-
- PGVERSION=9.4
8-
- PGVERSION=9.5
9-
- PGVERSION=9.6
4+
matrix:
5+
fast_finish: true
6+
include:
7+
- env: PGVERSION=9.4
8+
- env: PGVERSION=9.5
9+
- env: PGVERSION=9.6
10+
- env: PGVERSION=10
11+
- env: PGVERSION=11
12+
allow_failures:
13+
- env: PGVERSION=11
14+
before_install:
15+
- git clone -b v0.7.5 --depth 1 https://github.com/citusdata/tools.git
16+
- sudo make -C tools install
17+
- setup_apt
18+
- nuke_pg
19+
install:
20+
- install_uncrustify
21+
- install_pg
1022
before_script:
11-
- export PATH=/usr/lib/postgresql/$PGVERSION/bin:$PATH # Add our chosen PG version to the path
12-
- sudo /etc/init.d/postgresql stop # Stop whichever version of PG that travis started
13-
- sudo /etc/init.d/postgresql start $PGVERSION # Start the version of PG that we want to test
14-
- sudo apt-get update -qq # Retrieves new list of packages
15-
- sudo apt-get install postgresql-server-dev-$PGVERSION # Required for PGXS
16-
- sudo apt-get install postgresql-common # Required for extension support files
17-
- createdb hll_regress # Create the test database
18-
script:
19-
- make && sudo make install
20-
- psql -c "create extension hll" hll_regress
21-
- make -C regress
23+
- config_and_start_cluster
24+
script: pg_travis_test
File renamed without changes.
File renamed without changes.

Makefile

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,26 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
MODULE_big = hll
16-
OBJS = \
17-
hll.o \
18-
MurmurHash3.o \
19-
$(NULL)
20-
2114
EXTENSION = hll
22-
DATA = \
23-
hll--2.10.sql \
24-
$(NULL)
25-
26-
EXTRA_CLEAN += -r $(RPM_BUILD_ROOT)
15+
EXTVERSION = 2.10
2716

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

32-
ifdef DEBUG
33-
COPT += -O0
34-
CXXFLAGS += -g -O0
35-
endif
20+
MODULE_big = $(EXTENSION)
21+
OBJS = src/hll.o \
22+
src/MurmurHash3.o
3623

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

39-
ifndef PG_CONFIG
40-
PG_CONFIG = pg_config
41-
endif
26+
REGRESS = setup $(filter-out setup,$(patsubst sql/%.sql,%,$(sort $(wildcard sql/*.sql))))
4227

43-
PGXS := $(shell $(PG_CONFIG) --pgxs)
28+
PG_CONFIG ?= pg_config
29+
PGXS = $(shell $(PG_CONFIG) --pgxs)
4430
include $(PGXS)
4531

32+
src/hll.o: override CFLAGS += -std=c99
33+
34+
$(EXTENSION)--2.10.sql: $(EXTENSION).sql
35+
cat $^ > $@
36+
File renamed without changes.
File renamed without changes.

regress/add_agg.ref renamed to expected/add_agg.out

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ SELECT hll_set_output_version(1);
88
(1 row)
99

1010
DROP TABLE IF EXISTS test_khvengxf;
11-
DROP TABLE
11+
NOTICE: table "test_khvengxf" does not exist, skipping
1212
CREATE TABLE test_khvengxf (
1313
val integer
1414
);
15-
CREATE TABLE
1615
insert into test_khvengxf(val) values (1), (2), (3);
17-
INSERT 0 3
1816
-- Check default and explicit signatures.
1917
select hll_print(hll_add_agg(hll_hash_integer(val)))
2018
from test_khvengxf;
@@ -79,28 +77,28 @@ select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, 0))
7977
-- Check range checking.
8078
select hll_print(hll_add_agg(hll_hash_integer(val), -1))
8179
from test_khvengxf;
82-
psql:add_agg.sql:38: ERROR: log2m modifier must be between 0 and 31
80+
ERROR: log2m modifier must be between 0 and 31
8381
select hll_print(hll_add_agg(hll_hash_integer(val), 32))
8482
from test_khvengxf;
85-
psql:add_agg.sql:41: ERROR: log2m modifier must be between 0 and 31
83+
ERROR: log2m modifier must be between 0 and 31
8684
select hll_print(hll_add_agg(hll_hash_integer(val), 10, -1))
8785
from test_khvengxf;
88-
psql:add_agg.sql:44: ERROR: regwidth modifier must be between 0 and 7
86+
ERROR: regwidth modifier must be between 0 and 7
8987
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 8))
9088
from test_khvengxf;
91-
psql:add_agg.sql:47: ERROR: regwidth modifier must be between 0 and 7
89+
ERROR: regwidth modifier must be between 0 and 7
9290
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, -2))
9391
from test_khvengxf;
94-
psql:add_agg.sql:50: ERROR: expthresh modifier must be between -1 and 2^32
92+
ERROR: expthresh modifier must be between -1 and 2^32
9593
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 8589934592))
9694
from test_khvengxf;
97-
psql:add_agg.sql:53: ERROR: expthresh modifier must be between -1 and 2^32
95+
ERROR: expthresh modifier must be between -1 and 2^32
9896
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, -1))
9997
from test_khvengxf;
100-
psql:add_agg.sql:56: ERROR: sparseon modifier must be 0 or 1
98+
ERROR: sparseon modifier must be 0 or 1
10199
select hll_print(hll_add_agg(hll_hash_integer(val), 10, 4, 512, 2))
102100
from test_khvengxf;
103-
psql:add_agg.sql:59: ERROR: sparseon modifier must be 0 or 1
101+
ERROR: sparseon modifier must be 0 or 1
104102
-- Check that we return hll_empty on null input.
105103
select hll_print(hll_add_agg(NULL));
106104
hll_print
@@ -139,4 +137,3 @@ select hll_print(hll_add_agg(NULL, 10, 4, 512, 0));
139137
(1 row)
140138

141139
DROP TABLE test_khvengxf;
142-
DROP TABLE

regress/agg_oob.ref renamed to expected/agg_oob.out

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ SELECT hll_set_output_version(1);
1010
(1 row)
1111

1212
DROP TABLE IF EXISTS test_wdflbzfx;
13-
DROP TABLE
13+
NOTICE: table "test_wdflbzfx" does not exist, skipping
1414
CREATE TABLE test_wdflbzfx (
1515
recno SERIAL,
1616
v1 hll
1717
);
18-
CREATE TABLE
1918
INSERT INTO test_wdflbzfx (recno, v1) VALUES
2019
-- NULL --
2120
(0, NULL),
@@ -42,22 +41,21 @@ INSERT INTO test_wdflbzfx (recno, v1) VALUES
4241
(17, E'\\x138b7f0022'),
4342
(18, E'\\x138b7f0041'),
4443
(19, E'\\x138b7f0061');
45-
INSERT 0 20
4644
-- ----------------------------------------------------------------
4745
-- Aggregate Union
4846
-- ----------------------------------------------------------------
4947
-- No rows selected
5048
SELECT hll_union_agg(v1) FROM test_wdflbzfx WHERE recno > 100;
5149
hll_union_agg
5250
---------------
53-
NULL
51+
5452
(1 row)
5553

5654
-- NULLs
5755
SELECT hll_union_agg(v1) FROM test_wdflbzfx WHERE recno IN (0, 1, 2, 3);
5856
hll_union_agg
5957
---------------
60-
NULL
58+
6159
(1 row)
6260

6361
-- UNDEFINED
@@ -253,23 +251,23 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
253251
FROM test_wdflbzfx WHERE recno > 100;
254252
ceiling
255253
---------
256-
NULL
254+
257255
(1 row)
258256

259257
-- NULLs
260258
SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
261259
FROM test_wdflbzfx WHERE recno IN (0, 1, 2, 3);
262260
ceiling
263261
---------
264-
NULL
262+
265263
(1 row)
266264

267265
-- UNDEFINED
268266
SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
269267
FROM test_wdflbzfx WHERE recno IN (4, 5, 6, 7);
270268
ceiling
271269
---------
272-
NULL
270+
273271
(1 row)
274272

275273
-- UNDEFINED and NULL
@@ -278,7 +276,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
278276
OR recno IN (0, 1, 2, 3);
279277
ceiling
280278
---------
281-
NULL
279+
282280
(1 row)
283281

284282
-- EMPTY
@@ -304,7 +302,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
304302
OR recno IN (4, 5, 6, 7);
305303
ceiling
306304
---------
307-
NULL
305+
308306
(1 row)
309307

310308
-- EMPTY, UNDEFINED and NULL
@@ -314,7 +312,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
314312
OR recno IN (0, 1, 2, 3);
315313
ceiling
316314
---------
317-
NULL
315+
318316
(1 row)
319317

320318
-- EXPLICIT
@@ -340,7 +338,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
340338
OR recno IN (4, 5, 6, 7);
341339
ceiling
342340
---------
343-
NULL
341+
344342
(1 row)
345343

346344
-- EXPLICIT, UNDEFINED and NULL
@@ -350,7 +348,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
350348
OR recno IN (0, 1, 2, 3);
351349
ceiling
352350
---------
353-
NULL
351+
354352
(1 row)
355353

356354
-- EXPLICIT and EMPTY
@@ -379,7 +377,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
379377
OR recno IN (4, 5, 6, 7);
380378
ceiling
381379
---------
382-
NULL
380+
383381
(1 row)
384382

385383
-- EXPLICIT, EMPTY, UNDEFINED and NULL
@@ -390,7 +388,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
390388
OR recno IN (0, 1, 2, 3);
391389
ceiling
392390
---------
393-
NULL
391+
394392
(1 row)
395393

396394
-- Don't feel like a full sparse/explicit permuatation is adding
@@ -418,7 +416,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
418416
OR recno IN (4, 5, 6, 7);
419417
ceiling
420418
---------
421-
NULL
419+
422420
(1 row)
423421

424422
-- SPARSE, UNDEFINED and NULL
@@ -428,7 +426,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
428426
OR recno IN (0, 1, 2, 3);
429427
ceiling
430428
---------
431-
NULL
429+
432430
(1 row)
433431

434432
-- SPARSE and EMPTY
@@ -457,7 +455,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
457455
OR recno IN (4, 5, 6, 7);
458456
ceiling
459457
---------
460-
NULL
458+
461459
(1 row)
462460

463461
-- SPARSE, EMPTY, UNDEFINED and NULL
@@ -468,8 +466,7 @@ SELECT ceiling(hll_cardinality(hll_union_agg(v1)))
468466
OR recno IN (0, 1, 2, 3);
469467
ceiling
470468
---------
471-
NULL
469+
472470
(1 row)
473471

474472
DROP TABLE IF EXISTS test_wdflbzfx;
475-
DROP TABLE
File renamed without changes.

expected/card_op.out

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
-- ----------------------------------------------------------------
2+
-- Regression tests for cardinality operator.
3+
-- ----------------------------------------------------------------
4+
SELECT hll_set_output_version(1);
5+
hll_set_output_version
6+
------------------------
7+
1
8+
(1 row)
9+
10+
SELECT #E'\\x108b49'::hll;
11+
?column?
12+
----------
13+
14+
(1 row)
15+
16+
SELECT #hll_empty(11,5,256,1);
17+
?column?
18+
----------
19+
0
20+
(1 row)
21+
22+
-- # gets evaluated first so || hll_union(double, bigint) fails
23+
SELECT #hll_empty(11,5,256,1) || hll_hash_integer(1,0);
24+
ERROR: operator does not exist: double precision || hll_hashval
25+
LINE 1: SELECT #hll_empty(11,5,256,1) || hll_hash_integer(1,0);
26+
^
27+
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
28+
SELECT #(hll_empty(11,5,256,1) || hll_hash_integer(1,0));
29+
?column?
30+
----------
31+
1
32+
(1 row)
33+
34+
SELECT #E'\\x128b498895a3f5af28cafe'::hll;
35+
?column?
36+
----------
37+
1
38+
(1 row)
39+
40+
SELECT #E'\\x128b498895a3f5af28cafeda0ce907e4355b60'::hll;
41+
?column?
42+
----------
43+
2
44+
(1 row)
45+
46+
SELECT #E'\\x138b4f0061'::hll;
47+
?column?
48+
------------------
49+
1.00024422012692
50+
(1 row)
51+
52+
SELECT #E'\\x148B480800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'::hll;
53+
?column?
54+
------------------
55+
1.00024422012692
56+
(1 row)
57+
58+
SELECT #E'\\x148B480842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084210842108421084200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'::hll;
59+
?column?
60+
------------------
61+
545.638878057197
62+
(1 row)
63+

0 commit comments

Comments
 (0)