Skip to content

Commit ad037c3

Browse files
Use help from columnar 0.1.1 (#606)
1 parent f201abd commit ad037c3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

timely/examples/columnar.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ mod container {
251251
fn length_in_bytes(&self) -> usize {
252252
match self {
253253
// We'll need one u64 for the length, then the length rounded up to a multiple of 8.
254-
Column::Typed(t) => t.as_bytes().map(|(_, x)| 8 * (1 + (x.len()/8) + if x.len() % 8 == 0 { 0 } else { 1 })).sum(),
254+
Column::Typed(t) => 8 * t.length_in_words(),
255255
Column::Bytes(b) => b.len(),
256256
Column::Align(a) => 8 * a.len(),
257257
}
@@ -304,10 +304,10 @@ mod builder {
304304
fn push_into(&mut self, item: T) {
305305
self.current.push(item);
306306
// If there is less than 10% slop with 2MB backing allocations, mint a container.
307-
let len: usize = self.current.as_bytes().map(|(_, x)| 8 * (1 + (x.len()/8) + if x.len() % 8 == 0 { 0 } else { 1 })).sum();
308-
let up: usize = (len + ((1 << 20) - 1)) & !((1 << 20) - 1);
309-
if up - len < up / 10 {
310-
let mut alloc = Vec::with_capacity(up/8);
307+
let words = self.current.length_in_words();
308+
let round = (words + ((1 << 18) - 1)) & !((1 << 18) - 1);
309+
if round - words < round / 10 {
310+
let mut alloc = Vec::with_capacity(round);
311311
columnar::bytes::serialization::encode(&mut alloc, self.current.as_bytes());
312312
self.pending.push_back(Column::Align(alloc.into_boxed_slice()));
313313
self.current.clear();

0 commit comments

Comments
 (0)