This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new f52a100 ARROW-10938: [Rust] upgrade dependency "flatbuffers" to 0.8
f52a100 is described below
commit f52a100c3bf71904b73b122238111bb50c90d915
Author: mqy <[email protected]>
AuthorDate: Mon Dec 21 08:07:00 2020 -0500
ARROW-10938: [Rust] upgrade dependency "flatbuffers" to 0.8
[flatbuffers](https://crates.io/crates/flatbuffers) 0.8.0 was released on
Dec 10, 2020, with some notable changes:
- new verifier
- common rust traits to FlatBufferBuilder
- new VectorIter
- add FlatBufferBuilder::force_defaults API
- Optional Scalars
- up to 2018 edition
- possible performance speedup
- ... and minor breaking change to some APIs, for example: remove "get_",
return Result.
flatbuffers 0.8.0 requires the latest flatc, the git commit for flatc is
updated too.
I deliberately commit all changes step by step to make them clear.
Closes #8936 from mqy/flatbuffers-0.8.0
Authored-by: mqy <[email protected]>
Signed-off-by: Andrew Lamb <[email protected]>
---
rust/arrow-flight/src/utils.rs | 31 +-
rust/arrow/Cargo.toml | 2 +-
rust/arrow/regen.sh | 58 ++-
rust/arrow/src/ipc/convert.rs | 24 +-
rust/arrow/src/ipc/gen/File.rs | 118 +++++-
rust/arrow/src/ipc/gen/Message.rs | 235 +++++++++++-
rust/arrow/src/ipc/gen/Schema.rs | 677 +++++++++++++++++++++++++++++++--
rust/arrow/src/ipc/gen/SparseTensor.rs | 269 ++++++++++++-
rust/arrow/src/ipc/gen/Tensor.rs | 129 ++++++-
rust/arrow/src/ipc/reader.rs | 21 +-
rust/parquet/src/arrow/schema.rs | 21 +-
11 files changed, 1442 insertions(+), 143 deletions(-)
diff --git a/rust/arrow-flight/src/utils.rs b/rust/arrow-flight/src/utils.rs
index 995aa18..c2e01fb 100644
--- a/rust/arrow-flight/src/utils.rs
+++ b/rust/arrow-flight/src/utils.rs
@@ -85,10 +85,11 @@ pub fn flight_data_from_arrow_schema(
impl TryFrom<&FlightData> for Schema {
type Error = ArrowError;
fn try_from(data: &FlightData) -> Result<Self> {
- convert::schema_from_bytes(&data.data_header[..]).ok_or_else(|| {
- ArrowError::ParseError(
- "Unable to convert flight data to Arrow schema".to_string(),
- )
+ convert::schema_from_bytes(&data.data_header[..]).map_err(|err| {
+ ArrowError::ParseError(format!(
+ "Unable to convert flight data to Arrow schema: {}",
+ err
+ ))
})
}
}
@@ -99,10 +100,11 @@ impl TryFrom<&FlightData> for Schema {
impl TryFrom<&SchemaResult> for Schema {
type Error = ArrowError;
fn try_from(data: &SchemaResult) -> Result<Self> {
- convert::schema_from_bytes(&data.schema[..]).ok_or_else(|| {
- ArrowError::ParseError(
- "Unable to convert schema result to Arrow schema".to_string(),
- )
+ convert::schema_from_bytes(&data.schema[..]).map_err(|err| {
+ ArrowError::ParseError(format!(
+ "Unable to convert schema result to Arrow schema: {}",
+ err
+ ))
})
}
}
@@ -113,7 +115,18 @@ pub fn flight_data_to_arrow_batch(
schema: SchemaRef,
) -> Option<Result<RecordBatch>> {
// check that the data_header is a record batch message
- let message = arrow::ipc::get_root_as_message(&data.data_header[..]);
+ let res = arrow::ipc::root_as_message(&data.data_header[..]);
+
+ // Catch error.
+ if let Err(err) = res {
+ return Some(Err(ArrowError::ParseError(format!(
+ "Unable to get root as message: {:?}",
+ err
+ ))));
+ }
+
+ let message = res.unwrap();
+
let dictionaries_by_field = Vec::new();
message
diff --git a/rust/arrow/Cargo.toml b/rust/arrow/Cargo.toml
index a29583e..7142a0b 100644
--- a/rust/arrow/Cargo.toml
+++ b/rust/arrow/Cargo.toml
@@ -47,7 +47,7 @@ regex = "1.3"
lazy_static = "1.4"
packed_simd = { version = "0.3.4", optional = true, package = "packed_simd_2" }
chrono = "0.4"
-flatbuffers = "0.6"
+flatbuffers = "^0.8"
hex = "0.4"
prettytable-rs = { version = "0.8.0", optional = true }
lexical-core = "^0.7"
diff --git a/rust/arrow/regen.sh b/rust/arrow/regen.sh
index 14596c6..4bc35a4 100755
--- a/rust/arrow/regen.sh
+++ b/rust/arrow/regen.sh
@@ -24,48 +24,42 @@ pushd $DIR/../../
# As of 2020-12-06, the snapshot flatc version is not changed since "1.12.0",
# so let's build flatc from source.
+echo "Build flatc from source ..."
+
FB_URL="https://github.com/google/flatbuffers"
-FB_COMMIT="2046bffa40400904c926c2a5bedab67a8d6b7e08"
+FB_COMMIT="05192553f434d10c5f585aeb6a07a55a6ac702a5"
FB_DIR="rust/arrow/.flatbuffers"
FLATC="$FB_DIR/bazel-bin/flatc"
-if [ ! -e "$FLATC" ]; then
- echo "$FLATC: not found, let's build it ..."
-
- if [ -z $(which bazel) ]; then
- echo "bazel is required to build flatc"
- exit 1
- fi
+if [ -z $(which bazel) ]; then
+ echo "bazel is required to build flatc"
+ exit 1
+fi
- echo "Bazel version: $(bazel version | head -1 | awk -F':' '{print $2}')"
+echo "Bazel version: $(bazel version | head -1 | awk -F':' '{print $2}')"
- if [ ! -e $FB_DIR ]; then
- echo "git clone $FB_URL ..."
- git clone -b master --no-tag --depth 1 $FB_URL $FB_DIR
- else
- echo "git pull $FB_URL ..."
- git -C $FB_DIR pull
- fi
+if [ ! -e $FB_DIR ]; then
+ echo "git clone $FB_URL ..."
+ git clone -b master --no-tag --depth 1 $FB_URL $FB_DIR
+else
+ echo "git pull $FB_URL ..."
+ git -C $FB_DIR pull
+fi
- echo "hard reset to $FB_COMMIT"
- git -C $FB_DIR reset --hard $FB_COMMIT
+echo "hard reset to $FB_COMMIT"
+git -C $FB_DIR reset --hard $FB_COMMIT
- pushd $FB_DIR
- echo "run: bazel build :flatc ..."
- bazel build :flatc
- popd
-fi
+pushd $FB_DIR
+echo "run: bazel build :flatc ..."
+bazel build :flatc
+popd
# Execute the code generation:
-$FLATC --rust -o rust/arrow/src/ipc/gen/ format/*.fbs
+$FLATC --filename-suffix "" --rust -o rust/arrow/src/ipc/gen/ format/*.fbs
# Now the files are wrongly named so we have to change that.
popd
pushd $DIR/src/ipc/gen
-for f in `ls *_generated.rs`; do
- adj_length=$((${#f}-13))
- mv $f "${f:0:$adj_length}.rs"
-done
PREFIX=$(cat <<'HEREDOC'
// Licensed to the Apache Software Foundation (ASF) under one
@@ -98,7 +92,7 @@ SCHEMA_IMPORT="\nuse crate::ipc::gen::Schema::*;"
SPARSE_TENSOR_IMPORT="\nuse crate::ipc::gen::SparseTensor::*;"
TENSOR_IMPORT="\nuse crate::ipc::gen::Tensor::*;"
-# For flatbuffer(1.12.0+), remove: use crate::${name}_generated::\*;
+# For flatbuffer(1.12.0+), remove: use crate::${name}::\*;
names=("File" "Message" "Schema" "SparseTensor" "Tensor")
# Remove all generated lines we don't need
@@ -126,11 +120,13 @@ for f in `ls *.rs`; do
# required by flatc 1.12.0+
sed -i '' "/\#\!\[allow(unused_imports, dead_code)\]/d" $f
for name in ${names[@]}; do
- sed -i '' "/use crate::${name}_generated::\*;/d" $f
+ sed -i '' "/use crate::${name}::\*;/d" $f
+ sed -i '' "s/use self::flatbuffers::Verifiable;/use
flatbuffers::Verifiable;/g" $f
done
- # Replace all occurrences of type__ with type_
+ # Replace all occurrences of "type__" with "type_", "TYPE__" with "TYPE_".
sed -i '' 's/type__/type_/g' $f
+ sed -i '' 's/TYPE__/TYPE_/g' $f
# Some files need prefixes
if [[ $f == "File.rs" ]]; then
diff --git a/rust/arrow/src/ipc/convert.rs b/rust/arrow/src/ipc/convert.rs
index b1368fc..f003d6e 100644
--- a/rust/arrow/src/ipc/convert.rs
+++ b/rust/arrow/src/ipc/convert.rs
@@ -18,6 +18,7 @@
//! Utilities for converting between IPC types and native Arrow types
use crate::datatypes::{DataType, DateUnit, Field, IntervalUnit, Schema,
TimeUnit};
+use crate::error::{ArrowError, Result};
use crate::ipc;
use flatbuffers::{
@@ -123,9 +124,20 @@ pub fn fb_to_schema(fb: ipc::Schema) -> Schema {
}
/// Deserialize an IPC message into a schema
-pub fn schema_from_bytes(bytes: &[u8]) -> Option<Schema> {
- let ipc = ipc::get_root_as_message(bytes);
- ipc.header_as_schema().map(fb_to_schema)
+pub fn schema_from_bytes(bytes: &[u8]) -> Result<Schema> {
+ if let Ok(ipc) = ipc::root_as_message(bytes) {
+ if let Some(schema) = ipc.header_as_schema().map(fb_to_schema) {
+ Ok(schema)
+ } else {
+ Err(ArrowError::IoError(
+ "Unable to get head as schema".to_string(),
+ ))
+ }
+ } else {
+ Err(ArrowError::IoError(
+ "Unable to get root as message".to_string(),
+ ))
+ }
}
/// Get the Arrow data type from the flatbuffer Field table
@@ -777,7 +789,7 @@ mod tests {
let fb = schema_to_fb(&schema);
// read back fields
- let ipc = ipc::get_root_as_schema(fb.finished_data());
+ let ipc = ipc::root_as_schema(fb.finished_data()).unwrap();
let schema2 = fb_to_schema(ipc);
assert_eq!(schema, schema2);
}
@@ -794,7 +806,7 @@ mod tests {
4, 0, 6, 0, 0, 0, 32, 0, 0, 0, 6, 0, 0, 0, 102, 105, 101, 108,
100, 49, 0, 0,
0, 0, 0, 0,
];
- let ipc = ipc::get_root_as_message(&bytes[..]);
+ let ipc = ipc::root_as_message(&bytes[..]).unwrap();
let schema = ipc.header_as_schema().unwrap();
// a message generated from Rust, same as the Python one
@@ -806,7 +818,7 @@ mod tests {
8, 0, 4, 0, 6, 0, 0, 0, 32, 0, 0, 0, 6, 0, 0, 0, 102, 105, 101,
108, 100, 49,
0, 0,
];
- let ipc2 = ipc::get_root_as_message(&bytes[..]);
+ let ipc2 = ipc::root_as_message(&bytes[..]).unwrap();
let schema2 = ipc.header_as_schema().unwrap();
assert_eq!(schema, schema2);
diff --git a/rust/arrow/src/ipc/gen/File.rs b/rust/arrow/src/ipc/gen/File.rs
index af798ce..3f8e278 100644
--- a/rust/arrow/src/ipc/gen/File.rs
+++ b/rust/arrow/src/ipc/gen/File.rs
@@ -42,6 +42,7 @@ impl std::fmt::Debug for Block {
}
}
+impl flatbuffers::SimpleToVerifyInSlice for Block {}
impl flatbuffers::SafeSliceAccess for Block {}
impl<'a> flatbuffers::Follow<'a> for Block {
type Inner = &'a Block;
@@ -79,6 +80,16 @@ impl<'b> flatbuffers::Push for &'b Block {
}
}
+impl<'a> flatbuffers::Verifiable for Block {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
impl Block {
pub fn new(_offset: i64, _metaDataLength: i32, _bodyLength: i64) -> Self {
Block {
@@ -166,12 +177,12 @@ impl<'a> Footer<'a> {
#[inline]
pub fn schema(&self) -> Option<Schema<'a>> {
self._tab
-
.get::<flatbuffers::ForwardsUOffset<Schema<'a>>>(Footer::VT_SCHEMA, None)
+ .get::<flatbuffers::ForwardsUOffset<Schema>>(Footer::VT_SCHEMA,
None)
}
#[inline]
pub fn dictionaries(&self) -> Option<&'a [Block]> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Block>>>(
+ .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a,
Block>>>(
Footer::VT_DICTIONARIES,
None,
)
@@ -180,7 +191,7 @@ impl<'a> Footer<'a> {
#[inline]
pub fn recordBatches(&self) -> Option<&'a [Block]> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Block>>>(
+ .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a,
Block>>>(
Footer::VT_RECORDBATCHES,
None,
)
@@ -192,11 +203,42 @@ impl<'a> Footer<'a> {
&self,
) -> Option<flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
self._tab.get::<flatbuffers::ForwardsUOffset<
- flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>,
+ flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue>>,
>>(Footer::VT_CUSTOM_METADATA, None)
}
}
+impl flatbuffers::Verifiable for Footer<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<MetadataVersion>(&"version", Self::VT_VERSION,
false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Schema>>(
+ &"schema",
+ Self::VT_SCHEMA,
+ false,
+ )?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Block>>>(
+ &"dictionaries",
+ Self::VT_DICTIONARIES,
+ false,
+ )?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Block>>>(
+ &"recordBatches",
+ Self::VT_RECORDBATCHES,
+ false,
+ )?
+ .visit_field::<flatbuffers::ForwardsUOffset<
+ flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<KeyValue>>,
+ >>(&"custom_metadata", Self::VT_CUSTOM_METADATA, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct FooterArgs<'a> {
pub version: MetadataVersion,
pub schema: Option<flatbuffers::WIPOffset<Schema<'a>>>,
@@ -302,16 +344,80 @@ impl std::fmt::Debug for Footer<'_> {
}
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_root_as_footer<'a>(buf: &'a [u8]) -> Footer<'a> {
- flatbuffers::get_root::<Footer<'a>>(buf)
+ unsafe { flatbuffers::root_unchecked::<Footer<'a>>(buf) }
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_size_prefixed_root_as_footer<'a>(buf: &'a [u8]) -> Footer<'a> {
- flatbuffers::get_size_prefixed_root::<Footer<'a>>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Footer<'a>>(buf) }
}
#[inline]
+/// Verifies that a buffer of bytes contains a `Footer`
+/// and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_footer_unchecked`.
+pub fn root_as_footer(buf: &[u8]) -> Result<Footer,
flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root::<Footer>(buf)
+}
+#[inline]
+/// Verifies that a buffer of bytes contains a size prefixed
+/// `Footer` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `size_prefixed_root_as_footer_unchecked`.
+pub fn size_prefixed_root_as_footer(
+ buf: &[u8],
+) -> Result<Footer, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root::<Footer>(buf)
+}
+#[inline]
+/// Verifies, with the given options, that a buffer of bytes
+/// contains a `Footer` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_footer_unchecked`.
+pub fn root_as_footer_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Footer<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root_with_opts::<Footer<'b>>(opts, buf)
+}
+#[inline]
+/// Verifies, with the given verifier options, that a buffer of
+/// bytes contains a size prefixed `Footer` and returns
+/// it. Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_footer_unchecked`.
+pub fn size_prefixed_root_as_footer_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Footer<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root_with_opts::<Footer<'b>>(opts, buf)
+}
+#[inline]
+/// Assumes, without verification, that a buffer of bytes contains a Footer
and returns it.
+/// # 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)
+}
+#[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)
+}
+#[inline]
pub fn finish_footer_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Footer<'a>>,
diff --git a/rust/arrow/src/ipc/gen/Message.rs
b/rust/arrow/src/ipc/gen/Message.rs
index cc85348..0d05a49 100644
--- a/rust/arrow/src/ipc/gen/Message.rs
+++ b/rust/arrow/src/ipc/gen/Message.rs
@@ -76,7 +76,8 @@ impl<'a> flatbuffers::Follow<'a> for CompressionType {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i8>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
+ Self(b)
}
}
@@ -91,14 +92,28 @@ impl flatbuffers::Push for CompressionType {
impl flatbuffers::EndianScalar for CompressionType {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i8::to_le(self.0))
+ let b = i8::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i8::from_le(self.0))
+ let b = i8::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for CompressionType {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for CompressionType {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -158,7 +173,8 @@ impl<'a> flatbuffers::Follow<'a> for BodyCompressionMethod {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i8>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i8>(buf, loc);
+ Self(b)
}
}
@@ -173,14 +189,28 @@ impl flatbuffers::Push for BodyCompressionMethod {
impl flatbuffers::EndianScalar for BodyCompressionMethod {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i8::to_le(self.0))
+ let b = i8::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i8::from_le(self.0))
+ let b = i8::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for BodyCompressionMethod {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for BodyCompressionMethod {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -257,11 +287,13 @@ impl std::fmt::Debug for MessageHeader {
}
}
}
+pub struct MessageHeaderUnionTableOffset {}
impl<'a> flatbuffers::Follow<'a> for MessageHeader {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<u8>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ Self(b)
}
}
@@ -276,15 +308,28 @@ impl flatbuffers::Push for MessageHeader {
impl flatbuffers::EndianScalar for MessageHeader {
#[inline]
fn to_little_endian(self) -> Self {
- Self(u8::to_le(self.0))
+ let b = u8::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(u8::from_le(self.0))
+ let b = u8::from_le(self.0);
+ Self(b)
}
}
-pub struct MessageHeaderUnionTableOffset {}
+impl<'a> flatbuffers::Verifiable for MessageHeader {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for MessageHeader {}
/// ----------------------------------------------------------------------
/// Data structures for describing a table row batch (a collection of
/// equal-length Arrow arrays)
@@ -310,6 +355,7 @@ impl std::fmt::Debug for FieldNode {
}
}
+impl flatbuffers::SimpleToVerifyInSlice for FieldNode {}
impl flatbuffers::SafeSliceAccess for FieldNode {}
impl<'a> flatbuffers::Follow<'a> for FieldNode {
type Inner = &'a FieldNode;
@@ -353,6 +399,16 @@ impl<'b> flatbuffers::Push for &'b FieldNode {
}
}
+impl<'a> flatbuffers::Verifiable for FieldNode {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
impl FieldNode {
pub fn new(_length: i64, _null_count: i64) -> Self {
FieldNode {
@@ -434,6 +490,20 @@ impl<'a> BodyCompression<'a> {
}
}
+impl flatbuffers::Verifiable for BodyCompression<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<CompressionType>(&"codec", Self::VT_CODEC, false)?
+ .visit_field::<BodyCompressionMethod>(&"method", Self::VT_METHOD,
false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct BodyCompressionArgs {
pub codec: CompressionType,
pub method: BodyCompressionMethod,
@@ -554,7 +624,7 @@ impl<'a> RecordBatch<'a> {
#[inline]
pub fn nodes(&self) -> Option<&'a [FieldNode]> {
self._tab
-
.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<FieldNode>>>(
+ .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a,
FieldNode>>>(
RecordBatch::VT_NODES,
None,
)
@@ -569,7 +639,7 @@ impl<'a> RecordBatch<'a> {
#[inline]
pub fn buffers(&self) -> Option<&'a [Buffer]> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Buffer>>>(
+ .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a,
Buffer>>>(
RecordBatch::VT_BUFFERS,
None,
)
@@ -579,13 +649,29 @@ impl<'a> RecordBatch<'a> {
#[inline]
pub fn compression(&self) -> Option<BodyCompression<'a>> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<BodyCompression<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<BodyCompression>>(
RecordBatch::VT_COMPRESSION,
None,
)
}
}
+impl flatbuffers::Verifiable for RecordBatch<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i64>(&"length", Self::VT_LENGTH, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
FieldNode>>>(&"nodes", Self::VT_NODES, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
Buffer>>>(&"buffers", Self::VT_BUFFERS, false)?
+
.visit_field::<flatbuffers::ForwardsUOffset<BodyCompression>>(&"compression",
Self::VT_COMPRESSION, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct RecordBatchArgs<'a> {
pub length: i64,
pub nodes: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a,
FieldNode>>>,
@@ -723,11 +809,10 @@ impl<'a> DictionaryBatch<'a> {
}
#[inline]
pub fn data(&self) -> Option<RecordBatch<'a>> {
- self._tab
- .get::<flatbuffers::ForwardsUOffset<RecordBatch<'a>>>(
- DictionaryBatch::VT_DATA,
- None,
- )
+ self._tab.get::<flatbuffers::ForwardsUOffset<RecordBatch>>(
+ DictionaryBatch::VT_DATA,
+ None,
+ )
}
/// If isDelta is true the values in the dictionary are to be appended to a
/// dictionary with the indicated id. If isDelta is false this dictionary
@@ -740,6 +825,25 @@ impl<'a> DictionaryBatch<'a> {
}
}
+impl flatbuffers::Verifiable for DictionaryBatch<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i64>(&"id", Self::VT_ID, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<RecordBatch>>(
+ &"data",
+ Self::VT_DATA,
+ false,
+ )?
+ .visit_field::<bool>(&"isDelta", Self::VT_ISDELTA, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct DictionaryBatchArgs<'a> {
pub id: i64,
pub data: Option<flatbuffers::WIPOffset<RecordBatch<'a>>>,
@@ -880,7 +984,7 @@ impl<'a> Message<'a> {
&self,
) -> Option<flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
self._tab.get::<flatbuffers::ForwardsUOffset<
- flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>,
+ flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue>>,
>>(Message::VT_CUSTOM_METADATA, None)
}
#[inline]
@@ -934,6 +1038,31 @@ impl<'a> Message<'a> {
}
}
+impl flatbuffers::Verifiable for Message<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<MetadataVersion>(&"version", Self::VT_VERSION, false)?
+ .visit_union::<MessageHeader, _>(&"header_type", Self::VT_HEADER_TYPE,
&"header", Self::VT_HEADER, false, |key, v, pos| {
+ match key {
+ MessageHeader::Schema =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Schema>>("MessageHeader::Schema",
pos),
+ MessageHeader::DictionaryBatch =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<DictionaryBatch>>("MessageHeader::DictionaryBatch",
pos),
+ MessageHeader::RecordBatch =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<RecordBatch>>("MessageHeader::RecordBatch",
pos),
+ MessageHeader::Tensor =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Tensor>>("MessageHeader::Tensor",
pos),
+ MessageHeader::SparseTensor =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensor>>("MessageHeader::SparseTensor",
pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<i64>(&"bodyLength", Self::VT_BODYLENGTH, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<KeyValue>>>>(&"custom_metadata",
Self::VT_CUSTOM_METADATA, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct MessageArgs<'a> {
pub version: MetadataVersion,
pub header_type: MessageHeader,
@@ -1087,16 +1216,80 @@ impl std::fmt::Debug for Message<'_> {
}
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_root_as_message<'a>(buf: &'a [u8]) -> Message<'a> {
- flatbuffers::get_root::<Message<'a>>(buf)
+ unsafe { flatbuffers::root_unchecked::<Message<'a>>(buf) }
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_size_prefixed_root_as_message<'a>(buf: &'a [u8]) -> Message<'a> {
- flatbuffers::get_size_prefixed_root::<Message<'a>>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Message<'a>>(buf) }
}
#[inline]
+/// Verifies that a buffer of bytes contains a `Message`
+/// and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_message_unchecked`.
+pub fn root_as_message(buf: &[u8]) -> Result<Message,
flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root::<Message>(buf)
+}
+#[inline]
+/// Verifies that a buffer of bytes contains a size prefixed
+/// `Message` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `size_prefixed_root_as_message_unchecked`.
+pub fn size_prefixed_root_as_message(
+ buf: &[u8],
+) -> Result<Message, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root::<Message>(buf)
+}
+#[inline]
+/// Verifies, with the given options, that a buffer of bytes
+/// contains a `Message` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_message_unchecked`.
+pub fn root_as_message_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Message<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root_with_opts::<Message<'b>>(opts, buf)
+}
+#[inline]
+/// Verifies, with the given verifier options, that a buffer of
+/// bytes contains a size prefixed `Message` and returns
+/// it. Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_message_unchecked`.
+pub fn size_prefixed_root_as_message_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Message<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root_with_opts::<Message<'b>>(opts, buf)
+}
+#[inline]
+/// Assumes, without verification, that a buffer of bytes contains a Message
and returns it.
+/// # 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)
+}
+#[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)
+}
+#[inline]
pub fn finish_message_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Message<'a>>,
diff --git a/rust/arrow/src/ipc/gen/Schema.rs b/rust/arrow/src/ipc/gen/Schema.rs
index ee3c994..55bbc33 100644
--- a/rust/arrow/src/ipc/gen/Schema.rs
+++ b/rust/arrow/src/ipc/gen/Schema.rs
@@ -96,7 +96,8 @@ impl<'a> flatbuffers::Follow<'a> for MetadataVersion {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -111,14 +112,28 @@ impl flatbuffers::Push for MetadataVersion {
impl flatbuffers::EndianScalar for MetadataVersion {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for MetadataVersion {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for MetadataVersion {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -202,7 +217,8 @@ impl<'a> flatbuffers::Follow<'a> for Feature {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i64>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i64>(buf, loc);
+ Self(b)
}
}
@@ -217,14 +233,28 @@ impl flatbuffers::Push for Feature {
impl flatbuffers::EndianScalar for Feature {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i64::to_le(self.0))
+ let b = i64::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i64::from_le(self.0))
+ let b = i64::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for Feature {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i64::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Feature {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -275,7 +305,8 @@ impl<'a> flatbuffers::Follow<'a> for UnionMode {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -290,14 +321,28 @@ impl flatbuffers::Push for UnionMode {
impl flatbuffers::EndianScalar for UnionMode {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for UnionMode {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for UnionMode {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -351,7 +396,8 @@ impl<'a> flatbuffers::Follow<'a> for Precision {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -366,14 +412,28 @@ impl flatbuffers::Push for Precision {
impl flatbuffers::EndianScalar for Precision {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Precision {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
}
}
+impl flatbuffers::SimpleToVerifyInSlice for Precision {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -424,7 +484,8 @@ impl<'a> flatbuffers::Follow<'a> for DateUnit {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -439,14 +500,28 @@ impl flatbuffers::Push for DateUnit {
impl flatbuffers::EndianScalar for DateUnit {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for DateUnit {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for DateUnit {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -511,7 +586,8 @@ impl<'a> flatbuffers::Follow<'a> for TimeUnit {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -526,14 +602,28 @@ impl flatbuffers::Push for TimeUnit {
impl flatbuffers::EndianScalar for TimeUnit {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for TimeUnit {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
}
}
+impl flatbuffers::SimpleToVerifyInSlice for TimeUnit {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -585,7 +675,8 @@ impl<'a> flatbuffers::Follow<'a> for IntervalUnit {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -600,14 +691,28 @@ impl flatbuffers::Push for IntervalUnit {
impl flatbuffers::EndianScalar for IntervalUnit {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for IntervalUnit {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
}
}
+impl flatbuffers::SimpleToVerifyInSlice for IntervalUnit {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -743,11 +848,13 @@ impl std::fmt::Debug for Type {
}
}
}
+pub struct TypeUnionTableOffset {}
impl<'a> flatbuffers::Follow<'a> for Type {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<u8>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ Self(b)
}
}
@@ -762,15 +869,28 @@ impl flatbuffers::Push for Type {
impl flatbuffers::EndianScalar for Type {
#[inline]
fn to_little_endian(self) -> Self {
- Self(u8::to_le(self.0))
+ let b = u8::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(u8::from_le(self.0))
+ let b = u8::from_le(self.0);
+ Self(b)
}
}
-pub struct TypeUnionTableOffset {}
+impl<'a> flatbuffers::Verifiable for Type {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Type {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -824,7 +944,8 @@ impl<'a> flatbuffers::Follow<'a> for DictionaryKind {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -839,14 +960,28 @@ impl flatbuffers::Push for DictionaryKind {
impl flatbuffers::EndianScalar for DictionaryKind {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for DictionaryKind {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
}
}
+impl flatbuffers::SimpleToVerifyInSlice for DictionaryKind {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -899,7 +1034,8 @@ impl<'a> flatbuffers::Follow<'a> for Endianness {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -914,14 +1050,28 @@ impl flatbuffers::Push for Endianness {
impl flatbuffers::EndianScalar for Endianness {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Endianness {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
}
}
+impl flatbuffers::SimpleToVerifyInSlice for Endianness {}
/// ----------------------------------------------------------------------
/// A Buffer represents a single contiguous memory segment
// struct Buffer, aligned to 8
@@ -940,6 +1090,7 @@ impl std::fmt::Debug for Buffer {
}
}
+impl flatbuffers::SimpleToVerifyInSlice for Buffer {}
impl flatbuffers::SafeSliceAccess for Buffer {}
impl<'a> flatbuffers::Follow<'a> for Buffer {
type Inner = &'a Buffer;
@@ -980,6 +1131,16 @@ impl<'b> flatbuffers::Push for &'b Buffer {
}
}
+impl<'a> flatbuffers::Verifiable for Buffer {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
impl Buffer {
pub fn new(_offset: i64, _length: i64) -> Self {
Buffer {
@@ -1035,6 +1196,17 @@ impl<'a> Null<'a> {
}
}
+impl flatbuffers::Verifiable for Null<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct NullArgs {}
impl<'a> Default for NullArgs {
#[inline]
@@ -1103,6 +1275,17 @@ impl<'a> Struct_<'a> {
}
}
+impl flatbuffers::Verifiable for Struct_<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct Struct_Args {}
impl<'a> Default for Struct_Args {
#[inline]
@@ -1170,6 +1353,17 @@ impl<'a> List<'a> {
}
}
+impl flatbuffers::Verifiable for List<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct ListArgs {}
impl<'a> Default for ListArgs {
#[inline]
@@ -1237,6 +1431,17 @@ impl<'a> LargeList<'a> {
}
}
+impl flatbuffers::Verifiable for LargeList<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct LargeListArgs {}
impl<'a> Default for LargeListArgs {
#[inline]
@@ -1315,6 +1520,19 @@ impl<'a> FixedSizeList<'a> {
}
}
+impl flatbuffers::Verifiable for FixedSizeList<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>(&"listSize", Self::VT_LISTSIZE, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct FixedSizeListArgs {
pub listSize: i32,
}
@@ -1425,6 +1643,19 @@ impl<'a> Map<'a> {
}
}
+impl flatbuffers::Verifiable for Map<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<bool>(&"keysSorted", Self::VT_KEYSSORTED, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct MapArgs {
pub keysSorted: bool,
}
@@ -1524,6 +1755,24 @@ impl<'a> Union<'a> {
}
}
+impl flatbuffers::Verifiable for Union<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<UnionMode>(&"mode", Self::VT_MODE, false)?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>(
+ &"typeIds",
+ Self::VT_TYPEIDS,
+ false,
+ )?
+ .finish();
+ Ok(())
+ }
+}
pub struct UnionArgs<'a> {
pub mode: UnionMode,
pub typeIds: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i32>>>,
@@ -1626,6 +1875,20 @@ impl<'a> Int<'a> {
}
}
+impl flatbuffers::Verifiable for Int<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>(&"bitWidth", Self::VT_BITWIDTH, false)?
+ .visit_field::<bool>(&"is_signed", Self::VT_IS_SIGNED, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct IntArgs {
pub bitWidth: i32,
pub is_signed: bool,
@@ -1718,6 +1981,19 @@ impl<'a> FloatingPoint<'a> {
}
}
+impl flatbuffers::Verifiable for FloatingPoint<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<Precision>(&"precision", Self::VT_PRECISION, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct FloatingPointArgs {
pub precision: Precision,
}
@@ -1799,6 +2075,17 @@ impl<'a> Utf8<'a> {
}
}
+impl flatbuffers::Verifiable for Utf8<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct Utf8Args {}
impl<'a> Default for Utf8Args {
#[inline]
@@ -1865,6 +2152,17 @@ impl<'a> Binary<'a> {
}
}
+impl flatbuffers::Verifiable for Binary<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct BinaryArgs {}
impl<'a> Default for BinaryArgs {
#[inline]
@@ -1934,6 +2232,17 @@ impl<'a> LargeUtf8<'a> {
}
}
+impl flatbuffers::Verifiable for LargeUtf8<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct LargeUtf8Args {}
impl<'a> Default for LargeUtf8Args {
#[inline]
@@ -2003,6 +2312,17 @@ impl<'a> LargeBinary<'a> {
}
}
+impl flatbuffers::Verifiable for LargeBinary<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct LargeBinaryArgs {}
impl<'a> Default for LargeBinaryArgs {
#[inline]
@@ -2081,6 +2401,19 @@ impl<'a> FixedSizeBinary<'a> {
}
}
+impl flatbuffers::Verifiable for FixedSizeBinary<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>(&"byteWidth", Self::VT_BYTEWIDTH, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct FixedSizeBinaryArgs {
pub byteWidth: i32,
}
@@ -2156,6 +2489,17 @@ impl<'a> Bool<'a> {
}
}
+impl flatbuffers::Verifiable for Bool<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?.finish();
+ Ok(())
+ }
+}
pub struct BoolArgs {}
impl<'a> Default for BoolArgs {
#[inline]
@@ -2253,6 +2597,21 @@ impl<'a> Decimal<'a> {
}
}
+impl flatbuffers::Verifiable for Decimal<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i32>(&"precision", Self::VT_PRECISION, false)?
+ .visit_field::<i32>(&"scale", Self::VT_SCALE, false)?
+ .visit_field::<i32>(&"bitWidth", Self::VT_BITWIDTH, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct DecimalArgs {
pub precision: i32,
pub scale: i32,
@@ -2361,6 +2720,19 @@ impl<'a> Date<'a> {
}
}
+impl flatbuffers::Verifiable for Date<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<DateUnit>(&"unit", Self::VT_UNIT, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct DateArgs {
pub unit: DateUnit,
}
@@ -2455,6 +2827,20 @@ impl<'a> Time<'a> {
}
}
+impl flatbuffers::Verifiable for Time<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<TimeUnit>(&"unit", Self::VT_UNIT, false)?
+ .visit_field::<i32>(&"bitWidth", Self::VT_BITWIDTH, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct TimeArgs {
pub unit: TimeUnit,
pub bitWidth: i32,
@@ -2582,6 +2968,24 @@ impl<'a> Timestamp<'a> {
}
}
+impl flatbuffers::Verifiable for Timestamp<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<TimeUnit>(&"unit", Self::VT_UNIT, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<&str>>(
+ &"timezone",
+ Self::VT_TIMEZONE,
+ false,
+ )?
+ .finish();
+ Ok(())
+ }
+}
pub struct TimestampArgs<'a> {
pub unit: TimeUnit,
pub timezone: Option<flatbuffers::WIPOffset<&'a str>>,
@@ -2679,6 +3083,19 @@ impl<'a> Interval<'a> {
}
}
+impl flatbuffers::Verifiable for Interval<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<IntervalUnit>(&"unit", Self::VT_UNIT, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct IntervalArgs {
pub unit: IntervalUnit,
}
@@ -2769,6 +3186,19 @@ impl<'a> Duration<'a> {
}
}
+impl flatbuffers::Verifiable for Duration<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<TimeUnit>(&"unit", Self::VT_UNIT, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct DurationArgs {
pub unit: TimeUnit,
}
@@ -2869,6 +3299,28 @@ impl<'a> KeyValue<'a> {
}
}
+impl flatbuffers::Verifiable for KeyValue<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<&str>>(
+ &"key",
+ Self::VT_KEY,
+ false,
+ )?
+ .visit_field::<flatbuffers::ForwardsUOffset<&str>>(
+ &"value",
+ Self::VT_VALUE,
+ false,
+ )?
+ .finish();
+ Ok(())
+ }
+}
pub struct KeyValueArgs<'a> {
pub key: Option<flatbuffers::WIPOffset<&'a str>>,
pub value: Option<flatbuffers::WIPOffset<&'a str>>,
@@ -2980,7 +3432,7 @@ impl<'a> DictionaryEncoding<'a> {
/// and to avoid uint64 indices unless they are required by an application.
#[inline]
pub fn indexType(&self) -> Option<Int<'a>> {
- self._tab.get::<flatbuffers::ForwardsUOffset<Int<'a>>>(
+ self._tab.get::<flatbuffers::ForwardsUOffset<Int>>(
DictionaryEncoding::VT_INDEXTYPE,
None,
)
@@ -3006,6 +3458,30 @@ impl<'a> DictionaryEncoding<'a> {
}
}
+impl flatbuffers::Verifiable for DictionaryEncoding<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i64>(&"id", Self::VT_ID, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
+ &"indexType",
+ Self::VT_INDEXTYPE,
+ false,
+ )?
+ .visit_field::<bool>(&"isOrdered", Self::VT_ISORDERED, false)?
+ .visit_field::<DictionaryKind>(
+ &"dictionaryKind",
+ Self::VT_DICTIONARYKIND,
+ false,
+ )?
+ .finish();
+ Ok(())
+ }
+}
pub struct DictionaryEncodingArgs<'a> {
pub id: i64,
pub indexType: Option<flatbuffers::WIPOffset<Int<'a>>>,
@@ -3170,7 +3646,7 @@ impl<'a> Field<'a> {
#[inline]
pub fn dictionary(&self) -> Option<DictionaryEncoding<'a>> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<DictionaryEncoding<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<DictionaryEncoding>>(
Field::VT_DICTIONARY,
None,
)
@@ -3182,7 +3658,7 @@ impl<'a> Field<'a> {
&self,
) -> Option<flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<Field<'a>>>> {
self._tab.get::<flatbuffers::ForwardsUOffset<
- flatbuffers::Vector<flatbuffers::ForwardsUOffset<Field<'a>>>,
+ flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Field>>,
>>(Field::VT_CHILDREN, None)
}
/// User-defined metadata
@@ -3191,7 +3667,7 @@ impl<'a> Field<'a> {
&self,
) -> Option<flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
self._tab.get::<flatbuffers::ForwardsUOffset<
- flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>,
+ flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue>>,
>>(Field::VT_CUSTOM_METADATA, None)
}
#[inline]
@@ -3405,6 +3881,49 @@ impl<'a> Field<'a> {
}
}
+impl flatbuffers::Verifiable for Field<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<&str>>(&"name",
Self::VT_NAME, false)?
+ .visit_field::<bool>(&"nullable", Self::VT_NULLABLE, false)?
+ .visit_union::<Type, _>(&"type_type", Self::VT_TYPE_TYPE, &"type_",
Self::VT_TYPE_, false, |key, v, pos| {
+ match key {
+ Type::Null =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>("Type::Null", pos),
+ Type::Int =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>("Type::Int", pos),
+ Type::FloatingPoint =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>("Type::FloatingPoint",
pos),
+ Type::Binary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>("Type::Binary",
pos),
+ Type::Utf8 =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>("Type::Utf8", pos),
+ Type::Bool =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>("Type::Bool", pos),
+ Type::Decimal =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>("Type::Decimal",
pos),
+ Type::Date =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>("Type::Date", pos),
+ Type::Time =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>("Type::Time", pos),
+ Type::Timestamp =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>("Type::Timestamp",
pos),
+ Type::Interval =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>("Type::Interval",
pos),
+ Type::List =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>("Type::List", pos),
+ Type::Struct_ =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>("Type::Struct_",
pos),
+ Type::Union =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>("Type::Union",
pos),
+ Type::FixedSizeBinary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>("Type::FixedSizeBinary",
pos),
+ Type::FixedSizeList =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>("Type::FixedSizeList",
pos),
+ Type::Map =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>("Type::Map", pos),
+ Type::Duration =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>("Type::Duration",
pos),
+ Type::LargeBinary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>("Type::LargeBinary",
pos),
+ Type::LargeUtf8 =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>("Type::LargeUtf8",
pos),
+ Type::LargeList =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>("Type::LargeList",
pos),
+ _ => Ok(()),
+ }
+ })?
+
.visit_field::<flatbuffers::ForwardsUOffset<DictionaryEncoding>>(&"dictionary",
Self::VT_DICTIONARY, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<Field>>>>(&"children", Self::VT_CHILDREN, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<KeyValue>>>>(&"custom_metadata",
Self::VT_CUSTOM_METADATA, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct FieldArgs<'a> {
pub name: Option<flatbuffers::WIPOffset<&'a str>>,
pub nullable: bool,
@@ -3802,7 +4321,7 @@ impl<'a> Schema<'a> {
&self,
) -> Option<flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<Field<'a>>>> {
self._tab.get::<flatbuffers::ForwardsUOffset<
- flatbuffers::Vector<flatbuffers::ForwardsUOffset<Field<'a>>>,
+ flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Field>>,
>>(Schema::VT_FIELDS, None)
}
#[inline]
@@ -3810,7 +4329,7 @@ impl<'a> Schema<'a> {
&self,
) -> Option<flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<KeyValue<'a>>>> {
self._tab.get::<flatbuffers::ForwardsUOffset<
- flatbuffers::Vector<flatbuffers::ForwardsUOffset<KeyValue<'a>>>,
+ flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<KeyValue>>,
>>(Schema::VT_CUSTOM_METADATA, None)
}
/// Features used in the stream/file.
@@ -3824,6 +4343,22 @@ impl<'a> Schema<'a> {
}
}
+impl flatbuffers::Verifiable for Schema<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<Endianness>(&"endianness", Self::VT_ENDIANNESS, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<Field>>>>(&"fields", Self::VT_FIELDS, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<KeyValue>>>>(&"custom_metadata",
Self::VT_CUSTOM_METADATA, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
Feature>>>(&"features", Self::VT_FEATURES, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct SchemaArgs<'a> {
pub endianness: Endianness,
pub fields: Option<
@@ -3920,16 +4455,80 @@ impl std::fmt::Debug for Schema<'_> {
}
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_root_as_schema<'a>(buf: &'a [u8]) -> Schema<'a> {
- flatbuffers::get_root::<Schema<'a>>(buf)
+ unsafe { flatbuffers::root_unchecked::<Schema<'a>>(buf) }
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_size_prefixed_root_as_schema<'a>(buf: &'a [u8]) -> Schema<'a> {
- flatbuffers::get_size_prefixed_root::<Schema<'a>>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Schema<'a>>(buf) }
}
#[inline]
+/// Verifies that a buffer of bytes contains a `Schema`
+/// and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_schema_unchecked`.
+pub fn root_as_schema(buf: &[u8]) -> Result<Schema,
flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root::<Schema>(buf)
+}
+#[inline]
+/// Verifies that a buffer of bytes contains a size prefixed
+/// `Schema` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `size_prefixed_root_as_schema_unchecked`.
+pub fn size_prefixed_root_as_schema(
+ buf: &[u8],
+) -> Result<Schema, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root::<Schema>(buf)
+}
+#[inline]
+/// Verifies, with the given options, that a buffer of bytes
+/// contains a `Schema` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_schema_unchecked`.
+pub fn root_as_schema_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Schema<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root_with_opts::<Schema<'b>>(opts, buf)
+}
+#[inline]
+/// Verifies, with the given verifier options, that a buffer of
+/// bytes contains a size prefixed `Schema` and returns
+/// it. Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_schema_unchecked`.
+pub fn size_prefixed_root_as_schema_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Schema<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root_with_opts::<Schema<'b>>(opts, buf)
+}
+#[inline]
+/// Assumes, without verification, that a buffer of bytes contains a Schema
and returns it.
+/// # 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)
+}
+#[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)
+}
+#[inline]
pub fn finish_schema_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Schema<'a>>,
diff --git a/rust/arrow/src/ipc/gen/SparseTensor.rs
b/rust/arrow/src/ipc/gen/SparseTensor.rs
index 004f516..1b45a82 100644
--- a/rust/arrow/src/ipc/gen/SparseTensor.rs
+++ b/rust/arrow/src/ipc/gen/SparseTensor.rs
@@ -77,7 +77,8 @@ impl<'a> flatbuffers::Follow<'a> for
SparseMatrixCompressedAxis {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<i16>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<i16>(buf, loc);
+ Self(b)
}
}
@@ -92,14 +93,28 @@ impl flatbuffers::Push for SparseMatrixCompressedAxis {
impl flatbuffers::EndianScalar for SparseMatrixCompressedAxis {
#[inline]
fn to_little_endian(self) -> Self {
- Self(i16::to_le(self.0))
+ let b = i16::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(i16::from_le(self.0))
+ let b = i16::from_le(self.0);
+ Self(b)
}
}
+impl<'a> flatbuffers::Verifiable for SparseMatrixCompressedAxis {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ i16::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for SparseMatrixCompressedAxis {}
#[deprecated(
since = "1.13",
note = "Use associated constants instead. This will no longer be generated
in 2021."
@@ -160,11 +175,13 @@ impl std::fmt::Debug for SparseTensorIndex {
}
}
}
+pub struct SparseTensorIndexUnionTableOffset {}
impl<'a> flatbuffers::Follow<'a> for SparseTensorIndex {
type Inner = Self;
#[inline]
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self(flatbuffers::read_scalar_at::<u8>(buf, loc))
+ let b = flatbuffers::read_scalar_at::<u8>(buf, loc);
+ Self(b)
}
}
@@ -179,15 +196,28 @@ impl flatbuffers::Push for SparseTensorIndex {
impl flatbuffers::EndianScalar for SparseTensorIndex {
#[inline]
fn to_little_endian(self) -> Self {
- Self(u8::to_le(self.0))
+ let b = u8::to_le(self.0);
+ Self(b)
}
#[inline]
fn from_little_endian(self) -> Self {
- Self(u8::from_le(self.0))
+ let b = u8::from_le(self.0);
+ Self(b)
}
}
-pub struct SparseTensorIndexUnionTableOffset {}
+impl<'a> flatbuffers::Verifiable for SparseTensorIndex {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for SparseTensorIndex {}
pub enum SparseTensorIndexCOOOffset {}
#[derive(Copy, Clone, PartialEq)]
@@ -270,7 +300,7 @@ impl<'a> SparseTensorIndexCOO<'a> {
#[inline]
pub fn indicesType(&self) -> Int<'a> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<Int<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<Int>>(
SparseTensorIndexCOO::VT_INDICESTYPE,
None,
)
@@ -306,6 +336,30 @@ impl<'a> SparseTensorIndexCOO<'a> {
}
}
+impl flatbuffers::Verifiable for SparseTensorIndexCOO<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
+ &"indicesType",
+ Self::VT_INDICESTYPE,
+ true,
+ )?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>(
+ &"indicesStrides",
+ Self::VT_INDICESSTRIDES,
+ false,
+ )?
+ .visit_field::<Buffer>(&"indicesBuffer", Self::VT_INDICESBUFFER,
true)?
+ .visit_field::<bool>(&"isCanonical", Self::VT_ISCANONICAL, false)?
+ .finish();
+ Ok(())
+ }
+}
pub struct SparseTensorIndexCOOArgs<'a> {
pub indicesType: Option<flatbuffers::WIPOffset<Int<'a>>>,
pub indicesStrides: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a,
i64>>>,
@@ -456,7 +510,7 @@ impl<'a> SparseMatrixIndexCSX<'a> {
#[inline]
pub fn indptrType(&self) -> Int<'a> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<Int<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<Int>>(
SparseMatrixIndexCSX::VT_INDPTRTYPE,
None,
)
@@ -494,7 +548,7 @@ impl<'a> SparseMatrixIndexCSX<'a> {
#[inline]
pub fn indicesType(&self) -> Int<'a> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<Int<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<Int>>(
SparseMatrixIndexCSX::VT_INDICESTYPE,
None,
)
@@ -517,6 +571,35 @@ impl<'a> SparseMatrixIndexCSX<'a> {
}
}
+impl flatbuffers::Verifiable for SparseMatrixIndexCSX<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<SparseMatrixCompressedAxis>(
+ &"compressedAxis",
+ Self::VT_COMPRESSEDAXIS,
+ false,
+ )?
+ .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
+ &"indptrType",
+ Self::VT_INDPTRTYPE,
+ true,
+ )?
+ .visit_field::<Buffer>(&"indptrBuffer", Self::VT_INDPTRBUFFER,
true)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
+ &"indicesType",
+ Self::VT_INDICESTYPE,
+ true,
+ )?
+ .visit_field::<Buffer>(&"indicesBuffer", Self::VT_INDICESBUFFER,
true)?
+ .finish();
+ Ok(())
+ }
+}
pub struct SparseMatrixIndexCSXArgs<'a> {
pub compressedAxis: SparseMatrixCompressedAxis,
pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
@@ -701,7 +784,7 @@ impl<'a> SparseTensorIndexCSF<'a> {
#[inline]
pub fn indptrType(&self) -> Int<'a> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<Int<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<Int>>(
SparseTensorIndexCSF::VT_INDPTRTYPE,
None,
)
@@ -724,7 +807,7 @@ impl<'a> SparseTensorIndexCSF<'a> {
#[inline]
pub fn indptrBuffers(&self) -> &'a [Buffer] {
self._tab
- .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Buffer>>>(
+ .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a,
Buffer>>>(
SparseTensorIndexCSF::VT_INDPTRBUFFERS,
None,
)
@@ -735,7 +818,7 @@ impl<'a> SparseTensorIndexCSF<'a> {
#[inline]
pub fn indicesType(&self) -> Int<'a> {
self._tab
- .get::<flatbuffers::ForwardsUOffset<Int<'a>>>(
+ .get::<flatbuffers::ForwardsUOffset<Int>>(
SparseTensorIndexCSF::VT_INDICESTYPE,
None,
)
@@ -755,7 +838,7 @@ impl<'a> SparseTensorIndexCSF<'a> {
#[inline]
pub fn indicesBuffers(&self) -> &'a [Buffer] {
self._tab
- .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Buffer>>>(
+ .get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a,
Buffer>>>(
SparseTensorIndexCSF::VT_INDICESBUFFERS,
None,
)
@@ -779,6 +862,43 @@ impl<'a> SparseTensorIndexCSF<'a> {
}
}
+impl flatbuffers::Verifiable for SparseTensorIndexCSF<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
+ &"indptrType",
+ Self::VT_INDPTRTYPE,
+ true,
+ )?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
+ &"indptrBuffers",
+ Self::VT_INDPTRBUFFERS,
+ true,
+ )?
+ .visit_field::<flatbuffers::ForwardsUOffset<Int>>(
+ &"indicesType",
+ Self::VT_INDICESTYPE,
+ true,
+ )?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Buffer>>>(
+ &"indicesBuffers",
+ Self::VT_INDICESBUFFERS,
+ true,
+ )?
+
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i32>>>(
+ &"axisOrder",
+ Self::VT_AXISORDER,
+ true,
+ )?
+ .finish();
+ Ok(())
+ }
+}
pub struct SparseTensorIndexCSFArgs<'a> {
pub indptrType: Option<flatbuffers::WIPOffset<Int<'a>>>,
pub indptrBuffers: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a,
Buffer>>>,
@@ -964,7 +1084,7 @@ impl<'a> SparseTensor<'a> {
) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
self._tab
.get::<flatbuffers::ForwardsUOffset<
-
flatbuffers::Vector<flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
+ flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<TensorDim>>,
>>(SparseTensor::VT_SHAPE, None)
.unwrap()
}
@@ -1272,6 +1392,55 @@ impl<'a> SparseTensor<'a> {
}
}
+impl flatbuffers::Verifiable for SparseTensor<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_union::<Type, _>(&"type_type", Self::VT_TYPE_TYPE, &"type_",
Self::VT_TYPE_, true, |key, v, pos| {
+ match key {
+ Type::Null =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>("Type::Null", pos),
+ Type::Int =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>("Type::Int", pos),
+ Type::FloatingPoint =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>("Type::FloatingPoint",
pos),
+ Type::Binary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>("Type::Binary",
pos),
+ Type::Utf8 =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>("Type::Utf8", pos),
+ Type::Bool =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>("Type::Bool", pos),
+ Type::Decimal =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>("Type::Decimal",
pos),
+ Type::Date =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>("Type::Date", pos),
+ Type::Time =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>("Type::Time", pos),
+ Type::Timestamp =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>("Type::Timestamp",
pos),
+ Type::Interval =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>("Type::Interval",
pos),
+ Type::List =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>("Type::List", pos),
+ Type::Struct_ =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>("Type::Struct_",
pos),
+ Type::Union =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>("Type::Union",
pos),
+ Type::FixedSizeBinary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>("Type::FixedSizeBinary",
pos),
+ Type::FixedSizeList =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>("Type::FixedSizeList",
pos),
+ Type::Map =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>("Type::Map", pos),
+ Type::Duration =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>("Type::Duration",
pos),
+ Type::LargeBinary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>("Type::LargeBinary",
pos),
+ Type::LargeUtf8 =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>("Type::LargeUtf8",
pos),
+ Type::LargeList =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>("Type::LargeList",
pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<TensorDim>>>>(&"shape", Self::VT_SHAPE, true)?
+ .visit_field::<i64>(&"non_zero_length", Self::VT_NON_ZERO_LENGTH, false)?
+ .visit_union::<SparseTensorIndex, _>(&"sparseIndex_type",
Self::VT_SPARSEINDEX_TYPE, &"sparseIndex", Self::VT_SPARSEINDEX, true, |key, v,
pos| {
+ match key {
+ SparseTensorIndex::SparseTensorIndexCOO =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCOO>>("SparseTensorIndex::SparseTensorIndexCOO",
pos),
+ SparseTensorIndex::SparseMatrixIndexCSX =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseMatrixIndexCSX>>("SparseTensorIndex::SparseMatrixIndexCSX",
pos),
+ SparseTensorIndex::SparseTensorIndexCSF =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<SparseTensorIndexCSF>>("SparseTensorIndex::SparseTensorIndexCSF",
pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<Buffer>(&"data", Self::VT_DATA, true)?
+ .finish();
+ Ok(())
+ }
+}
pub struct SparseTensorArgs<'a> {
pub type_type: Type,
pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
@@ -1641,16 +1810,82 @@ impl std::fmt::Debug for SparseTensor<'_> {
}
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_root_as_sparse_tensor<'a>(buf: &'a [u8]) -> SparseTensor<'a> {
- flatbuffers::get_root::<SparseTensor<'a>>(buf)
+ unsafe { flatbuffers::root_unchecked::<SparseTensor<'a>>(buf) }
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_size_prefixed_root_as_sparse_tensor<'a>(buf: &'a [u8]) ->
SparseTensor<'a> {
- flatbuffers::get_size_prefixed_root::<SparseTensor<'a>>(buf)
+ unsafe {
flatbuffers::size_prefixed_root_unchecked::<SparseTensor<'a>>(buf) }
}
#[inline]
+/// Verifies that a buffer of bytes contains a `SparseTensor`
+/// and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_sparse_tensor_unchecked`.
+pub fn root_as_sparse_tensor(
+ buf: &[u8],
+) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root::<SparseTensor>(buf)
+}
+#[inline]
+/// Verifies that a buffer of bytes contains a size prefixed
+/// `SparseTensor` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `size_prefixed_root_as_sparse_tensor_unchecked`.
+pub fn size_prefixed_root_as_sparse_tensor(
+ buf: &[u8],
+) -> Result<SparseTensor, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root::<SparseTensor>(buf)
+}
+#[inline]
+/// Verifies, with the given options, that a buffer of bytes
+/// contains a `SparseTensor` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_sparse_tensor_unchecked`.
+pub fn root_as_sparse_tensor_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root_with_opts::<SparseTensor<'b>>(opts, buf)
+}
+#[inline]
+/// Verifies, with the given verifier options, that a buffer of
+/// bytes contains a size prefixed `SparseTensor` and returns
+/// it. Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_sparse_tensor_unchecked`.
+pub fn size_prefixed_root_as_sparse_tensor_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<SparseTensor<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root_with_opts::<SparseTensor<'b>>(opts, buf)
+}
+#[inline]
+/// Assumes, without verification, that a buffer of bytes contains a
SparseTensor and returns it.
+/// # 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)
+}
+#[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)
+}
+#[inline]
pub fn finish_sparse_tensor_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<SparseTensor<'a>>,
diff --git a/rust/arrow/src/ipc/gen/Tensor.rs b/rust/arrow/src/ipc/gen/Tensor.rs
index c4551fe..6ae99fd 100644
--- a/rust/arrow/src/ipc/gen/Tensor.rs
+++ b/rust/arrow/src/ipc/gen/Tensor.rs
@@ -77,6 +77,24 @@ impl<'a> TensorDim<'a> {
}
}
+impl flatbuffers::Verifiable for TensorDim<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .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 name: Option<flatbuffers::WIPOffset<&'a str>>,
@@ -203,7 +221,7 @@ impl<'a> Tensor<'a> {
) -> flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<TensorDim<'a>>> {
self._tab
.get::<flatbuffers::ForwardsUOffset<
-
flatbuffers::Vector<flatbuffers::ForwardsUOffset<TensorDim<'a>>>,
+ flatbuffers::Vector<'a,
flatbuffers::ForwardsUOffset<TensorDim>>,
>>(Tensor::VT_SHAPE, None)
.unwrap()
}
@@ -454,6 +472,47 @@ impl<'a> Tensor<'a> {
}
}
+impl flatbuffers::Verifiable for Tensor<'_> {
+ #[inline]
+ fn run_verifier<'o, 'b>(
+ v: &mut flatbuffers::Verifier<'o, 'b>,
+ pos: usize,
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_union::<Type, _>(&"type_type", Self::VT_TYPE_TYPE, &"type_",
Self::VT_TYPE_, true, |key, v, pos| {
+ match key {
+ Type::Null =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Null>>("Type::Null", pos),
+ Type::Int =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Int>>("Type::Int", pos),
+ Type::FloatingPoint =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FloatingPoint>>("Type::FloatingPoint",
pos),
+ Type::Binary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Binary>>("Type::Binary",
pos),
+ Type::Utf8 =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Utf8>>("Type::Utf8", pos),
+ Type::Bool =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Bool>>("Type::Bool", pos),
+ Type::Decimal =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Decimal>>("Type::Decimal",
pos),
+ Type::Date =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Date>>("Type::Date", pos),
+ Type::Time =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Time>>("Type::Time", pos),
+ Type::Timestamp =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Timestamp>>("Type::Timestamp",
pos),
+ Type::Interval =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Interval>>("Type::Interval",
pos),
+ Type::List =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<List>>("Type::List", pos),
+ Type::Struct_ =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Struct_>>("Type::Struct_",
pos),
+ Type::Union =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Union>>("Type::Union",
pos),
+ Type::FixedSizeBinary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeBinary>>("Type::FixedSizeBinary",
pos),
+ Type::FixedSizeList =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<FixedSizeList>>("Type::FixedSizeList",
pos),
+ Type::Map =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Map>>("Type::Map", pos),
+ Type::Duration =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<Duration>>("Type::Duration",
pos),
+ Type::LargeBinary =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeBinary>>("Type::LargeBinary",
pos),
+ Type::LargeUtf8 =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeUtf8>>("Type::LargeUtf8",
pos),
+ Type::LargeList =>
v.verify_union_variant::<flatbuffers::ForwardsUOffset<LargeList>>("Type::LargeList",
pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
flatbuffers::ForwardsUOffset<TensorDim>>>>(&"shape", Self::VT_SHAPE, true)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_,
i64>>>(&"strides", Self::VT_STRIDES, false)?
+ .visit_field::<Buffer>(&"data", Self::VT_DATA, true)?
+ .finish();
+ Ok(())
+ }
+}
pub struct TensorArgs<'a> {
pub type_type: Type,
pub type_: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
@@ -764,16 +823,80 @@ impl std::fmt::Debug for Tensor<'_> {
}
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_root_as_tensor<'a>(buf: &'a [u8]) -> Tensor<'a> {
- flatbuffers::get_root::<Tensor<'a>>(buf)
+ unsafe { flatbuffers::root_unchecked::<Tensor<'a>>(buf) }
}
#[inline]
+#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...`
methods.")]
pub fn get_size_prefixed_root_as_tensor<'a>(buf: &'a [u8]) -> Tensor<'a> {
- flatbuffers::get_size_prefixed_root::<Tensor<'a>>(buf)
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Tensor<'a>>(buf) }
}
#[inline]
+/// Verifies that a buffer of bytes contains a `Tensor`
+/// and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_tensor_unchecked`.
+pub fn root_as_tensor(buf: &[u8]) -> Result<Tensor,
flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root::<Tensor>(buf)
+}
+#[inline]
+/// Verifies that a buffer of bytes contains a size prefixed
+/// `Tensor` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `size_prefixed_root_as_tensor_unchecked`.
+pub fn size_prefixed_root_as_tensor(
+ buf: &[u8],
+) -> Result<Tensor, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root::<Tensor>(buf)
+}
+#[inline]
+/// Verifies, with the given options, that a buffer of bytes
+/// contains a `Tensor` and returns it.
+/// Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_tensor_unchecked`.
+pub fn root_as_tensor_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Tensor<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::root_with_opts::<Tensor<'b>>(opts, buf)
+}
+#[inline]
+/// Verifies, with the given verifier options, that a buffer of
+/// bytes contains a size prefixed `Tensor` and returns
+/// it. Note that verification is still experimental and may not
+/// catch every error, or be maximally performant. For the
+/// previous, unchecked, behavior use
+/// `root_as_tensor_unchecked`.
+pub fn size_prefixed_root_as_tensor_with_opts<'b, 'o>(
+ opts: &'o flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+) -> Result<Tensor<'b>, flatbuffers::InvalidFlatbuffer> {
+ flatbuffers::size_prefixed_root_with_opts::<Tensor<'b>>(opts, buf)
+}
+#[inline]
+/// Assumes, without verification, that a buffer of bytes contains a Tensor
and returns it.
+/// # 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)
+}
+#[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)
+}
+#[inline]
pub fn finish_tensor_buffer<'a, 'b>(
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
root: flatbuffers::WIPOffset<Tensor<'a>>,
diff --git a/rust/arrow/src/ipc/reader.rs b/rust/arrow/src/ipc/reader.rs
index 559d83c..29e0e23 100644
--- a/rust/arrow/src/ipc/reader.rs
+++ b/rust/arrow/src/ipc/reader.rs
@@ -590,7 +590,10 @@ impl<R: Read + Seek> FileReader<R> {
let mut footer_data = vec![0; footer_len as usize];
reader.seek(SeekFrom::End(-10 - footer_len as i64))?;
reader.read_exact(&mut footer_data)?;
- let footer = ipc::get_root_as_footer(&footer_data[..]);
+
+ let footer = ipc::root_as_footer(&footer_data[..]).map_err(|err| {
+ ArrowError::IoError(format!("Unable to get root as footer: {:?}",
err))
+ })?;
let blocks = footer.recordBatches().ok_or_else(|| {
ArrowError::IoError(
@@ -621,7 +624,9 @@ impl<R: Read + Seek> FileReader<R> {
reader.read_exact(&mut block_data)?;
- let message = ipc::get_root_as_message(&block_data[..]);
+ let message = ipc::root_as_message(&block_data[..]).map_err(|err| {
+ ArrowError::IoError(format!("Unable to get root as message:
{:?}", err))
+ })?;
match message.header_type() {
ipc::MessageHeader::DictionaryBatch => {
@@ -698,7 +703,9 @@ impl<R: Read + Seek> FileReader<R> {
let mut block_data = vec![0; meta_len as usize];
self.reader.read_exact(&mut block_data)?;
- let message = ipc::get_root_as_message(&block_data[..]);
+ let message = ipc::root_as_message(&block_data[..]).map_err(|err| {
+ ArrowError::IoError(format!("Unable to get root as footer: {:?}",
err))
+ })?;
// some old test data's footer metadata is not set, so we account for
that
if self.metadata_version != ipc::MetadataVersion::V1
@@ -804,7 +811,9 @@ impl<R: Read> StreamReader<R> {
let mut meta_buffer = vec![0; meta_len as usize];
reader.read_exact(&mut meta_buffer)?;
- let message = ipc::get_root_as_message(meta_buffer.as_slice());
+ let message =
ipc::root_as_message(meta_buffer.as_slice()).map_err(|err| {
+ ArrowError::IoError(format!("Unable to get root as message: {:?}",
err))
+ })?;
// message header is a Schema, so read it
let ipc_schema: ipc::Schema = message.header_as_schema().ok_or_else(||
{
ArrowError::IoError("Unable to read IPC message as
schema".to_string())
@@ -873,7 +882,9 @@ impl<R: Read> StreamReader<R> {
self.reader.read_exact(&mut meta_buffer)?;
let vecs = &meta_buffer.to_vec();
- let message = ipc::get_root_as_message(vecs);
+ let message = ipc::root_as_message(vecs).map_err(|err| {
+ ArrowError::IoError(format!("Unable to get root as message: {:?}",
err))
+ })?;
match message.header_type() {
ipc::MessageHeader::Schema => Err(ArrowError::IoError(
diff --git a/rust/parquet/src/arrow/schema.rs b/rust/parquet/src/arrow/schema.rs
index 6a30539..22213d4 100644
--- a/rust/parquet/src/arrow/schema.rs
+++ b/rust/parquet/src/arrow/schema.rs
@@ -35,7 +35,7 @@ use crate::file::{metadata::KeyValue,
properties::WriterProperties};
use crate::schema::types::{ColumnDescriptor, SchemaDescriptor, Type, TypePtr};
/// Convert Parquet schema to Arrow schema including optional metadata.
-/// Attempts to decode any existing Arrow shcema metadata, falling back
+/// Attempts to decode any existing Arrow schema metadata, falling back
/// to converting the Parquet schema column-wise
pub fn parquet_to_arrow_schema(
parquet_schema: &SchemaDescriptor,
@@ -184,10 +184,21 @@ fn get_arrow_schema_from_metadata(encoded_meta: &str) ->
Option<Schema> {
} else {
bytes.as_slice()
};
- let message = arrow::ipc::get_root_as_message(slice);
- message
- .header_as_schema()
- .map(arrow::ipc::convert::fb_to_schema)
+ match arrow::ipc::root_as_message(slice) {
+ Ok(message) => message
+ .header_as_schema()
+ .map(arrow::ipc::convert::fb_to_schema),
+ Err(err) => {
+ // The flatbuffers implementation returns an error on
verification error.
+ // TODO: return error to caller?
+ eprintln!(
+ "Unable to get root as message stored in {}: {:?}",
+ super::ARROW_SCHEMA_META_KEY,
+ err
+ );
+ None
+ }
+ }
}
Err(err) => {
// The C++ implementation returns an error if the schema can't be
parsed.