Skip to content

Commit

Permalink
Merge branch 'main' into cmc/python_partial_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Jan 15, 2025
2 parents 0c5b261 + d0a7d1f commit 68bf5a0
Show file tree
Hide file tree
Showing 57 changed files with 2,401 additions and 902 deletions.
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@
// Uncomment the following options and restart rust-analyzer to get it to check code behind `cfg(target_arch=wasm32)`.
// Don't forget to put it in a comment again before committing.
// "rust-analyzer.cargo.target": "wasm32-unknown-unknown",
// "rust-analyzer.cargo.cfgs": {
// "web": null,
// "webgl": null,
// "webgpu": null,
// },
// "rust-analyzer.cargo.cfgs": ["web","webgl","webgpu"],

"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", // Use cmake-tools to grab configs.
"C_Cpp.autoAddFileAssociations": false,
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5913,6 +5913,7 @@ version = "0.22.0-alpha.1+dev"
dependencies = [
"anyhow",
"arrow",
"insta",
"itertools 0.13.0",
"nohash-hasher",
"rayon",
Expand Down
8 changes: 3 additions & 5 deletions crates/store/re_chunk/src/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ impl TransportChunk {
/// related rust structures that refer to those data buffers.
pub fn try_to_arrow_record_batch(&self) -> Result<RecordBatch, ArrowError> {
let columns: Vec<_> = self
.all_columns()
.map(|(_field, arr2_array)| {
let data = arrow2::array::to_data(arr2_array.as_ref());
make_array(data)
})
.columns()
.iter()
.map(|arr2_array| make_array(arrow2::array::to_data(*arr2_array)))
.collect();

RecordBatch::try_new(self.schema(), columns)
Expand Down
15 changes: 9 additions & 6 deletions crates/store/re_chunk/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl std::fmt::Display for TransportChunk {
.iter()
.map(|list_array| ArrowArrayRef::from(list_array.clone()))
.collect_vec(),
f.width(),
)
.fmt(f)
}
Expand Down Expand Up @@ -380,7 +381,7 @@ impl TransportChunk {
/// * [`Self::FIELD_METADATA_VALUE_KIND_CONTROL`]
/// * [`Self::FIELD_METADATA_VALUE_KIND_DATA`]
#[inline]
pub fn columns<'a>(
fn columns_of_kind<'a>(
&'a self,
kind: &'a str,
) -> impl Iterator<Item = (&'a ArrowField, &'a Box<dyn Arrow2Array>)> + 'a {
Expand All @@ -402,7 +403,9 @@ impl TransportChunk {
}

#[inline]
pub fn all_columns(&self) -> impl Iterator<Item = (&ArrowField, &Box<dyn Arrow2Array>)> + '_ {
pub fn fields_and_columns(
&self,
) -> impl Iterator<Item = (&ArrowField, &Box<dyn Arrow2Array>)> + '_ {
self.schema
.fields
.iter()
Expand All @@ -416,26 +419,26 @@ impl TransportChunk {
}

#[inline]
pub fn all_columns_collected(&self) -> Vec<&dyn Arrow2Array> {
pub fn columns(&self) -> Vec<&dyn Arrow2Array> {
self.data.iter().map(|c| c.as_ref()).collect()
}

/// Iterates all control columns present in this chunk.
#[inline]
pub fn controls(&self) -> impl Iterator<Item = (&ArrowField, &Box<dyn Arrow2Array>)> {
self.columns(Self::FIELD_METADATA_VALUE_KIND_CONTROL)
self.columns_of_kind(Self::FIELD_METADATA_VALUE_KIND_CONTROL)
}

/// Iterates all data columns present in this chunk.
#[inline]
pub fn components(&self) -> impl Iterator<Item = (&ArrowField, &Box<dyn Arrow2Array>)> {
self.columns(Self::FIELD_METADATA_VALUE_KIND_DATA)
self.columns_of_kind(Self::FIELD_METADATA_VALUE_KIND_DATA)
}

/// Iterates all timeline columns present in this chunk.
#[inline]
pub fn timelines(&self) -> impl Iterator<Item = (&ArrowField, &Box<dyn Arrow2Array>)> {
self.columns(Self::FIELD_METADATA_VALUE_KIND_TIME)
self.columns_of_kind(Self::FIELD_METADATA_VALUE_KIND_TIME)
}

/// How many columns in total? Includes control, time, and component columns.
Expand Down
7 changes: 6 additions & 1 deletion crates/store/re_chunk_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,12 @@ impl std::fmt::Display for ChunkStore {
f.write_str(&indent::indent_all_by(4, "chunks: [\n"))?;
for chunk_id in chunk_id_per_min_row_id.values().flatten() {
if let Some(chunk) = chunks_per_chunk_id.get(chunk_id) {
f.write_str(&indent::indent_all_by(8, format!("{chunk}\n")))?;
if let Some(width) = f.width() {
let chunk_width = width.saturating_sub(8);
f.write_str(&indent::indent_all_by(8, format!("{chunk:chunk_width$}\n")))?;
} else {
f.write_str(&indent::indent_all_by(8, format!("{chunk}\n")))?;
}
} else {
f.write_str(&indent::indent_all_by(8, "<not_found>\n"))?;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk_store/tests/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn format_chunk_store() -> anyhow::Result<()> {
.build()?,
))?;

insta::assert_snapshot!("format_chunk_store", store.to_string());
insta::assert_snapshot!("format_chunk_store", format!("{:200}", store));

Ok(())
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: crates/store/re_chunk_store/tests/formatting.rs
assertion_line: 45
expression: store.to_string()
expression: "format!(\"{:200}\", store)"
snapshot_kind: text
---
ChunkStore {
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_dataframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ re_types_core.workspace = true
anyhow.workspace = true
arrow.workspace = true
arrow2.workspace = true
insta.workspace = true
itertools.workspace = true
nohash-hasher.workspace = true
rayon.workspace = true
Expand Down
Loading

0 comments on commit 68bf5a0

Please sign in to comment.