Skip to content

Commit

Permalink
Port re_format_arrow to arrow-rs (#8664)
Browse files Browse the repository at this point in the history
* Part of #3741 

The "Print Datastore" feature will produce a slightly different result.
  • Loading branch information
emilk authored Jan 14, 2025
1 parent 1ffe586 commit e4f8df4
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 118 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5980,9 +5980,9 @@ dependencies = [
name = "re_format_arrow"
version = "0.22.0-alpha.1+dev"
dependencies = [
"arrow",
"comfy-table",
"itertools 0.13.0",
"re_arrow2",
"re_tuid",
"re_types_core",
]
Expand Down
20 changes: 16 additions & 4 deletions crates/store/re_chunk/src/transport.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use arrow::array::{ArrayRef as ArrowArrayRef, StructArray as ArrowStructArray};
use arrow::array::{
Array as ArrowArray, ArrayRef as ArrowArrayRef, StructArray as ArrowStructArray,
};
use arrow2::{
array::{Array as Arrow2Array, ListArray},
chunk::Chunk as Arrow2Chunk,
Expand Down Expand Up @@ -48,10 +50,20 @@ pub struct TransportChunk {
impl std::fmt::Display for TransportChunk {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// TODO(#3741): simplify code when we have migrated to arrow-rs
re_format_arrow::format_dataframe(
&self.schema.metadata,
&self.schema.fields,
self.data.iter().map(|list_array| &**list_array),
&self.schema.metadata.clone().into_iter().collect(),
&self
.schema
.fields
.iter()
.map(|field| arrow::datatypes::Field::from(field.clone()))
.collect(),
&self
.data
.iter()
.map(|list_array| ArrowArrayRef::from(list_array.clone()))
.collect_vec(),
)
.fmt(f)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ ChunkStore {
│ ┌──────────────────────────────────┬───────────────┬───────────────────────────────┬───────────────────┬───────────────────┐ │
│ │ RowIdframe_nrlog_timeexample.MyColorexample.MyIndex │ │
│ │ --------------- │ │
│ │ type: "struct[2]"type: "i64"type: "timestamp(ns)"type: "list[u32]"type: "list[u64]" │ │
│ │ type: "Struct[2]"type: "i64"type: "Timestamp(ns)"type: "List[u32]"type: "List[u64]" │ │
│ │ ARROW:extension:name: "TUID"is_sorted: ""is_sorted: ""kind: "data"kind: "data" │ │
│ │ kind: "control"kind: "time"kind: "time" ┆ ┆ │ │
│ ╞══════════════════════════════════╪═══════════════╪═══════════════════════════════╪═══════════════════╪═══════════════════╡ │
│ │ 0000000067816A6BB4B8C1254D40007B12025-01-10 18:43:42.123456789 ┆ [0, 1, 2] ┆ [0, 1, 2] │ │
│ │ 0000000067816A6BB4B8C1254D40007B12025-01-10T18:43:42.123456789 ┆ [0, 1, 2] ┆ [0, 1, 2] │ │
│ └──────────────────────────────────┴───────────────┴───────────────────────────────┴───────────────────┴───────────────────┘ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
]
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_format_arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ all-features = true


[dependencies]
arrow2.workspace = true
arrow.workspace = true
itertools.workspace = true
re_tuid.workspace = true
re_types_core.workspace = true # tuid serialization
Expand Down
Loading

0 comments on commit e4f8df4

Please sign in to comment.