MCPcopy Create free account
hub / github.com/apache/impala / NextBatch

Method NextBatch

be/src/experiments/data-provider.cc:81–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void* DataProvider::NextBatch(int* rows_returned) {
82 int num_rows = min(batch_size_, num_rows_ - rows_returned_);
83 *rows_returned = num_rows;
84 if (num_rows == 0) return NULL;
85 COUNTER_ADD(bytes_generated_, num_rows * row_size_);
86
87 uniform_real<> dist(0,1);
88 variate_generator<minstd_rand&, uniform_real<>> rand_double(rand_generator_, dist);
89
90 char* data = data_.get();
91 for (int i = 0, row_idx = rows_returned_; i < num_rows; ++i, ++row_idx) {
92 for (int j = 0; j < cols_.size(); ++j) {
93 double r = rand_double();
94 const ColDesc& col = cols_[j];
95 switch (col.type) {
96 case TYPE_BOOLEAN:
97 *reinterpret_cast<bool*>(data) = col.Generate<bool>(r, row_idx);
98 break;
99 case TYPE_TINYINT:
100 *reinterpret_cast<int8_t*>(data) = col.Generate<int8_t>(r, row_idx);
101 break;
102 case TYPE_SMALLINT:
103 *reinterpret_cast<int16_t*>(data) = col.Generate<int16_t>(r, row_idx);
104 break;
105 case TYPE_INT:
106 *reinterpret_cast<int32_t*>(data) = col.Generate<int32_t>(r, row_idx);
107 break;
108 case TYPE_BIGINT:
109 *reinterpret_cast<int64_t*>(data) = col.Generate<int64_t>(r, row_idx);
110 break;
111 case TYPE_FLOAT:
112 *reinterpret_cast<float*>(data) = col.Generate<float>(r, row_idx);
113 break;
114 case TYPE_DOUBLE:
115 *reinterpret_cast<double*>(data) = col.Generate<double>(r, row_idx);
116 break;
117 case TYPE_VARCHAR:
118 case TYPE_STRING: {
119 // TODO: generate sequential strings
120 StringValue* str = reinterpret_cast<StringValue*>(data);
121 RandString(pool_, str, col.min.s, col.max.s, r, rand_double);
122 break;
123 }
124 default:
125 break;
126 }
127 data += col.bytes;
128 }
129 }
130 rows_returned_ += num_rows;
131 return reinterpret_cast<void*>(data_.get());
132}
133
134void DataProvider::Print(ostream* stream, char* data, int rows) const {
135 char* next_col = reinterpret_cast<char*>(data);

Callers 4

mainFunction · 0.80
mainFunction · 0.80
GetNextScannerBatchMethod · 0.80
mainFunction · 0.80

Calls 11

minFunction · 0.85
RandStringFunction · 0.85
Generate<bool>Method · 0.80
Generate<int8_t>Method · 0.80
Generate<int16_t>Method · 0.80
Generate<int32_t>Method · 0.80
Generate<int64_t>Method · 0.80
Generate<float>Method · 0.80
Generate<double>Method · 0.80
getMethod · 0.65
sizeMethod · 0.45

Tested by 2

mainFunction · 0.64
mainFunction · 0.64