Skip to content

Commit 06e066e

Browse files
committed
fix compile error
1 parent 5210e8b commit 06e066e

16 files changed

Lines changed: 42 additions & 40 deletions

opteryx/__version__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# THIS FILE IS AUTOMATICALLY UPDATED DURING THE BUILD PROCESS
22
# DO NOT EDIT THIS FILE DIRECTLY
33

4-
__build__ = 1857
4+
__build__ = 1861
55
__author__ = "@joocer"
6-
__version__ = "0.26.2-beta.1857"
6+
__version__ = "0.26.2-beta.1861"
77

88
# Store the version here so:
99
# 1) we don't load dependencies by storing it in __init__.py

opteryx/draken/vectors/vector.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cdef const uint64_t MIX_HASH_CONSTANT
1515
cdef const uint64_t NULL_HASH
1616

1717
cdef extern from "simd_hash.h":
18-
void simd_mix_hash(uint64_t* dest, const uint64_t* values, size_t count, uint64_t mix_constant) nogil
18+
void simd_mix_hash(uint64_t* dest, const uint64_t* values, size_t count) nogil
1919

2020
cdef inline uint64_t mix_hash(uint64_t current, uint64_t value) nogil:
2121
cdef uint64_t mixed = current ^ value

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "opteryx"
3-
version = "0.26.2-beta.1857"
3+
version = "0.26.2-beta.1861"
44
description = "Query your data, where it lives"
55
requires-python = '>=3.11'
66
readme = {file = "README.md", content-type = "text/markdown"}

