| 40 | namespace parquet { |
| 41 | |
| 42 | TEST(SizeStatistics, UpdateLevelHistogram) { |
| 43 | { |
| 44 | // max_level = 1 |
| 45 | std::vector<int64_t> histogram(2, 0); |
| 46 | UpdateLevelHistogram(std::vector<int16_t>{0, 1, 1, 1, 0}, histogram); |
| 47 | EXPECT_THAT(histogram, ::testing::ElementsAre(2, 3)); |
| 48 | UpdateLevelHistogram(std::vector<int16_t>{1, 1, 0}, histogram); |
| 49 | EXPECT_THAT(histogram, ::testing::ElementsAre(3, 5)); |
| 50 | UpdateLevelHistogram(std::vector<int16_t>{}, histogram); |
| 51 | EXPECT_THAT(histogram, ::testing::ElementsAre(3, 5)); |
| 52 | } |
| 53 | { |
| 54 | // Cross the chunk boundary used by the max_level = 1 fast path. |
| 55 | std::vector<int16_t> levels(1 << 14, 1); |
| 56 | levels.push_back(0); |
| 57 | std::vector<int64_t> histogram(2, 0); |
| 58 | UpdateLevelHistogram(levels, histogram); |
| 59 | EXPECT_THAT(histogram, ::testing::ElementsAre(1, 1 << 14)); |
| 60 | } |
| 61 | { |
| 62 | // max_level > 1 |
| 63 | std::vector<int64_t> histogram(3, 0); |
| 64 | UpdateLevelHistogram(std::vector<int16_t>{0, 1, 2, 2, 0}, histogram); |
| 65 | EXPECT_THAT(histogram, ::testing::ElementsAre(2, 1, 2)); |
| 66 | UpdateLevelHistogram(std::vector<int16_t>{1, 1, 0}, histogram); |
| 67 | EXPECT_THAT(histogram, ::testing::ElementsAre(3, 3, 2)); |
| 68 | UpdateLevelHistogram(std::vector<int16_t>{}, histogram); |
| 69 | EXPECT_THAT(histogram, ::testing::ElementsAre(3, 3, 2)); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | TEST(SizeStatistics, ThriftSerDe) { |
| 74 | const std::vector<int64_t> kDefLevels = {128, 64, 32, 16}; |
nothing calls this directly
no test coverage detected