-
Notifications
You must be signed in to change notification settings - Fork 385
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
Create re_arrow_util
#8689
Merged
Merged
Create re_arrow_util
#8689
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
155069a
Add helpers for downcasting arrow arrays
emilk 752b770
Move arrow utils to new crate re_arrow_util
emilk 98681f5
Call it `downcast_array2_ref` for arrow2
emilk cb7efd7
Implement downcast_array_ref for all arrays, not just dyn Array
emilk dd6f359
Use downcast_array2_ref in a bunch of places
emilk 910544b
Use downcast_array_ref
emilk dcbf2b7
Update ARCHITECTURE.md
emilk abf808e
toml fmt
emilk 551c095
Merge branch 'main' into emilk/downcast-array
emilk 93adae2
Update re_arrow2
emilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::TransportChunk; | ||
|
||
use arrow::datatypes::Schema as ArrowSchema; | ||
use arrow2::chunk::Chunk as Arrow2Chunk; | ||
|
||
/// Concatenate multiple [`TransportChunk`]s into one. | ||
/// | ||
/// This is a temporary method that we use while waiting to migrate towards `arrow-rs`. | ||
/// * `arrow2` doesn't have a `RecordBatch` type, therefore we emulate that using our `TransportChunk`s. | ||
/// * `arrow-rs` does have one, and it natively supports concatenation. | ||
pub fn concatenate_record_batches( | ||
schema: impl Into<ArrowSchema>, | ||
batches: &[TransportChunk], | ||
) -> anyhow::Result<TransportChunk> { | ||
let schema: ArrowSchema = schema.into(); | ||
anyhow::ensure!( | ||
batches | ||
.iter() | ||
.all(|batch| batch.schema_ref().as_ref() == &schema), | ||
"concatenate_record_batches: all batches must have the same schema" | ||
); | ||
|
||
let mut output_columns = Vec::new(); | ||
|
||
if !batches.is_empty() { | ||
for (i, _field) in schema.fields.iter().enumerate() { | ||
let arrays: Option<Vec<_>> = batches.iter().map(|batch| batch.column(i)).collect(); | ||
let arrays = arrays.ok_or_else(|| { | ||
anyhow::anyhow!("concatenate_record_batches: all batches must have the same schema") | ||
})?; | ||
let array = re_arrow_util::arrow2_util::concat_arrays(&arrays)?; | ||
output_columns.push(array); | ||
} | ||
} | ||
|
||
Ok(TransportChunk::new( | ||
schema, | ||
Arrow2Chunk::new(output_columns), | ||
)) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old code; moved