Skip to content

Commit

Permalink
Partially revert TimeColumnDescriptor refactor (#8685)
Browse files Browse the repository at this point in the history
* Reverts #8658
* Why? Because it conflicted with
#8651
  • Loading branch information
emilk authored Jan 14, 2025
1 parent 3906792 commit d4f99a1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 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 @@ -152,8 +151,9 @@ impl TimeColumnDescriptor {

#[inline]
pub fn to_arrow_field(&self) -> Arrow2Field {
let Self { timeline, datatype } = self;
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)
Arrow2Field::new(timeline.name().to_string(), datatype.clone(), nullable)
.with_metadata(self.metadata())
}
}
Expand Down Expand Up @@ -735,7 +735,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 +809,7 @@ impl ChunkStore {

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

Expand Down

0 comments on commit d4f99a1

Please sign in to comment.