Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially revert TimeColumnDescriptor refactor #8685

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions crates/store/re_chunk_store/src/dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::collections::{BTreeMap, BTreeSet};
use std::ops::Deref;
use std::ops::DerefMut;

use arrow::datatypes::DataType as ArrowDatatype;
use arrow2::{
array::ListArray as ArrowListArray,
datatypes::{DataType as Arrow2Datatype, Field as Arrow2Field},
Expand Down Expand Up @@ -46,7 +45,7 @@ impl ColumnDescriptor {
#[inline]
pub fn datatype(&self) -> Arrow2Datatype {
match self {
Self::Time(descr) => descr.datatype().into(),
Self::Time(descr) => descr.datatype.clone(),
Self::Component(descr) => descr.returned_datatype(),
}
}
Expand Down Expand Up @@ -80,9 +79,10 @@ impl ColumnDescriptor {
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct TimeColumnDescriptor {
/// The timeline this column is associated with.
timeline: Timeline,
pub timeline: Timeline,

is_null: bool,
/// The Arrow datatype of the column.
pub datatype: Arrow2Datatype,
}

impl PartialOrd for TimeColumnDescriptor {
Expand All @@ -97,49 +97,48 @@ impl Ord for TimeColumnDescriptor {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
let Self {
timeline,
is_null: _,
datatype: _,
} = self;
timeline.cmp(&other.timeline)
}
}

impl TimeColumnDescriptor {
/// Used when returning a null column, i.e. when a lookup failed.
#[inline]
pub fn new_null(name: TimelineName) -> Self {
Self {
// TODO(cmc): I picked a sequence here because I have to pick something.
// It doesn't matter, only the name will remain in the Arrow schema anyhow.
timeline: Timeline::new_sequence(name),
is_null: true,
datatype: Arrow2Datatype::Null,
}
}

#[inline]
pub fn timeline(&self) -> Timeline {
self.timeline
}

#[inline]
pub fn name(&self) -> &TimelineName {
self.timeline.name()
}

#[inline]
pub fn typ(&self) -> re_log_types::TimeType {
self.timeline.typ()
}

#[inline]
pub fn datatype(&self) -> ArrowDatatype {
let Self { timeline, is_null } = self;
if *is_null {
ArrowDatatype::Null
} else {
timeline.typ().datatype()
}
pub fn datatype(&self) -> &Arrow2Datatype {
&self.datatype
}

fn metadata(&self) -> arrow2::datatypes::Metadata {
let Self {
timeline,
is_null: _,
datatype: _,
} = self;

std::iter::once(Some((
Expand All @@ -151,10 +150,15 @@ impl TimeColumnDescriptor {
}

#[inline]
// Time column must be nullable since static data doesn't have a time.
pub fn to_arrow_field(&self) -> Arrow2Field {
let nullable = true; // Time column must be nullable since static data doesn't have a time.
Arrow2Field::new(self.name().to_string(), self.datatype().into(), nullable)
.with_metadata(self.metadata())
let Self { timeline, datatype } = self;
Arrow2Field::new(
timeline.name().to_string(),
datatype.clone(),
true, /* nullable */
)
.with_metadata(self.metadata())
}
}

Expand Down Expand Up @@ -735,7 +739,7 @@ impl ChunkStore {
let timelines = self.all_timelines_sorted().into_iter().map(|timeline| {
ColumnDescriptor::Time(TimeColumnDescriptor {
timeline,
is_null: false,
datatype: timeline.datatype().into(),
})
});

Expand Down Expand Up @@ -809,7 +813,7 @@ impl ChunkStore {

TimeColumnDescriptor {
timeline,
is_null: false,
datatype: timeline.datatype().into(),
}
}

Expand Down
4 changes: 3 additions & 1 deletion crates/store/re_dataframe/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@ impl<E: StorageEngineLike> QueryHandle<E> {
ColumnDescriptor::Time(view_descr) => Some((idx, view_descr)),
ColumnDescriptor::Component(_) => None,
})
.find(|(_idx, view_descr)| *view_descr.name() == *selected_timeline)
.find(|(_idx, view_descr)| {
*view_descr.timeline.name() == *selected_timeline
})
.map_or_else(
|| {
(
Expand Down
Loading