Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions rust/arrow/regen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Change to the toplevel Rust directory
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="05192553f434d10c5f585aeb6a07a55a6ac702a5"
# https://github.com/google/flatbuffers/pull/6393
FB_COMMIT="408cf5802415e1dea65fef7489a6c2f3740fb381"
FB_DIR="rust/arrow/.flatbuffers"
FLATC="$FB_DIR/bazel-bin/flatc"

Expand Down
105 changes: 81 additions & 24 deletions rust/arrow/src/ipc/gen/File.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ use std::{cmp::Ordering, mem};
// automatically generated by the FlatBuffers compiler, do not modify

// struct Block, aligned to 8
#[repr(C, align(8))]
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Block {
offset_: i64,
metaDataLength_: i32,
padding0__: u32,
bodyLength_: i64,
} // pub struct Block
pub struct Block(pub [u8; 24]);
impl std::fmt::Debug for Block {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("Block")
Expand Down Expand Up @@ -82,36 +77,98 @@ 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>,
fn run_verifier(
v: &mut flatbuffers::Verifier,
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 {
offset_: _offset.to_little_endian(),
metaDataLength_: _metaDataLength.to_little_endian(),
bodyLength_: _bodyLength.to_little_endian(),

padding0__: 0,
}
#[allow(clippy::too_many_arguments)]
pub fn new(offset: i64, metaDataLength: i32, bodyLength: i64) -> Self {
let mut s = Self([0; 24]);
s.set_offset(offset);
s.set_metaDataLength(metaDataLength);
s.set_bodyLength(bodyLength);
s
}

/// Index to the start of the RecordBlock (note this is past the Message header)
pub fn offset(&self) -> i64 {
self.offset_.from_little_endian()
let mut mem = core::mem::MaybeUninit::<i64>::uninit();
unsafe {
core::ptr::copy_nonoverlapping(
self.0[0..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
core::mem::size_of::<i64>(),
);
mem.assume_init()
}
.from_little_endian()
}

pub fn set_offset(&mut self, x: i64) {
let x_le = x.to_little_endian();
unsafe {
core::ptr::copy_nonoverlapping(
&x_le as *const i64 as *const u8,
self.0[0..].as_mut_ptr(),
core::mem::size_of::<i64>(),
);
}
}

/// Length of the metadata
pub fn metaDataLength(&self) -> i32 {
self.metaDataLength_.from_little_endian()
let mut mem = core::mem::MaybeUninit::<i32>::uninit();
unsafe {
core::ptr::copy_nonoverlapping(
self.0[8..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
core::mem::size_of::<i32>(),
);
mem.assume_init()
}
.from_little_endian()
}

pub fn set_metaDataLength(&mut self, x: i32) {
let x_le = x.to_little_endian();
unsafe {
core::ptr::copy_nonoverlapping(
&x_le as *const i32 as *const u8,
self.0[8..].as_mut_ptr(),
core::mem::size_of::<i32>(),
);
}
}

/// Length of the data (this is aligned so there can be a gap between this and
/// the metadata).
pub fn bodyLength(&self) -> i64 {
self.bodyLength_.from_little_endian()
let mut mem = core::mem::MaybeUninit::<i64>::uninit();
unsafe {
core::ptr::copy_nonoverlapping(
self.0[16..].as_ptr(),
mem.as_mut_ptr() as *mut u8,
core::mem::size_of::<i64>(),
);
mem.assume_init()
}
.from_little_endian()
}

pub fn set_bodyLength(&mut self, x: i64) {
let x_le = x.to_little_endian();
unsafe {
core::ptr::copy_nonoverlapping(
&x_le as *const i64 as *const u8,
self.0[16..].as_mut_ptr(),
core::mem::size_of::<i64>(),
);
}
}
}

Expand Down Expand Up @@ -210,8 +267,8 @@ impl<'a> Footer<'a> {

impl flatbuffers::Verifiable for Footer<'_> {
#[inline]
fn run_verifier<'o, 'b>(
v: &mut flatbuffers::Verifier<'o, 'b>,
fn run_verifier(
v: &mut flatbuffers::Verifier,
pos: usize,
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
use flatbuffers::Verifiable;
Expand Down Expand Up @@ -344,13 +401,13 @@ impl std::fmt::Debug for Footer<'_> {
}
}
#[inline]
#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...` methods.")]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_root_as_footer<'a>(buf: &'a [u8]) -> Footer<'a> {
unsafe { flatbuffers::root_unchecked::<Footer<'a>>(buf) }
}

#[inline]
#[deprecated(since = "1.13", note = "Deprecated in favor of `root_as...` methods.")]
#[deprecated(since = "2.0.0", note = "Deprecated in favor of `root_as...` methods.")]
pub fn get_size_prefixed_root_as_footer<'a>(buf: &'a [u8]) -> Footer<'a> {
unsafe { flatbuffers::size_prefixed_root_unchecked::<Footer<'a>>(buf) }
}
Expand Down
Loading