Skip to content

Commit 0ae255c

Browse files
committed
Address review feedback
- Fix sys.path to use os.path for reliable execution from any directory - Fix ShortType test data to use modulo for large vector sizes - Expand Cython deserializer benchmark docstring - Remove unnecessary blank lines between test_configs groups - Fix NotImplemented -> NotImplementedError in integration test
1 parent 6497369 commit 0ae255c

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

benchmarks/vector_deserialize.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
Run with: python benchmarks/vector_deserialize.py
2626
"""
2727

28+
import os
2829
import sys
2930
import time
3031
import struct
3132

32-
# Add parent directory to path
33-
sys.path.insert(0, '.')
33+
# Add project root to path so the benchmark can be run from any directory
34+
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
3435

3536
from cassandra.cqltypes import FloatType, DoubleType, Int32Type, LongType, ShortType
3637
from cassandra.marshal import float_pack, double_pack, int32_pack, int64_pack, int16_pack
@@ -51,7 +52,7 @@ def create_test_data(vector_size, element_type):
5152
values = list(range(vector_size))
5253
pack_fn = int64_pack
5354
elif element_type == ShortType:
54-
values = list(range(min(vector_size, 32767)))
55+
values = [i % 32767 for i in range(vector_size)]
5556
pack_fn = int16_pack
5657
else:
5758
raise ValueError(f"Unsupported element type: {element_type}")
@@ -144,7 +145,12 @@ def benchmark_numpy_optimization(vector_type, serialized_data, iterations=10000)
144145

145146

146147
def benchmark_cython_deserializer(vector_type, serialized_data, iterations=10000):
147-
"""Benchmark Cython DesVectorType deserializer."""
148+
"""Benchmark Cython DesVectorType deserializer.
149+
150+
This benchmark requires the Cython deserializers extension to be compiled.
151+
When the extension is not available, or the type does not have a dedicated
152+
DesVectorType deserializer, the benchmark is silently skipped (returns None).
153+
"""
148154
try:
149155
from cassandra.deserializers import find_deserializer
150156
except ImportError:
@@ -284,15 +290,12 @@ def main():
284290
# Small vectors
285291
(3, FloatType, "float", 50000),
286292
(4, FloatType, "float", 50000),
287-
288293
# Medium vectors (common in ML)
289294
(128, FloatType, "float", 10000),
290295
(384, FloatType, "float", 10000),
291-
292296
# Large vectors (embeddings)
293297
(768, FloatType, "float", 5000),
294298
(1536, FloatType, "float", 2000),
295-
296299
# Other types (smaller iteration counts)
297300
(128, DoubleType, "double", 10000),
298301
(768, DoubleType, "double", 5000),

tests/integration/standard/test_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def test_can_insert_tuples_all_collection_datatypes(self):
583583

584584
# make sure we're testing all non primitive data types in the future
585585
if set(COLLECTION_TYPES) != set(['tuple', 'list', 'map', 'set']):
586-
raise NotImplemented('Missing datatype not implemented: {}'.format(
586+
raise NotImplementedError('Missing datatype not implemented: {}'.format(
587587
set(COLLECTION_TYPES) - set(['tuple', 'list', 'map', 'set'])
588588
))
589589

0 commit comments

Comments
 (0)