Skip to content

Commit ed36db3

Browse files
committed
refactor: preallocate zero offsets in binary compression
1 parent 17ec111 commit ed36db3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/common/native/src/compression/binary/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ pub fn compress_binary(
6060
offsets.clone()
6161
} else {
6262
let first = offsets.first().unwrap();
63-
let mut zero_offsets = Vec::with_capacity(offsets.len());
64-
for offset in offsets.iter() {
65-
zero_offsets.push(*offset - *first);
63+
let mut zero_offsets = vec![0_u64; offsets.len()];
64+
for (idx, offset) in offsets.iter().enumerate() {
65+
zero_offsets[idx] = *offset - *first;
6666
}
6767
zero_offsets.into()
6868
};

src/query/service/src/spillers/block_reader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
use std::collections::VecDeque;
16+
use std::mem::size_of;
1617

1718
use byteorder::BigEndian;
1819
use byteorder::ReadBytesExt;

0 commit comments

Comments
 (0)