Skip to content

Commit

Permalink
Fix empty buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cswinter committed Aug 19, 2024
1 parent 4b2b70e commit 389dd66
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ingest/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ impl Buffer {
}

pub fn filter(&self, columns: &[String]) -> Buffer {
let mut columns: HashMap<_, _> = columns
.iter()
.filter_map(|name| self.buffer.get(name).map(|col| (name.clone(), col.clone())))
.collect();
// Need at least one column to have a length
if columns.is_empty() {
let (key, val) = self.buffer.iter().next().unwrap();
columns.insert(key.clone(), val.clone());
}
Buffer {
buffer: columns
.iter()
.filter_map(|name| self.buffer.get(name).map(|col| (name.clone(), col.clone())))
.collect(),
buffer: columns,
length: self.length,
}
}
Expand Down

0 comments on commit 389dd66

Please sign in to comment.