src/cpp/simd_hash.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
namespace {
1313

14-
inline void scalar_mix(uint64_t* dest, const uint64_t* values, std::size_t count, uint64_t mix_constant) {
14+
inline void scalar_mix(uint64_t* dest, const uint64_t* values, std::size_t count) {
1515
for (std::size_t i = 0; i < count; ++i) {
1616
uint64_t mixed = dest[i] ^ values[i];
17-
mixed *= mix_constant;
17+
mixed *= MIX_HASH_CONSTANT;
1818
mixed ^= mixed >> 32;
1919
dest[i] = mixed;
2020
}
@@ -53,14 +53,14 @@ inline uint64x2_t mullo_u64(uint64x2_t a, uint64x2_t b) {
5353

5454
} // namespace
5555

56-
void simd_mix_hash(uint64_t* dest, const uint64_t* values, std::size_t count, uint64_t mix_constant) {
56+
void simd_mix_hash(uint64_t* dest, const uint64_t* values, std::size_t count) {
5757
if (dest == nullptr || values == nullptr || count == 0) {
5858
return;
5959
}
6060

6161
#if defined(__AVX2__)
6262
const std::size_t stride = 4;
63-
const __m256i const_vec = _mm256_set1_epi64x(static_cast<long long>(mix_constant));
63+
const __m256i const_vec = _mm256_set1_epi64x(static_cast<long long>(MIX_HASH_CONSTANT));
6464
std::size_t i = 0;
6565
for (; i + stride <= count; i += stride) {
6666
__m256i dst_vec = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(dest + i));
@@ -72,11 +72,11 @@ void simd_mix_hash(uint64_t* dest, const uint64_t* values, std::size_t count, ui
7272
_mm256_storeu_si256(reinterpret_cast<__m256i*>(dest + i), combined);
7373
}
7474
if (i < count) {
75-
scalar_mix(dest + i, values + i, count - i, mix_constant);
75+
scalar_mix(dest + i, values + i, count - i);
7676
}
7777
#elif defined(__ARM_NEON) || defined(__ARM_NEON__)
7878
const std::size_t stride = 2;
79-
const uint64x2_t const_vec = vdupq_n_u64(mix_constant);
79+
const uint64x2_t const_vec = vdupq_n_u64(MIX_HASH_CONSTANT);
8080
std::size_t i = 0;
8181
for (; i + stride <= count; i += stride) {
8282
uint64x2_t dst_vec = vld1q_u64(dest + i);
@@ -88,9 +88,9 @@ void simd_mix_hash(uint64_t* dest, const uint64_t* values, std::size_t count, ui
8888
vst1q_u64(dest + i, combined);
8989
}
9090
if (i < count) {
91-
scalar_mix(dest + i, values + i, count - i, mix_constant);
91+
scalar_mix(dest + i, values + i, count - i);
9292
}
9393
#else
94-
scalar_mix(dest, values, count, mix_constant);
94+
scalar_mix(dest, values, count);
9595
#endif
9696
}

src/cpp/simd_hash.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
extern "C" {
88
#endif
99

10-
void simd_mix_hash(uint64_t* dest, const uint64_t* values, size_t count, uint64_t mix_constant);
10+
// Shared mixing constant used by scalar and SIMD mixers.
11+
#ifndef MIX_HASH_CONSTANT
12+
#define MIX_HASH_CONSTANT ((uint64_t)0x9e3779b97f4a7c15ULL)
13+
#endif
14+
15+
void simd_mix_hash(uint64_t* dest, const uint64_t* values, size_t count);
1116

1217
#ifdef __cplusplus
1318
}

tests/draken/morsels/test_hash_into.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def _mix_hash(current: int, value: int, mix_constant: int) -> int:
3434

3535

3636
def _vector_hash_to_list(vector, mix_constant: int = 0x9E3779B97F4A7C15):
37+
"""Compute vector hashes into a Python list.
38+
39+
The `mix_constant` parameter is accepted for compatibility with older
40+
tests but is ignored because the mixing constant is now enforced
41+
internally by the implementation.
42+
"""
3743
length = getattr(vector, "length", None)
3844

3945
if length is None:
@@ -43,7 +49,7 @@ def _vector_hash_to_list(vector, mix_constant: int = 0x9E3779B97F4A7C15):
4349
length = len(vector.to_pylist())
4450

4551
out = array("Q", [0] * length)
46-
hash_into_vector(vector, out, mix_constant=mix_constant)
52+
hash_into_vector(vector, out)
4753
return list(out)
4854

4955

@@ -317,7 +323,7 @@ def test_hash_into_consistency_with_hash():
317323
expected.append(hashed)
318324

319325
out_buf = array('Q', [0] * len(expected))
320-
hash_into_vector(vec, out_buf, 0, mix_constant)
326+
hash_into_vector(vec, out_buf, 0)
321327

322328
assert list(out_buf) == expected
323329

@@ -750,8 +756,8 @@ def test_hash_into_zero_mix_constant():
750756
out_buf = array('Q', [0, 0, 0])
751757
out_view = memoryview(out_buf)
752758

753-
# Should not raise even with zero mix constant
754-
hash_into_vector(vec, out_view, 0, 0)
759+
# Should not raise (mix constant override removed)
760+
hash_into_vector(vec, out_view, 0)
755761

756762
result = list(out_buf)
757763
baseline = _vector_hash_to_list(vec, mix_constant=MIX_HASH_CONSTANT)
@@ -769,7 +775,7 @@ def test_hash_into_max_uint64_mix_constant():
769775
out_view = memoryview(out_buf)
770776

771777
max_uint64 = 0xFFFFFFFFFFFFFFFF
772-
hash_into_vector(vec, out_view, 0, max_uint64)
778+
hash_into_vector(vec, out_view, 0)
773779

774780
result = list(out_buf)
775781
assert all(h != 0 for h in result)

third_party/mabel/draken/vectors/array_vector.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ cdef class ArrayVector(Vector):
373373
encoded = repr(value).encode("utf-8")
374374
scratch[j] = hash_bytes(encoded)
375375

376-
simd_mix_hash(&out_buf[offset + i], scratch_ptr, <size_t> block, MIX_HASH_CONSTANT)
376+
simd_mix_hash(&out_buf[offset + i], scratch_ptr, <size_t> block)
377377
i += block
378378

379379
def __str__(self):

third_party/mabel/draken/vectors/bool_vector.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ cdef class BoolVector(Vector):
303303
scratch[j] = TRUE_HASH
304304
else:
305305
scratch[j] = FALSE_HASH
306-
simd_mix_hash(dst + i, scratch_ptr, <size_t> block, MIX_HASH_CONSTANT)
306+
simd_mix_hash(dst + i, scratch_ptr, <size_t> block)
307307
i += block
308308
return
309309

third_party/mabel/draken/vectors/date32_vector.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ cdef class Date32Vector(Vector):
347347
block = DATE32_HASH_CHUNK
348348
for j in range(block):
349349
scratch[j] = <uint64_t>(<int64_t> data[i + j])
350-
simd_mix_hash(dst + i, scratch_ptr, <size_t> block, MIX_HASH_CONSTANT)
350+
simd_mix_hash(dst + i, scratch_ptr, <size_t> block)
351351
i += block
352352
return
353353

third_party/mabel/draken/vectors/float64_vector.pyx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ cdef class Float64Vector(Vector):
346346
self,
347347
uint64_t[::1] out_buf,
348348
Py_ssize_t offset=0,
349-
uint64_t mix_constant=<uint64_t>0x9e3779b97f4a7c15U,
350349
) except *:
351350
cdef DrakenFixedBuffer* ptr = self.ptr
352351
cdef double* data = <double*> ptr.data
@@ -365,10 +364,7 @@ cdef class Float64Vector(Vector):
365364
cdef uint8_t byte
366365
cdef uint64_t value
367366

368-
mix_constant = MIX_HASH_CONSTANT # enforce shared mixing constant
369-
if mix_constant != MIX_HASH_CONSTANT:
370-
mix_constant = MIX_HASH_CONSTANT
371-
367+
# Use shared MIX_HASH_CONSTANT directly; no need to pass it in.
372368
if has_nulls:
373369
for i in range(n):
374370
byte = null_bitmap[i >> 3]
@@ -378,7 +374,7 @@ cdef class Float64Vector(Vector):
378374
value = NULL_HASH
379375
dst[i] = mix_hash(dst[i], value)
380376
else:
381-
simd_mix_hash(dst, bits, <size_t>n, mix_constant)
377+
simd_mix_hash(dst, bits, <size_t>n)
382378
return
383379

384380
def __str__(self):

0 commit comments

Comments
 (0)