-
Notifications
You must be signed in to change notification settings - Fork 839
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 all 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 | ||||
---|---|---|---|---|---|---|
|
@@ -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 | ||||||
|
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