Skip to content

Commit b383dba

Browse files
authored
Move *Selector from re_chunk_store to re_sorbet (#9851)
### Related * Part of #9837 ### What Move `{Column|ComponentColumn|TimelineColumn}Selector` to `re_sorbet` where they belong (alongside the `*Descriptor` crowd).
1 parent b091044 commit b383dba

File tree

12 files changed

+188
-178
lines changed

12 files changed

+188
-178
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -7845,6 +7845,7 @@ dependencies = [
78457845
"re_log",
78467846
"re_log_types",
78477847
"re_renderer",
7848+
"re_sorbet",
78487849
"re_tracing",
78497850
"re_types",
78507851
"re_types_core",

crates/store/re_chunk_store/src/dataframe.rs

+2-163
Original file line numberDiff line numberDiff line change
@@ -14,175 +14,14 @@ use itertools::Itertools as _;
1414
use re_chunk::{LatestAtQuery, RangeQuery, TimelineName};
1515
use re_log_types::{EntityPath, ResolvedTimeRange, TimeInt, Timeline};
1616
use re_sorbet::{
17-
ColumnDescriptor, ComponentColumnDescriptor, IndexColumnDescriptor, SorbetColumnDescriptors,
17+
ColumnDescriptor, ColumnSelector, ComponentColumnDescriptor, ComponentColumnSelector,
18+
IndexColumnDescriptor, SorbetColumnDescriptors, TimeColumnSelector,
1819
};
1920
use re_types_core::ComponentName;
2021
use tap::Tap as _;
2122

2223
use crate::{ChunkStore, ColumnMetadata};
2324

24-
// --- Selectors ---
25-
26-
/// Describes a column selection to return as part of a query.
27-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
28-
pub enum ColumnSelector {
29-
Time(TimeColumnSelector),
30-
Component(ComponentColumnSelector),
31-
//TODO(jleibs): Add support for archetype-based component selection.
32-
//ArchetypeField(ArchetypeFieldColumnSelector),
33-
}
34-
35-
impl From<ColumnDescriptor> for ColumnSelector {
36-
#[inline]
37-
fn from(desc: ColumnDescriptor) -> Self {
38-
match desc {
39-
ColumnDescriptor::Time(desc) => Self::Time(desc.into()),
40-
ColumnDescriptor::Component(desc) => Self::Component(desc.into()),
41-
}
42-
}
43-
}
44-
45-
impl From<TimeColumnSelector> for ColumnSelector {
46-
#[inline]
47-
fn from(desc: TimeColumnSelector) -> Self {
48-
Self::Time(desc)
49-
}
50-
}
51-
52-
impl From<ComponentColumnSelector> for ColumnSelector {
53-
#[inline]
54-
fn from(desc: ComponentColumnSelector) -> Self {
55-
Self::Component(desc)
56-
}
57-
}
58-
59-
/// Select a time column.
60-
//
61-
// TODO(cmc): This shouldn't be specific to time, this should be an `IndexColumnSelector` or smth.
62-
// Particularly unfortunate that this one already leaks into the public API…
63-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
64-
pub struct TimeColumnSelector {
65-
/// The name of the timeline.
66-
pub timeline: TimelineName,
67-
}
68-
69-
impl From<TimelineName> for TimeColumnSelector {
70-
#[inline]
71-
fn from(timeline: TimelineName) -> Self {
72-
Self { timeline }
73-
}
74-
}
75-
76-
impl From<Timeline> for TimeColumnSelector {
77-
#[inline]
78-
fn from(timeline: Timeline) -> Self {
79-
Self {
80-
timeline: *timeline.name(),
81-
}
82-
}
83-
}
84-
85-
impl From<&str> for TimeColumnSelector {
86-
#[inline]
87-
fn from(timeline: &str) -> Self {
88-
Self {
89-
timeline: timeline.into(),
90-
}
91-
}
92-
}
93-
94-
impl From<String> for TimeColumnSelector {
95-
#[inline]
96-
fn from(timeline: String) -> Self {
97-
Self {
98-
timeline: timeline.into(),
99-
}
100-
}
101-
}
102-
103-
impl From<IndexColumnDescriptor> for TimeColumnSelector {
104-
#[inline]
105-
fn from(desc: IndexColumnDescriptor) -> Self {
106-
Self {
107-
timeline: desc.timeline_name(),
108-
}
109-
}
110-
}
111-
112-
/// Select a component based on its `EntityPath` and `ComponentName`.
113-
///
114-
/// Note, that in the future when Rerun supports duplicate tagged components
115-
/// on the same entity, this selector may be ambiguous. In this case, the
116-
/// query result will return an Error if it cannot determine a single selected
117-
/// component.
118-
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
119-
pub struct ComponentColumnSelector {
120-
/// The path of the entity.
121-
pub entity_path: EntityPath,
122-
123-
/// Semantic name associated with this data.
124-
///
125-
/// This string will be flexibly matched against the available component names.
126-
/// Valid matches are case invariant matches of either the full name or the short name.
127-
pub component_name: String,
128-
}
129-
130-
impl From<ComponentColumnDescriptor> for ComponentColumnSelector {
131-
#[inline]
132-
fn from(desc: ComponentColumnDescriptor) -> Self {
133-
Self {
134-
entity_path: desc.entity_path.clone(),
135-
component_name: desc.component_name.short_name().to_owned(),
136-
}
137-
}
138-
}
139-
140-
impl ComponentColumnSelector {
141-
/// Select a component of a given type, based on its [`EntityPath`]
142-
#[inline]
143-
pub fn new<C: re_types_core::Component>(entity_path: EntityPath) -> Self {
144-
Self {
145-
entity_path,
146-
component_name: C::name().short_name().to_owned(),
147-
}
148-
}
149-
150-
/// Select a component based on its [`EntityPath`] and [`ComponentName`].
151-
#[inline]
152-
pub fn new_for_component_name(entity_path: EntityPath, component_name: ComponentName) -> Self {
153-
Self {
154-
entity_path,
155-
component_name: component_name.short_name().to_owned(),
156-
}
157-
}
158-
}
159-
160-
impl std::fmt::Display for ComponentColumnSelector {
161-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
162-
let Self {
163-
entity_path,
164-
component_name,
165-
} = self;
166-
167-
f.write_fmt(format_args!("{entity_path}:{component_name}"))
168-
}
169-
}
170-
171-
// TODO(jleibs): Add support for archetype-based column selection.
172-
/*
173-
/// Select a component based on its `Archetype` and field.
174-
pub struct ArchetypeFieldColumnSelector {
175-
/// The path of the entity.
176-
entity_path: EntityPath,
177-
178-
/// Name of the `Archetype` associated with this data.
179-
archetype: ArchetypeName,
180-
181-
/// The field within the `Archetype` associated with this data.
182-
field: String,
183-
}
184-
*/
185-
18625
// --- Queries v2 ---
18726

18827
/// Specifies how null values should be filled in the returned dataframe.

crates/store/re_chunk_store/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ mod writes;
2626

2727
pub use self::{
2828
dataframe::{
29-
ColumnSelector, ComponentColumnSelector, Index, IndexRange, IndexValue, QueryExpression,
30-
SparseFillStrategy, TimeColumnSelector, ViewContentsSelector,
29+
Index, IndexRange, IndexValue, QueryExpression, SparseFillStrategy, ViewContentsSelector,
3130
},
3231
events::{ChunkCompactionReport, ChunkStoreDiff, ChunkStoreDiffKind, ChunkStoreEvent},
3332
gc::{GarbageCollectionOptions, GarbageCollectionTarget},

crates/store/re_dataframe/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pub use self::query::QueryHandle;
88

99
#[doc(no_inline)]
1010
pub use self::external::re_chunk_store::{
11-
ChunkStoreConfig, ChunkStoreHandle, ColumnSelector, ComponentColumnSelector, Index, IndexRange,
12-
IndexValue, QueryExpression, SparseFillStrategy, TimeColumnSelector, ViewContentsSelector,
11+
ChunkStoreConfig, ChunkStoreHandle, Index, IndexRange, IndexValue, QueryExpression,
12+
SparseFillStrategy, ViewContentsSelector,
1313
};
1414
#[doc(no_inline)]
1515
pub use self::external::re_log_types::{

crates/store/re_dataframe/src/query.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ use re_chunk::{
2626
TimelineName, UnitChunkShared,
2727
};
2828
use re_chunk_store::{
29-
ChunkStore, ColumnDescriptor, ColumnSelector, ComponentColumnDescriptor,
30-
ComponentColumnSelector, Index, IndexColumnDescriptor, IndexValue, QueryExpression,
31-
SparseFillStrategy, TimeColumnSelector,
29+
ChunkStore, ColumnDescriptor, ComponentColumnDescriptor, Index, IndexColumnDescriptor,
30+
IndexValue, QueryExpression, SparseFillStrategy,
3231
};
3332
use re_log_types::ResolvedTimeRange;
3433
use re_query::{QueryCache, StorageEngineLike};
35-
use re_sorbet::SorbetColumnDescriptors;
34+
use re_sorbet::{
35+
ColumnSelector, ComponentColumnSelector, SorbetColumnDescriptors, TimeColumnSelector,
36+
};
3637
use re_types_core::{components::ClearIsRecursive, ComponentDescriptor};
3738

3839
// ---

crates/store/re_sorbet/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ mod ipc;
2727
mod metadata;
2828
mod migration;
2929
mod row_id_column_descriptor;
30+
mod selectors;
3031
mod sorbet_batch;
3132
mod sorbet_columns;
3233
mod sorbet_schema;
@@ -47,6 +48,7 @@ pub use self::{
4748
},
4849
migration::migrate_record_batch,
4950
row_id_column_descriptor::{RowIdColumnDescriptor, WrongDatatypeError},
51+
selectors::{ColumnSelector, ComponentColumnSelector, TimeColumnSelector},
5052
sorbet_batch::SorbetBatch,
5153
sorbet_columns::SorbetColumnDescriptors,
5254
sorbet_schema::SorbetSchema,

0 commit comments

Comments
 (0)