This is an automated email from the ASF dual-hosted git repository.
mbrobbel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new b8ae8e013d Migrate `arrow-ipc` to Rust 2024 (#8457)
b8ae8e013d is described below
commit b8ae8e013d69816c1cdee5b2b6b8833a8b0c6a47
Author: Matthijs Brobbel <[email protected]>
AuthorDate: Fri Sep 26 15:55:46 2025 +0200
Migrate `arrow-ipc` to Rust 2024 (#8457)
# Which issue does this PR close?
- Contribute to #6827
# Rationale for this change
Splitting up #8227.
# What changes are included in this PR?
Migrate `arrow-ipc` to Rust 2024
# Are these changes tested?
CI
# Are there any user-facing changes?
Yes
---
arrow-ipc/Cargo.toml | 2 +-
arrow-ipc/benches/ipc_reader.rs | 10 +--
arrow-ipc/benches/ipc_writer.rs | 6 +-
arrow-ipc/regen.sh | 8 +-
arrow-ipc/src/convert.rs | 14 ++--
arrow-ipc/src/gen/File.rs | 19 +++--
arrow-ipc/src/gen/Message.rs | 48 ++++++-----
arrow-ipc/src/gen/Schema.rs | 135 ++++++++++++++++++-------------
arrow-ipc/src/gen/SparseTensor.rs | 28 ++++---
arrow-ipc/src/gen/Tensor.rs | 30 +++----
arrow-ipc/src/lib.rs | 12 +--
arrow-ipc/src/reader.rs | 34 ++++----
arrow-ipc/src/reader/stream.rs | 10 +--
arrow-ipc/src/tests/delta_dictionary.rs | 4 +-
arrow-ipc/src/writer.rs | 61 +++++++-------
arrow-ipc/tests/test_delta_dictionary.rs | 2 +-
16 files changed, 232 insertions(+), 191 deletions(-)
diff --git a/arrow-ipc/Cargo.toml b/arrow-ipc/Cargo.toml
index eb42a1ea95..1a58be10b6 100644
--- a/arrow-ipc/Cargo.toml
+++ b/arrow-ipc/Cargo.toml
@@ -25,7 +25,7 @@ authors = { workspace = true }
license = { workspace = true }
keywords = { workspace = true }
include = { workspace = true }
-edition = { workspace = true }
+edition = "2024"
rust-version = { workspace = true }
[lib]
diff --git a/arrow-ipc/benches/ipc_reader.rs b/arrow-ipc/benches/ipc_reader.rs
index ab77449eeb..ef1de88d32 100644
--- a/arrow-ipc/benches/ipc_reader.rs
+++ b/arrow-ipc/benches/ipc_reader.rs
@@ -16,14 +16,14 @@
// under the License.
use arrow_array::builder::{Date32Builder, Decimal128Builder, Int32Builder};
-use arrow_array::{builder::StringBuilder, RecordBatch};
+use arrow_array::{RecordBatch, builder::StringBuilder};
use arrow_buffer::Buffer;
use arrow_ipc::convert::fb_to_schema;
-use arrow_ipc::reader::{read_footer_length, FileDecoder, FileReader,
StreamReader};
+use arrow_ipc::reader::{FileDecoder, FileReader, StreamReader,
read_footer_length};
use arrow_ipc::writer::{FileWriter, IpcWriteOptions, StreamWriter};
-use arrow_ipc::{root_as_footer, Block, CompressionType};
+use arrow_ipc::{Block, CompressionType, root_as_footer};
use arrow_schema::{DataType, Field, Schema};
-use criterion::{criterion_group, criterion_main, Criterion};
+use criterion::{Criterion, criterion_group, criterion_main};
use std::io::{Cursor, Write};
use std::sync::Arc;
use tempfile::tempdir;
@@ -240,7 +240,7 @@ impl IPCBufferDecoder {
}
unsafe fn with_skip_validation(mut self, skip_validation: bool) -> Self {
- self.decoder = self.decoder.with_skip_validation(skip_validation);
+ self.decoder = unsafe {
self.decoder.with_skip_validation(skip_validation) };
self
}
diff --git a/arrow-ipc/benches/ipc_writer.rs b/arrow-ipc/benches/ipc_writer.rs
index 6b4d184b45..eda7e3c58f 100644
--- a/arrow-ipc/benches/ipc_writer.rs
+++ b/arrow-ipc/benches/ipc_writer.rs
@@ -16,11 +16,11 @@
// under the License.
use arrow_array::builder::{Date32Builder, Decimal128Builder, Int32Builder};
-use arrow_array::{builder::StringBuilder, RecordBatch};
-use arrow_ipc::writer::{FileWriter, IpcWriteOptions, StreamWriter};
+use arrow_array::{RecordBatch, builder::StringBuilder};
use arrow_ipc::CompressionType;
+use arrow_ipc::writer::{FileWriter, IpcWriteOptions, StreamWriter};
use arrow_schema::{DataType, Field, Schema};
-use criterion::{criterion_group, criterion_main, Criterion};
+use criterion::{Criterion, criterion_group, criterion_main};
use std::sync::Arc;
fn criterion_benchmark(c: &mut Criterion) {
diff --git a/arrow-ipc/regen.sh b/arrow-ipc/regen.sh
index b368bd1bc7..676ec9933c 100755
--- a/arrow-ipc/regen.sh
+++ b/arrow-ipc/regen.sh
@@ -88,9 +88,9 @@ use flatbuffers::EndianScalar;
HEREDOC
)
-SCHEMA_IMPORT="\nuse crate::gen::Schema::*;"
-SPARSE_TENSOR_IMPORT="\nuse crate::gen::SparseTensor::*;"
-TENSOR_IMPORT="\nuse crate::gen::Tensor::*;"
+SCHEMA_IMPORT="\nuse crate::r#gen::Schema::*;"
+SPARSE_TENSOR_IMPORT="\nuse crate::r#gen::SparseTensor::*;"
+TENSOR_IMPORT="\nuse crate::r#gen::Tensor::*;"
# For flatbuffer(1.12.0+), remove: use crate::${name}::\*;
names=("File" "Message" "Schema" "SparseTensor" "Tensor")
@@ -129,7 +129,7 @@ for f in `ls *.rs`; do
sed --in-place='' 's/TYPE__/TYPE_/g' $f
# Some files need prefixes
- if [[ $f == "File.rs" ]]; then
+ if [[ $f == "File.rs" ]]; then
# Now prefix the file with the static contents
echo -e "${PREFIX}" "${SCHEMA_IMPORT}" | cat - $f > temp && mv temp $f
elif [[ $f == "Message.rs" ]]; then
diff --git a/arrow-ipc/src/convert.rs b/arrow-ipc/src/convert.rs
index af0bdb1df3..24beb1f83a 100644
--- a/arrow-ipc/src/convert.rs
+++ b/arrow-ipc/src/convert.rs
@@ -29,7 +29,7 @@ use std::fmt::{Debug, Formatter};
use std::sync::Arc;
use crate::writer::DictionaryTracker;
-use crate::{KeyValue, Message, CONTINUATION_MARKER};
+use crate::{CONTINUATION_MARKER, KeyValue, Message};
use DataType::*;
/// Low level Arrow [Schema] to IPC bytes converter
@@ -279,9 +279,9 @@ pub fn try_schema_from_ipc_buffer(buffer: &[u8]) ->
Result<Schema, ArrowError> {
if buffer.len() < len as usize {
let actual_len = buffer.len();
- return Err(ArrowError::ParseError(
- format!("The buffer length ({actual_len}) is less than the
encapsulated message's reported length ({len})")
- ));
+ return Err(ArrowError::ParseError(format!(
+ "The buffer length ({actual_len}) is less than the encapsulated
message's reported length ({len})"
+ )));
}
let msg = crate::root_as_message(buffer)
@@ -760,7 +760,7 @@ pub(crate) fn get_fb_field_type<'a>(
children: Some(fbb.create_vector(&empty_fields[..])),
}
}
- List(ref list_type) => {
+ List(list_type) => {
let child = build_field(fbb, dictionary_tracker, list_type);
FBFieldType {
type_type: crate::Type::List,
@@ -769,7 +769,7 @@ pub(crate) fn get_fb_field_type<'a>(
}
}
ListView(_) | LargeListView(_) =>
unimplemented!("ListView/LargeListView not implemented"),
- LargeList(ref list_type) => {
+ LargeList(list_type) => {
let child = build_field(fbb, dictionary_tracker, list_type);
FBFieldType {
type_type: crate::Type::LargeList,
@@ -777,7 +777,7 @@ pub(crate) fn get_fb_field_type<'a>(
children: Some(fbb.create_vector(&[child])),
}
}
- FixedSizeList(ref list_type, len) => {
+ FixedSizeList(list_type, len) => {
let child = build_field(fbb, dictionary_tracker, list_type);
let mut builder = crate::FixedSizeListBuilder::new(fbb);
builder.add_listSize(*len);
diff --git a/arrow-ipc/src/gen/File.rs b/arrow-ipc/src/gen/File.rs
index 427cf75de0..ab22736147 100644
--- a/arrow-ipc/src/gen/File.rs
+++ b/arrow-ipc/src/gen/File.rs
@@ -18,7 +18,7 @@
#![allow(dead_code)]
#![allow(unused_imports)]
-use crate::gen::Schema::*;
+use crate::r#gen::Schema::*;
use flatbuffers::EndianScalar;
use std::{cmp::Ordering, mem};
// automatically generated by the FlatBuffers compiler, do not modify
@@ -49,21 +49,26 @@ impl<'a> flatbuffers::Follow<'a> for Block {
type Inner = &'a Block;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- <&'a Block>::follow(buf, loc)
+ unsafe { <&'a Block>::follow(buf, loc) }
}
}
impl<'a> flatbuffers::Follow<'a> for &'a Block {
type Inner = &'a Block;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- flatbuffers::follow_cast_ref::<Block>(buf, loc)
+ unsafe { flatbuffers::follow_cast_ref::<Block>(buf, loc) }
}
}
impl<'b> flatbuffers::Push for Block {
type Output = Block;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- let src = ::core::slice::from_raw_parts(self as *const Block as *const
u8, Self::size());
+ let src = unsafe {
+ ::core::slice::from_raw_parts(
+ self as *const Block as *const u8,
+ <Self as flatbuffers::Push>::size(),
+ )
+ };
dst.copy_from_slice(src);
}
#[inline]
@@ -200,7 +205,7 @@ impl<'a> flatbuffers::Follow<'a> for Footer<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -470,14 +475,14 @@ pub fn size_prefixed_root_as_footer_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Footer`.
pub unsafe fn root_as_footer_unchecked(buf: &[u8]) -> Footer {
- flatbuffers::root_unchecked::<Footer>(buf)
+ unsafe { flatbuffers::root_unchecked::<Footer>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size
prefixed Footer and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed
`Footer`.
pub unsafe fn size_prefixed_root_as_footer_unchecked(buf: &[u8]) -> Footer {
- flatbuffers::size_prefixed_root_unchecked::<Footer>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Footer>(buf) }
}
#[inline]
pub fn finish_footer_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
diff --git a/arrow-ipc/src/gen/Message.rs b/arrow-ipc/src/gen/Message.rs
index 928b41cc06..082461c900 100644
--- a/arrow-ipc/src/gen/Message.rs
+++ b/arrow-ipc/src/gen/Message.rs
@@ -18,9 +18,9 @@
#![allow(dead_code)]
#![allow(unused_imports)]
-use crate::gen::Schema::*;
-use crate::gen::SparseTensor::*;
-use crate::gen::Tensor::*;
+use crate::r#gen::Schema::*;
+use crate::r#gen::SparseTensor::*;
+use crate::r#gen::Tensor::*;
use flatbuffers::EndianScalar;
use std::{cmp::Ordering, mem};
// automatically generated by the FlatBuffers compiler, do not modify
@@ -78,7 +78,7 @@ impl<'a> flatbuffers::Follow<'a> for CompressionType {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i8>(buf, loc) };
Self(b)
}
}
@@ -87,7 +87,9 @@ impl flatbuffers::Push for CompressionType {
type Output = CompressionType;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i8>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i8>(dst, self.0);
+ }
}
}
@@ -176,7 +178,7 @@ impl<'a> flatbuffers::Follow<'a> for BodyCompressionMethod {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i8>(buf, loc) };
Self(b)
}
}
@@ -185,7 +187,9 @@ impl flatbuffers::Push for BodyCompressionMethod {
type Output = BodyCompressionMethod;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i8>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i8>(dst, self.0);
+ }
}
}
@@ -295,7 +299,7 @@ impl<'a> flatbuffers::Follow<'a> for MessageHeader {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
Self(b)
}
}
@@ -304,7 +308,9 @@ impl flatbuffers::Push for MessageHeader {
type Output = MessageHeader;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ }
}
}
@@ -368,22 +374,26 @@ impl<'a> flatbuffers::Follow<'a> for FieldNode {
type Inner = &'a FieldNode;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- <&'a FieldNode>::follow(buf, loc)
+ unsafe { <&'a FieldNode>::follow(buf, loc) }
}
}
impl<'a> flatbuffers::Follow<'a> for &'a FieldNode {
type Inner = &'a FieldNode;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- flatbuffers::follow_cast_ref::<FieldNode>(buf, loc)
+ unsafe { flatbuffers::follow_cast_ref::<FieldNode>(buf, loc) }
}
}
impl<'b> flatbuffers::Push for FieldNode {
type Output = FieldNode;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- let src =
- ::core::slice::from_raw_parts(self as *const FieldNode as *const
u8, Self::size());
+ let src = unsafe {
+ ::core::slice::from_raw_parts(
+ self as *const FieldNode as *const u8,
+ <Self as flatbuffers::Push>::size(),
+ )
+ };
dst.copy_from_slice(src);
}
#[inline]
@@ -491,7 +501,7 @@ impl<'a> flatbuffers::Follow<'a> for BodyCompression<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -634,7 +644,7 @@ impl<'a> flatbuffers::Follow<'a> for RecordBatch<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -901,7 +911,7 @@ impl<'a> flatbuffers::Follow<'a> for DictionaryBatch<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1057,7 +1067,7 @@ impl<'a> flatbuffers::Follow<'a> for Message<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1474,14 +1484,14 @@ pub fn size_prefixed_root_as_message_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Message`.
pub unsafe fn root_as_message_unchecked(buf: &[u8]) -> Message {
- flatbuffers::root_unchecked::<Message>(buf)
+ unsafe { flatbuffers::root_unchecked::<Message>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size
prefixed Message and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed
`Message`.
pub unsafe fn size_prefixed_root_as_message_unchecked(buf: &[u8]) -> Message {
- flatbuffers::size_prefixed_root_unchecked::<Message>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Message>(buf) }
}
#[inline]
pub fn finish_message_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
diff --git a/arrow-ipc/src/gen/Schema.rs b/arrow-ipc/src/gen/Schema.rs
index 223e5a2f6c..0472455ce0 100644
--- a/arrow-ipc/src/gen/Schema.rs
+++ b/arrow-ipc/src/gen/Schema.rs
@@ -97,7 +97,7 @@ impl<'a> flatbuffers::Follow<'a> for MetadataVersion {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -106,7 +106,9 @@ impl flatbuffers::Push for MetadataVersion {
type Output = MetadataVersion;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -219,7 +221,7 @@ impl<'a> flatbuffers::Follow<'a> for Feature {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i64>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i64>(buf, loc) };
Self(b)
}
}
@@ -228,7 +230,9 @@ impl flatbuffers::Push for Feature {
type Output = Feature;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i64>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i64>(dst, self.0);
+ }
}
}
@@ -308,7 +312,7 @@ impl<'a> flatbuffers::Follow<'a> for UnionMode {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -317,7 +321,9 @@ impl flatbuffers::Push for UnionMode {
type Output = UnionMode;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -400,7 +406,7 @@ impl<'a> flatbuffers::Follow<'a> for Precision {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -409,7 +415,9 @@ impl flatbuffers::Push for Precision {
type Output = Precision;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -489,7 +497,7 @@ impl<'a> flatbuffers::Follow<'a> for DateUnit {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -498,7 +506,9 @@ impl flatbuffers::Push for DateUnit {
type Output = DateUnit;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -592,7 +602,7 @@ impl<'a> flatbuffers::Follow<'a> for TimeUnit {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -601,7 +611,9 @@ impl flatbuffers::Push for TimeUnit {
type Output = TimeUnit;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -688,7 +700,7 @@ impl<'a> flatbuffers::Follow<'a> for IntervalUnit {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -697,7 +709,9 @@ impl flatbuffers::Push for IntervalUnit {
type Output = IntervalUnit;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -886,7 +900,7 @@ impl<'a> flatbuffers::Follow<'a> for Type {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
Self(b)
}
}
@@ -895,7 +909,9 @@ impl flatbuffers::Push for Type {
type Output = Type;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ }
}
}
@@ -980,7 +996,7 @@ impl<'a> flatbuffers::Follow<'a> for DictionaryKind {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -989,7 +1005,9 @@ impl flatbuffers::Push for DictionaryKind {
type Output = DictionaryKind;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -1071,7 +1089,7 @@ impl<'a> flatbuffers::Follow<'a> for Endianness {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -1080,7 +1098,9 @@ impl flatbuffers::Push for Endianness {
type Output = Endianness;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -1135,21 +1155,26 @@ impl<'a> flatbuffers::Follow<'a> for Buffer {
type Inner = &'a Buffer;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- <&'a Buffer>::follow(buf, loc)
+ unsafe { <&'a Buffer>::follow(buf, loc) }
}
}
impl<'a> flatbuffers::Follow<'a> for &'a Buffer {
type Inner = &'a Buffer;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- flatbuffers::follow_cast_ref::<Buffer>(buf, loc)
+ unsafe { flatbuffers::follow_cast_ref::<Buffer>(buf, loc) }
}
}
impl<'b> flatbuffers::Push for Buffer {
type Output = Buffer;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- let src = ::core::slice::from_raw_parts(self as *const Buffer as
*const u8, Self::size());
+ let src = unsafe {
+ ::core::slice::from_raw_parts(
+ self as *const Buffer as *const u8,
+ <Self as flatbuffers::Push>::size(),
+ )
+ };
dst.copy_from_slice(src);
}
#[inline]
@@ -1257,7 +1282,7 @@ impl<'a> flatbuffers::Follow<'a> for Null<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1337,7 +1362,7 @@ impl<'a> flatbuffers::Follow<'a> for Struct_<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1414,7 +1439,7 @@ impl<'a> flatbuffers::Follow<'a> for List<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1493,7 +1518,7 @@ impl<'a> flatbuffers::Follow<'a> for LargeList<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1573,7 +1598,7 @@ impl<'a> flatbuffers::Follow<'a> for ListView<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1652,7 +1677,7 @@ impl<'a> flatbuffers::Follow<'a> for LargeListView<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1731,7 +1756,7 @@ impl<'a> flatbuffers::Follow<'a> for FixedSizeList<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1861,7 +1886,7 @@ impl<'a> flatbuffers::Follow<'a> for Map<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1968,7 +1993,7 @@ impl<'a> flatbuffers::Follow<'a> for Union<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2102,7 +2127,7 @@ impl<'a> flatbuffers::Follow<'a> for Int<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2223,7 +2248,7 @@ impl<'a> flatbuffers::Follow<'a> for FloatingPoint<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2330,7 +2355,7 @@ impl<'a> flatbuffers::Follow<'a> for Utf8<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2408,7 +2433,7 @@ impl<'a> flatbuffers::Follow<'a> for Binary<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2487,7 +2512,7 @@ impl<'a> flatbuffers::Follow<'a> for LargeUtf8<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2566,7 +2591,7 @@ impl<'a> flatbuffers::Follow<'a> for LargeBinary<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2652,7 +2677,7 @@ impl<'a> flatbuffers::Follow<'a> for Utf8View<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2736,7 +2761,7 @@ impl<'a> flatbuffers::Follow<'a> for BinaryView<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2815,7 +2840,7 @@ impl<'a> flatbuffers::Follow<'a> for FixedSizeBinary<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2920,7 +2945,7 @@ impl<'a> flatbuffers::Follow<'a> for Bool<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3002,7 +3027,7 @@ impl<'a> flatbuffers::Follow<'a> for RunEndEncoded<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3085,7 +3110,7 @@ impl<'a> flatbuffers::Follow<'a> for Decimal<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3238,7 +3263,7 @@ impl<'a> flatbuffers::Follow<'a> for Date<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3356,7 +3381,7 @@ impl<'a> flatbuffers::Follow<'a> for Time<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3582,7 +3607,7 @@ impl<'a> flatbuffers::Follow<'a> for Timestamp<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3723,7 +3748,7 @@ impl<'a> flatbuffers::Follow<'a> for Interval<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3827,7 +3852,7 @@ impl<'a> flatbuffers::Follow<'a> for Duration<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -3934,7 +3959,7 @@ impl<'a> flatbuffers::Follow<'a> for KeyValue<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -4062,7 +4087,7 @@ impl<'a> flatbuffers::Follow<'a> for
DictionaryEncoding<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -4261,7 +4286,7 @@ impl<'a> flatbuffers::Follow<'a> for Field<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -5326,7 +5351,7 @@ impl<'a> flatbuffers::Follow<'a> for Schema<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -5578,14 +5603,14 @@ pub fn size_prefixed_root_as_schema_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Schema`.
pub unsafe fn root_as_schema_unchecked(buf: &[u8]) -> Schema {
- flatbuffers::root_unchecked::<Schema>(buf)
+ unsafe { flatbuffers::root_unchecked::<Schema>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size
prefixed Schema and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed
`Schema`.
pub unsafe fn size_prefixed_root_as_schema_unchecked(buf: &[u8]) -> Schema {
- flatbuffers::size_prefixed_root_unchecked::<Schema>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Schema>(buf) }
}
#[inline]
pub fn finish_schema_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
diff --git a/arrow-ipc/src/gen/SparseTensor.rs
b/arrow-ipc/src/gen/SparseTensor.rs
index 21cb7e116c..1cadd1d3e0 100644
--- a/arrow-ipc/src/gen/SparseTensor.rs
+++ b/arrow-ipc/src/gen/SparseTensor.rs
@@ -18,8 +18,8 @@
#![allow(dead_code)]
#![allow(unused_imports)]
-use crate::gen::Schema::*;
-use crate::gen::Tensor::*;
+use crate::r#gen::Schema::*;
+use crate::r#gen::Tensor::*;
use flatbuffers::EndianScalar;
use std::{cmp::Ordering, mem};
// automatically generated by the FlatBuffers compiler, do not modify
@@ -79,7 +79,7 @@ impl<'a> flatbuffers::Follow<'a> for
SparseMatrixCompressedAxis {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<i16>(buf, loc) };
Self(b)
}
}
@@ -88,7 +88,9 @@ impl flatbuffers::Push for SparseMatrixCompressedAxis {
type Output = SparseMatrixCompressedAxis;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<i16>(dst, self.0);
+ }
}
}
@@ -182,7 +184,7 @@ impl<'a> flatbuffers::Follow<'a> for SparseTensorIndex {
type Inner = Self;
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
Self(b)
}
}
@@ -191,7 +193,9 @@ impl flatbuffers::Push for SparseTensorIndex {
type Output = SparseTensorIndex;
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ unsafe {
+ flatbuffers::emplace_scalar::<u8>(dst, self.0);
+ }
}
}
@@ -267,7 +271,7 @@ impl<'a> flatbuffers::Follow<'a> for
SparseTensorIndexCOO<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -479,7 +483,7 @@ impl<'a> flatbuffers::Follow<'a> for
SparseMatrixIndexCSX<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -750,7 +754,7 @@ impl<'a> flatbuffers::Follow<'a> for
SparseTensorIndexCSF<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1078,7 +1082,7 @@ impl<'a> flatbuffers::Follow<'a> for SparseTensor<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -2263,14 +2267,14 @@ pub fn
size_prefixed_root_as_sparse_tensor_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid
`SparseTensor`.
pub unsafe fn root_as_sparse_tensor_unchecked(buf: &[u8]) -> SparseTensor {
- flatbuffers::root_unchecked::<SparseTensor>(buf)
+ unsafe { flatbuffers::root_unchecked::<SparseTensor>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size
prefixed SparseTensor and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed
`SparseTensor`.
pub unsafe fn size_prefixed_root_as_sparse_tensor_unchecked(buf: &[u8]) ->
SparseTensor {
- flatbuffers::size_prefixed_root_unchecked::<SparseTensor>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<SparseTensor>(buf) }
}
#[inline]
pub fn finish_sparse_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
diff --git a/arrow-ipc/src/gen/Tensor.rs b/arrow-ipc/src/gen/Tensor.rs
index b332a5d77e..80be30b686 100644
--- a/arrow-ipc/src/gen/Tensor.rs
+++ b/arrow-ipc/src/gen/Tensor.rs
@@ -18,7 +18,7 @@
#![allow(dead_code)]
#![allow(unused_imports)]
-use crate::gen::Schema::*;
+use crate::r#gen::Schema::*;
use flatbuffers::EndianScalar;
use std::{cmp::Ordering, mem};
// automatically generated by the FlatBuffers compiler, do not modify
@@ -40,13 +40,13 @@ impl<'a> flatbuffers::Follow<'a> for TensorDim<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
impl<'a> TensorDim<'a> {
- pub const VT_SIZE_: flatbuffers::VOffsetT = 4;
+ pub const VT_SIZE: flatbuffers::VOffsetT = 4;
pub const VT_NAME: flatbuffers::VOffsetT = 6;
#[inline]
@@ -59,7 +59,7 @@ impl<'a> TensorDim<'a> {
args: &'args TensorDimArgs<'args>,
) -> flatbuffers::WIPOffset<TensorDim<'bldr>> {
let mut builder = TensorDimBuilder::new(_fbb);
- builder.add_size_(args.size_);
+ builder.add_size(args.size);
if let Some(x) = args.name {
builder.add_name(x);
}
@@ -68,11 +68,11 @@ impl<'a> TensorDim<'a> {
/// Length of dimension
#[inline]
- pub fn size_(&self) -> i64 {
+ pub fn size(&self) -> i64 {
// Safety:
// Created from valid Table for this object
// which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(TensorDim::VT_SIZE_, Some(0)).unwrap() }
+ unsafe { self._tab.get::<i64>(TensorDim::VT_SIZE, Some(0)).unwrap() }
}
/// Name of the dimension, optional
#[inline]
@@ -95,21 +95,21 @@ impl flatbuffers::Verifiable for TensorDim<'_> {
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use flatbuffers::Verifiable;
v.visit_table(pos)?
- .visit_field::<i64>("size_", Self::VT_SIZE_, false)?
+ .visit_field::<i64>("size", Self::VT_SIZE, false)?
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("name",
Self::VT_NAME, false)?
.finish();
Ok(())
}
}
pub struct TensorDimArgs<'a> {
- pub size_: i64,
+ pub size: i64,
pub name: Option<flatbuffers::WIPOffset<&'a str>>,
}
impl<'a> Default for TensorDimArgs<'a> {
#[inline]
fn default() -> Self {
TensorDimArgs {
- size_: 0,
+ size: 0,
name: None,
}
}
@@ -121,8 +121,8 @@ pub struct TensorDimBuilder<'a: 'b, 'b, A:
flatbuffers::Allocator + 'a> {
}
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TensorDimBuilder<'a, 'b, A> {
#[inline]
- pub fn add_size_(&mut self, size_: i64) {
- self.fbb_.push_slot::<i64>(TensorDim::VT_SIZE_, size_, 0);
+ pub fn add_size(&mut self, size: i64) {
+ self.fbb_.push_slot::<i64>(TensorDim::VT_SIZE, size, 0);
}
#[inline]
pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
@@ -147,7 +147,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a>
TensorDimBuilder<'a, 'b, A> {
impl core::fmt::Debug for TensorDim<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut ds = f.debug_struct("TensorDim");
- ds.field("size_", &self.size_());
+ ds.field("size", &self.size());
ds.field("name", &self.name());
ds.finish()
}
@@ -164,7 +164,7 @@ impl<'a> flatbuffers::Follow<'a> for Tensor<'a> {
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self {
- _tab: flatbuffers::Table::new(buf, loc),
+ _tab: unsafe { flatbuffers::Table::new(buf, loc) },
}
}
}
@@ -1182,14 +1182,14 @@ pub fn size_prefixed_root_as_tensor_with_opts<'b, 'o>(
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Tensor`.
pub unsafe fn root_as_tensor_unchecked(buf: &[u8]) -> Tensor {
- flatbuffers::root_unchecked::<Tensor>(buf)
+ unsafe { flatbuffers::root_unchecked::<Tensor>(buf) }
}
#[inline]
/// Assumes, without verification, that a buffer of bytes contains a size
prefixed Tensor and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed
`Tensor`.
pub unsafe fn size_prefixed_root_as_tensor_unchecked(buf: &[u8]) -> Tensor {
- flatbuffers::size_prefixed_root_unchecked::<Tensor>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Tensor>(buf) }
}
#[inline]
pub fn finish_tensor_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
diff --git a/arrow-ipc/src/lib.rs b/arrow-ipc/src/lib.rs
index 447c85cc88..2798f1f10b 100644
--- a/arrow-ipc/src/lib.rs
+++ b/arrow-ipc/src/lib.rs
@@ -61,13 +61,13 @@ mod tests;
#[allow(clippy::redundant_field_names)]
#[allow(non_camel_case_types)]
#[allow(missing_docs)] // Because this is autogenerated
-pub mod gen;
+pub mod r#gen;
-pub use self::gen::File::*;
-pub use self::gen::Message::*;
-pub use self::gen::Schema::*;
-pub use self::gen::SparseTensor::*;
-pub use self::gen::Tensor::*;
+pub use self::r#gen::File::*;
+pub use self::r#gen::Message::*;
+pub use self::r#gen::Schema::*;
+pub use self::r#gen::SparseTensor::*;
+pub use self::r#gen::Tensor::*;
const ARROW_MAGIC: [u8; 6] = [b'A', b'R', b'R', b'O', b'W', b'1'];
const CONTINUATION_MARKER: [u8; 4] = [0xff; 4];
diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs
index 7702c814e8..987188548f 100644
--- a/arrow-ipc/src/reader.rs
+++ b/arrow-ipc/src/reader.rs
@@ -43,8 +43,8 @@ use arrow_data::{ArrayData, ArrayDataBuilder, UnsafeFlag};
use arrow_schema::*;
use crate::compression::CompressionCodec;
-use crate::gen::Message::{self};
-use crate::{Block, FieldNode, MetadataVersion, CONTINUATION_MARKER};
+use crate::r#gen::Message::{self};
+use crate::{Block, CONTINUATION_MARKER, FieldNode, MetadataVersion};
use DataType::*;
/// Read a buffer based on offset and length
@@ -116,13 +116,13 @@ impl RecordBatchDecoder<'_> {
let buffers = [self.next_buffer()?, self.next_buffer()?];
self.create_primitive_array(field_node, data_type, &buffers)
}
- List(ref list_field) | LargeList(ref list_field) | Map(ref
list_field, _) => {
+ List(list_field) | LargeList(list_field) | Map(list_field, _) => {
let list_node = self.next_node(field)?;
let list_buffers = [self.next_buffer()?, self.next_buffer()?];
let values = self.create_array(list_field, variadic_counts)?;
self.create_list_array(list_node, data_type, &list_buffers,
values)
}
- FixedSizeList(ref list_field, _) => {
+ FixedSizeList(list_field, _) => {
let list_node = self.next_node(field)?;
let list_buffers = [self.next_buffer()?];
let values = self.create_array(list_field, variadic_counts)?;
@@ -790,7 +790,7 @@ fn get_dictionary_values(
// values array, we need to retrieve this from the schema.
// Get an array representing this dictionary's values.
let dictionary_values: ArrayRef = match first_field.data_type() {
- DataType::Dictionary(_, ref value_type) => {
+ DataType::Dictionary(_, value_type) => {
// Make a fake schema for the dictionary batch.
let value = value_type.as_ref().clone();
let schema = Schema::new(vec![Field::new("", value, true)]);
@@ -979,7 +979,7 @@ impl FileDecoder {
/// For example, some programs may wish to trust reading IPC files written
/// by the same process that created the files.
pub unsafe fn with_skip_validation(mut self, skip_validation: bool) ->
Self {
- self.skip_validation.set(skip_validation);
+ unsafe { self.skip_validation.set(skip_validation) };
self
}
@@ -1286,7 +1286,7 @@ impl<R: Read + Seek> FileReader<R> {
/// Try to create a new file reader.
///
/// There is no internal buffering. If buffered reads are needed you
likely want to use
- /// [`FileReader::try_new_buffered`] instead.
+ /// [`FileReader::try_new_buffered`] instead.
///
/// # Errors
///
@@ -1360,7 +1360,7 @@ impl<R: Read + Seek> FileReader<R> {
///
/// See [`FileDecoder::with_skip_validation`]
pub unsafe fn with_skip_validation(mut self, skip_validation: bool) ->
Self {
- self.decoder = self.decoder.with_skip_validation(skip_validation);
+ self.decoder = unsafe {
self.decoder.with_skip_validation(skip_validation) };
self
}
}
@@ -1673,7 +1673,7 @@ impl<R: Read> StreamReader<R> {
///
/// See [`FileDecoder::with_skip_validation`]
pub unsafe fn with_skip_validation(mut self, skip_validation: bool) ->
Self {
- self.skip_validation.set(skip_validation);
+ unsafe { self.skip_validation.set(skip_validation) };
self
}
}
@@ -1814,7 +1814,7 @@ mod tests {
use crate::convert::fb_to_schema;
use crate::writer::{
- unslice_run_array, write_message, DictionaryTracker, IpcDataGenerator,
IpcWriteOptions,
+ DictionaryTracker, IpcDataGenerator, IpcWriteOptions,
unslice_run_array, write_message,
};
use super::*;
@@ -2699,9 +2699,9 @@ mod tests {
)])
.unwrap();
- let gen = IpcDataGenerator {};
+ let r#gen = IpcDataGenerator {};
let mut dict_tracker = DictionaryTracker::new(false);
- let (_, encoded) = gen
+ let (_, encoded) = r#gen
.encode(
&batch,
&mut dict_tracker,
@@ -2742,9 +2742,9 @@ mod tests {
)])
.unwrap();
- let gen = IpcDataGenerator {};
+ let r#gen = IpcDataGenerator {};
let mut dict_tracker = DictionaryTracker::new(false);
- let (_, encoded) = gen
+ let (_, encoded) = r#gen
.encode(
&batch,
&mut dict_tracker,
@@ -2987,7 +2987,7 @@ mod tests {
expect_ipc_validation_error(
Arc::new(array),
- "Invalid argument error: Offset invariant failure: offset at
position 2 out of bounds: 4 > 2"
+ "Invalid argument error: Offset invariant failure: offset at
position 2 out of bounds: 4 > 2",
);
}
@@ -3009,7 +3009,7 @@ mod tests {
};
expect_ipc_validation_error(
Arc::new(array),
- "Invalid argument error: Invalid UTF8 sequence at string index 3
(3..45): invalid utf-8 sequence of 1 bytes from index 38"
+ "Invalid argument error: Invalid UTF8 sequence at string index 3
(3..45): invalid utf-8 sequence of 1 bytes from index 38",
);
}
@@ -3032,7 +3032,7 @@ mod tests {
};
expect_ipc_validation_error(
Arc::new(array),
- "Invalid argument error: Encountered non-UTF-8 data at index 3:
invalid utf-8 sequence of 1 bytes from index 38"
+ "Invalid argument error: Encountered non-UTF-8 data at index 3:
invalid utf-8 sequence of 1 bytes from index 38",
);
}
diff --git a/arrow-ipc/src/reader/stream.rs b/arrow-ipc/src/reader/stream.rs
index b276e4fe47..d0d833b471 100644
--- a/arrow-ipc/src/reader/stream.rs
+++ b/arrow-ipc/src/reader/stream.rs
@@ -25,8 +25,8 @@ use arrow_data::UnsafeFlag;
use arrow_schema::{ArrowError, SchemaRef};
use crate::convert::MessageBuffer;
-use crate::reader::{read_dictionary_impl, RecordBatchDecoder};
-use crate::{MessageHeader, CONTINUATION_MARKER};
+use crate::reader::{RecordBatchDecoder, read_dictionary_impl};
+use crate::{CONTINUATION_MARKER, MessageHeader};
/// A low-level interface for reading [`RecordBatch`] data from a stream of
bytes
///
@@ -260,12 +260,12 @@ impl StreamDecoder {
t => {
return Err(ArrowError::IpcError(format!(
"Message type unsupported by StreamDecoder:
{t:?}"
- )))
+ )));
}
}
}
DecoderState::Finished => {
- return Err(ArrowError::IpcError("Unexpected
EOS".to_string()))
+ return Err(ArrowError::IpcError("Unexpected
EOS".to_string()));
}
}
}
@@ -293,7 +293,7 @@ mod tests {
use super::*;
use crate::writer::{IpcWriteOptions, StreamWriter};
use arrow_array::{
- types::Int32Type, DictionaryArray, Int32Array, Int64Array,
RecordBatch, RunArray,
+ DictionaryArray, Int32Array, Int64Array, RecordBatch, RunArray,
types::Int32Type,
};
use arrow_schema::{DataType, Field, Schema};
diff --git a/arrow-ipc/src/tests/delta_dictionary.rs
b/arrow-ipc/src/tests/delta_dictionary.rs
index 3f2f99b751..dfd8cd33e5 100644
--- a/arrow-ipc/src/tests/delta_dictionary.rs
+++ b/arrow-ipc/src/tests/delta_dictionary.rs
@@ -24,8 +24,8 @@ use crate::{
writer::FileWriter,
};
use arrow_array::{
- builder::StringDictionaryBuilder, types::Int32Type, Array, ArrayRef,
DictionaryArray,
- RecordBatch, StringArray,
+ Array, ArrayRef, DictionaryArray, RecordBatch, StringArray,
builder::StringDictionaryBuilder,
+ types::Int32Type,
};
use arrow_schema::{DataType, Field, Schema};
use std::io::Cursor;
diff --git a/arrow-ipc/src/writer.rs b/arrow-ipc/src/writer.rs
index ed05998ad1..beb66c940b 100644
--- a/arrow-ipc/src/writer.rs
+++ b/arrow-ipc/src/writer.rs
@@ -38,13 +38,13 @@ use arrow_array::types::{Int16Type, Int32Type, Int64Type,
RunEndIndexType};
use arrow_array::*;
use arrow_buffer::bit_util;
use arrow_buffer::{ArrowNativeType, Buffer, MutableBuffer};
-use arrow_data::{layout, ArrayData, ArrayDataBuilder, BufferSpec};
+use arrow_data::{ArrayData, ArrayDataBuilder, BufferSpec, layout};
use arrow_schema::*;
+use crate::CONTINUATION_MARKER;
use crate::compression::CompressionCodec;
pub use crate::compression::CompressionContext;
use crate::convert::IpcSchemaEncoder;
-use crate::CONTINUATION_MARKER;
/// IPC write options used to control the behaviour of the [`IpcDataGenerator`]
#[derive(Debug, Clone)]
@@ -181,7 +181,7 @@ impl Default for IpcWriteOptions {
/// let mut dictionary_tracker = DictionaryTracker::new(error_on_replacement);
///
/// let mut compression_context = CompressionContext::default();
-///
+///
/// // encode the batch into zero or more encoded dictionaries
/// // and the data for the actual array.
/// let data_gen = IpcDataGenerator::default();
@@ -931,8 +931,7 @@ impl DictionaryTracker {
return Ok(DictionaryUpdate::None);
}
- const REPLACEMENT_ERROR: &str =
- "Dictionary replacement detected when writing IPC file format. \
+ const REPLACEMENT_ERROR: &str = "Dictionary replacement detected when
writing IPC file format. \
Arrow IPC files only support a single dictionary for a given
field \
across all batches.";
@@ -2032,10 +2031,10 @@ mod tests {
use arrow_array::types::*;
use arrow_buffer::ScalarBuffer;
+ use crate::MetadataVersion;
use crate::convert::fb_to_schema;
use crate::reader::*;
use crate::root_as_footer;
- use crate::MetadataVersion;
use super::*;
@@ -2319,9 +2318,9 @@ mod tests {
false,
)]));
- let gen = IpcDataGenerator::default();
+ let r#gen = IpcDataGenerator::default();
let mut dict_tracker = DictionaryTracker::new(false);
- gen.schema_to_bytes_with_dictionary_tracker(
+ r#gen.schema_to_bytes_with_dictionary_tracker(
&schema,
&mut dict_tracker,
&IpcWriteOptions::default(),
@@ -2329,13 +2328,14 @@ mod tests {
let batch = RecordBatch::try_new(schema,
vec![Arc::new(union)]).unwrap();
- gen.encode(
- &batch,
- &mut dict_tracker,
- &Default::default(),
- &mut Default::default(),
- )
- .unwrap();
+ r#gen
+ .encode(
+ &batch,
+ &mut dict_tracker,
+ &Default::default(),
+ &mut Default::default(),
+ )
+ .unwrap();
// The encoder will assign dict IDs itself to ensure uniqueness and
ignore the dict ID in the schema
// so we expect the dict will be keyed to 0
@@ -2367,9 +2367,9 @@ mod tests {
false,
)]));
- let gen = IpcDataGenerator::default();
+ let r#gen = IpcDataGenerator::default();
let mut dict_tracker = DictionaryTracker::new(false);
- gen.schema_to_bytes_with_dictionary_tracker(
+ r#gen.schema_to_bytes_with_dictionary_tracker(
&schema,
&mut dict_tracker,
&IpcWriteOptions::default(),
@@ -2377,13 +2377,14 @@ mod tests {
let batch = RecordBatch::try_new(schema, vec![struct_array]).unwrap();
- gen.encode(
- &batch,
- &mut dict_tracker,
- &Default::default(),
- &mut Default::default(),
- )
- .unwrap();
+ r#gen
+ .encode(
+ &batch,
+ &mut dict_tracker,
+ &Default::default(),
+ &mut Default::default(),
+ )
+ .unwrap();
assert!(dict_tracker.written.contains_key(&0));
}
@@ -2687,13 +2688,9 @@ mod tests {
#[test]
fn test_large_slice_uint32() {
- ensure_roundtrip(Arc::new(UInt32Array::from_iter((0..8000).map(|i| {
- if i % 2 == 0 {
- Some(i)
- } else {
- None
- }
- }))));
+ ensure_roundtrip(Arc::new(UInt32Array::from_iter(
+ (0..8000).map(|i| if i % 2 == 0 { Some(i) } else { None }),
+ )));
}
#[test]
@@ -3508,7 +3505,7 @@ mod tests {
// Set metadata on both the schema and a field within it.
let schema = Arc::new(
Schema::new(vec![
- Field::new("a", DataType::Int64,
true).with_metadata(metadata.clone())
+ Field::new("a", DataType::Int64,
true).with_metadata(metadata.clone()),
])
.with_metadata(metadata)
.clone(),
diff --git a/arrow-ipc/tests/test_delta_dictionary.rs
b/arrow-ipc/tests/test_delta_dictionary.rs
index f7c4e7f325..bd4fbf8312 100644
--- a/arrow-ipc/tests/test_delta_dictionary.rs
+++ b/arrow-ipc/tests/test_delta_dictionary.rs
@@ -16,8 +16,8 @@
// under the License.
use arrow_array::{
- builder::{ListBuilder, PrimitiveDictionaryBuilder,
StringDictionaryBuilder},
Array, ArrayRef, DictionaryArray, ListArray, RecordBatch, StringArray,
+ builder::{ListBuilder, PrimitiveDictionaryBuilder,
StringDictionaryBuilder},
};
use arrow_ipc::reader::StreamReader;
use arrow_ipc::writer::{DictionaryHandling, IpcWriteOptions, StreamWriter};