Skip to content

Conversation

@Mytherin
Copy link
Collaborator

@Mytherin Mytherin commented Aug 6, 2020

This PR implements the HUGEINT/INT128 type. This type allows for storing exact integer values between -170141183460469231731687303715884105727 and 170141183460469231731687303715884105727 (i.e. pretty big). The type is supported everywhere that other numbers are supported (i.e. you can store it in tables, perform arithmetic, perform certain functions/ops, join on it, etc). Internally it is stored as follows:

struct hugeint_t {
	uint64_t lower;
	int64_t upper;
};

The value of a hugeint is equivalent to upper * 2^64 + lower, i.e. the value 1 is represented as lower: 1, upper: 0 and the value -1 is represented as upper: -1, lower: 2^64-1.

The primary purpose of the HUGEINT type is overflow prevention (and in the future, larger decimal support). Currently the HUGEINT type can either be manually created, but is also created by performing SUM on INT32 or INT64 columns.

Persistent Storage Support for SQLLogicTests

Besides the HUGEINT package, this PR also includes basic storage support for the sqllogictests. You can now load a database file on disk using the load command, e.g. load __TEST_DIR__/hugeint_storage_test.db. Databases can be reloaded (with forced checkpointing enabled) using the restart command. This allows most persistent storage tests to be written within the sqllogictests as well.

Interpreted Benchmarks

This PR also includes basic support for interpreted benchmarks. They use a format that looks similar to the sqllogictests. Example below:

# name: benchmark/micro/cast/cast_hugeint_string.benchmark
# description: Cast small HUGEINT values to string
# group: [cast]

load
CREATE TABLE integers AS SELECT i::HUGEINT AS i FROM range(0, 10000000, 1) tbl(i);

run
SELECT MAX(CAST(i AS VARCHAR)) FROM integers

result I
9999999

First the load query will be issued, after which the run query will be issued and verified against the result. Benchmark files should have the .benchmark extension and be located in the benchmark directory. They will automatically be found by the benchmark_runner, much like the unittests are.

Mytherin added 30 commits August 4, 2020 09:47
… operator overloading to avoid having to specialize functions
…gin converting some storage tests to sqllogictests
…onnection is destroyed after db is destroyed with temporary tables still active
…ts wrapper class that also supports hugeint_t
@Mytherin Mytherin merged commit 8bb43d5 into master Aug 7, 2020
@Mytherin Mytherin deleted the hugeint branch August 11, 2020 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants