-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1491 from quickwit-oss/col-trait-refact
Introducing a column trait
- Loading branch information
Showing
27 changed files
with
294 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
pub trait Column<T = u64> { | ||
/// Return the value associated to the given idx. | ||
/// | ||
/// This accessor should return as fast as possible. | ||
/// | ||
/// # Panics | ||
/// | ||
/// May panic if `idx` is greater than the column length. | ||
fn get_val(&self, idx: u64) -> T; | ||
|
||
/// Fills an output buffer with the fast field values | ||
/// associated with the `DocId` going from | ||
/// `start` to `start + output.len()`. | ||
/// | ||
/// Regardless of the type of `Item`, this method works | ||
/// - transmuting the output array | ||
/// - extracting the `Item`s as if they were `u64` | ||
/// - possibly converting the `u64` value to the right type. | ||
/// | ||
/// # Panics | ||
/// | ||
/// May panic if `start + output.len()` is greater than | ||
/// the segment's `maxdoc`. | ||
fn get_range(&self, start: u64, output: &mut [T]) { | ||
for (out, idx) in output.iter_mut().zip(start..) { | ||
*out = self.get_val(idx); | ||
} | ||
} | ||
|
||
/// Returns the minimum value for this fast field. | ||
/// | ||
/// The min value does not take in account of possible | ||
/// deleted document, and should be considered as a lower bound | ||
/// of the actual minimum value. | ||
fn min_value(&self) -> T; | ||
|
||
/// Returns the maximum value for this fast field. | ||
/// | ||
/// The max value does not take in account of possible | ||
/// deleted document, and should be considered as an upper bound | ||
/// of the actual maximum value | ||
fn max_value(&self) -> T; | ||
|
||
fn num_vals(&self) -> u64; | ||
/// Returns a iterator over the data | ||
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = T> + 'a> { | ||
Box::new((0..self.num_vals()).map(|idx| self.get_val(idx))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.