mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
store_manip.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <random>
6#include <utility>
7#include <vector>
8
9
10namespace m {
11
14void set_all_null(uint8_t *column_ptr, std::size_t num_attrs, std::size_t begin, std::size_t end);
15
18void set_all_not_null(uint8_t *column_ptr, std::size_t num_attrs, std::size_t begin, std::size_t end);
19
22void generate_primary_keys(void *column_ptr, const Type &type, std::size_t begin, std::size_t end);
23
27template<typename T, typename Generator = std::mt19937_64>
28std::enable_if_t<std::is_arithmetic_v<T>, void>
29M_EXPORT
30fill_uniform(T *column_ptr, std::vector<T> values, std::size_t begin, std::size_t end, Generator &&g = Generator()) {
31 M_insist(begin < end, "must set at least one row");
32
33 const auto count = end - begin;
34
35 /* Write distinct values repeatedly in arbitrary order to column. */
36 auto ptr = column_ptr + begin;
37 for (std::size_t i = 0; i != count; ) {
38 /* Shuffle the vector before writing its values to the column. */
39 std::shuffle(values.begin(), values.end(), std::forward<Generator>(g));
40 for (auto v : values) {
41 *ptr++ = v;
42 ++i;
43 if (i == count)
44 goto exit;
45 }
46 }
47exit:
48 M_insist(ptr - column_ptr == long(count), "incorrect number of elements written");
49}
50
53void generate_column_data(void *column_ptr, const Attribute &attr, std::size_t num_distinct_values, std::size_t begin,
54 std::size_t end);
55
58void generate_correlated_column_data(void *left_ptr, void *right_ptr, const Attribute &attr,
59 std::size_t num_distinct_values_left, std::size_t num_distinct_values_right,
60 std::size_t count_left, std::size_t count_right,
61 std::size_t num_distinct_values_matching);
62
63}
#define M_insist(...)
Definition: macro.hpp:129
‍mutable namespace
Definition: Backend.hpp:10
void set_all_not_null(uint8_t *column_ptr, std::size_t num_attrs, std::size_t begin, std::size_t end)
Sets all attributes of the begin-th row (including) to the end-th row (excluding) of column at addres...
void generate_column_data(void *column_ptr, const Attribute &attr, std::size_t num_distinct_values, std::size_t begin, std::size_t end)
Generates data for the column at address column_ptr from begin-th row (including) to end-th row (excl...
void set_all_null(uint8_t *column_ptr, std::size_t num_attrs, std::size_t begin, std::size_t end)
Sets all attributes of the begin-th row (including) to the end-th row (excluding) of column at addres...
void generate_correlated_column_data(void *left_ptr, void *right_ptr, const Attribute &attr, std::size_t num_distinct_values_left, std::size_t num_distinct_values_right, std::size_t count_left, std::size_t count_right, std::size_t num_distinct_values_matching)
Generates data for two columns at addresses left_ptr and right_ptr correlated by num_distinct_values_...
void generate_primary_keys(void *column_ptr, const Type &type, std::size_t begin, std::size_t end)
Generates primary keys of Type type for the begin-th row (including) to the end-th row (excluding) of...
std::enable_if_t< std::is_arithmetic_v< T >, void > M_EXPORT fill_uniform(T *column_ptr, std::vector< T > values, std::size_t begin, std::size_t end, Generator &&g=Generator())
Fills column at address column_ptr from begin-th row (including) to end-th row (excluding) with data ...
Definition: store_manip.hpp:30