Skip to content

Commit 25bb0bd

Browse files
committed
space usage
1 parent 2f42942 commit 25bb0bd

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

include/sketch/sketch_columns.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class FixedSizeSketchColumn {
4848
void atomic_update(const vec_t update);
4949
void merge(FixedSizeSketchColumn const& other);
5050
uint8_t get_depth() const;
51+
size_t space_usage_bytes() const;
5152
void serialize(std::ostream &binary_out) const;
5253

5354
static uint8_t suggest_capacity(size_t num_indices) {
@@ -131,6 +132,7 @@ FRIEND_TEST(SketchColumnTestSuite, TestUpdateReallocation);
131132
void atomic_apply_entry_delta(const ColumnEntryDelta &delta);
132133
void merge(ResizeableSketchColumn const& other);
133134
uint8_t get_depth() const;
135+
size_t space_usage_bytes() const;
134136

135137
[[deprecated]]
136138
void zero_contents() {
@@ -214,6 +216,7 @@ class ResizeableAlignedSketchColumn {
214216
}
215217
void merge(ResizeableAlignedSketchColumn const& other);
216218
uint8_t get_depth() const;
219+
size_t space_usage_bytes() const;
217220

218221
[[deprecated]]
219222
void zero_contents() {

include/sketch/sketch_concept.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ concept SketchColumnConcept = requires(T t, T other) {
5656
{ t.prefetch() } -> std::same_as<void>;
5757

5858
{ t.is_initialized() } -> std::same_as<bool>;
59+
{ t.space_usage_bytes() } -> std::same_as<size_t>;
5960

6061
{ t.clear()} -> std::same_as<void>;
6162
{ t.zero_contents()} -> std::same_as<void>;

src/sketch_columns.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ uint8_t FixedSizeSketchColumn::get_depth() const {
6969
}
7070
return 0;
7171
}
72+
size_t FixedSizeSketchColumn::space_usage_bytes() const {
73+
return sizeof(FixedSizeSketchColumn) + (capacity * sizeof(Bucket));
74+
}
7275

7376
// TODO - implement actual deserialization
7477
void FixedSizeSketchColumn::serialize(std::ostream &binary_out) const {
@@ -400,6 +403,9 @@ uint8_t ResizeableSketchColumn::get_depth() const {
400403
}
401404
return 0;
402405
}
406+
size_t ResizeableSketchColumn::space_usage_bytes() const {
407+
return sizeof(ResizeableSketchColumn) + (this->capacity * sizeof(Bucket));
408+
}
403409

404410

405411

@@ -511,6 +517,9 @@ uint8_t ResizeableAlignedSketchColumn::get_depth() const {
511517
}
512518
return 0;
513519
}
520+
size_t ResizeableAlignedSketchColumn::space_usage_bytes() const{
521+
return sizeof(ResizeableAlignedSketchColumn) + (this->capacity * sizeof(Bucket));
522+
}
514523

515524

516525
static_assert(SketchColumnConcept<FixedSizeSketchColumn, vec_t>,

0 commit comments

Comments
 (0)