From 712dfebfc1373e0e5df1693b95a8ac5facaf3214 Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Sat, 7 Dec 2024 08:35:39 -0700 Subject: [PATCH] address feedback --- arrow-schema/Cargo.toml | 2 +- arrow-schema/src/ffi.rs | 82 ++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arrow-schema/Cargo.toml b/arrow-schema/Cargo.toml index eeae6574092..1e1f9fbde0e 100644 --- a/arrow-schema/Cargo.toml +++ b/arrow-schema/Cargo.toml @@ -36,7 +36,6 @@ bench = false [dependencies] serde = { version = "1.0", default-features = false, features = ["derive", "std", "rc"], optional = true } bitflags = { version = "2.0.0", default-features = false, optional = true } -criterion = { version = "0.5", default-features = false } [features] # Enable ffi support @@ -48,6 +47,7 @@ features = ["ffi"] [dev-dependencies] serde_json = "1.0" bincode = { version = "1.3.3", default-features = false } +criterion = { version = "0.5", default-features = false } [[bench]] name = "ffi" diff --git a/arrow-schema/src/ffi.rs b/arrow-schema/src/ffi.rs index c0fc8b25d85..08b1e6d0b18 100644 --- a/arrow-schema/src/ffi.rs +++ b/arrow-schema/src/ffi.rs @@ -688,57 +688,57 @@ impl TryFrom<&DataType> for FFI_ArrowSchema { fn get_format_string(dtype: &DataType) -> Result, ArrowError> { match dtype { - DataType::Null => Ok(Cow::Borrowed("n")), - DataType::Boolean => Ok(Cow::Borrowed("b")), - DataType::Int8 => Ok(Cow::Borrowed("c")), - DataType::UInt8 => Ok(Cow::Borrowed("C")), - DataType::Int16 => Ok(Cow::Borrowed("s")), - DataType::UInt16 => Ok(Cow::Borrowed("S")), - DataType::Int32 => Ok(Cow::Borrowed("i")), - DataType::UInt32 => Ok(Cow::Borrowed("I")), - DataType::Int64 => Ok(Cow::Borrowed("l")), - DataType::UInt64 => Ok(Cow::Borrowed("L")), - DataType::Float16 => Ok(Cow::Borrowed("e")), - DataType::Float32 => Ok(Cow::Borrowed("f")), - DataType::Float64 => Ok(Cow::Borrowed("g")), - DataType::BinaryView => Ok(Cow::Borrowed("vz")), - DataType::Binary => Ok(Cow::Borrowed("z")), - DataType::LargeBinary => Ok(Cow::Borrowed("Z")), - DataType::Utf8View => Ok(Cow::Borrowed("vu")), - DataType::Utf8 => Ok(Cow::Borrowed("u")), - DataType::LargeUtf8 => Ok(Cow::Borrowed("U")), + DataType::Null => Ok("n".into()), + DataType::Boolean => Ok("b".into()), + DataType::Int8 => Ok("c".into()), + DataType::UInt8 => Ok("C".into()), + DataType::Int16 => Ok("s".into()), + DataType::UInt16 => Ok("S".into()), + DataType::Int32 => Ok("i".into()), + DataType::UInt32 => Ok("I".into()), + DataType::Int64 => Ok("l".into()), + DataType::UInt64 => Ok("L".into()), + DataType::Float16 => Ok("e".into()), + DataType::Float32 => Ok("f".into()), + DataType::Float64 => Ok("g".into()), + DataType::BinaryView => Ok("vz".into()), + DataType::Binary => Ok("z".into()), + DataType::LargeBinary => Ok("Z".into()), + DataType::Utf8View => Ok("vu".into()), + DataType::Utf8 => Ok("u".into()), + DataType::LargeUtf8 => Ok("U".into()), DataType::FixedSizeBinary(num_bytes) => Ok(Cow::Owned(format!("w:{num_bytes}"))), DataType::FixedSizeList(_, num_elems) => Ok(Cow::Owned(format!("+w:{num_elems}"))), DataType::Decimal128(precision, scale) => Ok(Cow::Owned(format!("d:{precision},{scale}"))), DataType::Decimal256(precision, scale) => { Ok(Cow::Owned(format!("d:{precision},{scale},256"))) } - DataType::Date32 => Ok(Cow::Borrowed("tdD")), - DataType::Date64 => Ok(Cow::Borrowed("tdm")), - DataType::Time32(TimeUnit::Second) => Ok(Cow::Borrowed("tts")), - DataType::Time32(TimeUnit::Millisecond) => Ok(Cow::Borrowed("ttm")), - DataType::Time64(TimeUnit::Microsecond) => Ok(Cow::Borrowed("ttu")), - DataType::Time64(TimeUnit::Nanosecond) => Ok(Cow::Borrowed("ttn")), - DataType::Timestamp(TimeUnit::Second, None) => Ok(Cow::Borrowed("tss:")), - DataType::Timestamp(TimeUnit::Millisecond, None) => Ok(Cow::Borrowed("tsm:")), - DataType::Timestamp(TimeUnit::Microsecond, None) => Ok(Cow::Borrowed("tsu:")), - DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok(Cow::Borrowed("tsn:")), + DataType::Date32 => Ok("tdD".into()), + DataType::Date64 => Ok("tdm".into()), + DataType::Time32(TimeUnit::Second) => Ok("tts".into()), + DataType::Time32(TimeUnit::Millisecond) => Ok("ttm".into()), + DataType::Time64(TimeUnit::Microsecond) => Ok("ttu".into()), + DataType::Time64(TimeUnit::Nanosecond) => Ok("ttn".into()), + DataType::Timestamp(TimeUnit::Second, None) => Ok("tss:".into()), + DataType::Timestamp(TimeUnit::Millisecond, None) => Ok("tsm:".into()), + DataType::Timestamp(TimeUnit::Microsecond, None) => Ok("tsu:".into()), + DataType::Timestamp(TimeUnit::Nanosecond, None) => Ok("tsn:".into()), DataType::Timestamp(TimeUnit::Second, Some(tz)) => Ok(Cow::Owned(format!("tss:{tz}"))), DataType::Timestamp(TimeUnit::Millisecond, Some(tz)) => Ok(Cow::Owned(format!("tsm:{tz}"))), DataType::Timestamp(TimeUnit::Microsecond, Some(tz)) => Ok(Cow::Owned(format!("tsu:{tz}"))), DataType::Timestamp(TimeUnit::Nanosecond, Some(tz)) => Ok(Cow::Owned(format!("tsn:{tz}"))), - DataType::Duration(TimeUnit::Second) => Ok(Cow::Borrowed("tDs")), - DataType::Duration(TimeUnit::Millisecond) => Ok(Cow::Borrowed("tDm")), - DataType::Duration(TimeUnit::Microsecond) => Ok(Cow::Borrowed("tDu")), - DataType::Duration(TimeUnit::Nanosecond) => Ok(Cow::Borrowed("tDn")), - DataType::Interval(IntervalUnit::YearMonth) => Ok(Cow::Borrowed("tiM")), - DataType::Interval(IntervalUnit::DayTime) => Ok(Cow::Borrowed("tiD")), - DataType::Interval(IntervalUnit::MonthDayNano) => Ok(Cow::Borrowed("tin")), - DataType::List(_) => Ok(Cow::Borrowed("+l")), - DataType::LargeList(_) => Ok(Cow::Borrowed("+L")), - DataType::Struct(_) => Ok(Cow::Borrowed("+s")), - DataType::Map(_, _) => Ok(Cow::Borrowed("+m")), - DataType::RunEndEncoded(_, _) => Ok(Cow::Borrowed("+r")), + DataType::Duration(TimeUnit::Second) => Ok("tDs".into()), + DataType::Duration(TimeUnit::Millisecond) => Ok("tDm".into()), + DataType::Duration(TimeUnit::Microsecond) => Ok("tDu".into()), + DataType::Duration(TimeUnit::Nanosecond) => Ok("tDn".into()), + DataType::Interval(IntervalUnit::YearMonth) => Ok("tiM".into()), + DataType::Interval(IntervalUnit::DayTime) => Ok("tiD".into()), + DataType::Interval(IntervalUnit::MonthDayNano) => Ok("tin".into()), + DataType::List(_) => Ok("+l".into()), + DataType::LargeList(_) => Ok("+L".into()), + DataType::Struct(_) => Ok("+s".into()), + DataType::Map(_, _) => Ok("+m".into()), + DataType::RunEndEncoded(_, _) => Ok("+r".into()), DataType::Dictionary(key_data_type, _) => get_format_string(key_data_type), DataType::Union(fields, mode) => { let formats = fields