refactor: use AggregateVec for results

pull/24376/head
Edd Robinson 2021-03-18 17:35:33 +00:00 committed by kodiakhq[bot]
parent 3725161fc3
commit e5f7cc143a
5 changed files with 1551 additions and 455 deletions

View File

@ -330,7 +330,7 @@ impl Column {
// Check the column for all rows that satisfy the predicate.
let row_ids = match &self {
Self::String(_, data) => data.row_ids_filter(op, value.string(), dst),
Self::String(_, data) => data.row_ids_filter(op, value.str(), dst),
Self::Float(_, data) => data.row_ids_filter(op, value.scalar(), dst),
Self::Integer(_, data) => data.row_ids_filter(op, value.scalar(), dst),
Self::Unsigned(_, data) => data.row_ids_filter(op, value.scalar(), dst),

File diff suppressed because it is too large Load Diff

View File

@ -50,6 +50,7 @@ impl ResultSchema {
self.len() == 0
}
/// The total number of columns the schema represents.
pub fn len(&self) -> usize {
self.select_columns.len() + self.group_columns.len() + self.aggregate_columns.len()
}

View File

@ -10,7 +10,7 @@ use arrow_deps::arrow::record_batch::RecordBatch;
use internal_types::selection::Selection;
use snafu::{ensure, Snafu};
use crate::row_group::{self, ColumnName, GroupKey, Predicate, RowGroup};
use crate::row_group::{self, ColumnName, Predicate, RowGroup};
use crate::schema::{AggregateType, ColumnType, LogicalDataType, ResultSchema};
use crate::value::{AggregateResult, Scalar, Value};
#[derive(Debug, Snafu)]
@ -273,7 +273,7 @@ impl Table {
_group_columns: Vec<ColumnName<'a>>,
_aggregates: Vec<(ColumnName<'a>, AggregateType)>,
_window: i64,
) -> BTreeMap<GroupKey<'_>, Vec<(ColumnName<'a>, AggregateResult<'_>)>> {
) -> BTreeMap<Vec<String>, Vec<(ColumnName<'a>, AggregateResult<'_>)>> {
// identify segments where time range and predicates match could match
// using segment meta data, and then execute against those segments and
// merge results.
@ -942,7 +942,7 @@ mod test {
use crate::row_group::{BinaryExpr, ColumnType, ReadAggregateResult};
use crate::schema;
use crate::schema::LogicalDataType;
use crate::value::{OwnedValue, Scalar};
use crate::value::{AggregateVec, OwnedValue, Scalar};
#[test]
fn meta_data_update_with() {
@ -1237,7 +1237,7 @@ mod test {
#[test]
fn read_aggregate_result_display() {
let mut result_a = ReadAggregateResult {
let result_a = ReadAggregateResult {
schema: ResultSchema {
select_columns: vec![],
group_columns: vec![
@ -1256,14 +1256,12 @@ mod test {
LogicalDataType::Integer,
)],
},
group_key_cols: vec![vec![Some("east")], vec![Some("host-a")]],
aggregate_cols: vec![AggregateVec::SumI64(vec![Some(10)])],
..ReadAggregateResult::default()
};
result_a.add_row(
vec![Value::String("east"), Value::String("host-a")],
vec![AggregateResult::Sum(Scalar::I64(10))],
);
let mut result_b = ReadAggregateResult {
let result_b = ReadAggregateResult {
schema: ResultSchema {
select_columns: vec![],
group_columns: vec![
@ -1282,12 +1280,10 @@ mod test {
LogicalDataType::Integer,
)],
},
group_key_cols: vec![vec![Some("west")], vec![Some("host-b")]],
aggregate_cols: vec![AggregateVec::SumI64(vec![Some(100)])],
..Default::default()
};
result_b.add_row(
vec![Value::String("west"), Value::String("host-b")],
vec![AggregateResult::Sum(Scalar::I64(100))],
);
let results = DisplayReadAggregateResults(vec![result_a, result_b]); //Display implementation
assert_eq!(

File diff suppressed because it is too large Load Diff