Skip to content

Updated python package with finalized create column family changes. … #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="tidesdb",
version="0.1",
version="0.2",
packages=find_packages(),
author="Alex Gaetano Padula",
author_email="[email protected]",
Expand Down
15 changes: 9 additions & 6 deletions tests/test_create_cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def test_create_cf_no_compression(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)
families = self.db.list_column_families()
self.assertIn("test_family", families)
Expand All @@ -32,8 +33,9 @@ def test_create_duplicate_cf(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)

with self.assertRaises(Exception):
Expand All @@ -43,8 +45,9 @@ def test_create_duplicate_cf(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)

if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def setUp(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)


Expand Down
5 changes: 3 additions & 2 deletions tests/test_data_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def setUp(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)

def tearDown(self):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_tidesdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ def test_operations_after_close(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)

if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ def setUp(self):
max_level=12,
probability=0.24,
compressed=False,
compress_algo=0,
bloom_filter=False
compress_algo=NO_COMPRESSION,
bloom_filter=False,
memtable_ds=SKIP_LIST
)

def tearDown(self):
Expand Down
16 changes: 14 additions & 2 deletions tidesdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
# Load the tidesdb library
lib = ctypes.CDLL('PATH_TO_TIDESDB_LIB')

# TidesDB supported compression algorithm options
class TidesDBCompressionAlgo:
NO_COMPRESSION = 0
COMPRESS_SNAPPY = 1
COMPRESS_LZ4 = 2
COMPRESS_ZSTD = 3

# Column family memtable data structure options
class TidesDBMemtableDS:
SKIP_LIST = 0
HASH_TABLE = 1

# TidesDB class
class TidesDB:
def __init__(self, tdb):
Expand All @@ -38,9 +50,9 @@ def close(self):
if result != 0:
raise Exception("Failed to close TidesDB")

def create_column_family(self, name, flush_threshold, max_level, probability, compressed, compress_algo, bloom_filter):
def create_column_family(self, name, flush_threshold, max_level, probability, compressed, compress_algo, bloom_filter, memtable_ds):
c_name = create_string_buffer(name.encode('utf-8'))
result = lib.tidesdb_create_column_family(self.tdb, c_name, c_int(flush_threshold), c_int(max_level), c_float(probability), c_bool(compressed), c_int(compress_algo), c_bool(bloom_filter))
result = lib.tidesdb_create_column_family(self.tdb, c_name, c_int(flush_threshold), c_int(max_level), c_float(probability), c_bool(compressed), c_int(compress_algo), c_bool(bloom_filter), c_int(memtable_ds))
if result != 0:
raise Exception("Failed to create column family")

Expand Down