|
11 | 11 | #include "util.h" |
12 | 12 | #include "bucket.h" |
13 | 13 |
|
| 14 | +// TODO: Do we want to use row major or column major order? |
| 15 | +// TODO: How do we want to handle raw_bucket_merge() and get_readonly_bucket_ptr()? |
| 16 | +// These functions are nice for performance because we can skip serialization but aren't |
| 17 | +// strictly necessary. |
| 18 | +// TODO: It would be nice to preallocate the structure if we know how big its probably going to be. |
| 19 | +// This would be helpful for delta sketches for example. |
| 20 | +// TODO: What are we doing with the num_buckets variable? Could be nice to just be the size of |
| 21 | +// buckets array. Could also be upperbound on the size. |
| 22 | + |
| 23 | +// A strategy that could work well would be to allocate a chunk of memory some of which is given to |
| 24 | +// the dense region of the sketch and 3 * sizeof(uint64_t) are given to sparse region. |
| 25 | +// 3 -> position, alpha, gamma (could save a little more space by using 16 bits for position) |
| 26 | + |
14 | 27 | // enum SerialType { |
15 | 28 | // FULL, |
16 | 29 | // RANGE, |
@@ -43,14 +56,34 @@ class Sketch { |
43 | 56 | size_t num_samples; // number of samples we can perform |
44 | 57 | size_t cols_per_sample; // number of columns to use on each sample |
45 | 58 | size_t num_columns; // Total number of columns. (product of above 2) |
46 | | - size_t bkt_per_col; // number of buckets per column |
| 59 | + size_t bkt_per_col; // maximum number of buckets per column (max number of rows) |
47 | 60 | size_t num_buckets; // number of total buckets (product of above 2) |
48 | 61 |
|
49 | 62 | size_t sample_idx = 0; // number of samples performed so far |
50 | 63 |
|
51 | | - // bucket data |
| 64 | + // bucket data, stored densely |
52 | 65 | Bucket* buckets; |
53 | 66 |
|
| 67 | +#ifndef L0_FULLY_DENSE |
| 68 | + size_t num_dense_rows = 4; |
| 69 | + |
| 70 | + // sparse representation of lower levels of Matrix |
| 71 | + // TODO: Evaluate if this is shit. It probably is |
| 72 | + std::vector<std::unordered_map<size_t, Bucket>> bucket_buffer; |
| 73 | + size_t number_of_sparse_buckets = 0; |
| 74 | + size_t sparse_capacity = 2 * num_columns; // TODO: evaluate implications of this constant |
| 75 | + |
| 76 | + /** |
| 77 | + * Reallocates the dense region of the sketch to have a different number of rows |
| 78 | + * @param new_num_rows the new number of rows to store densely |
| 79 | + */ |
| 80 | + void reallocate_dense_region(size_t new_num_rows); |
| 81 | +#endif |
| 82 | + |
| 83 | + inline Bucket& get_deterministic_bucket() { |
| 84 | + // TODO: implement this |
| 85 | + } |
| 86 | + |
54 | 87 | public: |
55 | 88 | /** |
56 | 89 | * The below constructors use vector length as their input. However, in graph sketching our input |
|
0 commit comments