Skip to content

Commit 78c4949

Browse files
committed
Further concat optimizations
1 parent f848a4b commit 78c4949

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

  • datafusion/physical-expr/src/expressions/binary

datafusion/physical-expr/src/expressions/binary/kernels.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,28 +178,26 @@ pub fn concat_elements_utf8view(
178178
right.len()
179179
)));
180180
}
181-
let capacity = left.len();
182-
let mut result = StringViewBuilder::with_capacity(capacity);
181+
let mut result = StringViewBuilder::with_capacity(left.len());
183182

184-
// Avoid reallocations by writing to a reused buffer (note we
185-
// could be even more efficient r by creating the view directly
186-
// here and avoid the buffer but that would be more complex)
183+
// Avoid reallocations by writing to a reused buffer (note we could be even
184+
// more efficient by creating the view directly here and avoid the buffer
185+
// but that would be more complex)
187186
let mut buffer = String::new();
188187

189-
// Pre-compute combined null bitmap instead of checking each
190-
// array's nulls per row via Option-returning iterators
188+
// Pre-compute combined null bitmap, so the per-row NULL check is more
189+
// efficient
191190
let nulls = NullBuffer::union(left.nulls(), right.nulls());
192191

193192
for i in 0..left.len() {
194193
if nulls.as_ref().is_some_and(|n| n.is_null(i)) {
195194
result.append_null();
196195
} else {
197-
use std::fmt::Write;
198-
buffer.clear();
199196
let l = left.value(i);
200197
let r = right.value(i);
201-
write!(&mut buffer, "{l}{r}")
202-
.expect("writing into string buffer failed");
198+
buffer.clear();
199+
buffer.push_str(l);
200+
buffer.push_str(r);
203201
result.try_append_value(&buffer)?;
204202
}
205203
}

0 commit comments

Comments
 (0)