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

Method ValidateRleSkip

be/src/util/rle-test.cc:164–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162 }
163
164 int ValidateRleSkip(
165 const vector<int>& values, int bit_width, int skip_at, int skip_count) {
166 stringstream ss;
167 ss << "bit_width=" << bit_width
168 << " skip_at=" << skip_at
169 << " skip_count=" << skip_count
170 << " values.size()=" << values.size();
171 const string& description = ss.str();
172 const int len = 64 * 1024;
173 uint8_t buffer[len];
174
175 RleEncoder encoder(buffer, len, bit_width);
176 int encoded_len = 0;
177
178 for (int i = 0; i < values.size(); ++i) {
179 bool result = encoder.Put(values[i]);
180 EXPECT_TRUE(result);
181 }
182 encoded_len = encoder.Flush();
183
184 vector<int> expected_values(values.begin(), values.begin() + skip_at);
185 for (int i = skip_at + skip_count; i < values.size(); ++i) {
186 expected_values.push_back(values[i]);
187 }
188
189 // Verify read.
190 RleBatchDecoder<uint64_t> per_value_decoder(buffer, len, bit_width);
191 RleBatchDecoder<uint64_t> per_run_decoder(buffer, len, bit_width);
192 RleBatchDecoder<uint64_t> batch_decoder(buffer, len, bit_width);
193 // Ensure it returns the same results after Reset().
194 for (int trial = 0; trial < 2; ++trial) {
195 for (int i = 0; i < skip_at; ++i) {
196 uint64_t val;
197 EXPECT_TRUE(per_value_decoder.GetSingleValue(&val)) << description;
198 EXPECT_EQ(expected_values[i], val) << description << " i=" << i << " trial="
199 << trial;
200 }
201 per_value_decoder.SkipValues(skip_count);
202 for (int i = skip_at; i < expected_values.size(); ++i) {
203 uint64_t val;
204 EXPECT_TRUE(per_value_decoder.GetSingleValue(&val)) << description;
205 EXPECT_EQ(expected_values[i], val) << description << " i=" << i << " trial="
206 << trial;
207 }
208 // Unpack everything at once from the other decoders.
209 vector<uint64_t> decoded_values1(expected_values.size());
210 vector<uint64_t> decoded_values2(expected_values.size());
211 EXPECT_TRUE(
212 GetRleValuesSkip(&per_run_decoder, values.size(),
213 decoded_values1.data(), skip_at, skip_count)) << description;
214 EXPECT_TRUE(
215 GetRleValuesBatchedSkip(&batch_decoder, values.size(),
216 decoded_values2.data(), skip_at, skip_count)) << description;
217 for (int i = 0; i < expected_values.size(); ++i) {
218 EXPECT_EQ(expected_values[i], decoded_values1[i]) << description << " i=" << i;
219 EXPECT_EQ(expected_values[i], decoded_values2[i]) << description << " i=" << i;
220 }
221 per_value_decoder.Reset(buffer, len, bit_width);

Callers

nothing calls this directly

Calls 10

push_backMethod · 0.80
GetSingleValueMethod · 0.80
sizeMethod · 0.45
strMethod · 0.45
PutMethod · 0.45
FlushMethod · 0.45
beginMethod · 0.45
SkipValuesMethod · 0.45
dataMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected