Skip to content

Commit ae1bb25

Browse files
committed
make work
1 parent 26bbb6a commit ae1bb25

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

include/bucket.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ struct Bucket {
1313
};
1414
#pragma pack(pop)
1515

16-
typedef col_hash_t[2] ColumnDepths;
17-
1816
namespace SketchBucket {
1917

18+
struct Depths {
19+
private:
20+
col_hash_t depths[2];
21+
public:
22+
col_hash_t& operator[](size_t i) { return depths[i]; }
23+
};
24+
2025
static constexpr size_t col_hash_bits = sizeof(col_hash_t) * 8;
2126
/**
2227
* Hashes the column index and the update index together to determine the depth of an update
@@ -33,16 +38,16 @@ inline static col_hash_t get_index_depth(const vec_t update_idx, const long seed
3338
return __builtin_ctzll(depth_hash);
3439
}
3540

36-
inline static depths get_index_depths(vec_t update_idx, size_t seed, col_hash_t max_depth) {
37-
col_hash_t depth_hash = col_hash(&update_idx, sizeof(vec_t), seed);
38-
depths ret;
41+
inline static Depths get_index_depths(vec_t update_idx, size_t seed, col_hash_t max_depth) {
42+
uint64_t depth_hash = col_hash(&update_idx, sizeof(vec_t), seed);
43+
Depths ret;
3944

4045
depth_hash |= (1ull << max_depth); // assert not > max_depth by ORing
4146
ret[0] = __builtin_ctzll(depth_hash);
4247

4348
// shift hash over and reassert max_depth
4449
depth_hash >>= 32;
45-
depth_hash depth_hash |= (1ull << max_depth);
50+
depth_hash |= (1ull << max_depth);
4651
ret[1] = __builtin_ctzll(depth_hash);
4752

4853
return ret;
@@ -56,7 +61,7 @@ inline static depths get_index_depths(vec_t update_idx, size_t seed, col_hash_t
5661
* @return The depth of the bucket to update
5762
*/
5863
inline static vec_hash_t get_index_hash(const vec_t index, const long sketch_seed) {
59-
return vec_hash(&update_idx, sizeof(vec_t), sketch_seed);
64+
return vec_hash(&index, sizeof(vec_t), sketch_seed);
6065
}
6166

6267
/**

src/sparse_sketch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void SparseSketch::update(const vec_t update_idx) {
249249

250250
// Update depth 0 bucket
251251
SketchBucket::update(deterministic_bucket(), update_idx, checksum);
252-
ColumnDepths depths;
252+
SketchBucket::Depths depths;
253253

254254
// Update higher depth buckets
255255
for (size_t i = 0; i < num_columns; i++) {

test/sketch_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST(SketchTestSuite, TestSampleResults) {
3535
continue;
3636
}
3737

38-
col_hash_t depth = SketchBucket::get_index_depth(k, sketch2.column_seed(i), guesses);
38+
col_hash_t depth = SketchBucket::get_index_depths(k, sketch2.column_seed(i - (i % 2)), guesses)[i & 0x1];
3939
if (depth >= 2) {
4040
vec_idx[k] = false; // force all updates to only touch depths <= 1
4141
i = 0;

0 commit comments

Comments
 (0)