Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port TimeColumn to arrow-rs #8638

Merged
merged 9 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5569,7 +5569,7 @@ dependencies = [
[[package]]
name = "re_arrow2"
version = "0.18.1"
source = "git+https://github.com/rerun-io/re_arrow2.git?branch=main#82095762a42eed76e4043c82833e391893d5821c"
source = "git+https://github.com/rerun-io/re_arrow2.git?branch=main#573b5bafd071d09698353d8f0de8d31f3fa59017"
dependencies = [
"ahash",
"arrow-array",
Expand Down Expand Up @@ -5802,6 +5802,7 @@ version = "0.22.0-alpha.1+dev"
dependencies = [
"ahash",
"anyhow",
"arrow",
"crossbeam",
"image",
"notify",
Expand Down Expand Up @@ -5879,6 +5880,7 @@ name = "re_dataframe"
version = "0.22.0-alpha.1+dev"
dependencies = [
"anyhow",
"arrow",
"itertools 0.13.0",
"nohash-hasher",
"rayon",
Expand Down Expand Up @@ -6330,7 +6332,6 @@ dependencies = [
"once_cell",
"parking_lot",
"rand",
"re_arrow2",
"re_build_info",
"re_build_tools",
"re_byte_size",
Expand Down Expand Up @@ -7341,6 +7342,7 @@ name = "rerun_c"
version = "0.22.0-alpha.1+dev"
dependencies = [
"ahash",
"arrow",
"infer",
"once_cell",
"parking_lot",
Expand Down
90 changes: 17 additions & 73 deletions crates/store/re_chunk/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use arrow::array::{Array as ArrowArray, ArrayRef};
use arrow2::array::PrimitiveArray as Arrow2PrimitiveArray;
use arrow::buffer::ScalarBuffer as ArrowScalarBuffer;
use crossbeam::channel::{Receiver, Sender};
use nohash_hasher::IntMap;

Expand Down Expand Up @@ -724,7 +724,7 @@ impl PendingRow {
let timelines = timepoint
.into_iter()
.map(|(timeline, time)| {
let times = Arrow2PrimitiveArray::<i64>::from_vec(vec![time.as_i64()]);
let times = ArrowScalarBuffer::from(vec![time.as_i64()]);
let time_column = TimeColumn::new(Some(true), timeline, times);
(timeline, time_column)
})
Expand Down Expand Up @@ -973,7 +973,7 @@ impl PendingTimeColumn {

TimeColumn {
timeline,
times: Arrow2PrimitiveArray::<i64>::from_vec(times).to(timeline.datatype()),
times: ArrowScalarBuffer::from(times),
is_sorted,
time_range,
}
Expand Down Expand Up @@ -1050,11 +1050,7 @@ mod tests {
let expected_row_ids = vec![row1.row_id, row2.row_id, row3.row_id];
let expected_timelines = [(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![42, 43, 44]),
),
TimeColumn::new(Some(true), timeline1, vec![42, 43, 44].into()),
)];
let expected_components = [(
MyPoint::descriptor(),
Expand Down Expand Up @@ -1206,11 +1202,7 @@ mod tests {
let expected_row_ids = vec![row1.row_id, row3.row_id];
let expected_timelines = [(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![42, 44]),
),
TimeColumn::new(Some(true), timeline1, vec![42, 44].into()),
)];
let expected_components = [(
MyPoint::descriptor(),
Expand All @@ -1234,11 +1226,7 @@ mod tests {
let expected_row_ids = vec![row2.row_id];
let expected_timelines = [(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![43]),
),
TimeColumn::new(Some(true), timeline1, vec![43].into()),
)];
let expected_components = [(
MyPoint::descriptor(),
Expand Down Expand Up @@ -1321,11 +1309,7 @@ mod tests {
let expected_row_ids = vec![row1.row_id];
let expected_timelines = [(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![42]),
),
TimeColumn::new(Some(true), timeline1, vec![42].into()),
)];
let expected_components = [(
MyPoint::descriptor(),
Expand All @@ -1350,19 +1334,11 @@ mod tests {
let expected_timelines = [
(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![43, 44]),
),
TimeColumn::new(Some(true), timeline1, vec![43, 44].into()),
),
(
timeline2,
TimeColumn::new(
Some(true),
timeline2,
Arrow2PrimitiveArray::from_vec(vec![1000, 1001]),
),
TimeColumn::new(Some(true), timeline2, vec![1000, 1001].into()),
),
];
let expected_components = [(
Expand Down Expand Up @@ -1442,11 +1418,7 @@ mod tests {
let expected_row_ids = vec![row1.row_id, row3.row_id];
let expected_timelines = [(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![42, 44]),
),
TimeColumn::new(Some(true), timeline1, vec![42, 44].into()),
)];
let expected_components = [(
MyPoint::descriptor(),
Expand All @@ -1470,11 +1442,7 @@ mod tests {
let expected_row_ids = vec![row2.row_id];
let expected_timelines = [(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![43]),
),
TimeColumn::new(Some(true), timeline1, vec![43].into()),
)];
let expected_components = [(
MyPoint::descriptor(),
Expand Down Expand Up @@ -1572,19 +1540,11 @@ mod tests {
let expected_timelines = [
(
timeline1,
TimeColumn::new(
Some(false),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![45, 42, 43, 44]),
),
TimeColumn::new(Some(false), timeline1, vec![45, 42, 43, 44].into()),
),
(
timeline2,
TimeColumn::new(
Some(false),
timeline2,
Arrow2PrimitiveArray::from_vec(vec![1003, 1000, 1001, 1002]),
),
TimeColumn::new(Some(false), timeline2, vec![1003, 1000, 1001, 1002].into()),
),
];
let expected_components = [(
Expand Down Expand Up @@ -1686,19 +1646,11 @@ mod tests {
let expected_timelines = [
(
timeline1,
TimeColumn::new(
Some(false),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![45, 42, 43]),
),
TimeColumn::new(Some(false), timeline1, vec![45, 42, 43].into()),
),
(
timeline2,
TimeColumn::new(
Some(false),
timeline2,
Arrow2PrimitiveArray::from_vec(vec![1003, 1000, 1001]),
),
TimeColumn::new(Some(false), timeline2, vec![1003, 1000, 1001].into()),
),
];
let expected_components = [(
Expand All @@ -1725,19 +1677,11 @@ mod tests {
let expected_timelines = [
(
timeline1,
TimeColumn::new(
Some(true),
timeline1,
Arrow2PrimitiveArray::from_vec(vec![44]),
),
TimeColumn::new(Some(true), timeline1, vec![44].into()),
),
(
timeline2,
TimeColumn::new(
Some(true),
timeline2,
Arrow2PrimitiveArray::from_vec(vec![1002]),
),
TimeColumn::new(Some(true), timeline2, vec![1002].into()),
),
];
let expected_components = [(
Expand Down
4 changes: 1 addition & 3 deletions crates/store/re_chunk/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ impl TimeColumnBuilder {
#[inline]
pub fn build(self) -> TimeColumn {
let Self { timeline, times } = self;

let times = arrow2::array::PrimitiveArray::<i64>::from_vec(times).to(timeline.datatype());
TimeColumn::new(None, timeline, times)
TimeColumn::new(None, timeline, times.into())
}
}
Loading
Loading