refactor: rename method

pull/24376/head
Edd Robinson 2021-01-15 16:45:57 +00:00
parent 42c0ccf274
commit 6dbb00715e
2 changed files with 16 additions and 20 deletions

View File

@ -1,7 +1,7 @@
use std::collections::{btree_map::Entry, BTreeMap, BTreeSet}; use std::collections::{btree_map::Entry, BTreeMap, BTreeSet};
use crate::row_group::{ColumnName, Predicate}; use crate::row_group::{ColumnName, Predicate};
use crate::table::{ColumnSelection, ReadFilterResults, ReadGroupResults, Table}; use crate::table::{ColumnSelection, ReadAggregateResults, ReadFilterResults, Table};
use crate::{column::AggregateType, row_group::RowGroup}; use crate::{column::AggregateType, row_group::RowGroup};
type TableName = String; type TableName = String;
@ -119,7 +119,7 @@ impl Chunk {
predicate: Predicate, predicate: Predicate,
group_columns: Vec<ColumnName<'_>>, group_columns: Vec<ColumnName<'_>>,
aggregates: Vec<(ColumnName<'_>, AggregateType)>, aggregates: Vec<(ColumnName<'_>, AggregateType)>,
) -> ReadGroupResults<'_, '_> { ) -> ReadAggregateResults<'_, '_> {
// Lookup table by name and dispatch execution. // Lookup table by name and dispatch execution.
todo!() todo!()
} }

View File

@ -164,25 +164,21 @@ impl Table {
} }
} }
/// Returns aggregates segmented by grouping keys. /// Returns an iterable collection of data in group columns and aggregate
/// columns, optionally filtered by the provided predicate. Results are
/// merged across all row groups within the table.
/// ///
/// The set of data to be aggregated may be filtered by (currently only) /// Collectively, row-wise values in the group columns comprise a "group
/// equality predicates, but can be ranged by time, which should be /// key", and each value in the same row for the aggregate columns contains
/// represented as nanoseconds since the epoch. Results are included if they /// aggregate values for those group keys.
/// satisfy the predicate and fall with the [min, max) time range domain.
/// ///
/// Group keys are determined according to the provided group column names. /// Note: `read_aggregate` currently only supports "tag" columns.
/// Currently only grouping by string (tag key) columns is supported. pub fn read_aggregate<'input>(
///
/// Required aggregates are specified via a tuple comprising a column name
/// and the type of aggregation required. Multiple aggregations can be
/// applied to the same column.
pub fn aggregate<'input>(
&self, &self,
predicate: Predicate, predicate: Predicate,
group_columns: &'input [ColumnName<'input>], group_columns: &'input [ColumnName<'input>],
aggregates: &'input [(ColumnName<'input>, AggregateType)], aggregates: &'input [(ColumnName<'input>, AggregateType)],
) -> ReadGroupResults<'input, '_> { ) -> ReadAggregateResults<'input, '_> {
if !self.has_all_columns(&group_columns) { if !self.has_all_columns(&group_columns) {
todo!() //TODO(edd): return an error here "group key column x not todo!() //TODO(edd): return an error here "group key column x not
//found" //found"
@ -203,10 +199,10 @@ impl Table {
// found" // found"
} }
// identify segments where time range and predicates match could match // identify row groups where time range and predicates match could match
// using segment meta data, and then execute against those segments and // using row group meta data, and then execute against those row groups and
// merge results. // merge results.
let mut results = ReadGroupResults::default(); let mut results = ReadAggregateResults::default();
let row_groups = self.filter_row_groups(&predicate); let row_groups = self.filter_row_groups(&predicate);
if row_groups.is_empty() { if row_groups.is_empty() {
results.groupby_columns = group_columns; results.groupby_columns = group_columns;
@ -636,7 +632,7 @@ impl<'a> Display for DisplayReadFilterResults<'a> {
} }
#[derive(Default)] #[derive(Default)]
pub struct ReadGroupResults<'input, 'segment> { pub struct ReadAggregateResults<'input, 'segment> {
// column-wise collection of columns being grouped by // column-wise collection of columns being grouped by
groupby_columns: &'input [ColumnName<'input>], groupby_columns: &'input [ColumnName<'input>],
@ -647,7 +643,7 @@ pub struct ReadGroupResults<'input, 'segment> {
values: Vec<ReadGroupResult<'segment>>, values: Vec<ReadGroupResult<'segment>>,
} }
impl std::fmt::Display for ReadGroupResults<'_, '_> { impl std::fmt::Display for ReadAggregateResults<'_, '_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// header line - display group columns first // header line - display group columns first
for (i, name) in self.groupby_columns.iter().enumerate() { for (i, name) in self.groupby_columns.iter().enumerate() {