mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
Reserve exact size
This commit is contained in:
parent
f9113db7a4
commit
f56b9c353c
@ -63,7 +63,7 @@ MarksInCompressedFile::MarksInCompressedFile(const PlainArray & marks)
|
||||
|
||||
// Overallocate by +1 element to let the bit packing/unpacking do less bounds checking.
|
||||
size_t packed_length = (packed_bits + 63) / 64 + 1;
|
||||
packed.reserve(packed_length);
|
||||
packed.reserve_exact(packed_length);
|
||||
packed.resize_fill(packed_length);
|
||||
|
||||
// Second pass: write out the packed marks.
|
||||
|
@ -35,18 +35,29 @@ TEST(Marks, Compression)
|
||||
EXPECT_LE((marks.approximateMemoryUsage() - sizeof(MarksInCompressedFile)) * 8, plain.size() * max_bits_per_mark);
|
||||
};
|
||||
|
||||
// Typical.
|
||||
test(gen(10000, 1'000'000, 0), 30);
|
||||
{
|
||||
SCOPED_TRACE("Typical");
|
||||
test(gen(10000, 1'000'000, 0), 30);
|
||||
}
|
||||
|
||||
// Completely random 64-bit values.
|
||||
test(gen(10000, UINT64_MAX - 1, UINT64_MAX - 1), 130);
|
||||
|
||||
// All zeros.
|
||||
test(gen(10000, 0, 0), 2);
|
||||
{
|
||||
SCOPED_TRACE("Completely random 64-bit values");
|
||||
test(gen(10000, UINT64_MAX - 1, UINT64_MAX - 1), 130);
|
||||
}
|
||||
|
||||
// Short.
|
||||
test(gen(10, 1000, 1000), 65);
|
||||
{
|
||||
SCOPED_TRACE("All zeros");
|
||||
test(gen(10000, 0, 0), 2);
|
||||
}
|
||||
|
||||
// Empty.
|
||||
test(gen(0, 0, 0), 0);
|
||||
{
|
||||
SCOPED_TRACE("Short");
|
||||
test(gen(10, 1000, 1000), 65);
|
||||
}
|
||||
|
||||
{
|
||||
SCOPED_TRACE("Empty");
|
||||
test(gen(0, 0, 0), 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user