Skip to content

Commit

Permalink
Remove arrow-cast dependency from arrow-ipc (apache#3044)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Nov 9, 2022
1 parent fe3318b commit 9eb64ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion arrow-ipc/Cargo.toml
Expand Up @@ -40,7 +40,6 @@ bench = false
[dependencies]
arrow-array = { version = "26.0.0", path = "../arrow-array" }
arrow-buffer = { version = "26.0.0", path = "../arrow-buffer" }
arrow-cast = { version = "26.0.0", path = "../arrow-cast" }
arrow-data = { version = "26.0.0", path = "../arrow-data" }
arrow-schema = { version = "26.0.0", path = "../arrow-schema" }
flatbuffers = { version = "22.9.2", default-features = false, features = ["thiserror"] }
Expand Down
18 changes: 9 additions & 9 deletions arrow-ipc/src/reader.rs
Expand Up @@ -26,9 +26,9 @@ use std::fmt;
use std::io::{BufReader, Read, Seek, SeekFrom};
use std::sync::Arc;

use arrow_array::types::{Float32Type, Int32Type};
use arrow_array::*;
use arrow_buffer::{Buffer, MutableBuffer};
use arrow_cast::cast;
use arrow_data::ArrayData;
use arrow_schema::*;

Expand Down Expand Up @@ -436,10 +436,10 @@ fn create_primitive_array(
.null_bit_buffer(null_buffer)
.build()
.unwrap();
let values = Arc::new(Int64Array::from(data)) as ArrayRef;
// this cast is infallible, the unwrap is safe
let casted = cast(&values, data_type).unwrap();
casted.into_data()

Int64Array::from(data)
.unary::<_, Int32Type>(|x| x as _)
.into_data()
} else {
ArrayData::builder(data_type.clone())
.len(length)
Expand All @@ -458,10 +458,10 @@ fn create_primitive_array(
.null_bit_buffer(null_buffer)
.build()
.unwrap();
let values = Arc::new(Float64Array::from(data)) as ArrayRef;
// this cast is infallible, the unwrap is safe
let casted = cast(&values, data_type).unwrap();
casted.into_data()

Float64Array::from(data)
.unary::<_, Float32Type>(|x| x as _)
.into_data()
} else {
ArrayData::builder(data_type.clone())
.len(length)
Expand Down

0 comments on commit 9eb64ed

Please sign in to comment.