-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regenerate arrow-ipc/src/gen with patched flatbuffers #6426
Changes from 11 commits
df868b4
d850dec
7fa795c
de03d26
e1378c9
7121201
a5803fb
1dd6c28
c0c9ea8
d454ae0
ac8b01c
a2c11ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ arrow-array = { workspace = true } | |
arrow-buffer = { workspace = true } | ||
arrow-data = { workspace = true } | ||
arrow-schema = { workspace = true } | ||
flatbuffers = { version = "24.3.25", default-features = false } | ||
flatbuffers = { version = "24.12.23", default-features = false } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
lz4_flex = { version = "0.11", default-features = false, features = ["std", "frame"], optional = true } | ||
zstd = { version = "0.13.0", default-features = false, optional = true } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
diff --git a/arrow-ipc/src/gen/File.rs b/arrow-ipc/src/gen/File.rs | ||
index 35ed13c0..427cf75d 100644 | ||
--- a/arrow-ipc/src/gen/File.rs | ||
+++ b/arrow-ipc/src/gen/File.rs | ||
@@ -66,6 +66,10 @@ impl<'b> flatbuffers::Push for Block { | ||
let src = ::core::slice::from_raw_parts(self as *const Block as *const u8, Self::size()); | ||
dst.copy_from_slice(src); | ||
} | ||
+ #[inline] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't flatbuffers 24.12.23 do that now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a holdover; we don't need the patch anymore. I've removed it |
||
+ fn alignment() -> flatbuffers::PushAlignment { | ||
+ flatbuffers::PushAlignment::new(8) | ||
+ } | ||
} | ||
|
||
impl<'a> flatbuffers::Verifiable for Block { | ||
diff --git a/arrow-ipc/src/gen/Message.rs b/arrow-ipc/src/gen/Message.rs | ||
index ea0c7236..928b41cc 100644 | ||
--- a/arrow-ipc/src/gen/Message.rs | ||
+++ b/arrow-ipc/src/gen/Message.rs | ||
@@ -386,6 +386,10 @@ impl<'b> flatbuffers::Push for FieldNode { | ||
::core::slice::from_raw_parts(self as *const FieldNode as *const u8, Self::size()); | ||
dst.copy_from_slice(src); | ||
} | ||
+ #[inline] | ||
+ fn alignment() -> flatbuffers::PushAlignment { | ||
+ flatbuffers::PushAlignment::new(8) | ||
+ } | ||
} | ||
|
||
impl<'a> flatbuffers::Verifiable for FieldNode { | ||
diff --git a/arrow-ipc/src/gen/Schema.rs b/arrow-ipc/src/gen/Schema.rs | ||
index ebe3f5f1..223e5a2f 100644 | ||
--- a/arrow-ipc/src/gen/Schema.rs | ||
+++ b/arrow-ipc/src/gen/Schema.rs | ||
@@ -1152,6 +1152,10 @@ impl<'b> flatbuffers::Push for Buffer { | ||
let src = ::core::slice::from_raw_parts(self as *const Buffer as *const u8, Self::size()); | ||
dst.copy_from_slice(src); | ||
} | ||
+ #[inline] | ||
+ fn alignment() -> flatbuffers::PushAlignment { | ||
+ flatbuffers::PushAlignment::new(8) | ||
+ } | ||
} | ||
|
||
impl<'a> flatbuffers::Verifiable for Buffer { |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,33 +21,36 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |||||
# Change to the toplevel `arrow-rs` directory | ||||||
pushd $DIR/../ | ||||||
|
||||||
echo "Build flatc from source ..." | ||||||
|
||||||
FB_URL="https://github.com/google/flatbuffers" | ||||||
FB_DIR="arrow/.flatbuffers" | ||||||
FLATC="$FB_DIR/bazel-bin/flatc" | ||||||
|
||||||
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}')" | ||||||
|
||||||
if [ ! -e $FB_DIR ]; then | ||||||
echo "git clone $FB_URL ..." | ||||||
git clone -b master --no-tag --depth 1 $FB_URL $FB_DIR | ||||||
if [ -z "$FLATC" ]; then | ||||||
echo "Build flatc from source ..." | ||||||
|
||||||
FB_URL="https://github.com/google/flatbuffers" | ||||||
FB_DIR="arrow/.flatbuffers" | ||||||
FLATC="$FB_DIR/bazel-bin/flatc" | ||||||
|
||||||
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}')" | ||||||
|
||||||
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 | ||||||
|
||||||
pushd $FB_DIR | ||||||
echo "run: bazel build :flatc ..." | ||||||
bazel build :flatc | ||||||
popd | ||||||
else | ||||||
echo "git pull $FB_URL ..." | ||||||
git -C $FB_DIR pull | ||||||
echo "Using flatc $FLATC ..." | ||||||
fi | ||||||
|
||||||
pushd $FB_DIR | ||||||
echo "run: bazel build :flatc ..." | ||||||
bazel build :flatc | ||||||
popd | ||||||
|
||||||
|
||||||
# Execute the code generation: | ||||||
$FLATC --filename-suffix "" --rust -o arrow-ipc/src/gen/ format/*.fbs | ||||||
|
||||||
|
@@ -99,37 +102,38 @@ for f in `ls *.rs`; do | |||||
fi | ||||||
|
||||||
echo "Modifying: $f" | ||||||
sed -i '' '/extern crate flatbuffers;/d' $f | ||||||
sed -i '' '/use self::flatbuffers::EndianScalar;/d' $f | ||||||
sed -i '' '/\#\[allow(unused_imports, dead_code)\]/d' $f | ||||||
sed -i '' '/pub mod org {/d' $f | ||||||
sed -i '' '/pub mod apache {/d' $f | ||||||
sed -i '' '/pub mod arrow {/d' $f | ||||||
sed -i '' '/pub mod flatbuf {/d' $f | ||||||
sed -i '' '/} \/\/ pub mod flatbuf/d' $f | ||||||
sed -i '' '/} \/\/ pub mod arrow/d' $f | ||||||
sed -i '' '/} \/\/ pub mod apache/d' $f | ||||||
sed -i '' '/} \/\/ pub mod org/d' $f | ||||||
sed -i '' '/use core::mem;/d' $f | ||||||
sed -i '' '/use core::cmp::Ordering;/d' $f | ||||||
sed -i '' '/use self::flatbuffers::{EndianScalar, Follow};/d' $f | ||||||
sed --in-place='' '/extern crate flatbuffers;/d' $f | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why but bash/sed produced an error for me until I made this substitution
Reading the man page, it seems like the expected invocation for the short flag is
Should I replace this with
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC Mac's sed (BSD utils) and the Linux coreutils sed behave differently. It's a bit of a pain. |
||||||
sed --in-place='' '/use self::flatbuffers::EndianScalar;/d' $f | ||||||
sed --in-place='' '/\#\[allow(unused_imports, dead_code)\]/d' $f | ||||||
sed --in-place='' '/pub mod org {/d' $f | ||||||
sed --in-place='' '/pub mod apache {/d' $f | ||||||
sed --in-place='' '/pub mod arrow {/d' $f | ||||||
sed --in-place='' '/pub mod flatbuf {/d' $f | ||||||
sed --in-place='' '/} \/\/ pub mod flatbuf/d' $f | ||||||
sed --in-place='' '/} \/\/ pub mod arrow/d' $f | ||||||
sed --in-place='' '/} \/\/ pub mod apache/d' $f | ||||||
sed --in-place='' '/} \/\/ pub mod org/d' $f | ||||||
sed --in-place='' '/use core::mem;/d' $f | ||||||
sed --in-place='' '/use core::cmp::Ordering;/d' $f | ||||||
sed --in-place='' '/use self::flatbuffers::{EndianScalar, Follow};/d' $f | ||||||
|
||||||
# required by flatc 1.12.0+ | ||||||
sed -i '' "/\#\!\[allow(unused_imports, dead_code)\]/d" $f | ||||||
sed --in-place='' "/\#\!\[allow(unused_imports, dead_code)\]/d" $f | ||||||
for name in ${names[@]}; do | ||||||
sed -i '' "/use crate::${name}::\*;/d" $f | ||||||
sed -i '' "s/use self::flatbuffers::Verifiable;/use flatbuffers::Verifiable;/g" $f | ||||||
sed --in-place='' "/use crate::${name}::\*;/d" $f | ||||||
sed --in-place='' "s/use self::flatbuffers::Verifiable;/use flatbuffers::Verifiable;/g" $f | ||||||
done | ||||||
|
||||||
# Replace all occurrences of "type__" with "type_", "TYPE__" with "TYPE_". | ||||||
sed -i '' 's/type__/type_/g' $f | ||||||
sed -i '' 's/TYPE__/TYPE_/g' $f | ||||||
sed --in-place='' 's/type__/type_/g' $f | ||||||
sed --in-place='' 's/TYPE__/TYPE_/g' $f | ||||||
|
||||||
# Some files need prefixes | ||||||
if [[ $f == "File.rs" ]]; then | ||||||
# Now prefix the file with the static contents | ||||||
echo -e "${PREFIX}" "${SCHEMA_IMPORT}" | cat - $f > temp && mv temp $f | ||||||
elif [[ $f == "Message.rs" ]]; then | ||||||
sed --in-place='' 's/List<Int16>/\`List<Int16>\`/g' $f | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was another manual edit of the generated files. Moving it here should simplify the next time |
||||||
echo -e "${PREFIX}" "${SCHEMA_IMPORT}" "${SPARSE_TENSOR_IMPORT}" "${TENSOR_IMPORT}" | cat - $f > temp && mv temp $f | ||||||
elif [[ $f == "SparseTensor.rs" ]]; then | ||||||
echo -e "${PREFIX}" "${SCHEMA_IMPORT}" "${TENSOR_IMPORT}" | cat - $f > temp && mv temp $f | ||||||
|
@@ -144,6 +148,13 @@ done | |||||
popd | ||||||
cargo +stable fmt -- src/gen/* | ||||||
|
||||||
if git apply gen.patch; then | ||||||
echo "Applied gen.patch" | ||||||
else | ||||||
echo "Error applying gen.patch" | ||||||
exit 1 | ||||||
fi | ||||||
|
||||||
echo "DONE!" | ||||||
echo "Please run 'cargo doc' and 'cargo test' with nightly and stable, " | ||||||
echo "and fix possible errors or warnings!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line and having the test run successfully is quite compelling. Nice work @bkietz