@@ -14,175 +14,14 @@ use itertools::Itertools as _;
14
14
use re_chunk:: { LatestAtQuery , RangeQuery , TimelineName } ;
15
15
use re_log_types:: { EntityPath , ResolvedTimeRange , TimeInt , Timeline } ;
16
16
use re_sorbet:: {
17
- ColumnDescriptor , ComponentColumnDescriptor , IndexColumnDescriptor , SorbetColumnDescriptors ,
17
+ ColumnDescriptor , ColumnSelector , ComponentColumnDescriptor , ComponentColumnSelector ,
18
+ IndexColumnDescriptor , SorbetColumnDescriptors , TimeColumnSelector ,
18
19
} ;
19
20
use re_types_core:: ComponentName ;
20
21
use tap:: Tap as _;
21
22
22
23
use crate :: { ChunkStore , ColumnMetadata } ;
23
24
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
-
186
25
// --- Queries v2 ---
187
26
188
27
/// Specifies how null values should be filled in the returned dataframe.
0 commit comments