Skip to content

Commit

Permalink
fix empty filter
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Jul 21, 2023
1 parent 7c014e0 commit fbc9f6c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 12 additions & 8 deletions columnar/src/columnar/merge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,17 @@ fn group_columns_for_merge_iter<'a>(
group,
)
});
let iter = group_column_iter.filter(|res| {
let iter = group_column_iter.filter(move |res| {
// Filter out empty columns.
res.as_ref()
.map(|(_, _, group)| !group.columns.iter().all(|column| column.is_none()))
.map(|(_, _, group)| {
let column_is_required = force_type.is_some();
if column_is_required {
return true;
}
let all_columns_none = group.columns.iter().all(|column| column.is_none());
!all_columns_none
})
.unwrap_or(true)
});
Box::new(iter)
Expand All @@ -470,16 +477,13 @@ fn generate_require_column<'a>(
required_columns_map: &HashMap<String, ColumnType>,
) -> MergeIter<'a> {
let mut grouped_columns = GroupedColumns::new(columnar_readers.len());
let force_type: ColumnType = required_columns_map
.get(&*column_name)
.map(|el| (*el).into())
.unwrap();
let force_type: ColumnType = required_columns_map.get(&*column_name).cloned().unwrap();
grouped_columns.require_type(force_type).unwrap(); // Can't panic
return Box::new(std::iter::once(Ok((
Box::new(std::iter::once(Ok((
column_name,
force_type,
grouped_columns,
)))) as MergeIter<'a>;
)))) as MergeIter<'a>
}

fn group_columns_iter<'a>(
Expand Down
7 changes: 7 additions & 0 deletions src/indexer/index_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,13 @@ mod tests {
test_operation_strategy(&ops[..], false, true).unwrap();
}

#[test]
fn test_merge_regression_1() {
use IndexingOp::*;
let ops = &[AddDoc { id: 15 }, Commit, AddDoc { id: 9 }, Commit, Merge];
test_operation_strategy(&ops[..], false, true).unwrap();
}

#[test]
fn test_range_query_bug_1() {
use IndexingOp::*;
Expand Down

0 comments on commit fbc9f6c

Please sign in to comment.