This test will generate 20 rows of data, in all the types supported by the data provider.
| 34 | // This test will generate 20 rows of data, in all the types supported by the |
| 35 | // data provider. |
| 36 | int main(int argc, char **argv) { |
| 37 | |
| 38 | string min_std_str("a"); |
| 39 | string max_std_str("zzzzzz"); |
| 40 | |
| 41 | StringValue min_str(const_cast<char*>(min_std_str.c_str()), min_std_str.size()); |
| 42 | StringValue max_str(const_cast<char*>(max_std_str.c_str()), max_std_str.size()); |
| 43 | |
| 44 | vector<DataProvider::ColDesc> cols; |
| 45 | cols.push_back(DataProvider::ColDesc::Create<bool>(false, true)); |
| 46 | cols.push_back(DataProvider::ColDesc::Create<bool>( |
| 47 | false, true, DataProvider::SEQUENTIAL)); |
| 48 | cols.push_back(DataProvider::ColDesc::Create<int8_t>(0, 8)); |
| 49 | cols.push_back(DataProvider::ColDesc::Create<int8_t>(0, 8, DataProvider::SEQUENTIAL)); |
| 50 | cols.push_back(DataProvider::ColDesc::Create<int16_t>(8, 16)); |
| 51 | cols.push_back(DataProvider::ColDesc::Create<int32_t>(16, 32)); |
| 52 | cols.push_back(DataProvider::ColDesc::Create<int64_t>(32, 64)); |
| 53 | cols.push_back(DataProvider::ColDesc::Create<float>(-1, 1)); |
| 54 | cols.push_back(DataProvider::ColDesc::Create<float>(0, 5, DataProvider::SEQUENTIAL)); |
| 55 | cols.push_back(DataProvider::ColDesc::Create<double>(200, 300)); |
| 56 | cols.push_back(DataProvider::ColDesc::Create<StringValue>(min_str, max_str)); |
| 57 | |
| 58 | ObjectPool obj_pool; |
| 59 | RuntimeProfile* profile = RuntimeProfile::Create(&obj_pool, "DataGenTest"); |
| 60 | |
| 61 | MemTracker tracker; |
| 62 | MemPool pool(&tracker); |
| 63 | DataProvider provider(&pool, profile); |
| 64 | provider.Reset(20, 2, cols); |
| 65 | int rows; |
| 66 | void* data; |
| 67 | |
| 68 | cout << "Row size: " << provider.row_size() << endl; |
| 69 | |
| 70 | while ( (data = provider.NextBatch(&rows)) != NULL) { |
| 71 | provider.Print(&cout, reinterpret_cast<char*>(data), rows); |
| 72 | } |
| 73 | |
| 74 | profile->PrettyPrint(&cout); |
| 75 | |
| 76 | cout << endl << "Done." << endl; |
| 77 | return 0; |
| 78 | } |