6 #ifndef _UTILS_MICRODATASET_H_
7 #define _UTILS_MICRODATASET_H_
47 std::random_device rd;
48 std::default_random_engine e1;
86 template<
class dType=u
int32_t>
88 vector<dType> ru(len);
90 for (
size_t i = 0; i < len; i++) {
103 template<
class tsType=
size_t>
105 vector<tsType> ret(len);
106 vector<tsType> alphabet = genIncrementalAlphabet<tsType>(maxV);
109 gen = std::mt19937_64(rd());
111 gen = std::mt19937_64(seed);
115 std::uniform_real_distribution<> dis(0, 1);
116 vector<double> lut = genZipfLut<double>(maxV, fac);
117 for (
size_t i = 0; i < len; i++) {
122 size_t right = maxV - 1;
129 while (right - left > 1) {
130 m = (left + right) / 2;
140 ret[i] = alphabet[pos];
158 template<
class tsType=u
int32_t,
class genType=std::mt19937>
167 std::uniform_int_distribution<> dis(minV, maxV);
168 vector<tsType> ret(len);
169 for (
size_t i = 0; i < len; i++) {
170 ret[i] = (
tsType) dis(gen);
181 template<
class dType=
double>
183 dType scaling_factor;
185 vector<dType> lut(len);
192 scaling_factor = 0.0;
193 for (
size_t i = 1; i <= len; i++) { scaling_factor += 1.0 / pow(i, fac); }
198 for (
size_t i = 1; i <= len; i++) {
199 sum += 1.0 / std::pow(i, fac);
200 lut[i - 1] = sum / scaling_factor;
221 template<
class tsType=
size_t>
223 vector<tsType> ret(len);
225 for (
size_t i = 0; i < len; i++) {
227 if (i % (step) == 0) {
244 template<
class tsType=
size_t>
246 vector<tsType> ret = genZipfInt<tsType>(len, maxTime, fac);
247 std::sort(ret.begin(), ret.end());
The all-in-one class for the Micro dataset.
Definition: MicroDataSet.hpp:45
uint64_t tsType
Definition: Tuples.h:20
MicroDataSet(uint64_t _seed)
construction with seed
Definition: MicroDataSet.hpp:63
void setSeed(uint64_t _seed)
construction with seed
Definition: MicroDataSet.hpp:71
MicroDataSet()
default construction, with auto random generator
Definition: MicroDataSet.hpp:56
vector< tsType > genZipfInt(size_t len, tsType maxV, double fac)
The function to generate a vector of integers which has zipf distribution.
Definition: MicroDataSet.hpp:104
vector< tsType > genRandInt(size_t len, tsType maxV, tsType minV=0)
generate the vector of random integer
Definition: MicroDataSet.hpp:159
vector< dType > genZipfLut(size_t len, dType fac)
To generate the zipf Lut.
Definition: MicroDataSet.hpp:182
vector< dType > genIncrementalAlphabet(size_t len)
To generate incremental alphabet, starting from 0 and end at len.
Definition: MicroDataSet.hpp:87
vector< tsType > genSmoothTimeStamp(size_t len, size_t step, size_t interval)
The function to generate a vector of timestamp which grows smoothly.
Definition: MicroDataSet.hpp:222
vector< tsType > genZipfTimeStamp(size_t len, tsType maxTime, double fac)
The function to generate a vector of timestamp which has zipf distribution.
Definition: MicroDataSet.hpp:245