Skip to content

Commit

Permalink
implement god awful num_rows (antoine super happy)
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Oct 2, 2024
1 parent ab06ff8 commit e738ff0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/store/re_dataframe2/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::{
OnceLock,
};

use ahash::HashSet;
use arrow2::{
array::Array as ArrowArray, chunk::Chunk as ArrowChunk, datatypes::Schema as ArrowSchema,
};
Expand Down Expand Up @@ -336,6 +337,31 @@ impl QueryHandle<'_> {
&self.init().arrow_schema
}

/// How many rows of data will be returned?
///
/// The number of rows depends and only depends on the _view contents_.
/// The _selected contents_ has no influence on this value.
//
// TODO(cmc): implement this properly, cache the result, etc.
pub fn num_rows(&self) -> u64 {
let all_unique_timestamps: HashSet<TimeInt> = self
.init()
.view_chunks
.iter()
.flat_map(|chunks| {
chunks.iter().filter_map(|(_cursor, chunk)| {
chunk
.timelines()
.get(&self.query.filtered_index)
.map(|time_column| time_column.times())
})
})
.flatten()
.collect();

all_unique_timestamps.len() as _
}

/// Returns the next row's worth of data.
///
/// The returned vector of Arrow arrays strictly follows the schema specified by [`Self::schema`].
Expand Down

0 comments on commit e738ff0

Please sign in to comment.