Skip to content

Commit 11dee21

Browse files
authored
Introduce re_types_core (#3878)
This PR introduces a new crate: `re_types_core`. `re_types_core` only contains the fundamental traits and types that make up Rerun's data model. It is split off from the existing `re_types`. This makes it possible to work with our data model abstractions without having to depend on the `re_types` behemoth. This is more than a DX improvement: since so many things depend directly or indirectly on `re_types`, it is very easy to end-up with unsolvable dependency cycles. This helps with that in some cases (though certainly not all). In particular, `re_tuid` (and by extension `re_format`) are now completely free of `re_types`. For convenience, `re_types` reexports all of `re_types_core`, so the public API looks unchanged. In a handful of instances (`re_arrow_store`, `re_data_store`, `re_log_types`, `re_query`), I've went the extra mile and started porting these crates towards raw `re_types_core` rather than relying on the reexports. The reason is that, upon closer inspection, these crates are very close to being able to live free of `re_types`. In the future, the custom crate and custom module attributes coming with #3741 might allow us to make these independent. Similarly, the codegen now uses `re_types_core` directly, as that makes the life of the upcoming "serde-codegen" work much easier.
1 parent f292a5c commit 11dee21

File tree

210 files changed

+3396
-2911
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+3396
-2911
lines changed

Cargo.lock

Lines changed: 23 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ re_tensor_ops = { path = "crates/re_tensor_ops", version = "=0.10.0-alpha.7", de
5858
re_time_panel = { path = "crates/re_time_panel", version = "=0.10.0-alpha.7", default-features = false }
5959
re_tracing = { path = "crates/re_tracing", version = "=0.10.0-alpha.7", default-features = false }
6060
re_tuid = { path = "crates/re_tuid", version = "=0.10.0-alpha.7", default-features = false }
61+
re_types_core = { path = "crates/re_types_core", version = "=0.10.0-alpha.7", default-features = false }
6162
re_types = { path = "crates/re_types", version = "=0.10.0-alpha.7", default-features = false }
6263
re_types_builder = { path = "crates/re_types_builder", version = "=0.10.0-alpha.7", default-features = false }
6364
re_ui = { path = "crates/re_ui", version = "=0.10.0-alpha.7", default-features = false }
@@ -158,9 +159,12 @@ puffin_http = "0.13"
158159
rand = { version = "0.8", default-features = false }
159160
rayon = "1.7"
160161
rfd = { version = "0.12", default_features = false, features = ["xdg-portal"] }
162+
rmp-serde = "1"
161163
ron = "0.8.0"
162164
serde = "1"
165+
serde_bytes = "0.11"
163166
serde_json = { version = "1", default-features = false, features = ["std"] }
167+
serde_test = "1"
164168
serde_yaml = { version = "0.9.21", default-features = false }
165169
sha2 = "0.10"
166170
similar-asserts = "1.4.2"

crates/re_arrow_store/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ re_format.workspace = true
4040
re_log_types.workspace = true
4141
re_log.workspace = true
4242
re_tracing.workspace = true
43+
# NOTE: We're on our way to make this crate re_types-free, which is why we import both.
44+
re_types_core.workspace = true
4345
re_types.workspace = true
4446

4547
# External dependencies:

crates/re_arrow_store/benches/arrow2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use arrow2::array::{Array, PrimitiveArray, StructArray, UnionArray};
99
use criterion::Criterion;
1010
use itertools::Itertools;
1111

12-
use re_log_types::{DataCell, SizeBytes as _};
12+
use re_log_types::DataCell;
1313
use re_types::datagen::{build_some_instances, build_some_positions2d};
1414
use re_types::{
1515
components::{InstanceKey, Position2D},
1616
testing::{build_some_large_structs, LargeStruct},
17-
Component,
1817
};
18+
use re_types_core::{Component, SizeBytes as _};
1919

2020
// ---
2121

crates/re_arrow_store/benches/data_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use re_types::datagen::build_some_instances;
1515
use re_types::{
1616
components::InstanceKey,
1717
testing::{build_some_large_structs, LargeStruct},
18-
ComponentName, Loggable as _,
1918
};
19+
use re_types_core::{ComponentName, Loggable as _};
2020

2121
criterion_group!(benches, insert, latest_at, latest_at_missing, range, gc);
2222
criterion_main!(benches);

crates/re_arrow_store/examples/dump_dataframe.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
use re_arrow_store::{test_row, DataStore};
88
use re_log_types::{build_frame_nr, build_log_time, EntityPath, Time};
99
use re_types::datagen::{build_some_instances, build_some_instances_from, build_some_positions2d};
10-
use re_types::{components::InstanceKey, testing::build_some_large_structs, Loggable};
10+
use re_types::{components::InstanceKey, testing::build_some_large_structs};
11+
use re_types_core::Loggable as _;
1112

1213
// ---
1314

crates/re_arrow_store/examples/latest_component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use re_types::datagen::build_some_positions2d;
1111
use re_types::{
1212
components::{InstanceKey, Position2D},
1313
testing::{build_some_large_structs, LargeStruct},
14-
Loggable,
1514
};
15+
use re_types_core::Loggable as _;
1616

1717
fn main() {
1818
let mut store = DataStore::new(InstanceKey::name(), Default::default());

crates/re_arrow_store/examples/latest_components.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use re_types::datagen::build_some_positions2d;
1313
use re_types::{
1414
components::{InstanceKey, Position2D},
1515
testing::{build_some_large_structs, LargeStruct},
16-
Loggable,
1716
};
17+
use re_types_core::Loggable as _;
1818

1919
fn main() {
2020
let mut store = DataStore::new(InstanceKey::name(), Default::default());

crates/re_arrow_store/examples/range_components.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use re_types::datagen::build_some_positions2d;
1111
use re_types::{
1212
components::{InstanceKey, Position2D},
1313
testing::{build_some_large_structs, LargeStruct},
14-
Loggable as _,
1514
};
15+
use re_types_core::Loggable as _;
1616

1717
fn main() {
1818
let mut store = DataStore::new(InstanceKey::name(), Default::default());

crates/re_arrow_store/src/polars_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use itertools::Itertools;
22
use polars_core::{prelude::*, series::Series};
33
use polars_ops::prelude::*;
44
use re_log_types::{DataCell, EntityPath, RowId, TimeInt};
5-
use re_types::ComponentName;
5+
use re_types_core::ComponentName;
66

77
use crate::{ArrayExt, DataStore, LatestAtQuery, RangeQuery};
88

crates/re_arrow_store/src/store.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use ahash::HashMap;
55
use arrow2::datatypes::DataType;
66
use nohash_hasher::IntMap;
77
use parking_lot::RwLock;
8-
use re_types::{ComponentName, ComponentNameSet};
8+
use re_types_core::{ComponentName, ComponentNameSet, SizeBytes};
99
use smallvec::SmallVec;
1010

1111
use re_log_types::{
1212
DataCell, DataCellColumn, EntityPath, EntityPathHash, ErasedTimeVec, NumInstancesVec, RowId,
13-
RowIdVec, SizeBytes, TimeInt, TimePoint, TimeRange, Timeline,
13+
RowIdVec, TimeInt, TimePoint, TimeRange, Timeline,
1414
};
1515

1616
// --- Data store ---
@@ -285,7 +285,7 @@ impl DataStore {
285285
&self.config
286286
}
287287

288-
/// Lookup the arrow [`DataType`] of a [`re_types::Component`] in the internal
288+
/// Lookup the arrow [`DataType`] of a [`re_types_core::Component`] in the internal
289289
/// `DataTypeRegistry`.
290290
pub fn lookup_datatype(&self, component: &ComponentName) -> Option<&DataType> {
291291
self.type_registry.get(component)
@@ -336,10 +336,10 @@ impl DataStore {
336336
#[test]
337337
fn datastore_internal_repr() {
338338
use re_log_types::DataTable;
339-
use re_types::{components::InstanceKey, Loggable as _};
339+
use re_types_core::Loggable as _;
340340

341341
let mut store = DataStore::new(
342-
InstanceKey::name(),
342+
re_types::components::InstanceKey::name(),
343343
DataStoreConfig {
344344
indexed_bucket_num_rows: 0,
345345
store_insert_ids: true,

crates/re_arrow_store/src/store_arrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use re_log_types::{
66
DataCellColumn, DataTable, DataTableResult, RowId, Timeline, COLUMN_INSERT_ID,
77
COLUMN_NUM_INSTANCES,
88
};
9-
use re_types::ComponentName;
9+
use re_types_core::ComponentName;
1010

1111
use crate::store::{IndexedBucket, IndexedBucketInner, PersistentIndexedTable};
1212

crates/re_arrow_store/src/store_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use re_format::{format_bytes, format_number};
2-
use re_log_types::SizeBytes as _;
2+
use re_types_core::SizeBytes as _;
33

44
use crate::{DataStore, IndexedBucket, IndexedTable, PersistentIndexedTable};
55

crates/re_arrow_store/src/store_gc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use ahash::{HashMap, HashSet};
22

33
use nohash_hasher::IntMap;
4-
use re_log_types::{EntityPathHash, RowId, SizeBytes as _, TimeInt, TimeRange, Timeline};
5-
use re_types::ComponentName;
4+
use re_log_types::{EntityPathHash, RowId, TimeInt, TimeRange, Timeline};
5+
use re_types_core::{ComponentName, SizeBytes as _};
66

77
use crate::{
88
store::{IndexedBucketInner, IndexedTable, PersistentIndexedTable},

crates/re_arrow_store/src/store_helpers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use re_log_types::{DataCell, DataRow, EntityPath, RowId, TimePoint, Timeline};
22

3-
use re_types::{Component, ComponentName};
3+
use re_types_core::{Component, ComponentName};
44

55
use crate::{DataStore, LatestAtQuery};
66

@@ -35,7 +35,7 @@ impl<C: Component> std::ops::Deref for VersionedComponent<C> {
3535
}
3636

3737
impl DataStore {
38-
/// Get the latest value for a given [`re_types::Component`] and the associated [`RowId`].
38+
/// Get the latest value for a given [`re_types_core::Component`] and the associated [`RowId`].
3939
///
4040
/// This assumes that the row we get from the store only contains a single instance for this
4141
/// component; it will log a warning otherwise.
@@ -110,7 +110,7 @@ impl DataStore {
110110
None
111111
}
112112

113-
/// Get the latest value for a given [`re_types::Component`] and the associated [`RowId`], assuming it is timeless.
113+
/// Get the latest value for a given [`re_types_core::Component`] and the associated [`RowId`], assuming it is timeless.
114114
///
115115
/// This assumes that the row we get from the store only contains a single instance for this
116116
/// component; it will log a warning otherwise.
@@ -132,7 +132,7 @@ impl DataStore {
132132
// --- Write ---
133133

134134
impl DataStore {
135-
/// Stores a single value for a given [`re_types::Component`].
135+
/// Stores a single value for a given [`re_types_core::Component`].
136136
///
137137
/// This is a best-effort helper, it will merely log errors on failure.
138138
pub fn insert_component<'a, C>(
@@ -172,7 +172,7 @@ impl DataStore {
172172
}
173173
}
174174

175-
/// Stores a single empty value for a given [`re_log_types::ComponentName`].
175+
/// Stores a single empty value for a given [`re_types_core::ComponentName`].
176176
///
177177
/// This is a best-effort helper, it will merely log errors on failure.
178178
pub fn insert_empty_component(

crates/re_arrow_store/src/store_polars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use arrow2::{
1010
};
1111
use polars_core::{functions::diag_concat_df, prelude::*};
1212
use re_log_types::{DataCell, DataTable};
13-
use re_types::ComponentName;
13+
use re_types_core::ComponentName;
1414

1515
use crate::{
1616
store::InsertIdVec, ArrayExt, DataStore, DataStoreConfig, IndexedBucket, IndexedBucketInner,

crates/re_arrow_store/src/store_read.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{ops::RangeBounds, sync::atomic::Ordering};
33
use itertools::Itertools;
44
use re_log::trace;
55
use re_log_types::{DataCell, EntityPath, RowId, TimeInt, TimePoint, TimeRange, Timeline};
6-
use re_types::{ComponentName, ComponentNameSet};
6+
use re_types_core::{ComponentName, ComponentNameSet};
77
use smallvec::SmallVec;
88

99
use crate::{DataStore, IndexedBucket, IndexedBucketInner, IndexedTable, PersistentIndexedTable};
@@ -190,7 +190,7 @@ impl DataStore {
190190
/// ```rust
191191
/// # use polars_core::{prelude::*, series::Series};
192192
/// # use re_log_types::{EntityPath, RowId, TimeInt};
193-
/// # use re_types::{ComponentName};
193+
/// # use re_types_core::{ComponentName};
194194
/// # use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery};
195195
/// #
196196
/// pub fn latest_component(
@@ -359,7 +359,7 @@ impl DataStore {
359359
/// # use polars_core::{prelude::*, series::Series};
360360
/// # use re_log_types::{DataCell, EntityPath, RowId, TimeInt};
361361
/// # use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery};
362-
/// # use re_types::ComponentName;
362+
/// # use re_types_core::ComponentName;
363363
/// #
364364
/// # pub fn dataframe_from_cells<const N: usize>(
365365
/// # cells: [Option<DataCell>; N],

crates/re_arrow_store/src/store_sanity.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use re_log_types::{
2-
DataCellColumn, RowId, SizeBytes as _, TimeRange, COLUMN_NUM_INSTANCES, COLUMN_TIMEPOINT,
3-
};
4-
use re_types::{ComponentName, Loggable};
1+
use re_log_types::{DataCellColumn, RowId, TimeRange, COLUMN_NUM_INSTANCES, COLUMN_TIMEPOINT};
2+
use re_types_core::{ComponentName, Loggable, SizeBytes as _};
53

64
use crate::{DataStore, IndexedBucket, IndexedBucketInner, IndexedTable, PersistentIndexedTable};
75

crates/re_arrow_store/src/store_stats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use nohash_hasher::IntMap;
2-
use re_log_types::{SizeBytes, TimePoint, TimeRange};
3-
use re_types::ComponentName;
2+
use re_log_types::{TimePoint, TimeRange};
3+
use re_types_core::{ComponentName, SizeBytes};
44

55
use crate::{
66
store::IndexedBucketInner, ClusterCellCache, DataStore, DataTypeRegistry, IndexedBucket,

crates/re_arrow_store/src/store_write.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ use smallvec::SmallVec;
66

77
use re_log::{debug, trace};
88
use re_log_types::{
9-
DataCell, DataCellColumn, DataCellError, DataRow, DataTable, RowId, SizeBytes as _, TimeInt,
10-
TimePoint, TimeRange,
9+
DataCell, DataCellColumn, DataCellError, DataRow, DataTable, RowId, TimeInt, TimePoint,
10+
TimeRange,
1111
};
12-
use re_types::{components::InstanceKey, ComponentName, ComponentNameSet, Loggable};
12+
use re_types::components::InstanceKey;
13+
use re_types_core::{ComponentName, ComponentNameSet, Loggable, SizeBytes as _};
1314

1415
use crate::{
1516
store::MetadataRegistry, DataStore, DataStoreConfig, IndexedBucket, IndexedBucketInner,

crates/re_arrow_store/tests/correctness.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use re_arrow_store::{
1313
use re_log_types::{
1414
build_frame_nr, build_log_time, DataCell, Duration, EntityPath, Time, TimeType, Timeline,
1515
};
16+
use re_types::components::InstanceKey;
1617
use re_types::datagen::{build_some_colors, build_some_instances, build_some_positions2d};
17-
use re_types::{components::InstanceKey, Loggable as _};
18+
use re_types_core::Loggable as _;
1819

1920
// ---
2021

0 commit comments

Comments
 (0)