-
Notifications
You must be signed in to change notification settings - Fork 786
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
base: master
Are you sure you want to change the base?
Changes from all commits
9e92eff
7199304
9fd99ce
16fb310
043856d
8b19902
5d89e5a
43296c7
1858690
16783bc
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 |
---|---|---|
|
@@ -39,7 +39,7 @@ arrow-buffer = { workspace = true } | |
arrow-cast = { workspace = true } | ||
arrow-data = { workspace = true } | ||
arrow-schema = { workspace = true } | ||
flatbuffers = { version = "24.3.25", default-features = false } | ||
flatbuffers = { default-features = false, git = "https://github.com/google/flatbuffers.git", rev = "49061f8c7c99363eeea25c5e4337ebb499928467" } | ||
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 would need to be updated to a non-git version prior to merge, otherwise we'd be unable to make a release off main. 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. In fact I think we can't actually release a fix for arrow with this fix as the upstream change adds a new method 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. When I reverted this pin it fails to compile
Thus I think we need to wait for the next flatbuffers release 🤔 |
||
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] | ||
+ 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
|
||||||
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