Skip to content

Commit 0e25e63

Browse files
committed
test xindex size inaccurately
1 parent 056076a commit 0e25e63

31 files changed

+1428
-1058
lines changed

include/alex/alex.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ namespace alex
121121
int num_sideways_splits = 0;
122122
int num_model_node_expansions = 0;
123123
int num_model_node_splits = 0;
124-
long long num_downward_split_keys = 0;
125-
long long num_sideways_split_keys = 0;
126-
long long num_model_node_expansion_pointers = 0;
127-
long long num_model_node_split_pointers = 0;
128-
mutable long long num_node_lookups = 0;
129-
mutable long long num_lookups = 0;
130-
long long num_inserts = 0;
124+
double num_downward_split_keys = 0;
125+
double num_sideways_split_keys = 0;
126+
double num_model_node_expansion_pointers = 0;
127+
double num_model_node_split_pointers = 0;
128+
mutable double num_node_lookups = 0;
129+
mutable double num_lookups = 0;
130+
double num_inserts = 0;
131131
double splitting_time = 0;
132132
double cost_computation_time = 0;
133133
};
@@ -2697,9 +2697,9 @@ namespace alex
26972697
size_t max_size() const { return size_t(-1); }
26982698

26992699
// Size in bytes of all the keys, payloads, and bitmaps stored in this index
2700-
long long data_size() const
2700+
double data_size() const
27012701
{
2702-
long long size = 0;
2702+
double size = 0;
27032703
for (NodeIterator node_it = NodeIterator(this); !node_it.is_end();
27042704
node_it.next())
27052705
{
@@ -2714,9 +2714,9 @@ namespace alex
27142714

27152715
// Size in bytes of all the model nodes (including pointers) and metadata in
27162716
// data nodes
2717-
long long model_size() const
2717+
double model_size() const
27182718
{
2719-
long long size = 0;
2719+
double size = 0;
27202720
for (NodeIterator node_it = NodeIterator(this); !node_it.is_end();
27212721
node_it.next())
27222722
{

include/alex/alex_base.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class ExpectedShiftsAccumulator : public StatAccumulator {
255255
// Therefore, we track n^2/4.
256256
void accumulate(int actual_position, int) override {
257257
if (actual_position > last_position_ + 1) {
258-
long long dense_region_length = last_position_ - dense_region_start_idx_ + 1;
258+
double dense_region_length = last_position_ - dense_region_start_idx_ + 1;
259259
num_expected_shifts_ += (dense_region_length * dense_region_length) / 4;
260260
dense_region_start_idx_ = actual_position;
261261
}
@@ -266,8 +266,8 @@ class ExpectedShiftsAccumulator : public StatAccumulator {
266266
double get_stat() override {
267267
if (count_ == 0) return 0;
268268
// first need to accumulate statistics for current packed region
269-
long long dense_region_length = last_position_ - dense_region_start_idx_ + 1;
270-
long long cur_num_expected_shifts =
269+
double dense_region_length = last_position_ - dense_region_start_idx_ + 1;
270+
double cur_num_expected_shifts =
271271
num_expected_shifts_ + (dense_region_length * dense_region_length) / 4;
272272
return cur_num_expected_shifts / static_cast<double>(count_);
273273
}
@@ -282,7 +282,7 @@ class ExpectedShiftsAccumulator : public StatAccumulator {
282282
public:
283283
int last_position_ = -1;
284284
int dense_region_start_idx_ = 0;
285-
long long num_expected_shifts_ = 0;
285+
double num_expected_shifts_ = 0;
286286
int count_ = 0;
287287
int data_capacity_ = -1; // capacity of node
288288
};
@@ -299,7 +299,7 @@ class ExpectedIterationsAndShiftsAccumulator : public StatAccumulator {
299299
std::log2(std::abs(predicted_position - actual_position) + 1);
300300

301301
if (actual_position > last_position_ + 1) {
302-
long long dense_region_length = last_position_ - dense_region_start_idx_ + 1;
302+
double dense_region_length = last_position_ - dense_region_start_idx_ + 1;
303303
num_expected_shifts_ += (dense_region_length * dense_region_length) / 4;
304304
dense_region_start_idx_ = actual_position;
305305
}
@@ -320,8 +320,8 @@ class ExpectedIterationsAndShiftsAccumulator : public StatAccumulator {
320320

321321
double get_expected_num_shifts() {
322322
if (count_ == 0) return 0;
323-
long long dense_region_length = last_position_ - dense_region_start_idx_ + 1;
324-
long long cur_num_expected_shifts =
323+
double dense_region_length = last_position_ - dense_region_start_idx_ + 1;
324+
double cur_num_expected_shifts =
325325
num_expected_shifts_ + (dense_region_length * dense_region_length) / 4;
326326
return cur_num_expected_shifts / static_cast<double>(count_);
327327
}
@@ -338,7 +338,7 @@ class ExpectedIterationsAndShiftsAccumulator : public StatAccumulator {
338338
double cumulative_log_error_ = 0;
339339
int last_position_ = -1;
340340
int dense_region_start_idx_ = 0;
341-
long long num_expected_shifts_ = 0;
341+
double num_expected_shifts_ = 0;
342342
int count_ = 0;
343343
int data_capacity_ = -1; // capacity of node
344344
};

include/alex/alex_nodes.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class AlexNode {
6161
virtual ~AlexNode() = default;
6262

6363
// The size in bytes of all member variables in this class
64-
virtual long long node_size() const = 0;
64+
virtual double node_size() const = 0;
6565
};
6666

6767
template <class T, class P, class Alloc = std::allocator<std::pair<T, P>>>
@@ -143,8 +143,8 @@ class AlexModelNode : public AlexNode<T, P> {
143143
return pointer_alloc_type(allocator_);
144144
}
145145

146-
long long node_size() const override {
147-
long long size = sizeof(self_type);
146+
double node_size() const override {
147+
double size = sizeof(self_type);
148148
size += num_children_ * sizeof(AlexNode<T, P>*); // pointers to children
149149
return size;
150150
}
@@ -349,8 +349,8 @@ class AlexDataNode : public AlexNode<T, P> {
349349
sizeof(V); // cannot expand beyond this number of key/data slots
350350

351351
// Counters used in cost models
352-
long long num_shifts_ = 0; // does not reset after resizing
353-
long long num_exp_search_iterations_ = 0; // does not reset after resizing
352+
double num_shifts_ = 0; // does not reset after resizing
353+
double num_exp_search_iterations_ = 0; // does not reset after resizing
354354
int num_lookups_ = 0; // does not reset after resizing
355355
int num_inserts_ = 0; // does not reset after resizing
356356
int num_resizes_ = 0; // technically not required, but nice to have
@@ -2221,11 +2221,11 @@ class AlexDataNode : public AlexNode<T, P> {
22212221
/*** Stats ***/
22222222

22232223
// Total size of node metadata
2224-
long long node_size() const override { return sizeof(self_type); }
2224+
double node_size() const override { return sizeof(self_type); }
22252225

22262226
// Total size in bytes of key/payload/data_slots and bitmap
2227-
long long data_size() const {
2228-
long long data_size = data_capacity_ * sizeof(T);
2227+
double data_size() const {
2228+
double data_size = data_capacity_ * sizeof(T);
22292229
data_size += data_capacity_ * sizeof(P);
22302230
data_size += bitmap_size_ * sizeof(uint64_t);
22312231
return data_size;

include/xindex/xindex.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class XIndex {
5252
size_t range_scan(const key_t &begin, const key_t &end,
5353
std::vector<std::pair<key_t, val_t>> &result,
5454
const uint32_t worker_id);
55+
double index_size();
5556
private:
5657
void start_bg();
5758
void terminate_bg();

include/xindex/xindex_group.h

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ namespace xindex
113113

114114
void free_data();
115115
void free_buffer();
116+
double group_size();
116117

117118
private:
118119
inline size_t locate_model(const key_t &key);

0 commit comments

Comments
 (0)