You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/11/30 19:59:14 UTC
[arrow-rs] branch master updated: Validate dictionaries read over IPC (#3247)
This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 6bd559f10 Validate dictionaries read over IPC (#3247)
6bd559f10 is described below
commit 6bd559f10eca5eab0dc2caca8ce7e5c77a985500
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Wed Nov 30 19:59:08 2022 +0000
Validate dictionaries read over IPC (#3247)
---
arrow-ipc/src/reader.rs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs
index 32f580afb..ef0a49be6 100644
--- a/arrow-ipc/src/reader.rs
+++ b/arrow-ipc/src/reader.rs
@@ -131,7 +131,7 @@ fn create_array(
node_index = triple.1;
buffer_index = triple.2;
- create_list_array(list_node, data_type, &list_buffers, triple.0)
+ create_list_array(list_node, data_type, &list_buffers, triple.0)?
}
FixedSizeList(ref list_field, _) => {
let list_node = nodes.get(node_index);
@@ -156,7 +156,7 @@ fn create_array(
node_index = triple.1;
buffer_index = triple.2;
- create_list_array(list_node, data_type, &list_buffers, triple.0)
+ create_list_array(list_node, data_type, &list_buffers, triple.0)?
}
Struct(struct_fields) => {
let struct_node = nodes.get(node_index);
@@ -220,7 +220,7 @@ fn create_array(
data_type,
&index_buffers,
value_array.clone(),
- )
+ )?
}
Union(fields, field_type_ids, mode) => {
let union_node = nodes.get(node_index);
@@ -527,7 +527,7 @@ fn create_list_array(
data_type: &DataType,
buffers: &[Buffer],
child_array: ArrayRef,
-) -> ArrayRef {
+) -> Result<ArrayRef, ArrowError> {
let null_buffer = (field_node.null_count() > 0).then_some(buffers[0].clone());
let length = field_node.length() as usize;
let child_data = child_array.into_data();
@@ -545,7 +545,7 @@ fn create_list_array(
_ => unreachable!("Cannot create list or map array from {:?}", data_type),
};
- make_array(builder.build().unwrap())
+ Ok(make_array(builder.build()?))
}
/// Reads the correct number of buffers based on list type and null_count, and creates a
@@ -555,7 +555,7 @@ fn create_dictionary_array(
data_type: &DataType,
buffers: &[Buffer],
value_array: ArrayRef,
-) -> ArrayRef {
+) -> Result<ArrayRef, ArrowError> {
if let Dictionary(_, _) = *data_type {
let null_buffer = (field_node.null_count() > 0).then_some(buffers[0].clone());
let builder = ArrayData::builder(data_type.clone())
@@ -564,7 +564,7 @@ fn create_dictionary_array(
.add_child_data(value_array.into_data())
.null_bit_buffer(null_buffer);
- make_array(unsafe { builder.build_unchecked() })
+ Ok(make_array(builder.build()?))
} else {
unreachable!("Cannot create dictionary array from {:?}", data_type)
}