fix: Correct and clarify lifetimes around the segment store

pull/24376/head
Carol (Nichols || Goulding) 2020-12-09 13:49:35 -05:00
parent 0032d03656
commit f98f45e49f
2 changed files with 21 additions and 21 deletions

View File

@ -168,20 +168,20 @@ impl Segment {
/// predicates. /// predicates.
/// ///
/// Right now, predicates are conjunctive (AND). /// Right now, predicates are conjunctive (AND).
pub fn read_filter<'a>( pub fn read_filter<'input>(
&'a self, &self,
columns: &[ColumnName<'a>], columns: &'input [ColumnName<'input>],
predicates: &[Predicate<'_>], predicates: &[Predicate<'_>],
) -> ReadFilterResult<'_> { ) -> ReadFilterResult<'input, '_> {
let row_ids = self.row_ids_from_predicates(predicates); let row_ids = self.row_ids_from_predicates(predicates);
ReadFilterResult(self.materialise_rows(columns, row_ids)) ReadFilterResult(self.materialise_rows(columns, row_ids))
} }
fn materialise_rows<'a>( fn materialise_rows<'input>(
&'a self, &self,
columns: &[ColumnName<'a>], columns: &'input [ColumnName<'input>],
row_ids: RowIDsOption, row_ids: RowIDsOption,
) -> Vec<(ColumnName<'_>, Values<'_>)> { ) -> Vec<(ColumnName<'input>, Values<'_>)> {
let mut results = vec![]; let mut results = vec![];
match row_ids { match row_ids {
RowIDsOption::None(_) => results, // nothing to materialise RowIDsOption::None(_) => results, // nothing to materialise
@ -615,15 +615,15 @@ impl MetaData {
/// Encapsulates results from segments with a structure that makes them easier /// Encapsulates results from segments with a structure that makes them easier
/// to work with and display. /// to work with and display.
pub struct ReadFilterResult<'a>(pub Vec<(ColumnName<'a>, Values<'a>)>); pub struct ReadFilterResult<'input, 'segment>(pub Vec<(ColumnName<'input>, Values<'segment>)>);
impl<'a> ReadFilterResult<'a> { impl<'input, 'segment> ReadFilterResult<'input, 'segment> {
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.0.is_empty() self.0.is_empty()
} }
} }
impl<'a> std::fmt::Debug for &ReadFilterResult<'a> { impl<'input, 'segment> std::fmt::Debug for &ReadFilterResult<'input, 'segment> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// header line. // header line.
for (i, (k, _)) in self.0.iter().enumerate() { for (i, (k, _)) in self.0.iter().enumerate() {
@ -640,7 +640,7 @@ impl<'a> std::fmt::Debug for &ReadFilterResult<'a> {
} }
} }
impl<'a> std::fmt::Display for &ReadFilterResult<'a> { impl<'input, 'segment> std::fmt::Display for &ReadFilterResult<'input, 'segment> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.is_empty() { if self.is_empty() {
return Ok(()); return Ok(());

View File

@ -132,11 +132,11 @@ impl Table {
/// but can be ranged by time, which should be represented as nanoseconds /// but can be ranged by time, which should be represented as nanoseconds
/// since the epoch. Results are included if they satisfy the predicate and /// since the epoch. Results are included if they satisfy the predicate and
/// fall with the [min, max) time range domain. /// fall with the [min, max) time range domain.
pub fn select<'a>( pub fn select<'input>(
&'a self, &self,
columns: &[ColumnName<'a>], columns: &'input [ColumnName<'input>],
predicates: &[Predicate<'_>], predicates: &[Predicate<'_>],
) -> ReadFilterResults<'a> { ) -> ReadFilterResults<'input, '_> {
// identify segments where time range and predicates match could match // identify segments where time range and predicates match could match
// using segment meta data, and then execute against those segments and // using segment meta data, and then execute against those segments and
// merge results. // merge results.
@ -510,18 +510,18 @@ impl MetaData {
/// Encapsulates results from tables with a structure that makes them easier /// Encapsulates results from tables with a structure that makes them easier
/// to work with and display. /// to work with and display.
pub struct ReadFilterResults<'a> { pub struct ReadFilterResults<'input, 'segment> {
pub names: Vec<ColumnName<'a>>, pub names: Vec<ColumnName<'input>>,
pub values: Vec<ReadFilterResult<'a>>, pub values: Vec<ReadFilterResult<'input, 'segment>>,
} }
impl<'a> ReadFilterResults<'a> { impl<'input, 'segment> ReadFilterResults<'input, 'segment> {
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.values.is_empty() self.values.is_empty()
} }
} }
impl<'a> Display for ReadFilterResults<'a> { impl<'input, 'segment> Display for ReadFilterResults<'input, 'segment> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// header line. // header line.
for (i, k) in self.names.iter().enumerate() { for (i, k) in self.names.iter().enumerate() {