From f1ebf0104c7297199555ab22287e14e8966bef00 Mon Sep 17 00:00:00 2001 From: Robert Kruszewski Date: Fri, 11 Sep 2026 11:50:29 +0000 Subject: [PATCH] Move protobuf and flatbuffer definitions into their owning crates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #1906. The `.fbs` and `.proto` schemas all lived in `vortex-flatbuffers` and `vortex-proto`, away from the types they describe, with their generated Rust checked in. Build-time generation existed before #557 but was removed because `vortex-build` discovered include paths by walking workspace metadata with `cargo_metadata` and reaching outside the package directory, neither of which survives packaging, so publishing broke. Declaring the dependencies explicitly avoids that. Each schema moves to the crate that owns the types it describes, and is compiled into `OUT_DIR` by that crate's `build.rs`. Nothing generated is checked in: | Schema | Crate | Module | | -------------------------- | --------------- | ---------------------------- | | `array.fbs`, `dtype.fbs` | `vortex-array` | `vortex_array::flatbuffers` | | `dtype/scalar/expr.proto` | `vortex-array` | `vortex_array::proto` | | `layout.fbs` | `vortex-layout` | `vortex_layout::flatbuffers` | | `footer.fbs` | `vortex-file` | `vortex_file::flatbuffers` | | `message.fbs` | `vortex-ipc` | `vortex_ipc::flatbuffers` | `vortex-proto` and `vortex-flatbuffers` are both removed. The FlatBuffers read/write traits move into `vortex_array::flatbuffers` alongside the generated array and dtype bindings, which every crate that used them already depended on. The new `vortex-build` crate holds the shared build script helpers, and `xtask` is deleted since code generation was its only job. A crate whose schemas include another crate's names it explicitly: vortex_build::flatbuffers() .depends_on("vortex-array") .compile(&["vortex-serde/message.fbs"]); `depends_on` resolves the dependency's schema directory through Cargo's `links` metadata, so a path dependency in the workspace and a package unpacked from a registry behave identically. `flatc`'s `--include-prefix` points cross-crate includes at a small `deps` module each consuming crate provides by hand, so no schema is compiled twice. The issue suggests generating into `src/flatbuffers/` and git-ignoring it. Generating into `OUT_DIR` instead keeps the same property — no generated code in git — without a build script writing into its own package, which would invalidate the registry checksum for anyone building a published crate. `.proto` compilation uses `protox` rather than `protoc`, so protobuf codegen needs no external tooling; the generated output is byte-identical to what was checked in. `.fbs` compilation shells out to `flatc`, which must be on `PATH` or named by `FLATC`, so CI installs it as part of the shared Rust setup and the musl job pulls it from Alpine. The flatbuffer back-compat check now flattens each revision's per-crate schema directories into one tree before running `flatc --conform`. `vortex_proto::{dtype, scalar, expr}` becomes `vortex_array::proto::*`, and both the flatbuffer traits and the generated modules move from `vortex_flatbuffers::*` to `vortex_array::flatbuffers` and the crates listed above. The `vortex` facade keeps `vortex::proto` and `vortex::flatbuffers` pointing at the same items, and `vortex_array:: dtype`'s `proto` and `flatbuffers` re-exports are unchanged. Building any Vortex crate from source now requires `flatc`, including for downstream consumers and docs.rs. Signed-off-by: Robert Kruszewski Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_017zTmZ6ANxESomTnvkvk85t --- .cargo/config.toml | 2 +- .github/actions/setup-flatc/action.yml | 81 +- .github/actions/setup-prebuild/action.yml | 4 + .github/actions/setup-rust/action.yml | 3 + .github/workflows/ci.yml | 28 +- .github/workflows/codspeed.yml | 2 +- .github/workflows/musl.yml | 3 + .github/workflows/rust-instrumented.yml | 6 +- AGENTS.md | 5 + CONTRIBUTING.md | 12 + Cargo.lock | 190 +- Cargo.toml | 8 +- .../developer-guide/internals/architecture.md | 2 +- .../internals/serialization.md | 7 +- docs/specs/dtype-format.md | 4 +- docs/specs/file-format.md | 4 +- docs/specs/scalar-format.md | 2 +- encodings/parquet-variant/Cargo.toml | 1 - encodings/parquet-variant/src/vtable.rs | 2 +- encodings/sequence/Cargo.toml | 1 - encodings/sequence/src/array.rs | 11 +- vortex-array/Cargo.toml | 13 +- vortex-array/build.rs | 7 + .../flatbuffers/vortex-array/array.fbs | 0 .../flatbuffers/vortex-dtype/dtype.fbs | 0 .../proto/dtype.proto | 0 .../proto/expr.proto | 0 .../proto/scalar.proto | 0 .../src/aggregate_fn/fns/sum_v2/tests.rs | 2 +- vortex-array/src/aggregate_fn/proto.rs | 4 +- vortex-array/src/aggregate_fn/vtable.rs | 2 +- vortex-array/src/arrays/variant/vtable/mod.rs | 2 +- vortex-array/src/dtype/mod.rs | 4 +- vortex-array/src/dtype/serde/flatbuffers.rs | 17 +- vortex-array/src/dtype/struct_.rs | 4 +- vortex-array/src/expr/proto.rs | 4 +- vortex-array/src/flatbuffers.rs | 59 + vortex-array/src/flatbuffers/traits.rs | 76 + vortex-array/src/lib.rs | 7 +- vortex-array/src/proto.rs | 31 + vortex-array/src/scalar/proto.rs | 10 +- vortex-array/src/scalar/tests/round_trip.rs | 2 +- vortex-array/src/scalar_fn/fns/between/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/binary/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/case_when.rs | 2 +- vortex-array/src/scalar_fn/fns/cast/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/get_item.rs | 2 +- vortex-array/src/scalar_fn/fns/like/mod.rs | 2 +- vortex-array/src/scalar_fn/fns/list_sum.rs | 2 +- vortex-array/src/scalar_fn/fns/literal.rs | 2 +- vortex-array/src/scalar_fn/fns/operators.rs | 3 +- vortex-array/src/scalar_fn/fns/pack.rs | 2 +- vortex-array/src/scalar_fn/fns/select.rs | 6 +- .../src/scalar_fn/fns/variant_get/mod.rs | 4 +- vortex-array/src/serde.rs | 8 +- vortex-array/src/stats/flatbuffers.rs | 4 +- .../Cargo.toml | 16 +- vortex-build/README.md | 28 + vortex-build/src/lib.rs | 195 ++ vortex-file/Cargo.toml | 4 +- vortex-file/build.rs | 9 + .../flatbuffers/vortex-file/footer.fbs | 0 vortex-file/src/flatbuffers.rs | 35 + vortex-file/src/footer/deserializer.rs | 8 +- vortex-file/src/footer/file_layout.rs | 6 +- vortex-file/src/footer/file_statistics.rs | 7 +- vortex-file/src/footer/mod.rs | 5 +- vortex-file/src/footer/postscript.rs | 14 +- vortex-file/src/footer/segment.rs | 3 +- vortex-file/src/footer/serializer.rs | 8 +- vortex-file/src/lib.rs | 1 + vortex-file/src/tests.rs | 2 +- vortex-flatbuffers/README.md | 8 - vortex-flatbuffers/src/generated/REUSE.toml | 6 - vortex-flatbuffers/src/generated/array.rs | 989 -------- vortex-flatbuffers/src/generated/dtype.rs | 2252 ----------------- vortex-flatbuffers/src/generated/footer.rs | 1508 ----------- vortex-flatbuffers/src/generated/layout.rs | 260 -- vortex-flatbuffers/src/generated/message.rs | 768 ------ vortex-flatbuffers/src/lib.rs | 205 -- vortex-ipc/Cargo.toml | 4 +- vortex-ipc/build.rs | 8 + .../flatbuffers/vortex-serde/message.fbs | 0 vortex-ipc/src/flatbuffers.rs | 35 + vortex-ipc/src/lib.rs | 1 + vortex-ipc/src/messages/decoder.rs | 9 +- vortex-ipc/src/messages/encoder.rs | 7 +- vortex-json/Cargo.toml | 1 - vortex-json/src/json_to_variant.rs | 2 +- vortex-layout/Cargo.toml | 7 +- vortex-layout/build.rs | 6 + .../flatbuffers/vortex-layout/layout.fbs | 0 vortex-layout/src/children.rs | 4 +- vortex-layout/src/flatbuffers.rs | 325 +-- vortex-layout/src/lib.rs | 5 +- vortex-layout/src/serde.rs | 304 +++ vortex-proto/Cargo.toml | 36 - vortex-proto/README.md | 8 - vortex-proto/src/generated/REUSE.toml | 6 - vortex-proto/src/generated/vortex.dtype.rs | 208 -- vortex-proto/src/generated/vortex.expr.rs | 209 -- vortex-proto/src/generated/vortex.scalar.rs | 61 - vortex-proto/src/lib.rs | 19 - vortex-tui/src/inspect.rs | 2 +- vortex/Cargo.toml | 4 +- vortex/src/lib.rs | 10 +- xtask/Cargo.toml | 2 - xtask/README.md | 17 +- xtask/src/generate_fbs.rs | 32 - xtask/src/generate_proto.rs | 28 - xtask/src/main.rs | 12 - 111 files changed, 1246 insertions(+), 7128 deletions(-) create mode 100644 vortex-array/build.rs rename {vortex-flatbuffers => vortex-array}/flatbuffers/vortex-array/array.fbs (100%) rename {vortex-flatbuffers => vortex-array}/flatbuffers/vortex-dtype/dtype.fbs (100%) rename {vortex-proto => vortex-array}/proto/dtype.proto (100%) rename {vortex-proto => vortex-array}/proto/expr.proto (100%) rename {vortex-proto => vortex-array}/proto/scalar.proto (100%) create mode 100644 vortex-array/src/flatbuffers.rs create mode 100644 vortex-array/src/flatbuffers/traits.rs create mode 100644 vortex-array/src/proto.rs rename {vortex-flatbuffers => vortex-build}/Cargo.toml (65%) create mode 100644 vortex-build/README.md create mode 100644 vortex-build/src/lib.rs create mode 100644 vortex-file/build.rs rename {vortex-flatbuffers => vortex-file}/flatbuffers/vortex-file/footer.fbs (100%) create mode 100644 vortex-file/src/flatbuffers.rs delete mode 100644 vortex-flatbuffers/README.md delete mode 100644 vortex-flatbuffers/src/generated/REUSE.toml delete mode 100644 vortex-flatbuffers/src/generated/array.rs delete mode 100644 vortex-flatbuffers/src/generated/dtype.rs delete mode 100644 vortex-flatbuffers/src/generated/footer.rs delete mode 100644 vortex-flatbuffers/src/generated/layout.rs delete mode 100644 vortex-flatbuffers/src/generated/message.rs delete mode 100644 vortex-flatbuffers/src/lib.rs create mode 100644 vortex-ipc/build.rs rename {vortex-flatbuffers => vortex-ipc}/flatbuffers/vortex-serde/message.fbs (100%) create mode 100644 vortex-ipc/src/flatbuffers.rs create mode 100644 vortex-layout/build.rs rename {vortex-flatbuffers => vortex-layout}/flatbuffers/vortex-layout/layout.fbs (100%) create mode 100644 vortex-layout/src/serde.rs delete mode 100644 vortex-proto/Cargo.toml delete mode 100644 vortex-proto/README.md delete mode 100644 vortex-proto/src/generated/REUSE.toml delete mode 100644 vortex-proto/src/generated/vortex.dtype.rs delete mode 100644 vortex-proto/src/generated/vortex.expr.rs delete mode 100644 vortex-proto/src/generated/vortex.scalar.rs delete mode 100644 vortex-proto/src/lib.rs delete mode 100644 xtask/src/generate_fbs.rs delete mode 100644 xtask/src/generate_proto.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index b40ec53c4c7..f2db3b990d2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -4,8 +4,8 @@ rustflags = [ ] [alias] -xtask = "run -p xtask --" vx = "run -p vortex-tui --" +xtask = "run -p xtask --" [publish] # NOTE(aduffy): we run into frequent issues auto-releasing our workspace diff --git a/.github/actions/setup-flatc/action.yml b/.github/actions/setup-flatc/action.yml index 46d0856a539..6b6b54e4a2e 100644 --- a/.github/actions/setup-flatc/action.yml +++ b/.github/actions/setup-flatc/action.yml @@ -1,5 +1,5 @@ name: "Setup flatc" -description: "Download and install flatc binary" +description: "Install the pinned flatc, from the official release binary or from source" inputs: flatc_version: description: "Version of the flatc binary" @@ -7,10 +7,79 @@ inputs: runs: using: "composite" steps: - - name: Download flatc - id: download-flatc + # The generated bindings are not source-compatible across flatc releases (24.x names a + # `size` field `size_`, for example), so the version has to match exactly. Distro packages + # lag well behind it, hence the release binary, or a source build where none is published. + - name: Install flatc shell: bash run: | - wget -O /tmp/flatc.zip "https://github.com/google/flatbuffers/releases/download/v${{ inputs.flatc_version }}/Linux.flatc.binary.clang++-18.zip" - unzip /tmp/flatc.zip flatc - mv flatc /usr/local/bin/ + set -euo pipefail + + VERSION="${{ inputs.flatc_version }}" + if [ "$(flatc --version 2>/dev/null)" = "flatc version ${VERSION}" ]; then + echo "flatc ${VERSION} is already installed" + exit 0 + fi + + ARCH=$(uname -m) + OS=$(uname -s | tr '[:upper:]' '[:lower:]') + + # Official binaries exist for x86_64 glibc Linux, macOS and Windows only. + ASSET="" + case "$OS" in + linux) + if [ "$ARCH" = "x86_64" ] && ! ldd /bin/sh 2>&1 | grep -qi musl; then + ASSET="Linux.flatc.binary.clang++-18.zip" + fi + ;; + darwin) + case "$ARCH" in + arm64) ASSET="Mac.flatc.binary.zip" ;; + x86_64) ASSET="MacIntel.flatc.binary.zip" ;; + esac + ;; + *) ASSET="Windows.flatc.binary.zip" ;; + esac + + # This sometimes runs in a container where the user is root and there is no sudo. + if command -v sudo &>/dev/null + then + CMD=sudo + else + CMD= + fi + + RELEASE="https://github.com/google/flatbuffers/releases/download/v${VERSION}" + if [ -n "$ASSET" ]; then + curl -fsSL -o /tmp/flatc.zip "${RELEASE}/${ASSET}" + unzip -o /tmp/flatc.zip -d /tmp/flatc + rm -f /tmp/flatc.zip + else + echo "No official flatc binary for ${OS}/${ARCH}; building ${VERSION} from source" + git clone --depth 1 --branch "v${VERSION}" \ + https://github.com/google/flatbuffers.git /tmp/flatbuffers + cmake -S /tmp/flatbuffers -B /tmp/flatbuffers/build \ + -DCMAKE_BUILD_TYPE=Release \ + -DFLATBUFFERS_BUILD_TESTS=OFF \ + -DFLATBUFFERS_BUILD_FLATLIB=OFF \ + -DFLATBUFFERS_BUILD_FLATHASH=OFF \ + -DFLATBUFFERS_INSTALL=OFF + cmake --build /tmp/flatbuffers/build --target flatc \ + --parallel "$(nproc 2>/dev/null || echo 4)" + mkdir -p /tmp/flatc + mv /tmp/flatbuffers/build/flatc /tmp/flatc/flatc + rm -rf /tmp/flatbuffers + fi + + if [ "$OS" = "linux" ] || [ "$OS" = "darwin" ]; then + $CMD mv /tmp/flatc/flatc /usr/local/bin/ + else + # Windows runners do not have /usr/local/bin on PATH for non-bash steps. + mkdir -p "$HOME/.local/bin" + mv /tmp/flatc/flatc.exe "$HOME/.local/bin/" + cygpath -w "$HOME/.local/bin" >> "$GITHUB_PATH" + export PATH="$HOME/.local/bin:$PATH" + fi + + rm -rf /tmp/flatc + flatc --version diff --git a/.github/actions/setup-prebuild/action.yml b/.github/actions/setup-prebuild/action.yml index 45c3e81d3c2..075c619d6de 100644 --- a/.github/actions/setup-prebuild/action.yml +++ b/.github/actions/setup-prebuild/action.yml @@ -170,3 +170,7 @@ runs: components: ${{ inputs.components }} targets: ${{ inputs.targets }} enable-sccache: "false" + + # Pins the version; the prebuild AMIs bake in a flatc that may lag it. + - name: Install flatc (for FlatBuffers code generation) + uses: ./.github/actions/setup-flatc diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml index e0e04bb39dc..ab834ece23c 100644 --- a/.github/actions/setup-rust/action.yml +++ b/.github/actions/setup-rust/action.yml @@ -83,3 +83,6 @@ runs: - name: Install Protoc (for lance-encoding build step) if: runner.os != 'Windows' uses: ./.github/actions/setup-protoc + + - name: Install flatc (for FlatBuffers code generation) + uses: ./.github/actions/setup-flatc diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4dab0e61f2..da16044e846 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -809,12 +809,9 @@ jobs: - uses: ./.github/actions/setup-prebuild with: enable-sccache: "true" + - uses: ./.github/actions/setup-flatc - name: Install nightly for cbindgen macro expansion run: rustup toolchain install $NIGHTLY_TOOLCHAIN - - name: "regenerate all .fbs/.proto Rust code" - run: | - cargo run --profile ci -p xtask -- generate-fbs - cargo run --profile ci -p xtask -- generate-proto - name: "regenerate the edition records" run: | cargo run --profile ci -p xtask -- generate-editions @@ -833,16 +830,27 @@ jobs: git status --porcelain test -z "$(git status --porcelain)" - - name: "Checkout develop flatbuffers" - working-directory: vortex-flatbuffers/ + # Schemas live under `/flatbuffers/` but resolve includes against those dirs + # collectively, so flatten each revision into one tree for flatc to compare. + - name: "Collect flatbuffer schemas from this revision and from develop" run: | - cp -R flatbuffers flatbuffers.HEAD git fetch origin develop --depth 1 - git checkout origin/develop -- flatbuffers + collect() { + git ls-tree -r --name-only "$1" \ + | grep -E '(^|/)flatbuffers/.*\.fbs$' \ + | while read -r path; do + rel="${path#*/flatbuffers/}" + mkdir -p "$2/$(dirname "$rel")" + git show "$1:$path" > "$2/$rel" + done + } + collect HEAD "$RUNNER_TEMP/fbs.head" + collect origin/develop "$RUNNER_TEMP/fbs.develop" - name: "Verify flatbuffer back-compat" - working-directory: vortex-flatbuffers/ + working-directory: ${{ runner.temp }} run: | - find flatbuffers/ -type f -name "*.fbs" | sed 's/^flatbuffers\///' | xargs -I{} -n1 flatc -I flatbuffers.HEAD --conform-includes flatbuffers --conform flatbuffers/{} flatbuffers.HEAD/{} + find fbs.develop/ -type f -name "*.fbs" | sed 's|^fbs.develop/||' \ + | xargs -I{} -n1 flatc -I fbs.head --conform-includes fbs.develop --conform fbs.develop/{} fbs.head/{} ffi-c-test: name: "C API test build" diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index ca492ba43ca..da75fe1887b 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -56,7 +56,7 @@ jobs: - { shard: 5, name: "Encodings 2", packages: "vortex-decimal-byte-parts vortex-fastlanes vortex-fsst", features: "--features _test-harness" } - { shard: 6, name: "Encodings 3", packages: "vortex-pco vortex-runend vortex-sequence" } - { shard: 7, name: "Encodings 4 & layout", packages: "vortex-sparse vortex-zigzag vortex-zstd vortex-layout" } - - { shard: 8, name: "Storage formats & row encoding", packages: "vortex-flatbuffers vortex-proto vortex-btrblocks vortex-row" } + - { shard: 8, name: "Storage formats & row encoding", packages: "vortex-btrblocks vortex-row" } - { shard: 9, name: "Tensor & spatial", packages: "vortex-tensor vortex-spatial" } name: "Benchmark with Codspeed (Shard #${{ matrix.shard }})" timeout-minutes: 30 diff --git a/.github/workflows/musl.yml b/.github/workflows/musl.yml index da6e93ab581..b3d38c6eeb7 100644 --- a/.github/workflows/musl.yml +++ b/.github/workflows/musl.yml @@ -54,6 +54,9 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + # Alpine only packages flatc versions we cannot use, so this builds the pinned one. + - uses: ./.github/actions/setup-flatc + - name: Install nextest shell: bash # Prebuilt static musl nextest binary; building it from source would diff --git a/.github/workflows/rust-instrumented.yml b/.github/workflows/rust-instrumented.yml index 5d55836b768..e64753fd3b6 100644 --- a/.github/workflows/rust-instrumented.yml +++ b/.github/workflows/rust-instrumented.yml @@ -100,9 +100,9 @@ jobs: --llvm-path "${LLVM_TOOLS_BIN}" \ --threads $(nproc) \ --ignore '../*' --ignore '/*' --ignore 'fuzz/*' --ignore 'vortex-bench/*' \ - --ignore 'home/*' --ignore 'xtask/*' --ignore 'target/*' --ignore 'vortex-error/*' \ - --ignore 'vortex-python/*' --ignore 'vortex-jni/*' --ignore 'vortex-flatbuffers/*' \ - --ignore 'vortex-proto/*' --ignore 'vortex-tui/*' --ignore 'vortex-datafusion/examples/*' \ + --ignore 'home/*' --ignore 'xtask/*' --ignore 'vortex-build/*' --ignore 'target/*' --ignore 'vortex-error/*' \ + --ignore 'vortex-python/*' --ignore 'vortex-jni/*' \ + --ignore 'vortex-tui/*' --ignore 'vortex-datafusion/examples/*' \ --ignore 'vortex-ffi/examples/*' --ignore '*/arbitrary/*' --ignore '*/arbitrary.rs' \ --ignore benchmarks/* --ignore 'vortex-test/*' \ -o ${{ env.GRCOV_OUTPUT_FILE }} diff --git a/AGENTS.md b/AGENTS.md index 36ccc5ad1c9..18ec110191c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,6 +29,11 @@ documentation in `docs/`, and benchmark tooling in `vortex-bench/` and `benchmar and the OpenDAL-backed services (`cos://`, `oss://`). Every binding resolves URLs through it. - `vortex-scan`, `vortex-session`, `vortex-datafusion`, and `vortex-duckdb` contain scan and execution integrations. +- FlatBuffers (`.fbs`) and Protocol Buffers (`.proto`) schemas live in the crate that owns the + types they describe (`vortex-array`, `vortex-layout`, `vortex-file`, `vortex-ipc`), and are + compiled into `OUT_DIR` by that crate's `build.rs` via `vortex-build`. Generated code is never + checked in, and a schema that includes another crate's declares that crate with `depends_on`. + Building therefore requires `flatc` on `PATH` (or `FLATC` set); `protoc` is not needed. - `vortex-python` contains Python bindings. RST-flavored project docs live in `docs/`. ## Scoped Guidance diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e8c9960002b..fba8f6fe24f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,6 +36,18 @@ The contribution process is outlined below: ## Development Workflows +### Build prerequisites + +Bindings for the `.fbs` and `.proto` schemas are generated at build time into `OUT_DIR` by the +`build.rs` of the crate that owns each schema, and are never checked in. + +FlatBuffers generation shells out to the [`flatc`](https://github.com/google/flatbuffers/releases) +compiler, so building any Vortex crate requires it on `PATH`, or its location in the `FLATC` +environment variable. CI pins version `25.12.19`; other recent versions work, but may produce +cosmetically different generated code. + +Protocol Buffers generation parses schemas in pure Rust, so `protoc` is not required. + The repository uses [`uv`](https://docs.astral.sh/uv/) to manage its Python workspace. From the repository root, create or update the development environment with: diff --git a/Cargo.lock b/Cargo.lock index bf637fb4dc0..f98b121d737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1153,6 +1153,12 @@ dependencies = [ "unicode-width 0.2.2", ] +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + [[package]] name = "better_io" version = "0.2.0" @@ -6349,6 +6355,72 @@ version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" +[[package]] +name = "logos" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154" +dependencies = [ + "logos-derive 0.15.1", +] + +[[package]] +name = "logos" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2c55a318a87600ea870ff8c2012148b44bf18b74fad48d0f835c38c7d07c5f" +dependencies = [ + "logos-derive 0.16.1", +] + +[[package]] +name = "logos-codegen" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c" +dependencies = [ + "beef", + "fnv", + "lazy_static", + "proc-macro2", + "quote", + "regex-syntax", + "rustc_version", + "syn 2.0.119", +] + +[[package]] +name = "logos-codegen" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58b3ffaa284e1350d017a57d04ada118c4583cf260c8fb01e0fe28a2e9cf8970" +dependencies = [ + "fnv", + "proc-macro2", + "quote", + "regex-automata", + "regex-syntax", + "syn 2.0.119", +] + +[[package]] +name = "logos-derive" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470" +dependencies = [ + "logos-codegen 0.15.1", +] + +[[package]] +name = "logos-derive" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52d3a9855747c17eaf4383823f135220716ab49bea5fbea7dd42cc9a92f8aa31" +dependencies = [ + "logos-codegen 0.16.1", +] + [[package]] name = "loom" version = "0.7.2" @@ -6524,6 +6596,28 @@ dependencies = [ "libc", ] +[[package]] +name = "miette" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" +dependencies = [ + "cfg-if", + "miette-derive", + "unicode-width 0.1.14", +] + +[[package]] +name = "miette-derive" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "mimalloc" version = "0.1.52" @@ -7833,6 +7927,18 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "prost-reflect" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01b80ea363c31af2de2b92e3c07ed1156628f7838c4afb4df75ee78a37fedbd1" +dependencies = [ + "logos 0.16.1", + "miette", + "prost 0.14.4", + "prost-types", +] + [[package]] name = "prost-types" version = "0.14.4" @@ -7842,6 +7948,33 @@ dependencies = [ "prost 0.14.4", ] +[[package]] +name = "protox" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f25a07a73c6717f0b9bbbd685918f5df9815f7efba450b83d9c9dea41f0e3a1" +dependencies = [ + "bytes", + "miette", + "prost 0.14.4", + "prost-reflect", + "prost-types", + "protox-parse", + "thiserror 2.0.20", +] + +[[package]] +name = "protox-parse" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "072eee358134396a4643dff81cfff1c255c9fbd3fb296be14bdb6a26f9156366" +dependencies = [ + "logos 0.15.1", + "miette", + "prost-types", + "thiserror 2.0.20", +] + [[package]] name = "psm" version = "0.1.32" @@ -10440,7 +10573,6 @@ dependencies = [ "vortex-error", "vortex-fastlanes", "vortex-file", - "vortex-flatbuffers", "vortex-fsst", "vortex-io", "vortex-ipc", @@ -10449,7 +10581,6 @@ dependencies = [ "vortex-metrics", "vortex-parquet-variant", "vortex-pco", - "vortex-proto", "vortex-runend", "vortex-scan", "vortex-sequence", @@ -10513,6 +10644,7 @@ dependencies = [ "pin-project-lite", "primitive-types", "prost 0.14.4", + "prost-types", "rand 0.10.2", "rand_distr 0.6.0", "regex", @@ -10534,11 +10666,10 @@ dependencies = [ "vortex-array-macros", "vortex-bench-support", "vortex-buffer", + "vortex-build", "vortex-compute", "vortex-error", - "vortex-flatbuffers", "vortex-mask", - "vortex-proto", "vortex-session", "vortex-utils", ] @@ -10705,6 +10836,14 @@ dependencies = [ "vortex-error", ] +[[package]] +name = "vortex-build" +version = "0.1.0" +dependencies = [ + "prost-build", + "protox", +] + [[package]] name = "vortex-bytebool" version = "0.1.0" @@ -11062,13 +11201,13 @@ dependencies = [ "vortex-array", "vortex-btrblocks", "vortex-buffer", + "vortex-build", "vortex-bytebool", "vortex-datetime-parts", "vortex-decimal-byte-parts", "vortex-edition", "vortex-error", "vortex-fastlanes", - "vortex-flatbuffers", "vortex-fsst", "vortex-io", "vortex-layout", @@ -11087,15 +11226,6 @@ dependencies = [ "vortex-zstd", ] -[[package]] -name = "vortex-flatbuffers" -version = "0.1.0" -dependencies = [ - "flatbuffers", - "vortex-buffer", - "vortex-error", -] - [[package]] name = "vortex-fsst" version = "0.1.0" @@ -11186,8 +11316,8 @@ dependencies = [ "tokio", "vortex-array", "vortex-buffer", + "vortex-build", "vortex-error", - "vortex-flatbuffers", "vortex-session", ] @@ -11229,7 +11359,6 @@ dependencies = [ "vortex-arrow", "vortex-edition", "vortex-error", - "vortex-proto", "vortex-session", ] @@ -11270,8 +11399,8 @@ dependencies = [ "vortex-arrow", "vortex-btrblocks", "vortex-buffer", + "vortex-build", "vortex-error", - "vortex-flatbuffers", "vortex-io", "vortex-mask", "vortex-metrics", @@ -11353,7 +11482,6 @@ dependencies = [ "vortex-json", "vortex-layout", "vortex-mask", - "vortex-proto", "vortex-session", ] @@ -11372,14 +11500,6 @@ dependencies = [ "vortex-session", ] -[[package]] -name = "vortex-proto" -version = "0.1.0" -dependencies = [ - "prost 0.14.4", - "prost-types", -] - [[package]] name = "vortex-python" version = "0.1.0" @@ -11490,7 +11610,6 @@ dependencies = [ "vortex-buffer", "vortex-error", "vortex-mask", - "vortex-proto", "vortex-session", ] @@ -12185,21 +12304,6 @@ dependencies = [ "rustix", ] -[[package]] -name = "xshell" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d" -dependencies = [ - "xshell-macros", -] - -[[package]] -name = "xshell-macros" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" - [[package]] name = "xtask" version = "0.1.0" @@ -12207,14 +12311,12 @@ dependencies = [ "anyhow", "clap", "git2", - "prost-build", "toml", "vortex-edition", "vortex-json", "vortex-spatial", "vortex-tensor", "vortex-zstd", - "xshell", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5ac6274af31..1ac33bca6a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,11 +9,10 @@ members = [ "vortex-utils", "vortex-session", "vortex-edition", - "vortex-flatbuffers", + "vortex-build", "vortex-metrics", "vortex-io", "vortex-cloud", - "vortex-proto", "vortex-array", "vortex-arrow", "vortex-row", @@ -221,6 +220,7 @@ proc-macro2 = "1.0.95" prost = "0.14" prost-build = "0.14" prost-types = "0.14" +protox = "0.9.1" pyo3 = { version = "0.29.0" } pyo3-bytes = "0.7" pyo3-log = "0.13.0" @@ -289,7 +289,6 @@ url = "2.5.7" uuid = "1.23" wasm-bindgen-futures = "0.4.58" wkb = "0.9.2" -xshell = "0.2.6" zigzag = "0.1.0" zip = "8.0.0" zstd = { version = "0.13.3", default-features = false, features = [ @@ -304,6 +303,7 @@ vortex-array-macros = { version = "0.1.0", path = "./vortex-array-macros" } vortex-arrow = { version = "0.1.0", path = "./vortex-arrow", default-features = false } vortex-btrblocks = { version = "0.1.0", path = "./vortex-btrblocks", default-features = false } vortex-buffer = { version = "0.1.0", path = "./vortex-buffer", default-features = false } +vortex-build = { version = "0.1.0", path = "./vortex-build" } vortex-bytebool = { version = "0.1.0", path = "./encodings/bytebool", default-features = false } vortex-cloud = { version = "0.1.0", path = "./vortex-cloud", default-features = false } vortex-compressor = { version = "0.1.0", path = "./vortex-compressor", default-features = false } @@ -315,7 +315,6 @@ vortex-edition = { version = "0.1.0", path = "./vortex-edition", default-feature vortex-error = { version = "0.1.0", path = "./vortex-error", default-features = false } vortex-fastlanes = { version = "0.1.0", path = "./encodings/fastlanes", default-features = false } vortex-file = { version = "0.1.0", path = "./vortex-file", default-features = false } -vortex-flatbuffers = { version = "0.1.0", path = "./vortex-flatbuffers", default-features = false } vortex-fsst = { version = "0.1.0", path = "./encodings/fsst", default-features = false } vortex-io = { version = "0.1.0", path = "./vortex-io", default-features = false } vortex-ipc = { version = "0.1.0", path = "./vortex-ipc", default-features = false } @@ -326,7 +325,6 @@ vortex-metrics = { version = "0.1.0", path = "./vortex-metrics", default-feature vortex-onpair = { version = "0.1.0", path = "./encodings/onpair", default-features = false } vortex-parquet-variant = { version = "0.1.0", path = "./encodings/parquet-variant" } vortex-pco = { version = "0.1.0", path = "./encodings/pco", default-features = false } -vortex-proto = { version = "0.1.0", path = "./vortex-proto", default-features = false } vortex-row = { version = "0.1.0", path = "./vortex-row", default-features = false } vortex-runend = { version = "0.1.0", path = "./encodings/runend", default-features = false } vortex-scan = { version = "0.1.0", path = "./vortex-scan", default-features = false } diff --git a/docs/developer-guide/internals/architecture.md b/docs/developer-guide/internals/architecture.md index 3354c25cd85..2e66bb4726f 100644 --- a/docs/developer-guide/internals/architecture.md +++ b/docs/developer-guide/internals/architecture.md @@ -33,13 +33,13 @@ format, and I/O. | `vortex-mask` | Bitmask operations for validity and selection | | `vortex-session` | Session object holding registries for encodings, layouts, and extension types | | `vortex-array` | `Array` trait, canonical encodings, vtable system, statistics | +| `vortex-build` | Build script helpers that generate FlatBuffer and Protobuf bindings | | `vortex-io` | Async I/O abstraction (local filesystem, object store, HTTP) | | `vortex-layout` | Layout traits and built-in layouts (Flat, Struct, Chunked) | | `vortex-ipc` | IPC format for inter-process communication | | `vortex-file` | `.vortex` file reading and writing | | `vortex-scan` | Table scan with filter and projection pushdown | | `vortex-expr` | Expression representation and optimization | -| `vortex-flatbuffers` | FlatBuffer schema definitions | ## Encodings diff --git a/docs/developer-guide/internals/serialization.md b/docs/developer-guide/internals/serialization.md index 11cfe720c47..22c73e66d9a 100644 --- a/docs/developer-guide/internals/serialization.md +++ b/docs/developer-guide/internals/serialization.md @@ -99,8 +99,11 @@ message. This is important for wide schemas where only a few columns are accesse the reader can jump directly to the relevant layout node without deserializing the rest of the footer. -All FlatBuffers in Vortex are aligned to 8 bytes. Schema definitions live in the -`vortex-flatbuffers` crate and cover arrays, layouts, the file footer, and IPC messages. +All FlatBuffers in Vortex are aligned to 8 bytes. Each schema definition lives in the crate that +owns the types it describes -- arrays and dtypes in `vortex-array`, layouts in `vortex-layout`, the +file footer in `vortex-file`, and IPC messages in `vortex-ipc` -- next to the generated Rust +bindings, which `build.rs` compiles into `OUT_DIR`. The read/write traits they all share live in +`vortex_array::flatbuffers`. ## Zero-Copy Design diff --git a/docs/specs/dtype-format.md b/docs/specs/dtype-format.md index 39bed0938e6..5f0130ca8a1 100644 --- a/docs/specs/dtype-format.md +++ b/docs/specs/dtype-format.md @@ -2,11 +2,11 @@ ## FlatBuffer Definition -:::{literalinclude} ../../vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs +:::{literalinclude} ../../vortex-array/flatbuffers/vortex-dtype/dtype.fbs ::: ## Protobuf Definition -:::{literalinclude} ../../vortex-proto/proto/dtype.proto +:::{literalinclude} ../../vortex-array/proto/dtype.proto :language: protobuf ::: diff --git a/docs/specs/file-format.md b/docs/specs/file-format.md index 4a977365cb8..04e065ac5f1 100644 --- a/docs/specs/file-format.md +++ b/docs/specs/file-format.md @@ -62,7 +62,7 @@ Readers do not load the opaque metadata values by default. Opt-in metadata reads locator separately, allowing values outside the initial file-tail read to be fetched without reading the intervening file contents. -:::{literalinclude} ../../vortex-flatbuffers/flatbuffers/vortex-file/footer.fbs +:::{literalinclude} ../../vortex-file/flatbuffers/vortex-file/footer.fbs :start-after: [postscript] :end-before: [postscript] ::: @@ -87,7 +87,7 @@ The footer is a flat buffer serialized `Footer` object. This object contains all load the root `Layout` object into a usable `LayoutReader`). For example, it contains the locations, compression schemes, encryption schemes, and required alignment of all segments in the file. -:::{literalinclude} ../../vortex-flatbuffers/flatbuffers/vortex-file/footer.fbs +:::{literalinclude} ../../vortex-file/flatbuffers/vortex-file/footer.fbs :start-after: [footer] :end-before: [footer] ::: diff --git a/docs/specs/scalar-format.md b/docs/specs/scalar-format.md index 2ee512c2be0..e14efde23d0 100644 --- a/docs/specs/scalar-format.md +++ b/docs/specs/scalar-format.md @@ -2,6 +2,6 @@ ## Protobuf Definition -:::{literalinclude} ../../vortex-proto/proto/scalar.proto +:::{literalinclude} ../../vortex-array/proto/scalar.proto :language: protobuf ::: diff --git a/encodings/parquet-variant/Cargo.toml b/encodings/parquet-variant/Cargo.toml index e90da6c8ebe..9c6d8f99611 100644 --- a/encodings/parquet-variant/Cargo.toml +++ b/encodings/parquet-variant/Cargo.toml @@ -30,7 +30,6 @@ vortex-buffer = { workspace = true } vortex-error = { workspace = true } vortex-json = { workspace = true } vortex-mask = { workspace = true } -vortex-proto = { workspace = true, features = ["expr"] } vortex-session = { workspace = true } [dev-dependencies] diff --git a/encodings/parquet-variant/src/vtable.rs b/encodings/parquet-variant/src/vtable.rs index 297198df438..f4e90d758fa 100644 --- a/encodings/parquet-variant/src/vtable.rs +++ b/encodings/parquet-variant/src/vtable.rs @@ -15,6 +15,7 @@ use vortex_array::arrays::VariantArray; use vortex_array::buffer::BufferHandle; use vortex_array::dtype::DType; use vortex_array::dtype::Nullability; +use vortex_array::proto::dtype as pb; use vortex_array::serde::ArrayChildren; use vortex_array::validity::Validity; use vortex_array::vtable::VTable; @@ -25,7 +26,6 @@ use vortex_error::vortex_ensure; use vortex_error::vortex_ensure_eq; use vortex_error::vortex_err; use vortex_error::vortex_panic; -use vortex_proto::dtype as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; diff --git a/encodings/sequence/Cargo.toml b/encodings/sequence/Cargo.toml index e60d6be29b7..e307d07f075 100644 --- a/encodings/sequence/Cargo.toml +++ b/encodings/sequence/Cargo.toml @@ -21,7 +21,6 @@ vortex-array = { workspace = true } vortex-buffer = { workspace = true } vortex-error = { workspace = true } vortex-mask = { workspace = true } -vortex-proto = { workspace = true } vortex-session = { workspace = true } [dev-dependencies] diff --git a/encodings/sequence/src/array.rs b/encodings/sequence/src/array.rs index 10a222544b6..a36a1f6edab 100644 --- a/encodings/sequence/src/array.rs +++ b/encodings/sequence/src/array.rs @@ -29,6 +29,7 @@ use vortex_array::expr::stats::Precision as StatPrecision; use vortex_array::expr::stats::Stat; use vortex_array::match_each_integer_ptype; use vortex_array::match_each_pvalue; +use vortex_array::proto::scalar::ScalarValue as ProtoScalarValue; use vortex_array::scalar::PValue; use vortex_array::scalar::Scalar; use vortex_array::scalar::ScalarValue; @@ -58,9 +59,9 @@ pub type SequenceArray = Array; #[derive(Clone, prost::Message)] pub struct SequenceMetadata { #[prost(message, tag = "1")] - base: Option, + base: Option, #[prost(message, tag = "2")] - multiplier: Option, + multiplier: Option, } pub(super) const SLOT_NAMES: [&str; 0] = []; @@ -175,10 +176,8 @@ impl SequenceData { } /// The step's ptype: the serialized form preserves its signedness but not its width. - fn multiplier_ptype_from_proto( - multiplier: &vortex_proto::scalar::ScalarValue, - ) -> VortexResult { - use vortex_proto::scalar::scalar_value::Kind; + fn multiplier_ptype_from_proto(multiplier: &ProtoScalarValue) -> VortexResult { + use vortex_array::proto::scalar::scalar_value::Kind; match multiplier .kind .as_ref() diff --git a/vortex-array/Cargo.toml b/vortex-array/Cargo.toml index f6b06544baf..cc5d869aaa1 100644 --- a/vortex-array/Cargo.toml +++ b/vortex-array/Cargo.toml @@ -11,11 +11,18 @@ license = { workspace = true } readme = "README.md" repository = { workspace = true } rust-version = { workspace = true } + +# Exports the `flatbuffers` and `proto` schema directories to dependent build scripts. +links = "vortex-array" version = { workspace = true } [package.metadata.docs.rs] all-features = true +[package.metadata.cargo-shear] +# Referenced only by the generated Protocol Buffers bindings. +ignored = ["prost-types"] + [lints] workspace = true @@ -47,6 +54,7 @@ primitive-types = { workspace = true, optional = true, features = [ "arbitrary", ] } prost = { workspace = true } +prost-types = { workspace = true } rand = { workspace = true } regex = { workspace = true } regex-syntax = { workspace = true } @@ -66,9 +74,7 @@ vortex-array-macros = { workspace = true } vortex-buffer = { workspace = true } vortex-compute = { workspace = true } vortex-error = { workspace = true, features = ["flatbuffers"] } -vortex-flatbuffers = { workspace = true, features = ["array", "dtype"] } vortex-mask = { workspace = true } -vortex-proto = { workspace = true, features = ["dtype", "expr", "scalar"] } vortex-session = { workspace = true } vortex-utils = { workspace = true, features = ["dyn-traits"] } @@ -82,6 +88,9 @@ serde = ["dep:serde", "vortex-buffer/serde", "vortex-mask/serde"] # Exposes experimental row-function APIs without compatibility guarantees. unstable_row_fns = [] +[build-dependencies] +vortex-build = { workspace = true } + [dev-dependencies] allocator-api2 = { workspace = true } divan = { workspace = true } diff --git a/vortex-array/build.rs b/vortex-array/build.rs new file mode 100644 index 00000000000..9a9d8edda8e --- /dev/null +++ b/vortex-array/build.rs @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +fn main() { + vortex_build::flatbuffers().compile(&["vortex-array/array.fbs", "vortex-dtype/dtype.fbs"]); + vortex_build::proto().compile(&["dtype.proto", "scalar.proto", "expr.proto"]); +} diff --git a/vortex-flatbuffers/flatbuffers/vortex-array/array.fbs b/vortex-array/flatbuffers/vortex-array/array.fbs similarity index 100% rename from vortex-flatbuffers/flatbuffers/vortex-array/array.fbs rename to vortex-array/flatbuffers/vortex-array/array.fbs diff --git a/vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs b/vortex-array/flatbuffers/vortex-dtype/dtype.fbs similarity index 100% rename from vortex-flatbuffers/flatbuffers/vortex-dtype/dtype.fbs rename to vortex-array/flatbuffers/vortex-dtype/dtype.fbs diff --git a/vortex-proto/proto/dtype.proto b/vortex-array/proto/dtype.proto similarity index 100% rename from vortex-proto/proto/dtype.proto rename to vortex-array/proto/dtype.proto diff --git a/vortex-proto/proto/expr.proto b/vortex-array/proto/expr.proto similarity index 100% rename from vortex-proto/proto/expr.proto rename to vortex-array/proto/expr.proto diff --git a/vortex-proto/proto/scalar.proto b/vortex-array/proto/scalar.proto similarity index 100% rename from vortex-proto/proto/scalar.proto rename to vortex-array/proto/scalar.proto diff --git a/vortex-array/src/aggregate_fn/fns/sum_v2/tests.rs b/vortex-array/src/aggregate_fn/fns/sum_v2/tests.rs index 65e54a5bb6a..c470395f34f 100644 --- a/vortex-array/src/aggregate_fn/fns/sum_v2/tests.rs +++ b/vortex-array/src/aggregate_fn/fns/sum_v2/tests.rs @@ -5,7 +5,6 @@ use prost::Message; use rstest::rstest; use vortex_buffer::buffer; use vortex_error::VortexResult; -use vortex_proto::expr as pb; use super::SumV2; use super::sum_v2; @@ -38,6 +37,7 @@ use crate::dtype::Nullability::Nullable; use crate::dtype::PType; use crate::expr::stats::Precision; use crate::expr::stats::Stat; +use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar::ScalarValue; use crate::validity::Validity; diff --git a/vortex-array/src/aggregate_fn/proto.rs b/vortex-array/src/aggregate_fn/proto.rs index 92fac87892a..d4566b4bfc8 100644 --- a/vortex-array/src/aggregate_fn/proto.rs +++ b/vortex-array/src/aggregate_fn/proto.rs @@ -4,13 +4,13 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use crate::aggregate_fn::AggregateFnId; use crate::aggregate_fn::AggregateFnRef; use crate::aggregate_fn::new_foreign_aggregate_fn; use crate::aggregate_fn::session::AggregateFnSessionExt; +use crate::proto::expr as pb; impl AggregateFnRef { /// Serialize this aggregate function to its protobuf representation. @@ -63,7 +63,6 @@ mod tests { use rstest::rstest; use vortex_error::VortexResult; use vortex_error::vortex_panic; - use vortex_proto::expr as pb; use vortex_session::VortexSession; use crate::ArrayRef; @@ -79,6 +78,7 @@ mod tests { use crate::aggregate_fn::session::AggregateFnSession; use crate::aggregate_fn::session::AggregateFnSessionExt; use crate::dtype::DType; + use crate::proto::expr as pb; use crate::scalar::Scalar; /// A minimal serializable aggregate function used solely to exercise the serde round-trip. diff --git a/vortex-array/src/aggregate_fn/vtable.rs b/vortex-array/src/aggregate_fn/vtable.rs index 24449bc7572..df68dd294be 100644 --- a/vortex-array/src/aggregate_fn/vtable.rs +++ b/vortex-array/src/aggregate_fn/vtable.rs @@ -10,7 +10,6 @@ use std::hash::Hash; use prost::Message; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use crate::ArrayRef; @@ -21,6 +20,7 @@ use crate::aggregate_fn::AggregateFnId; use crate::aggregate_fn::AggregateFnRef; use crate::aggregate_fn::AggregateFnSatisfaction; use crate::dtype::DType; +use crate::proto::expr as pb; use crate::scalar::Scalar; /// Defines the interface for aggregate function vtables. diff --git a/vortex-array/src/arrays/variant/vtable/mod.rs b/vortex-array/src/arrays/variant/vtable/mod.rs index 12064cc626a..837bd32a7bf 100644 --- a/vortex-array/src/arrays/variant/vtable/mod.rs +++ b/vortex-array/src/arrays/variant/vtable/mod.rs @@ -10,7 +10,6 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_error::vortex_panic; -use vortex_proto::dtype as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; use vortex_utils::aliases::hash_set::HashSet; @@ -33,6 +32,7 @@ use crate::dtype::FieldName; use crate::dtype::FieldNames; use crate::dtype::Nullability; use crate::dtype::StructFields; +use crate::proto::dtype as pb; use crate::scalar::Scalar; use crate::scalar::ScalarValue; use crate::serde::ArrayChildren; diff --git a/vortex-array/src/dtype/mod.rs b/vortex-array/src/dtype/mod.rs index aaf729ef994..f568495cd93 100644 --- a/vortex-array/src/dtype/mod.rs +++ b/vortex-array/src/dtype/mod.rs @@ -200,7 +200,7 @@ pub mod proto { //! //! This module contains the code to serialize and deserialize DTypes to and from protocol buffers. - pub use vortex_proto::dtype; + pub use crate::proto::dtype; } pub mod flatbuffers { @@ -208,7 +208,7 @@ pub mod flatbuffers { //! //! This module contains the code to serialize and deserialize DTypes to and from flatbuffers. - pub use vortex_flatbuffers::dtype::*; + pub use crate::flatbuffers::dtype::*; } #[cfg(test)] diff --git a/vortex-array/src/dtype/serde/flatbuffers.rs b/vortex-array/src/dtype/serde/flatbuffers.rs index 8a1e7e6b611..baabcf10ce4 100644 --- a/vortex-array/src/dtype/serde/flatbuffers.rs +++ b/vortex-array/src/dtype/serde/flatbuffers.rs @@ -12,10 +12,6 @@ use vortex_error::VortexError; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::FlatBufferRoot; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::dtype as fbd; use vortex_session::VortexSession; use crate::dtype::DType; @@ -30,6 +26,10 @@ use crate::dtype::extension::ExtId; use crate::dtype::extension::ForeignExtDType; use crate::dtype::flatbuffers as fb; use crate::dtype::session::DTypeSessionExt; +use crate::flatbuffers::FlatBuffer; +use crate::flatbuffers::FlatBufferRoot; +use crate::flatbuffers::WriteFlatBuffer; +use crate::flatbuffers::dtype as fbd; /// A lazily evaluated DType, parsed on access from an underlying flatbuffer. #[derive(Debug, Clone)] @@ -568,9 +568,6 @@ mod test { use flatbuffers::FlatBufferBuilder; use flatbuffers::root; use vortex_buffer::ByteBuffer; - use vortex_flatbuffers::FlatBuffer; - use vortex_flatbuffers::WriteFlatBuffer; - use vortex_flatbuffers::WriteFlatBufferExt; use crate::dtype::DType; use crate::dtype::PType; @@ -580,6 +577,9 @@ mod test { use crate::dtype::nullability::Nullability; use crate::dtype::serde::flatbuffers::ViewedDType; use crate::dtype::test::SESSION; + use crate::flatbuffers::FlatBuffer; + use crate::flatbuffers::WriteFlatBuffer; + use crate::flatbuffers::WriteFlatBufferExt; fn roundtrip_dtype(dtype: DType) { let bytes = dtype.write_flatbuffer_bytes().unwrap(); @@ -802,7 +802,8 @@ mod test { fn test_union_malformed_flatbuffer_errors() { use flatbuffers::FlatBufferBuilder; use vortex_buffer::ByteBuffer; - use vortex_flatbuffers::WriteFlatBuffer; + + use crate::flatbuffers::WriteFlatBuffer; let mut fbb = FlatBufferBuilder::new(); diff --git a/vortex-array/src/dtype/struct_.rs b/vortex-array/src/dtype/struct_.rs index 4b457d84d16..861cc390b19 100644 --- a/vortex-array/src/dtype/struct_.rs +++ b/vortex-array/src/dtype/struct_.rs @@ -511,8 +511,6 @@ mod test { use insta::assert_snapshot; use itertools::Itertools; use vortex_error::VortexResult; - use vortex_flatbuffers::FlatBuffer; - use vortex_flatbuffers::WriteFlatBufferExt; use super::FieldDTypeInner; use crate::dtype::DType; @@ -521,6 +519,8 @@ mod test { use crate::dtype::PType; use crate::dtype::StructFields; use crate::dtype::test::SESSION; + use crate::flatbuffers::FlatBuffer; + use crate::flatbuffers::WriteFlatBufferExt; #[test] fn nullability() { diff --git a/vortex-array/src/expr/proto.rs b/vortex-array/src/expr/proto.rs index 4f544fecafb..b444420b085 100644 --- a/vortex-array/src/expr/proto.rs +++ b/vortex-array/src/expr/proto.rs @@ -5,10 +5,10 @@ use itertools::Itertools; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use crate::expr::Expression; +use crate::proto::expr as pb; use crate::scalar_fn::ForeignScalarFnVTable; use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::session::ScalarFnSessionExt; @@ -98,7 +98,6 @@ pub fn deserialize_expr_proto( #[cfg(test)] mod tests { use prost::Message; - use vortex_proto::expr as pb; use vortex_session::VortexSession; use super::ExprSerializeProtoExt; @@ -111,6 +110,7 @@ mod tests { use crate::expr::lit; use crate::expr::or; use crate::expr::root; + use crate::proto::expr as pb; use crate::scalar_fn::fns::between::BetweenOptions; use crate::scalar_fn::fns::between::StrictComparison; use crate::scalar_fn::session::ScalarFnSession; diff --git a/vortex-array/src/flatbuffers.rs b/vortex-array/src/flatbuffers.rs new file mode 100644 index 00000000000..aab38451eff --- /dev/null +++ b/vortex-array/src/flatbuffers.rs @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! FlatBuffers read/write traits, plus bindings generated from this crate's `flatbuffers` +//! schemas. Schemas owned by other crates generate into those crates instead. + +mod traits; + +pub use traits::*; + +/// A serialized array without its buffer (i.e. data). +/// +/// `array.fbs`: +/// ```flatbuffers +#[doc = include_str!("../flatbuffers/vortex-array/array.fbs")] +/// ``` +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::borrow_as_ptr)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(clippy::many_single_char_names)] +#[allow(clippy::unwrap_used)] +#[allow(dead_code)] +#[allow(mismatched_lifetime_syntaxes)] +#[allow(missing_docs)] +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[allow(unsafe_op_in_unsafe_fn)] +#[allow(unused_imports)] +#[allow(unused_lifetimes)] +#[allow(unused_qualifications)] +pub mod array { + include!(concat!(env!("OUT_DIR"), "/flatbuffers/array.rs")); +} + +/// A serialized data type. +/// +/// `dtype.fbs`: +/// ```flatbuffers +#[doc = include_str!("../flatbuffers/vortex-dtype/dtype.fbs")] +/// ``` +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::borrow_as_ptr)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(clippy::many_single_char_names)] +#[allow(clippy::unwrap_used)] +#[allow(dead_code)] +#[allow(mismatched_lifetime_syntaxes)] +#[allow(missing_docs)] +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[allow(unsafe_op_in_unsafe_fn)] +#[allow(unused_imports)] +#[allow(unused_lifetimes)] +#[allow(unused_qualifications)] +pub mod dtype { + include!(concat!(env!("OUT_DIR"), "/flatbuffers/dtype.rs")); +} diff --git a/vortex-array/src/flatbuffers/traits.rs b/vortex-array/src/flatbuffers/traits.rs new file mode 100644 index 00000000000..0d6f9a59f91 --- /dev/null +++ b/vortex-array/src/flatbuffers/traits.rs @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Traits for reading and writing Vortex types as flatbuffers. + +use flatbuffers::FlatBufferBuilder; +use flatbuffers::Follow; +use flatbuffers::InvalidFlatbuffer; +use flatbuffers::Verifiable; +use flatbuffers::WIPOffset; +use flatbuffers::root; +use vortex_buffer::ByteBuffer; +use vortex_buffer::ConstByteBuffer; +use vortex_error::VortexResult; + +/// We define a const-aligned byte buffer for flatbuffers with 8-byte alignment. +/// +/// This is based on the assumption that the maximum primitive type is 8 bytes. +/// See: +pub type FlatBuffer = ConstByteBuffer<8>; + +/// Marker trait for types that can be the root of a FlatBuffer. +pub trait FlatBufferRoot {} + +/// Trait for reading a type from a FlatBuffer. +pub trait ReadFlatBuffer: Sized { + /// The FlatBuffer type that this type can be read from. + type Source<'a>: Verifiable + Follow<'a>; + /// The error type returned when reading fails. + type Error: From; + + /// Reads this type from a FlatBuffer source. + fn read_flatbuffer<'buf>( + fb: & as Follow<'buf>>::Inner, + ) -> Result; + + /// Reads this type from bytes representing a FlatBuffer source. + fn read_flatbuffer_bytes<'buf>(bytes: &'buf [u8]) -> Result + where + ::Source<'buf>: 'buf, + { + let fb = root::>(bytes)?; + Self::read_flatbuffer(&fb) + } +} + +/// Trait for writing a type to a FlatBuffer. +pub trait WriteFlatBuffer { + /// The FlatBuffer type that this type can be written to. + type Target<'a>; + + /// Writes this type to a FlatBuffer builder. + fn write_flatbuffer<'fb>( + &self, + fbb: &mut FlatBufferBuilder<'fb>, + ) -> VortexResult>>; +} + +/// Extension trait for types that can be written as FlatBuffer root objects. +pub trait WriteFlatBufferExt: WriteFlatBuffer + FlatBufferRoot { + /// Writes self as a FlatBuffer root object into a [`FlatBuffer`] byte buffer. + fn write_flatbuffer_bytes(&self) -> VortexResult; +} + +impl WriteFlatBufferExt for F { + fn write_flatbuffer_bytes(&self) -> VortexResult { + let mut fbb = FlatBufferBuilder::new(); + let root_offset = self.write_flatbuffer(&mut fbb)?; + fbb.finish_minimal(root_offset); + let (vec, start) = fbb.collapse(); + let end = vec.len(); + Ok(FlatBuffer::align_from( + ByteBuffer::from(vec).slice(start..end), + )) + } +} diff --git a/vortex-array/src/lib.rs b/vortex-array/src/lib.rs index 9439dc7dd1b..fc64f01de52 100644 --- a/vortex-array/src/lib.rs +++ b/vortex-array/src/lib.rs @@ -121,6 +121,7 @@ mod executor; pub mod expr; mod expression; pub mod extension; +pub mod flatbuffers; mod hash; pub mod iter; pub mod kernel; @@ -133,6 +134,7 @@ pub mod normalize; pub mod optimizer; mod partial_ord; pub mod patches; +pub mod proto; pub mod scalar; pub mod scalar_fn; pub mod search_sorted; @@ -144,11 +146,6 @@ pub mod stream; pub mod test_harness; pub mod validity; -pub mod flatbuffers { - //! Re-exported autogenerated code from the core Vortex flatbuffer definitions. - pub use vortex_flatbuffers::array::*; -} - /// Register vortex-array's built-in session-scoped kernels into the active /// [`ArrayKernels`](optimizer::kernels::ArrayKernels) registry. /// diff --git a/vortex-array/src/proto.rs b/vortex-array/src/proto.rs new file mode 100644 index 00000000000..61f79783015 --- /dev/null +++ b/vortex-array/src/proto.rs @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Bindings generated from this crate's `proto` schemas. + +/// Data types. +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::nursery)] +#[allow(missing_docs)] +pub mod dtype { + include!(concat!(env!("OUT_DIR"), "/proto/vortex.dtype.rs")); +} + +/// Scalar values. +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::nursery)] +#[allow(missing_docs)] +pub mod scalar { + include!(concat!(env!("OUT_DIR"), "/proto/vortex.scalar.rs")); +} + +/// Expressions. +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::nursery)] +#[allow(missing_docs)] +pub mod expr { + include!(concat!(env!("OUT_DIR"), "/proto/vortex.expr.rs")); +} diff --git a/vortex-array/src/scalar/proto.rs b/vortex-array/src/scalar/proto.rs index 7e1b5ac85db..eab8ea23099 100644 --- a/vortex-array/src/scalar/proto.rs +++ b/vortex-array/src/scalar/proto.rs @@ -14,16 +14,16 @@ use vortex_error::vortex_bail; use vortex_error::vortex_ensure; use vortex_error::vortex_ensure_eq; use vortex_error::vortex_err; -use vortex_proto::scalar as pb; -use vortex_proto::scalar::ListValue; -use vortex_proto::scalar::UnionValue as PbUnionValue; -use vortex_proto::scalar::scalar_value::Kind; use vortex_session::VortexSession; use crate::dtype::DType; use crate::dtype::PType; use crate::dtype::half::f16; use crate::dtype::i256; +use crate::proto::scalar as pb; +use crate::proto::scalar::ListValue; +use crate::proto::scalar::UnionValue as PbUnionValue; +use crate::proto::scalar::scalar_value::Kind; use crate::scalar::DecimalValue; use crate::scalar::PValue; use crate::scalar::Scalar; @@ -534,7 +534,6 @@ mod tests { use vortex_buffer::BufferString; use vortex_error::VortexError; use vortex_error::vortex_panic; - use vortex_proto::scalar as pb; use vortex_session::VortexSession; use super::*; @@ -544,6 +543,7 @@ mod tests { use crate::dtype::PType; use crate::dtype::UnionVariants; use crate::dtype::half::f16; + use crate::proto::scalar as pb; use crate::scalar::DecimalValue; use crate::scalar::Scalar; use crate::scalar::ScalarValue; diff --git a/vortex-array/src/scalar/tests/round_trip.rs b/vortex-array/src/scalar/tests/round_trip.rs index ab315483d72..56dc1369e94 100644 --- a/vortex-array/src/scalar/tests/round_trip.rs +++ b/vortex-array/src/scalar/tests/round_trip.rs @@ -15,13 +15,13 @@ mod tests { use rstest::rstest; use vortex_buffer::ByteBuffer; - use vortex_proto::scalar as pb; use crate::dtype::DType; use crate::dtype::DecimalDType; use crate::dtype::Nullability; use crate::dtype::PType; use crate::dtype::i256; + use crate::proto::scalar as pb; use crate::scalar::DecimalValue; use crate::scalar::Scalar; use crate::scalar::ScalarValue; diff --git a/vortex-array/src/scalar_fn/fns/between/mod.rs b/vortex-array/src/scalar_fn/fns/between/mod.rs index a431045200d..e1ae042c3ef 100644 --- a/vortex-array/src/scalar_fn/fns/between/mod.rs +++ b/vortex-array/src/scalar_fn/fns/between/mod.rs @@ -10,7 +10,6 @@ pub use kernel::*; use prost::Message; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -27,6 +26,7 @@ use crate::dtype::DType; use crate::dtype::DType::Bool; use crate::expr::display::ExprDisplay; use crate::expr::expression::Expression; +use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; diff --git a/vortex-array/src/scalar_fn/fns/binary/mod.rs b/vortex-array/src/scalar_fn/fns/binary/mod.rs index ed31cdf8d46..e790bc4d18f 100644 --- a/vortex-array/src/scalar_fn/fns/binary/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/mod.rs @@ -11,7 +11,6 @@ pub use boolean::or_kleene; use prost::Message; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -24,6 +23,7 @@ use crate::expr::and; use crate::expr::display::ExprDisplay; use crate::expr::expression::Expression; use crate::expr::lit; +use crate::proto::expr as pb; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; use crate::scalar_fn::ExecutionArgs; diff --git a/vortex-array/src/scalar_fn/fns/case_when.rs b/vortex-array/src/scalar_fn/fns/case_when.rs index b9d3450562a..a89b06adcf3 100644 --- a/vortex-array/src/scalar_fn/fns/case_when.rs +++ b/vortex-array/src/scalar_fn/fns/case_when.rs @@ -20,7 +20,6 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_mask::AllOr; use vortex_mask::Mask; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -36,6 +35,7 @@ use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::expr::Expression; use crate::expr::display::ExprDisplay; +use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; diff --git a/vortex-array/src/scalar_fn/fns/cast/mod.rs b/vortex-array/src/scalar_fn/fns/cast/mod.rs index 16802d22d32..9359611da57 100644 --- a/vortex-array/src/scalar_fn/fns/cast/mod.rs +++ b/vortex-array/src/scalar_fn/fns/cast/mod.rs @@ -12,7 +12,6 @@ use vortex_error::VortexExpect as _; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -39,6 +38,7 @@ use crate::dtype::DType; use crate::expr::display::ExprDisplay; use crate::expr::expression::Expression; use crate::expr::lit; +use crate::proto::expr as pb; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; use crate::scalar_fn::ExecutionArgs; diff --git a/vortex-array/src/scalar_fn/fns/get_item.rs b/vortex-array/src/scalar_fn/fns/get_item.rs index 3e78c01f76b..f17d40dd796 100644 --- a/vortex-array/src/scalar_fn/fns/get_item.rs +++ b/vortex-array/src/scalar_fn/fns/get_item.rs @@ -7,7 +7,6 @@ use std::fmt::Formatter; use prost::Message; use vortex_error::VortexResult; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -27,6 +26,7 @@ use crate::dtype::Nullability; use crate::expr::Expression; use crate::expr::display::ExprDisplay; use crate::expr::lit; +use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; diff --git a/vortex-array/src/scalar_fn/fns/like/mod.rs b/vortex-array/src/scalar_fn/fns/like/mod.rs index 0b9af18d3c6..41213024e95 100644 --- a/vortex-array/src/scalar_fn/fns/like/mod.rs +++ b/vortex-array/src/scalar_fn/fns/like/mod.rs @@ -15,7 +15,6 @@ use vortex_buffer::BitBuffer; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -33,6 +32,7 @@ use crate::dtype::Nullability; use crate::expr::Expression; use crate::expr::and; use crate::expr::display::ExprDisplay; +use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; diff --git a/vortex-array/src/scalar_fn/fns/list_sum.rs b/vortex-array/src/scalar_fn/fns/list_sum.rs index f73551250c3..29576fbeb09 100644 --- a/vortex-array/src/scalar_fn/fns/list_sum.rs +++ b/vortex-array/src/scalar_fn/fns/list_sum.rs @@ -143,7 +143,6 @@ mod tests { use rstest::rstest; use vortex_buffer::buffer; use vortex_error::VortexResult; - use vortex_proto::expr as pb; use crate::ArrayRef; use crate::IntoArray; @@ -165,6 +164,7 @@ mod tests { use crate::expr::list_sum_opts; use crate::expr::proto::ExprSerializeProtoExt; use crate::expr::root; + use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar_fn::ScalarFnVTable; use crate::scalar_fn::fns::list_sum::ListSum; diff --git a/vortex-array/src/scalar_fn/fns/literal.rs b/vortex-array/src/scalar_fn/fns/literal.rs index 609a7a6dbda..33507ecef0d 100644 --- a/vortex-array/src/scalar_fn/fns/literal.rs +++ b/vortex-array/src/scalar_fn/fns/literal.rs @@ -6,7 +6,6 @@ use std::fmt::Formatter; use prost::Message; use vortex_error::VortexResult; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -17,6 +16,7 @@ use crate::arrays::ConstantArray; use crate::dtype::DType; use crate::expr::Expression; use crate::expr::display::ExprDisplay; +use crate::proto::expr as pb; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; diff --git a/vortex-array/src/scalar_fn/fns/operators.rs b/vortex-array/src/scalar_fn/fns/operators.rs index 498c9c67307..72e1db54c0a 100644 --- a/vortex-array/src/scalar_fn/fns/operators.rs +++ b/vortex-array/src/scalar_fn/fns/operators.rs @@ -6,7 +6,8 @@ use std::fmt::Display; use std::fmt::Formatter; use vortex_error::VortexError; -use vortex_proto::expr::binary_opts::BinaryOp; + +use crate::proto::expr::binary_opts::BinaryOp; /// Equalities, inequalities, and boolean operations over possibly null values. /// diff --git a/vortex-array/src/scalar_fn/fns/pack.rs b/vortex-array/src/scalar_fn/fns/pack.rs index ef03a1aafe3..c081b7e6ea5 100644 --- a/vortex-array/src/scalar_fn/fns/pack.rs +++ b/vortex-array/src/scalar_fn/fns/pack.rs @@ -9,7 +9,6 @@ use std::sync::Arc; use itertools::Itertools as _; use prost::Message; use vortex_error::VortexResult; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -25,6 +24,7 @@ use crate::dtype::StructFields; use crate::expr::Expression; use crate::expr::display::ExprDisplay; use crate::expr::lit; +use crate::proto::expr as pb; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; use crate::scalar_fn::ExecutionArgs; diff --git a/vortex-array/src/scalar_fn/fns/select.rs b/vortex-array/src/scalar_fn/fns/select.rs index 9d74614be70..5ea9bf197d4 100644 --- a/vortex-array/src/scalar_fn/fns/select.rs +++ b/vortex-array/src/scalar_fn/fns/select.rs @@ -10,9 +10,6 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_proto::expr::FieldNames as ProtoFieldNames; -use vortex_proto::expr::SelectOpts; -use vortex_proto::expr::select_opts::Opts; use vortex_session::VortexSession; use vortex_session::registry::CachedId; @@ -31,6 +28,9 @@ use crate::expr::expression::Expression; use crate::expr::field::DisplayFieldNames; use crate::expr::get_item; use crate::expr::pack; +use crate::proto::expr::FieldNames as ProtoFieldNames; +use crate::proto::expr::SelectOpts; +use crate::proto::expr::select_opts::Opts; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; use crate::scalar_fn::ExecutionArgs; diff --git a/vortex-array/src/scalar_fn/fns/variant_get/mod.rs b/vortex-array/src/scalar_fn/fns/variant_get/mod.rs index 2634aff1d82..db3f795f5a4 100644 --- a/vortex-array/src/scalar_fn/fns/variant_get/mod.rs +++ b/vortex-array/src/scalar_fn/fns/variant_get/mod.rs @@ -9,8 +9,6 @@ use prost::Message; use vortex_error::VortexResult; use vortex_error::vortex_ensure; use vortex_error::vortex_err; -use vortex_proto::expr as pb; -use vortex_proto::expr::variant_path_element; use vortex_session::VortexSession; use vortex_session::registry::CachedId; use vortex_utils::aliases::StringEscape; @@ -27,6 +25,8 @@ use crate::dtype::DType; use crate::dtype::FieldName; use crate::dtype::Nullability; use crate::expr::display::ExprDisplay; +use crate::proto::expr as pb; +use crate::proto::expr::variant_path_element; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; diff --git a/vortex-array/src/serde.rs b/vortex-array/src/serde.rs index 7a28ebbb81d..21db181d52e 100644 --- a/vortex-array/src/serde.rs +++ b/vortex-array/src/serde.rs @@ -19,10 +19,6 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; use vortex_error::vortex_panic; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::array as fba; -use vortex_flatbuffers::array::Compression; use vortex_session::VortexSession; use vortex_session::registry::ReadContext; use vortex_utils::aliases::hash_map::HashMap; @@ -36,6 +32,10 @@ use crate::array::new_foreign_array; use crate::buffer::BufferHandle; use crate::dtype::DType; use crate::dtype::TryFromBytes; +use crate::flatbuffers::FlatBuffer; +use crate::flatbuffers::WriteFlatBuffer; +use crate::flatbuffers::array as fba; +use crate::flatbuffers::array::Compression; use crate::session::ArraySessionExt; use crate::stats::StatsSet; diff --git a/vortex-array/src/stats/flatbuffers.rs b/vortex-array/src/stats/flatbuffers.rs index c8f5ed1684a..f8e78f2f83f 100644 --- a/vortex-array/src/stats/flatbuffers.rs +++ b/vortex-array/src/stats/flatbuffers.rs @@ -5,8 +5,6 @@ use flatbuffers::FlatBufferBuilder; use flatbuffers::WIPOffset; use vortex_error::VortexResult; use vortex_error::vortex_bail; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::array as fba; use vortex_session::VortexSession; use crate::dtype::DType; @@ -14,6 +12,8 @@ use crate::dtype::Nullability; use crate::dtype::PType; use crate::expr::stats::Precision; use crate::expr::stats::Stat; +use crate::flatbuffers::WriteFlatBuffer; +use crate::flatbuffers::array as fba; use crate::scalar::ScalarValue; use crate::stats::StatsSet; use crate::stats::StatsSetRef; diff --git a/vortex-flatbuffers/Cargo.toml b/vortex-build/Cargo.toml similarity index 65% rename from vortex-flatbuffers/Cargo.toml rename to vortex-build/Cargo.toml index 3e0bd21acc7..de063354618 100644 --- a/vortex-flatbuffers/Cargo.toml +++ b/vortex-build/Cargo.toml @@ -2,10 +2,10 @@ # SPDX-FileCopyrightText: Copyright the Vortex contributors [package] -name = "vortex-flatbuffers" +name = "vortex-build" authors = { workspace = true } categories = { workspace = true } -description = "Flatbuffers definitions for Vortex types" +description = "Build script helpers for generating Vortex FlatBuffers and Protocol Buffers bindings" edition = { workspace = true } homepage = { workspace = true } include = { workspace = true } @@ -19,17 +19,9 @@ version = { workspace = true } [package.metadata.docs.rs] all-features = true -[features] -array = ["dtype"] -dtype = [] -file = ["ipc"] -ipc = ["array"] -layout = ["array"] - [dependencies] -flatbuffers = { workspace = true } -vortex-buffer = { workspace = true } -vortex-error = { workspace = true } +prost-build = { workspace = true } +protox = { workspace = true } [lints] workspace = true diff --git a/vortex-build/README.md b/vortex-build/README.md new file mode 100644 index 00000000000..cdb78aaa5e5 --- /dev/null +++ b/vortex-build/README.md @@ -0,0 +1,28 @@ +# vortex-build + +Build script helpers used by the Vortex crates that own FlatBuffers (`.fbs`) or Protocol Buffers +(`.proto`) schema definitions. + +Each schema lives in the crate that owns the types it describes, and is compiled into `OUT_DIR` by +that crate's `build.rs`. Schemas that `include`/`import` schemas from another crate declare that +crate explicitly: + +```rust,ignore +fn main() { + vortex_build::flatbuffers() + .depends_on("vortex-array") + .compile(&["vortex-serde/message.fbs"]); +} +``` + +`depends_on` resolves the dependency's schema directory through Cargo's `links` metadata +(`DEP__FLATBUFFERS` / `DEP__PROTO`), so it works identically for path dependencies in +the workspace and for packages unpacked from a registry. The exporting crate only needs a `links` +key in its manifest; `vortex-build` emits the metadata automatically. + +## Requirements + +- `.proto` compilation is pure Rust (via [`protox`](https://docs.rs/protox)) and needs no external + tooling. +- `.fbs` compilation shells out to the FlatBuffers compiler. `flatc` must be on `PATH`, or its + location given in the `FLATC` environment variable. diff --git a/vortex-build/src/lib.rs b/vortex-build/src/lib.rs new file mode 100644 index 00000000000..469bdd5d730 --- /dev/null +++ b/vortex-build/src/lib.rs @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Build script helpers for compiling the FlatBuffers and Protocol Buffers schemas that ship with +//! the Vortex crates. +//! +//! Every schema lives in the crate that owns the types it describes and is compiled into `OUT_DIR` +//! by that crate's build script. Schemas referencing definitions owned by another crate name it +//! explicitly, so nothing is discovered by walking the workspace and a path dependency behaves the +//! same as a package unpacked from a registry: +//! +//! ```rust,ignore +//! vortex_build::flatbuffers() +//! .depends_on("vortex-array") +//! .compile(&["vortex-serde/message.fbs"]); +//! ``` + +#![deny(missing_docs)] +// Build scripts have no error channel back to Cargo, so failures are reported by panicking. +#![allow(clippy::expect_used)] +#![allow(clippy::manual_assert)] +#![allow(clippy::panic)] + +use std::env; +use std::fs::create_dir_all; +use std::path::Path; +use std::path::PathBuf; +use std::process::Command; + +use prost_build::Config; + +const FLATBUFFERS_KEY: &str = "flatbuffers"; +const PROTO_KEY: &str = "proto"; + +/// Module path, relative to the crate root, where generated FlatBuffers code looks for the schemas +/// it includes from other crates. Crates with cross-crate includes define it by hand; see +/// `vortex-ipc/src/flatbuffers.rs`. +const FLATBUFFERS_INCLUDE_PREFIX: &str = "flatbuffers::deps"; + +/// Compiles this crate's FlatBuffers schemas from `flatbuffers/` into `$OUT_DIR/flatbuffers`. +pub fn flatbuffers() -> FlatBuffers { + let schema_dir = manifest_dir().join(FLATBUFFERS_KEY); + FlatBuffers { + includes: vec![schema_dir.clone()], + schema_dir, + } +} + +/// Compiles this crate's Protocol Buffers schemas from `proto/` into `$OUT_DIR/proto`. +pub fn proto() -> Proto { + let schema_dir = manifest_dir().join(PROTO_KEY); + Proto { + includes: vec![schema_dir.clone()], + schema_dir, + } +} + +/// Builder for FlatBuffers compilation, driven by `flatc` from `FLATC` or `PATH`. +pub struct FlatBuffers { + schema_dir: PathBuf, + includes: Vec, +} + +impl FlatBuffers { + /// Makes the FlatBuffers schemas of the direct dependency declaring `links = ""` + /// available to `include` statements. + #[must_use] + pub fn depends_on(mut self, links: &str) -> Self { + self.includes.push(dep_schema_dir(links, FLATBUFFERS_KEY)); + self + } + + /// Compiles the given schemas, each named relative to this crate's `flatbuffers` directory. + pub fn compile(self, schemas: &[&str]) { + let out_dir = out_dir().join(FLATBUFFERS_KEY); + create_dir_all(&out_dir) + .unwrap_or_else(|e| panic!("failed to create {}: {e}", out_dir.display())); + + let mut flatc = Command::new(flatc_binary()); + flatc + .arg("--rust") + // Vortex modules are named for the schema, so drop flatc's `_generated` suffix. + .args(["--filename-suffix", ""]) + .args(["--include-prefix", FLATBUFFERS_INCLUDE_PREFIX]) + .arg("-o") + .arg(&out_dir); + + for include in &self.includes { + rerun_if_changed(include); + flatc.arg("-I").arg(include); + } + + for schema in schemas { + let path = self.schema_dir.join(schema); + assert!(path.exists(), "schema not found: {}", path.display()); + flatc.arg(path); + } + + run(flatc); + export_schema_dir(FLATBUFFERS_KEY, &self.schema_dir); + } +} + +/// Builder for Protocol Buffers compilation. Parsing uses [`protox`], so `protoc` is not needed. +pub struct Proto { + schema_dir: PathBuf, + includes: Vec, +} + +impl Proto { + /// Makes the Protocol Buffers schemas of the direct dependency declaring `links = ""` + /// available to `import` statements. + #[must_use] + pub fn depends_on(mut self, links: &str) -> Self { + self.includes.push(dep_schema_dir(links, PROTO_KEY)); + self + } + + /// Compiles the given schemas, each named relative to this crate's `proto` directory. + pub fn compile(self, schemas: &[&str]) { + let out_dir = out_dir().join(PROTO_KEY); + create_dir_all(&out_dir) + .unwrap_or_else(|e| panic!("failed to create {}: {e}", out_dir.display())); + + for include in &self.includes { + rerun_if_changed(include); + } + + let file_descriptors = protox::compile(schemas, &self.includes) + .unwrap_or_else(|e| panic!("failed to compile protos: {e}")); + + Config::new() + .out_dir(&out_dir) + .compile_fds(file_descriptors) + .unwrap_or_else(|e| panic!("failed to generate proto bindings: {e}")); + + export_schema_dir(PROTO_KEY, &self.schema_dir); + } +} + +/// Publishes `dir` to direct dependents as `DEP__`. Cargo only forwards build script +/// metadata for packages declaring `links`, so this is a no-op for the others. +fn export_schema_dir(key: &str, dir: &Path) { + if env::var_os("CARGO_MANIFEST_LINKS").is_some() { + println!("cargo::metadata={key}={}", dir.display()); + } +} + +fn dep_schema_dir(links: &str, key: &str) -> PathBuf { + let var = format!("DEP_{}_{}", env_fragment(links), env_fragment(key)); + let dir = env::var_os(&var).unwrap_or_else(|| { + panic!( + "{var} is not set: `{links}` must be a direct dependency of this crate and must \ + declare `links = \"{links}\"`" + ) + }); + PathBuf::from(dir) +} + +/// Spells `value` the way Cargo spells the components of its `DEP_*` variables. +fn env_fragment(value: &str) -> String { + value + .chars() + .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' }) + .collect::() + .to_uppercase() +} + +fn flatc_binary() -> PathBuf { + println!("cargo::rerun-if-env-changed=FLATC"); + env::var_os("FLATC").map_or_else(|| PathBuf::from("flatc"), PathBuf::from) +} + +fn manifest_dir() -> PathBuf { + PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not set")) +} + +fn out_dir() -> PathBuf { + PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR is not set")) +} + +fn rerun_if_changed(path: &Path) { + println!("cargo::rerun-if-changed={}", path.display()); +} + +fn run(mut command: Command) { + let program = command.get_program().to_string_lossy().into_owned(); + let status = command.status().unwrap_or_else(|e| { + panic!( + "failed to run {program}: {e}. Install the FlatBuffers compiler, or set FLATC to its \ + location." + ) + }); + assert!(status.success(), "{program} failed with {status}"); +} diff --git a/vortex-file/Cargo.toml b/vortex-file/Cargo.toml index 78ff4d1d5b6..db947430ed8 100644 --- a/vortex-file/Cargo.toml +++ b/vortex-file/Cargo.toml @@ -42,7 +42,6 @@ vortex-decimal-byte-parts = { workspace = true } vortex-edition = { workspace = true } vortex-error = { workspace = true } vortex-fastlanes = { workspace = true } -vortex-flatbuffers = { workspace = true, features = ["file"] } vortex-fsst = { workspace = true } vortex-io = { workspace = true } vortex-layout = { workspace = true } @@ -60,6 +59,9 @@ vortex-utils = { workspace = true, features = ["dashmap"] } vortex-zigzag = { workspace = true } vortex-zstd = { workspace = true, optional = true } +[build-dependencies] +vortex-build = { workspace = true } + [dev-dependencies] allocator-api2 = { workspace = true } divan = { workspace = true } diff --git a/vortex-file/build.rs b/vortex-file/build.rs new file mode 100644 index 00000000000..88d7a90e292 --- /dev/null +++ b/vortex-file/build.rs @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +fn main() { + vortex_build::flatbuffers() + .depends_on("vortex-array") + .depends_on("vortex-layout") + .compile(&["vortex-file/footer.fbs"]); +} diff --git a/vortex-flatbuffers/flatbuffers/vortex-file/footer.fbs b/vortex-file/flatbuffers/vortex-file/footer.fbs similarity index 100% rename from vortex-flatbuffers/flatbuffers/vortex-file/footer.fbs rename to vortex-file/flatbuffers/vortex-file/footer.fbs diff --git a/vortex-file/src/flatbuffers.rs b/vortex-file/src/flatbuffers.rs new file mode 100644 index 00000000000..14277139e6c --- /dev/null +++ b/vortex-file/src/flatbuffers.rs @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Bindings generated from this crate's `flatbuffers` schema. + +/// Where `flatc` resolves the `crate::flatbuffers::deps::*` paths it emits for `footer.fbs`'s includes. +mod deps { + pub use vortex_array::flatbuffers::array; + pub use vortex_layout::flatbuffers::layout; +} + +/// A file format footer containing a serialized `vortex-file` Layout. +/// +/// `footer.fbs`: +/// ```flatbuffers +#[doc = include_str!("../flatbuffers/vortex-file/footer.fbs")] +/// ``` +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::borrow_as_ptr)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(clippy::many_single_char_names)] +#[allow(clippy::unwrap_used)] +#[allow(dead_code)] +#[allow(mismatched_lifetime_syntaxes)] +#[allow(missing_docs)] +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[allow(unsafe_op_in_unsafe_fn)] +#[allow(unused_imports)] +#[allow(unused_lifetimes)] +#[allow(unused_qualifications)] +pub mod footer { + include!(concat!(env!("OUT_DIR"), "/flatbuffers/footer.rs")); +} diff --git a/vortex-file/src/footer/deserializer.rs b/vortex-file/src/footer/deserializer.rs index 992070fb0a6..b703a47c274 100644 --- a/vortex-file/src/footer/deserializer.rs +++ b/vortex-file/src/footer/deserializer.rs @@ -5,14 +5,14 @@ use std::sync::Arc; use flatbuffers::root; use vortex_array::dtype::DType; +use vortex_array::flatbuffers::FlatBuffer; +use vortex_array::flatbuffers::ReadFlatBuffer; use vortex_buffer::ByteBuffer; use vortex_buffer::ByteBufferMut; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::ReadFlatBuffer; use vortex_session::VortexSession; use crate::EOF_SIZE; @@ -299,7 +299,7 @@ impl FooterDeserializer { ) -> VortexResult { let sliced_buffer = checked_segment_slice(initial_read, initial_offset, segment)?; - let fb = root::(sliced_buffer)?; + let fb = root::(sliced_buffer)?; FileStatistics::from_flatbuffer(&fb, dtype, session) } @@ -364,7 +364,7 @@ mod tests { use vortex_array::array_session; use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; - use vortex_flatbuffers::WriteFlatBufferExt; + use vortex_array::flatbuffers::WriteFlatBufferExt; use super::*; diff --git a/vortex-file/src/footer/file_layout.rs b/vortex-file/src/footer/file_layout.rs index 22e5a3e593d..c848a3f207f 100644 --- a/vortex-file/src/footer/file_layout.rs +++ b/vortex-file/src/footer/file_layout.rs @@ -11,12 +11,12 @@ use std::sync::Arc; use flatbuffers::FlatBufferBuilder; use flatbuffers::WIPOffset; +use vortex_array::flatbuffers::FlatBufferRoot; +use vortex_array::flatbuffers::WriteFlatBuffer; use vortex_error::VortexResult; -use vortex_flatbuffers::FlatBufferRoot; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::footer as fb; use vortex_session::registry::ReadContext; +use crate::flatbuffers::footer as fb; use crate::footer::segment::SegmentSpec; /// A writer for serializing a file layout to a FlatBuffer. diff --git a/vortex-file/src/footer/file_statistics.rs b/vortex-file/src/footer/file_statistics.rs index 62cdf199afd..f78abf05de8 100644 --- a/vortex-file/src/footer/file_statistics.rs +++ b/vortex-file/src/footer/file_statistics.rs @@ -12,14 +12,15 @@ use flatbuffers::FlatBufferBuilder; use flatbuffers::WIPOffset; use itertools::Itertools; use vortex_array::dtype::DType; +use vortex_array::flatbuffers::FlatBufferRoot; +use vortex_array::flatbuffers::WriteFlatBuffer; use vortex_array::stats::StatsSet; use vortex_error::VortexResult; use vortex_error::vortex_ensure_eq; -use vortex_flatbuffers::FlatBufferRoot; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::footer as fb; use vortex_session::VortexSession; +use crate::flatbuffers::footer as fb; + /// Contains statistical information about the data in a Vortex file. /// /// This struct wraps an array of `StatsSet` objects, each containing statistics diff --git a/vortex-file/src/footer/mod.rs b/vortex-file/src/footer/mod.rs index 0d1c46f860a..3403060a8e3 100644 --- a/vortex-file/src/footer/mod.rs +++ b/vortex-file/src/footer/mod.rs @@ -27,18 +27,19 @@ use itertools::Itertools; pub use segment::*; use vortex_array::ArrayId; use vortex_array::dtype::DType; +use vortex_array::flatbuffers::FlatBuffer; use vortex_buffer::ByteBuffer; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::footer as fb; use vortex_layout::LayoutEncodingId; use vortex_layout::LayoutRef; use vortex_layout::layout_from_flatbuffer_with_options; use vortex_session::VortexSession; use vortex_session::registry::ReadContext; +use crate::flatbuffers::footer as fb; + /// Maximum number of user-defined metadata segments. Keeps postscript bookkeeping small so the /// footer and required segments still fit the initial tail read. pub(crate) const MAX_METADATA_SEGMENTS: usize = 16; diff --git a/vortex-file/src/footer/postscript.rs b/vortex-file/src/footer/postscript.rs index a41f7432bef..f1964f22163 100644 --- a/vortex-file/src/footer/postscript.rs +++ b/vortex-file/src/footer/postscript.rs @@ -4,18 +4,18 @@ use flatbuffers::FlatBufferBuilder; use flatbuffers::Follow; use flatbuffers::WIPOffset; +use vortex_array::flatbuffers::FlatBufferRoot; +use vortex_array::flatbuffers::ReadFlatBuffer; +use vortex_array::flatbuffers::WriteFlatBuffer; use vortex_buffer::Alignment; use vortex_error::VortexError; use vortex_error::VortexResult; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBufferRoot; -use vortex_flatbuffers::ReadFlatBuffer; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::footer as fb; use vortex_utils::aliases::hash_set::HashSet; use super::MAX_METADATA_KEY_BYTES; use super::MAX_METADATA_SEGMENTS; +use crate::flatbuffers::footer as fb; /// The postscript captures the locations and compression for the initial segments required for /// reading a Vortex file. @@ -274,10 +274,10 @@ impl ReadFlatBuffer for PostscriptSegment { #[cfg(test)] mod tests { + use vortex_array::flatbuffers::FlatBuffer; + use vortex_array::flatbuffers::ReadFlatBuffer; + use vortex_array::flatbuffers::WriteFlatBufferExt; use vortex_buffer::ByteBuffer; - use vortex_flatbuffers::FlatBuffer; - use vortex_flatbuffers::ReadFlatBuffer; - use vortex_flatbuffers::WriteFlatBufferExt; use super::*; use crate::MAX_POSTSCRIPT_SIZE; diff --git a/vortex-file/src/footer/segment.rs b/vortex-file/src/footer/segment.rs index 2659f18862b..957d1cb695c 100644 --- a/vortex-file/src/footer/segment.rs +++ b/vortex-file/src/footer/segment.rs @@ -5,7 +5,8 @@ use std::ops::Range; use vortex_buffer::Alignment; use vortex_error::VortexError; -use vortex_flatbuffers::footer as fb; + +use crate::flatbuffers::footer as fb; /// The location of a segment within a Vortex file. /// diff --git a/vortex-file/src/footer/serializer.rs b/vortex-file/src/footer/serializer.rs index a0b846d6b61..6997c1d30b0 100644 --- a/vortex-file/src/footer/serializer.rs +++ b/vortex-file/src/footer/serializer.rs @@ -3,14 +3,14 @@ use std::sync::Arc; +use vortex_array::flatbuffers::FlatBuffer; +use vortex_array::flatbuffers::FlatBufferRoot; +use vortex_array::flatbuffers::WriteFlatBuffer; +use vortex_array::flatbuffers::WriteFlatBufferExt; use vortex_buffer::ByteBuffer; use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::FlatBufferRoot; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::WriteFlatBufferExt; use vortex_layout::LayoutContext; use vortex_session::registry::ReadContext; use vortex_utils::aliases::hash_map::HashMap; diff --git a/vortex-file/src/lib.rs b/vortex-file/src/lib.rs index 70c08847445..707de8bb47e 100644 --- a/vortex-file/src/lib.rs +++ b/vortex-file/src/lib.rs @@ -105,6 +105,7 @@ mod counting; mod file; +pub mod flatbuffers; mod footer; pub mod multi; mod open; diff --git a/vortex-file/src/tests.rs b/vortex-file/src/tests.rs index 22b9104a6e2..640de874d2b 100644 --- a/vortex-file/src/tests.rs +++ b/vortex-file/src/tests.rs @@ -75,7 +75,6 @@ use vortex_buffer::buffer; use vortex_edition::EditionSession; use vortex_error::VortexExpect; use vortex_error::VortexResult; -use vortex_flatbuffers::footer as fb; use vortex_io::session::RuntimeSession; use vortex_layout::DynLayout; use vortex_layout::LayoutStrategy; @@ -100,6 +99,7 @@ use crate::V1_FOOTER_FBS_SIZE; use crate::VERSION; use crate::VortexFile; use crate::WriteOptionsSessionExt; +use crate::flatbuffers::footer as fb; use crate::footer::SegmentSpec; static SESSION: LazyLock = LazyLock::new(|| { let session = array_session() diff --git a/vortex-flatbuffers/README.md b/vortex-flatbuffers/README.md deleted file mode 100644 index 01b7a5edd70..00000000000 --- a/vortex-flatbuffers/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# vortex-flatbuffers - -This crate contains Flatbuffers definitions that can be used to convert other crates in this workspace back -and forth into Flatbuffers messages. - -## Regenerating the bindings - -Run the `cargo xtask generate-fbs` script. Be sure that you have the `flatc` utility installed before doing so. diff --git a/vortex-flatbuffers/src/generated/REUSE.toml b/vortex-flatbuffers/src/generated/REUSE.toml deleted file mode 100644 index 42719440df8..00000000000 --- a/vortex-flatbuffers/src/generated/REUSE.toml +++ /dev/null @@ -1,6 +0,0 @@ -version = 1 - -[[annotations]] -path = "*.rs" -SPDX-FileCopyrightText = "Copyright the Vortex contributors" -SPDX-License-Identifier = "Apache-2.0" diff --git a/vortex-flatbuffers/src/generated/array.rs b/vortex-flatbuffers/src/generated/array.rs deleted file mode 100644 index 6d903a56aa5..00000000000 --- a/vortex-flatbuffers/src/generated/array.rs +++ /dev/null @@ -1,989 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; - - -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_COMPRESSION: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_COMPRESSION: u8 = 1; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_COMPRESSION: [Compression; 2] = [ - Compression::None, - Compression::LZ4, -]; - -/// The compression mechanism used to compress the buffer. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct Compression(pub u8); -#[allow(non_upper_case_globals)] -impl Compression { - pub const None: Self = Self(0); - pub const LZ4: Self = Self(1); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 1; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::None, - Self::LZ4, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::None => Some("None"), - Self::LZ4 => Some("LZ4"), - _ => None, - } - } -} -impl ::core::fmt::Debug for Compression { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for Compression { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for Compression { - type Output = Compression; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for Compression { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for Compression { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for Compression {} -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_PRECISION: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_PRECISION: u8 = 1; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_PRECISION: [Precision; 2] = [ - Precision::Inexact, - Precision::Exact, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct Precision(pub u8); -#[allow(non_upper_case_globals)] -impl Precision { - pub const Inexact: Self = Self(0); - pub const Exact: Self = Self(1); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 1; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::Inexact, - Self::Exact, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::Inexact => Some("Inexact"), - Self::Exact => Some("Exact"), - _ => None, - } - } -} -impl ::core::fmt::Debug for Precision { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for Precision { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for Precision { - type Output = Precision; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for Precision { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for Precision { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for Precision {} -/// A Buffer describes the location of a data buffer in the byte stream as a packed 64-bit struct. -// struct Buffer, aligned to 4 -#[repr(transparent)] -#[derive(Clone, Copy, PartialEq)] -pub struct Buffer(pub [u8; 8]); -impl Default for Buffer { - fn default() -> Self { - Self([0; 8]) - } -} -impl ::core::fmt::Debug for Buffer { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - f.debug_struct("Buffer") - .field("padding", &self.padding()) - .field("alignment_exponent", &self.alignment_exponent()) - .field("compression", &self.compression()) - .field("length", &self.length()) - .finish() - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for Buffer {} -impl<'a> ::flatbuffers::Follow<'a> for Buffer { - type Inner = &'a Buffer; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - unsafe { <&'a Buffer>::follow(buf, loc) } - } -} -impl<'a> ::flatbuffers::Follow<'a> for &'a Buffer { - type Inner = &'a Buffer; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - unsafe { ::flatbuffers::follow_cast_ref::(buf, loc) } - } -} -impl<'b> ::flatbuffers::Push for Buffer { - type Output = Buffer; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = unsafe { ::core::slice::from_raw_parts(self as *const Buffer as *const u8, ::size()) }; - dst.copy_from_slice(src); - } - #[inline] - fn alignment() -> ::flatbuffers::PushAlignment { - ::flatbuffers::PushAlignment::new(4) - } -} - -impl<'a> ::flatbuffers::Verifiable for Buffer { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.in_buffer::(pos) - } -} - -impl<'a> Buffer { - #[allow(clippy::too_many_arguments)] - pub fn new( - padding: u16, - alignment_exponent: u8, - compression: Compression, - length: u32, - ) -> Self { - let mut s = Self([0; 8]); - s.set_padding(padding); - s.set_alignment_exponent(alignment_exponent); - s.set_compression(compression); - s.set_length(length); - s - } - - /// The length of any padding bytes written immediately before the buffer. - pub fn padding(&self) -> u16 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[0..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_padding(&mut self, x: u16) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[0..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - /// The minimum alignment of the buffer, stored as an exponent of 2. - pub fn alignment_exponent(&self) -> u8 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[2..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_alignment_exponent(&mut self, x: u8) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[2..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - /// The compression algorithm used to compress the buffer. - pub fn compression(&self) -> Compression { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[3..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_compression(&mut self, x: Compression) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[3..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - /// The length of the buffer in bytes. - pub fn length(&self) -> u32 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[4..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_length(&mut self, x: u32) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[4..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - -} - -pub enum ArrayOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// An Array describes the hierarchy of an array as well as the locations of the data buffers that appear -/// immediately after the message in the byte stream. -pub struct Array<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Array<'a> { - type Inner = Array<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Array<'a> { - pub const VT_ROOT: ::flatbuffers::VOffsetT = 4; - pub const VT_BUFFERS: ::flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Array { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ArrayArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ArrayBuilder::new(_fbb); - if let Some(x) = args.buffers { builder.add_buffers(x); } - if let Some(x) = args.root { builder.add_root(x); } - builder.finish() - } - - - /// The array's hierarchical definition. - #[inline] - pub fn root(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Array::VT_ROOT, None)} - } - /// The locations of the data buffers of the array - #[inline] - pub fn buffers(&self) -> Option<::flatbuffers::Vector<'a, Buffer>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Buffer>>>(Array::VT_BUFFERS, None)} - } -} - -impl ::flatbuffers::Verifiable for Array<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("root", Self::VT_ROOT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Buffer>>>("buffers", Self::VT_BUFFERS, false)? - .finish(); - Ok(()) - } -} -pub struct ArrayArgs<'a> { - pub root: Option<::flatbuffers::WIPOffset>>, - pub buffers: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Buffer>>>, -} -impl<'a> Default for ArrayArgs<'a> { - #[inline] - fn default() -> Self { - ArrayArgs { - root: None, - buffers: None, - } - } -} - -pub struct ArrayBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayBuilder<'a, 'b, A> { - #[inline] - pub fn add_root(&mut self, root: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Array::VT_ROOT, root); - } - #[inline] - pub fn add_buffers(&mut self, buffers: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Buffer>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Array::VT_BUFFERS, buffers); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ArrayBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Array<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Array"); - ds.field("root", &self.root()); - ds.field("buffers", &self.buffers()); - ds.finish() - } -} -pub enum ArrayNodeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ArrayNode<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for ArrayNode<'a> { - type Inner = ArrayNode<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> ArrayNode<'a> { - pub const VT_ENCODING: ::flatbuffers::VOffsetT = 4; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 6; - pub const VT_CHILDREN: ::flatbuffers::VOffsetT = 8; - pub const VT_BUFFERS: ::flatbuffers::VOffsetT = 10; - pub const VT_STATS: ::flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - ArrayNode { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ArrayNodeArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ArrayNodeBuilder::new(_fbb); - if let Some(x) = args.stats { builder.add_stats(x); } - if let Some(x) = args.buffers { builder.add_buffers(x); } - if let Some(x) = args.children { builder.add_children(x); } - if let Some(x) = args.metadata { builder.add_metadata(x); } - builder.add_encoding(args.encoding); - builder.finish() - } - - - #[inline] - pub fn encoding(&self) -> u16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayNode::VT_ENCODING, Some(0)).unwrap()} - } - #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayNode::VT_METADATA, None)} - } - #[inline] - pub fn children(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(ArrayNode::VT_CHILDREN, None)} - } - #[inline] - pub fn buffers(&self) -> Option<::flatbuffers::Vector<'a, u16>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u16>>>(ArrayNode::VT_BUFFERS, None)} - } - #[inline] - pub fn stats(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(ArrayNode::VT_STATS, None)} - } -} - -impl ::flatbuffers::Verifiable for ArrayNode<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("encoding", Self::VT_ENCODING, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("children", Self::VT_CHILDREN, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u16>>>("buffers", Self::VT_BUFFERS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("stats", Self::VT_STATS, false)? - .finish(); - Ok(()) - } -} -pub struct ArrayNodeArgs<'a> { - pub encoding: u16, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub children: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub buffers: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u16>>>, - pub stats: Option<::flatbuffers::WIPOffset>>, -} -impl<'a> Default for ArrayNodeArgs<'a> { - #[inline] - fn default() -> Self { - ArrayNodeArgs { - encoding: 0, - metadata: None, - children: None, - buffers: None, - stats: None, - } - } -} - -pub struct ArrayNodeBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayNodeBuilder<'a, 'b, A> { - #[inline] - pub fn add_encoding(&mut self, encoding: u16) { - self.fbb_.push_slot::(ArrayNode::VT_ENCODING, encoding, 0); - } - #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayNode::VT_METADATA, metadata); - } - #[inline] - pub fn add_children(&mut self, children: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayNode::VT_CHILDREN, children); - } - #[inline] - pub fn add_buffers(&mut self, buffers: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u16>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayNode::VT_BUFFERS, buffers); - } - #[inline] - pub fn add_stats(&mut self, stats: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(ArrayNode::VT_STATS, stats); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayNodeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ArrayNodeBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for ArrayNode<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("ArrayNode"); - ds.field("encoding", &self.encoding()); - ds.field("metadata", &self.metadata()); - ds.field("children", &self.children()); - ds.field("buffers", &self.buffers()); - ds.field("stats", &self.stats()); - ds.finish() - } -} -pub enum ArrayStatsOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct ArrayStats<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for ArrayStats<'a> { - type Inner = ArrayStats<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> ArrayStats<'a> { - pub const VT_MIN: ::flatbuffers::VOffsetT = 4; - pub const VT_MIN_PRECISION: ::flatbuffers::VOffsetT = 6; - pub const VT_MAX: ::flatbuffers::VOffsetT = 8; - pub const VT_MAX_PRECISION: ::flatbuffers::VOffsetT = 10; - pub const VT_SUM: ::flatbuffers::VOffsetT = 12; - pub const VT_IS_SORTED: ::flatbuffers::VOffsetT = 14; - pub const VT_IS_STRICT_SORTED: ::flatbuffers::VOffsetT = 16; - pub const VT_IS_CONSTANT: ::flatbuffers::VOffsetT = 18; - pub const VT_NULL_COUNT: ::flatbuffers::VOffsetT = 20; - pub const VT_UNCOMPRESSED_SIZE_IN_BYTES: ::flatbuffers::VOffsetT = 22; - pub const VT_NAN_COUNT: ::flatbuffers::VOffsetT = 24; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - ArrayStats { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ArrayStatsArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ArrayStatsBuilder::new(_fbb); - if let Some(x) = args.nan_count { builder.add_nan_count(x); } - if let Some(x) = args.uncompressed_size_in_bytes { builder.add_uncompressed_size_in_bytes(x); } - if let Some(x) = args.null_count { builder.add_null_count(x); } - if let Some(x) = args.sum { builder.add_sum(x); } - if let Some(x) = args.max { builder.add_max(x); } - if let Some(x) = args.min { builder.add_min(x); } - if let Some(x) = args.is_constant { builder.add_is_constant(x); } - if let Some(x) = args.is_strict_sorted { builder.add_is_strict_sorted(x); } - if let Some(x) = args.is_sorted { builder.add_is_sorted(x); } - builder.add_max_precision(args.max_precision); - builder.add_min_precision(args.min_precision); - builder.finish() - } - - - /// Protobuf serialized ScalarValue - #[inline] - pub fn min(&self) -> Option<::flatbuffers::Vector<'a, u8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayStats::VT_MIN, None)} - } - #[inline] - pub fn min_precision(&self) -> Precision { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_MIN_PRECISION, Some(Precision::Inexact)).unwrap()} - } - #[inline] - pub fn max(&self) -> Option<::flatbuffers::Vector<'a, u8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayStats::VT_MAX, None)} - } - #[inline] - pub fn max_precision(&self) -> Precision { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_MAX_PRECISION, Some(Precision::Inexact)).unwrap()} - } - #[inline] - pub fn sum(&self) -> Option<::flatbuffers::Vector<'a, u8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(ArrayStats::VT_SUM, None)} - } - #[inline] - pub fn is_sorted(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_IS_SORTED, None)} - } - #[inline] - pub fn is_strict_sorted(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_IS_STRICT_SORTED, None)} - } - #[inline] - pub fn is_constant(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_IS_CONSTANT, None)} - } - #[inline] - pub fn null_count(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_NULL_COUNT, None)} - } - #[inline] - pub fn uncompressed_size_in_bytes(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_UNCOMPRESSED_SIZE_IN_BYTES, None)} - } - #[inline] - pub fn nan_count(&self) -> Option { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayStats::VT_NAN_COUNT, None)} - } -} - -impl ::flatbuffers::Verifiable for ArrayStats<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("min", Self::VT_MIN, false)? - .visit_field::("min_precision", Self::VT_MIN_PRECISION, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("max", Self::VT_MAX, false)? - .visit_field::("max_precision", Self::VT_MAX_PRECISION, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("sum", Self::VT_SUM, false)? - .visit_field::("is_sorted", Self::VT_IS_SORTED, false)? - .visit_field::("is_strict_sorted", Self::VT_IS_STRICT_SORTED, false)? - .visit_field::("is_constant", Self::VT_IS_CONSTANT, false)? - .visit_field::("null_count", Self::VT_NULL_COUNT, false)? - .visit_field::("uncompressed_size_in_bytes", Self::VT_UNCOMPRESSED_SIZE_IN_BYTES, false)? - .visit_field::("nan_count", Self::VT_NAN_COUNT, false)? - .finish(); - Ok(()) - } -} -pub struct ArrayStatsArgs<'a> { - pub min: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub min_precision: Precision, - pub max: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub max_precision: Precision, - pub sum: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub is_sorted: Option, - pub is_strict_sorted: Option, - pub is_constant: Option, - pub null_count: Option, - pub uncompressed_size_in_bytes: Option, - pub nan_count: Option, -} -impl<'a> Default for ArrayStatsArgs<'a> { - #[inline] - fn default() -> Self { - ArrayStatsArgs { - min: None, - min_precision: Precision::Inexact, - max: None, - max_precision: Precision::Inexact, - sum: None, - is_sorted: None, - is_strict_sorted: None, - is_constant: None, - null_count: None, - uncompressed_size_in_bytes: None, - nan_count: None, - } - } -} - -pub struct ArrayStatsBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayStatsBuilder<'a, 'b, A> { - #[inline] - pub fn add_min(&mut self, min: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayStats::VT_MIN, min); - } - #[inline] - pub fn add_min_precision(&mut self, min_precision: Precision) { - self.fbb_.push_slot::(ArrayStats::VT_MIN_PRECISION, min_precision, Precision::Inexact); - } - #[inline] - pub fn add_max(&mut self, max: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayStats::VT_MAX, max); - } - #[inline] - pub fn add_max_precision(&mut self, max_precision: Precision) { - self.fbb_.push_slot::(ArrayStats::VT_MAX_PRECISION, max_precision, Precision::Inexact); - } - #[inline] - pub fn add_sum(&mut self, sum: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayStats::VT_SUM, sum); - } - #[inline] - pub fn add_is_sorted(&mut self, is_sorted: bool) { - self.fbb_.push_slot_always::(ArrayStats::VT_IS_SORTED, is_sorted); - } - #[inline] - pub fn add_is_strict_sorted(&mut self, is_strict_sorted: bool) { - self.fbb_.push_slot_always::(ArrayStats::VT_IS_STRICT_SORTED, is_strict_sorted); - } - #[inline] - pub fn add_is_constant(&mut self, is_constant: bool) { - self.fbb_.push_slot_always::(ArrayStats::VT_IS_CONSTANT, is_constant); - } - #[inline] - pub fn add_null_count(&mut self, null_count: u64) { - self.fbb_.push_slot_always::(ArrayStats::VT_NULL_COUNT, null_count); - } - #[inline] - pub fn add_uncompressed_size_in_bytes(&mut self, uncompressed_size_in_bytes: u64) { - self.fbb_.push_slot_always::(ArrayStats::VT_UNCOMPRESSED_SIZE_IN_BYTES, uncompressed_size_in_bytes); - } - #[inline] - pub fn add_nan_count(&mut self, nan_count: u64) { - self.fbb_.push_slot_always::(ArrayStats::VT_NAN_COUNT, nan_count); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayStatsBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ArrayStatsBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for ArrayStats<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("ArrayStats"); - ds.field("min", &self.min()); - ds.field("min_precision", &self.min_precision()); - ds.field("max", &self.max()); - ds.field("max_precision", &self.max_precision()); - ds.field("sum", &self.sum()); - ds.field("is_sorted", &self.is_sorted()); - ds.field("is_strict_sorted", &self.is_strict_sorted()); - ds.field("is_constant", &self.is_constant()); - ds.field("null_count", &self.null_count()); - ds.field("uncompressed_size_in_bytes", &self.uncompressed_size_in_bytes()); - ds.field("nan_count", &self.nan_count()); - ds.finish() - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `Array` -/// 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_array_unchecked`. -pub fn root_as_array(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `Array` 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_array_unchecked`. -pub fn size_prefixed_root_as_array(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `Array` 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_array_unchecked`. -pub fn root_as_array_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) -} -#[inline] -/// Verifies, with the given verifier options, that a buffer of -/// bytes contains a size prefixed `Array` 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_array_unchecked`. -pub fn size_prefixed_root_as_array_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a Array and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `Array`. -pub unsafe fn root_as_array_unchecked(buf: &[u8]) -> Array<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed Array and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `Array`. -pub unsafe fn size_prefixed_root_as_array_unchecked(buf: &[u8]) -> Array<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } -} -#[inline] -pub fn finish_array_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { - fbb.finish(root, None); -} - -#[inline] -pub fn finish_size_prefixed_array_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { - fbb.finish_size_prefixed(root, None); -} diff --git a/vortex-flatbuffers/src/generated/dtype.rs b/vortex-flatbuffers/src/generated/dtype.rs deleted file mode 100644 index 44470d5ed33..00000000000 --- a/vortex-flatbuffers/src/generated/dtype.rs +++ /dev/null @@ -1,2252 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; - - -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_PTYPE: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_PTYPE: u8 = 10; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_PTYPE: [PType; 11] = [ - PType::U8, - PType::U16, - PType::U32, - PType::U64, - PType::I8, - PType::I16, - PType::I32, - PType::I64, - PType::F16, - PType::F32, - PType::F64, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct PType(pub u8); -#[allow(non_upper_case_globals)] -impl PType { - pub const U8: Self = Self(0); - pub const U16: Self = Self(1); - pub const U32: Self = Self(2); - pub const U64: Self = Self(3); - pub const I8: Self = Self(4); - pub const I16: Self = Self(5); - pub const I32: Self = Self(6); - pub const I64: Self = Self(7); - pub const F16: Self = Self(8); - pub const F32: Self = Self(9); - pub const F64: Self = Self(10); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 10; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::U8, - Self::U16, - Self::U32, - Self::U64, - Self::I8, - Self::I16, - Self::I32, - Self::I64, - Self::F16, - Self::F32, - Self::F64, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::U8 => Some("U8"), - Self::U16 => Some("U16"), - Self::U32 => Some("U32"), - Self::U64 => Some("U64"), - Self::I8 => Some("I8"), - Self::I16 => Some("I16"), - Self::I32 => Some("I32"), - Self::I64 => Some("I64"), - Self::F16 => Some("F16"), - Self::F32 => Some("F32"), - Self::F64 => Some("F64"), - _ => None, - } - } -} -impl ::core::fmt::Debug for PType { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for PType { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for PType { - type Output = PType; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for PType { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for PType { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for PType {} -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_TYPE: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_TYPE: u8 = 13; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_TYPE: [Type; 14] = [ - Type::NONE, - Type::Null, - Type::Bool, - Type::Primitive, - Type::Decimal, - Type::Utf8, - Type::Binary, - Type::Struct_, - Type::List, - Type::Extension, - Type::FixedSizeList, - Type::Variant, - Type::Union, - Type::Map, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct Type(pub u8); -#[allow(non_upper_case_globals)] -impl Type { - pub const NONE: Self = Self(0); - pub const Null: Self = Self(1); - pub const Bool: Self = Self(2); - pub const Primitive: Self = Self(3); - pub const Decimal: Self = Self(4); - pub const Utf8: Self = Self(5); - pub const Binary: Self = Self(6); - pub const Struct_: Self = Self(7); - pub const List: Self = Self(8); - pub const Extension: Self = Self(9); - pub const FixedSizeList: Self = Self(10); - pub const Variant: Self = Self(11); - pub const Union: Self = Self(12); - pub const Map: Self = Self(13); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 13; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NONE, - Self::Null, - Self::Bool, - Self::Primitive, - Self::Decimal, - Self::Utf8, - Self::Binary, - Self::Struct_, - Self::List, - Self::Extension, - Self::FixedSizeList, - Self::Variant, - Self::Union, - Self::Map, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::Null => Some("Null"), - Self::Bool => Some("Bool"), - Self::Primitive => Some("Primitive"), - Self::Decimal => Some("Decimal"), - Self::Utf8 => Some("Utf8"), - Self::Binary => Some("Binary"), - Self::Struct_ => Some("Struct_"), - Self::List => Some("List"), - Self::Extension => Some("Extension"), - Self::FixedSizeList => Some("FixedSizeList"), - Self::Variant => Some("Variant"), - Self::Union => Some("Union"), - Self::Map => Some("Map"), - _ => None, - } - } -} -impl ::core::fmt::Debug for Type { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for Type { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for Type { - type Output = Type; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for Type { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for Type { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for Type {} -pub struct TypeUnionTableOffset {} - -pub enum NullOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Null<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Null<'a> { - type Inner = Null<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Null<'a> { - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Null { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - _args: &'args NullArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = NullBuilder::new(_fbb); - builder.finish() - } - -} - -impl ::flatbuffers::Verifiable for Null<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .finish(); - Ok(()) - } -} -pub struct NullArgs { -} -impl<'a> Default for NullArgs { - #[inline] - fn default() -> Self { - NullArgs { - } - } -} - -pub struct NullBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> NullBuilder<'a, 'b, A> { - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> NullBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - NullBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Null<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Null"); - ds.finish() - } -} -pub enum BoolOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Bool<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Bool<'a> { - type Inner = Bool<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Bool<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Bool { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args BoolArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = BoolBuilder::new(_fbb); - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Bool::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Bool<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct BoolArgs { - pub nullable: bool, -} -impl<'a> Default for BoolArgs { - #[inline] - fn default() -> Self { - BoolArgs { - nullable: false, - } - } -} - -pub struct BoolBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BoolBuilder<'a, 'b, A> { - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Bool::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> BoolBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - BoolBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Bool<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Bool"); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum PrimitiveOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Primitive<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Primitive<'a> { - type Inner = Primitive<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Primitive<'a> { - pub const VT_PTYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Primitive { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args PrimitiveArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = PrimitiveBuilder::new(_fbb); - builder.add_nullable(args.nullable); - builder.add_ptype(args.ptype); - builder.finish() - } - - - #[inline] - pub fn ptype(&self) -> PType { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Primitive::VT_PTYPE, Some(PType::U8)).unwrap()} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Primitive::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Primitive<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("ptype", Self::VT_PTYPE, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct PrimitiveArgs { - pub ptype: PType, - pub nullable: bool, -} -impl<'a> Default for PrimitiveArgs { - #[inline] - fn default() -> Self { - PrimitiveArgs { - ptype: PType::U8, - nullable: false, - } - } -} - -pub struct PrimitiveBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PrimitiveBuilder<'a, 'b, A> { - #[inline] - pub fn add_ptype(&mut self, ptype: PType) { - self.fbb_.push_slot::(Primitive::VT_PTYPE, ptype, PType::U8); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Primitive::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PrimitiveBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - PrimitiveBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Primitive<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Primitive"); - ds.field("ptype", &self.ptype()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum DecimalOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Decimal<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Decimal<'a> { - type Inner = Decimal<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Decimal<'a> { - pub const VT_PRECISION: ::flatbuffers::VOffsetT = 4; - pub const VT_SCALE: ::flatbuffers::VOffsetT = 6; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Decimal { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args DecimalArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = DecimalBuilder::new(_fbb); - builder.add_nullable(args.nullable); - builder.add_scale(args.scale); - builder.add_precision(args.precision); - builder.finish() - } - - - #[inline] - pub fn precision(&self) -> u8 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Decimal::VT_PRECISION, Some(0)).unwrap()} - } - #[inline] - pub fn scale(&self) -> i8 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Decimal::VT_SCALE, Some(0)).unwrap()} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Decimal::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Decimal<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("precision", Self::VT_PRECISION, false)? - .visit_field::("scale", Self::VT_SCALE, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct DecimalArgs { - pub precision: u8, - pub scale: i8, - pub nullable: bool, -} -impl<'a> Default for DecimalArgs { - #[inline] - fn default() -> Self { - DecimalArgs { - precision: 0, - scale: 0, - nullable: false, - } - } -} - -pub struct DecimalBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DecimalBuilder<'a, 'b, A> { - #[inline] - pub fn add_precision(&mut self, precision: u8) { - self.fbb_.push_slot::(Decimal::VT_PRECISION, precision, 0); - } - #[inline] - pub fn add_scale(&mut self, scale: i8) { - self.fbb_.push_slot::(Decimal::VT_SCALE, scale, 0); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Decimal::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> DecimalBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - DecimalBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Decimal<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Decimal"); - ds.field("precision", &self.precision()); - ds.field("scale", &self.scale()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum Utf8Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Utf8<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Utf8<'a> { - type Inner = Utf8<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Utf8<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Utf8 { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args Utf8Args - ) -> ::flatbuffers::WIPOffset> { - let mut builder = Utf8Builder::new(_fbb); - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Utf8::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Utf8<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct Utf8Args { - pub nullable: bool, -} -impl<'a> Default for Utf8Args { - #[inline] - fn default() -> Self { - Utf8Args { - nullable: false, - } - } -} - -pub struct Utf8Builder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Utf8Builder<'a, 'b, A> { - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Utf8::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Utf8Builder<'a, 'b, A> { - let start = _fbb.start_table(); - Utf8Builder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Utf8<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Utf8"); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum BinaryOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Binary<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Binary<'a> { - type Inner = Binary<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Binary<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Binary { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args BinaryArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = BinaryBuilder::new(_fbb); - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Binary::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Binary<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct BinaryArgs { - pub nullable: bool, -} -impl<'a> Default for BinaryArgs { - #[inline] - fn default() -> Self { - BinaryArgs { - nullable: false, - } - } -} - -pub struct BinaryBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BinaryBuilder<'a, 'b, A> { - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Binary::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> BinaryBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - BinaryBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Binary<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Binary"); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum Struct_Offset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Struct_<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Struct_<'a> { - type Inner = Struct_<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Struct_<'a> { - pub const VT_NAMES: ::flatbuffers::VOffsetT = 4; - pub const VT_DTYPES: ::flatbuffers::VOffsetT = 6; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Struct_ { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args Struct_Args<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = Struct_Builder::new(_fbb); - if let Some(x) = args.dtypes { builder.add_dtypes(x); } - if let Some(x) = args.names { builder.add_names(x); } - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn names(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Struct_::VT_NAMES, None)} - } - #[inline] - pub fn dtypes(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Struct_::VT_DTYPES, None)} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Struct_::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Struct_<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("names", Self::VT_NAMES, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("dtypes", Self::VT_DTYPES, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct Struct_Args<'a> { - pub names: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, - pub dtypes: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub nullable: bool, -} -impl<'a> Default for Struct_Args<'a> { - #[inline] - fn default() -> Self { - Struct_Args { - names: None, - dtypes: None, - nullable: false, - } - } -} - -pub struct Struct_Builder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Struct_Builder<'a, 'b, A> { - #[inline] - pub fn add_names(&mut self, names: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Struct_::VT_NAMES, names); - } - #[inline] - pub fn add_dtypes(&mut self, dtypes: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Struct_::VT_DTYPES, dtypes); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Struct_::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Struct_Builder<'a, 'b, A> { - let start = _fbb.start_table(); - Struct_Builder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Struct_<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Struct_"); - ds.field("names", &self.names()); - ds.field("dtypes", &self.dtypes()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum ListOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct List<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for List<'a> { - type Inner = List<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> List<'a> { - pub const VT_ELEMENT_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - List { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ListArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ListBuilder::new(_fbb); - if let Some(x) = args.element_type { builder.add_element_type(x); } - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn element_type(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(List::VT_ELEMENT_TYPE, None)} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(List::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for List<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("element_type", Self::VT_ELEMENT_TYPE, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct ListArgs<'a> { - pub element_type: Option<::flatbuffers::WIPOffset>>, - pub nullable: bool, -} -impl<'a> Default for ListArgs<'a> { - #[inline] - fn default() -> Self { - ListArgs { - element_type: None, - nullable: false, - } - } -} - -pub struct ListBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ListBuilder<'a, 'b, A> { - #[inline] - pub fn add_element_type(&mut self, element_type: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(List::VT_ELEMENT_TYPE, element_type); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(List::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ListBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ListBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for List<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("List"); - ds.field("element_type", &self.element_type()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum FixedSizeListOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct FixedSizeList<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for FixedSizeList<'a> { - type Inner = FixedSizeList<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> FixedSizeList<'a> { - pub const VT_ELEMENT_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_SIZE: ::flatbuffers::VOffsetT = 6; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - FixedSizeList { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args FixedSizeListArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = FixedSizeListBuilder::new(_fbb); - builder.add_size(args.size); - if let Some(x) = args.element_type { builder.add_element_type(x); } - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn element_type(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(FixedSizeList::VT_ELEMENT_TYPE, None)} - } - #[inline] - pub fn size(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(FixedSizeList::VT_SIZE, Some(0)).unwrap()} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(FixedSizeList::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for FixedSizeList<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("element_type", Self::VT_ELEMENT_TYPE, false)? - .visit_field::("size", Self::VT_SIZE, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct FixedSizeListArgs<'a> { - pub element_type: Option<::flatbuffers::WIPOffset>>, - pub size: u32, - pub nullable: bool, -} -impl<'a> Default for FixedSizeListArgs<'a> { - #[inline] - fn default() -> Self { - FixedSizeListArgs { - element_type: None, - size: 0, - nullable: false, - } - } -} - -pub struct FixedSizeListBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FixedSizeListBuilder<'a, 'b, A> { - #[inline] - pub fn add_element_type(&mut self, element_type: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(FixedSizeList::VT_ELEMENT_TYPE, element_type); - } - #[inline] - pub fn add_size(&mut self, size: u32) { - self.fbb_.push_slot::(FixedSizeList::VT_SIZE, size, 0); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(FixedSizeList::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FixedSizeListBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - FixedSizeListBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for FixedSizeList<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("FixedSizeList"); - ds.field("element_type", &self.element_type()); - ds.field("size", &self.size()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum ExtensionOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Extension<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Extension<'a> { - type Inner = Extension<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Extension<'a> { - pub const VT_ID: ::flatbuffers::VOffsetT = 4; - pub const VT_STORAGE_DTYPE: ::flatbuffers::VOffsetT = 6; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 8; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Extension { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ExtensionArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ExtensionBuilder::new(_fbb); - if let Some(x) = args.metadata { builder.add_metadata(x); } - if let Some(x) = args.storage_dtype { builder.add_storage_dtype(x); } - if let Some(x) = args.id { builder.add_id(x); } - builder.finish() - } - - - #[inline] - pub fn id(&self) -> Option<&'a str> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Extension::VT_ID, None)} - } - #[inline] - pub fn storage_dtype(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Extension::VT_STORAGE_DTYPE, None)} - } - #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Extension::VT_METADATA, None)} - } -} - -impl ::flatbuffers::Verifiable for Extension<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("storage_dtype", Self::VT_STORAGE_DTYPE, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)? - .finish(); - Ok(()) - } -} -pub struct ExtensionArgs<'a> { - pub id: Option<::flatbuffers::WIPOffset<&'a str>>, - pub storage_dtype: Option<::flatbuffers::WIPOffset>>, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, -} -impl<'a> Default for ExtensionArgs<'a> { - #[inline] - fn default() -> Self { - ExtensionArgs { - id: None, - storage_dtype: None, - metadata: None, - } - } -} - -pub struct ExtensionBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ExtensionBuilder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Extension::VT_ID, id); - } - #[inline] - pub fn add_storage_dtype(&mut self, storage_dtype: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Extension::VT_STORAGE_DTYPE, storage_dtype); - } - #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Extension::VT_METADATA, metadata); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ExtensionBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ExtensionBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Extension<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Extension"); - ds.field("id", &self.id()); - ds.field("storage_dtype", &self.storage_dtype()); - ds.field("metadata", &self.metadata()); - ds.finish() - } -} -pub enum VariantOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Variant<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Variant<'a> { - type Inner = Variant<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Variant<'a> { - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Variant { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args VariantArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = VariantBuilder::new(_fbb); - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Variant::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Variant<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct VariantArgs { - pub nullable: bool, -} -impl<'a> Default for VariantArgs { - #[inline] - fn default() -> Self { - VariantArgs { - nullable: false, - } - } -} - -pub struct VariantBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> VariantBuilder<'a, 'b, A> { - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Variant::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> VariantBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - VariantBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Variant<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Variant"); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum UnionOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Union<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Union<'a> { - type Inner = Union<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Union<'a> { - pub const VT_NAMES: ::flatbuffers::VOffsetT = 4; - pub const VT_DTYPES: ::flatbuffers::VOffsetT = 6; - pub const VT_TYPE_IDS: ::flatbuffers::VOffsetT = 8; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 10; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Union { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args UnionArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = UnionBuilder::new(_fbb); - if let Some(x) = args.type_ids { builder.add_type_ids(x); } - if let Some(x) = args.dtypes { builder.add_dtypes(x); } - if let Some(x) = args.names { builder.add_names(x); } - builder.add_nullable(args.nullable); - builder.finish() - } - - - #[inline] - pub fn names(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Union::VT_NAMES, None)} - } - #[inline] - pub fn dtypes(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Union::VT_DTYPES, None)} - } - #[inline] - pub fn type_ids(&self) -> Option<::flatbuffers::Vector<'a, i8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(Union::VT_TYPE_IDS, None)} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Union::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Union<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("names", Self::VT_NAMES, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("dtypes", Self::VT_DTYPES, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i8>>>("type_ids", Self::VT_TYPE_IDS, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct UnionArgs<'a> { - pub names: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, - pub dtypes: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub type_ids: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i8>>>, - pub nullable: bool, -} -impl<'a> Default for UnionArgs<'a> { - #[inline] - fn default() -> Self { - UnionArgs { - names: None, - dtypes: None, - type_ids: None, - nullable: false, - } - } -} - -pub struct UnionBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> UnionBuilder<'a, 'b, A> { - #[inline] - pub fn add_names(&mut self, names: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Union::VT_NAMES, names); - } - #[inline] - pub fn add_dtypes(&mut self, dtypes: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Union::VT_DTYPES, dtypes); - } - #[inline] - pub fn add_type_ids(&mut self, type_ids: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Union::VT_TYPE_IDS, type_ids); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Union::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UnionBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - UnionBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Union<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Union"); - ds.field("names", &self.names()); - ds.field("dtypes", &self.dtypes()); - ds.field("type_ids", &self.type_ids()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum MapOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Map<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Map<'a> { - type Inner = Map<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Map<'a> { - pub const VT_KEY_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_VALUE_TYPE: ::flatbuffers::VOffsetT = 6; - pub const VT_KEYS_SORTED: ::flatbuffers::VOffsetT = 8; - pub const VT_NULLABLE: ::flatbuffers::VOffsetT = 10; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Map { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args MapArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = MapBuilder::new(_fbb); - if let Some(x) = args.value_type { builder.add_value_type(x); } - if let Some(x) = args.key_type { builder.add_key_type(x); } - builder.add_nullable(args.nullable); - builder.add_keys_sorted(args.keys_sorted); - builder.finish() - } - - - #[inline] - pub fn key_type(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Map::VT_KEY_TYPE, None)} - } - #[inline] - pub fn value_type(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Map::VT_VALUE_TYPE, None)} - } - #[inline] - pub fn keys_sorted(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Map::VT_KEYS_SORTED, Some(false)).unwrap()} - } - #[inline] - pub fn nullable(&self) -> bool { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Map::VT_NULLABLE, Some(false)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for Map<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("key_type", Self::VT_KEY_TYPE, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("value_type", Self::VT_VALUE_TYPE, false)? - .visit_field::("keys_sorted", Self::VT_KEYS_SORTED, false)? - .visit_field::("nullable", Self::VT_NULLABLE, false)? - .finish(); - Ok(()) - } -} -pub struct MapArgs<'a> { - pub key_type: Option<::flatbuffers::WIPOffset>>, - pub value_type: Option<::flatbuffers::WIPOffset>>, - pub keys_sorted: bool, - pub nullable: bool, -} -impl<'a> Default for MapArgs<'a> { - #[inline] - fn default() -> Self { - MapArgs { - key_type: None, - value_type: None, - keys_sorted: false, - nullable: false, - } - } -} - -pub struct MapBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MapBuilder<'a, 'b, A> { - #[inline] - pub fn add_key_type(&mut self, key_type: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Map::VT_KEY_TYPE, key_type); - } - #[inline] - pub fn add_value_type(&mut self, value_type: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Map::VT_VALUE_TYPE, value_type); - } - #[inline] - pub fn add_keys_sorted(&mut self, keys_sorted: bool) { - self.fbb_.push_slot::(Map::VT_KEYS_SORTED, keys_sorted, false); - } - #[inline] - pub fn add_nullable(&mut self, nullable: bool) { - self.fbb_.push_slot::(Map::VT_NULLABLE, nullable, false); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MapBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - MapBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Map<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Map"); - ds.field("key_type", &self.key_type()); - ds.field("value_type", &self.value_type()); - ds.field("keys_sorted", &self.keys_sorted()); - ds.field("nullable", &self.nullable()); - ds.finish() - } -} -pub enum DTypeOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct DType<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for DType<'a> { - type Inner = DType<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> DType<'a> { - pub const VT_TYPE_TYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_TYPE_: ::flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - DType { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args DTypeArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = DTypeBuilder::new(_fbb); - if let Some(x) = args.type_ { builder.add_type_(x); } - builder.add_type_type(args.type_type); - builder.finish() - } - - - #[inline] - pub fn type_type(&self) -> Type { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(DType::VT_TYPE_TYPE, Some(Type::NONE)).unwrap()} - } - #[inline] - pub fn type_(&self) -> Option<::flatbuffers::Table<'a>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(DType::VT_TYPE_, None)} - } - #[inline] - #[allow(non_snake_case)] - pub fn type__as_null(&self) -> Option> { - if self.type_type() == Type::Null { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Null::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_bool(&self) -> Option> { - if self.type_type() == Type::Bool { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Bool::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_primitive(&self) -> Option> { - if self.type_type() == Type::Primitive { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Primitive::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_decimal(&self) -> Option> { - if self.type_type() == Type::Decimal { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Decimal::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_utf_8(&self) -> Option> { - if self.type_type() == Type::Utf8 { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Utf8::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_binary(&self) -> Option> { - if self.type_type() == Type::Binary { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Binary::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_struct_(&self) -> Option> { - if self.type_type() == Type::Struct_ { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Struct_::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_list(&self) -> Option> { - if self.type_type() == Type::List { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { List::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_extension(&self) -> Option> { - if self.type_type() == Type::Extension { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Extension::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_fixed_size_list(&self) -> Option> { - if self.type_type() == Type::FixedSizeList { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { FixedSizeList::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_variant(&self) -> Option> { - if self.type_type() == Type::Variant { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Variant::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_union(&self) -> Option> { - if self.type_type() == Type::Union { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Union::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn type__as_map(&self) -> Option> { - if self.type_type() == Type::Map { - self.type_().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { Map::init_from_table(t) } - }) - } else { - None - } - } - -} - -impl ::flatbuffers::Verifiable for DType<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_union::("type_type", Self::VT_TYPE_TYPE, "type_", Self::VT_TYPE_, false, |key, v, pos| { - match key { - Type::Null => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Null", pos), - Type::Bool => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Bool", pos), - Type::Primitive => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Primitive", pos), - Type::Decimal => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Decimal", pos), - Type::Utf8 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Utf8", pos), - Type::Binary => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Binary", pos), - Type::Struct_ => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Struct_", pos), - Type::List => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::List", pos), - Type::Extension => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Extension", pos), - Type::FixedSizeList => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::FixedSizeList", pos), - Type::Variant => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Variant", pos), - Type::Union => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Union", pos), - Type::Map => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Type::Map", pos), - _ => Ok(()), - } - })? - .finish(); - Ok(()) - } -} -pub struct DTypeArgs { - pub type_type: Type, - pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, -} -impl<'a> Default for DTypeArgs { - #[inline] - fn default() -> Self { - DTypeArgs { - type_type: Type::NONE, - type_: None, - } - } -} - -pub struct DTypeBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DTypeBuilder<'a, 'b, A> { - #[inline] - pub fn add_type_type(&mut self, type_type: Type) { - self.fbb_.push_slot::(DType::VT_TYPE_TYPE, type_type, Type::NONE); - } - #[inline] - pub fn add_type_(&mut self, type_: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(DType::VT_TYPE_, type_); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> DTypeBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - DTypeBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for DType<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("DType"); - ds.field("type_type", &self.type_type()); - match self.type_type() { - Type::Null => { - if let Some(x) = self.type__as_null() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Bool => { - if let Some(x) = self.type__as_bool() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Primitive => { - if let Some(x) = self.type__as_primitive() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Decimal => { - if let Some(x) = self.type__as_decimal() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Utf8 => { - if let Some(x) = self.type__as_utf_8() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Binary => { - if let Some(x) = self.type__as_binary() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Struct_ => { - if let Some(x) = self.type__as_struct_() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::List => { - if let Some(x) = self.type__as_list() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Extension => { - if let Some(x) = self.type__as_extension() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::FixedSizeList => { - if let Some(x) = self.type__as_fixed_size_list() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Variant => { - if let Some(x) = self.type__as_variant() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Union => { - if let Some(x) = self.type__as_union() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - Type::Map => { - if let Some(x) = self.type__as_map() { - ds.field("type_", &x) - } else { - ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - _ => { - let x: Option<()> = None; - ds.field("type_", &x) - }, - }; - ds.finish() - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `DType` -/// 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_dtype_unchecked`. -pub fn root_as_dtype(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `DType` 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_dtype_unchecked`. -pub fn size_prefixed_root_as_dtype(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `DType` 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_dtype_unchecked`. -pub fn root_as_dtype_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) -} -#[inline] -/// Verifies, with the given verifier options, that a buffer of -/// bytes contains a size prefixed `DType` 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_dtype_unchecked`. -pub fn size_prefixed_root_as_dtype_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a DType and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `DType`. -pub unsafe fn root_as_dtype_unchecked(buf: &[u8]) -> DType<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed DType and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `DType`. -pub unsafe fn size_prefixed_root_as_dtype_unchecked(buf: &[u8]) -> DType<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } -} -#[inline] -pub fn finish_dtype_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { - fbb.finish(root, None); -} - -#[inline] -pub fn finish_size_prefixed_dtype_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { - fbb.finish_size_prefixed(root, None); -} diff --git a/vortex-flatbuffers/src/generated/footer.rs b/vortex-flatbuffers/src/generated/footer.rs deleted file mode 100644 index 62ad85542e1..00000000000 --- a/vortex-flatbuffers/src/generated/footer.rs +++ /dev/null @@ -1,1508 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; - -use crate::array::*; -use crate::layout::*; - -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_COMPRESSION_SCHEME: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_COMPRESSION_SCHEME: u8 = 3; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_COMPRESSION_SCHEME: [CompressionScheme; 4] = [ - CompressionScheme::None, - CompressionScheme::LZ4, - CompressionScheme::ZLib, - CompressionScheme::ZStd, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct CompressionScheme(pub u8); -#[allow(non_upper_case_globals)] -impl CompressionScheme { - pub const None: Self = Self(0); - pub const LZ4: Self = Self(1); - pub const ZLib: Self = Self(2); - pub const ZStd: Self = Self(3); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 3; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::None, - Self::LZ4, - Self::ZLib, - Self::ZStd, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::None => Some("None"), - Self::LZ4 => Some("LZ4"), - Self::ZLib => Some("ZLib"), - Self::ZStd => Some("ZStd"), - _ => None, - } - } -} -impl ::core::fmt::Debug for CompressionScheme { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for CompressionScheme { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for CompressionScheme { - type Output = CompressionScheme; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for CompressionScheme { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for CompressionScheme { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for CompressionScheme {} -/// A `SegmentSpec` acts as the locator for a buffer within the file. -// struct SegmentSpec, aligned to 8 -#[repr(transparent)] -#[derive(Clone, Copy, PartialEq)] -pub struct SegmentSpec(pub [u8; 16]); -impl Default for SegmentSpec { - fn default() -> Self { - Self([0; 16]) - } -} -impl ::core::fmt::Debug for SegmentSpec { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - f.debug_struct("SegmentSpec") - .field("offset", &self.offset()) - .field("length", &self.length()) - .field("alignment_exponent", &self.alignment_exponent()) - .field("_compression", &self._compression()) - .field("_encryption", &self._encryption()) - .finish() - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for SegmentSpec {} -impl<'a> ::flatbuffers::Follow<'a> for SegmentSpec { - type Inner = &'a SegmentSpec; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - unsafe { <&'a SegmentSpec>::follow(buf, loc) } - } -} -impl<'a> ::flatbuffers::Follow<'a> for &'a SegmentSpec { - type Inner = &'a SegmentSpec; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - unsafe { ::flatbuffers::follow_cast_ref::(buf, loc) } - } -} -impl<'b> ::flatbuffers::Push for SegmentSpec { - type Output = SegmentSpec; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = unsafe { ::core::slice::from_raw_parts(self as *const SegmentSpec as *const u8, ::size()) }; - dst.copy_from_slice(src); - } - #[inline] - fn alignment() -> ::flatbuffers::PushAlignment { - ::flatbuffers::PushAlignment::new(8) - } -} - -impl<'a> ::flatbuffers::Verifiable for SegmentSpec { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.in_buffer::(pos) - } -} - -impl<'a> SegmentSpec { - #[allow(clippy::too_many_arguments)] - pub fn new( - offset: u64, - length: u32, - alignment_exponent: u8, - _compression: u8, - _encryption: u16, - ) -> Self { - let mut s = Self([0; 16]); - s.set_offset(offset); - s.set_length(length); - s.set_alignment_exponent(alignment_exponent); - s.set__compression(_compression); - s.set__encryption(_encryption); - s - } - - /// Offset relative to the start of the file. - pub fn offset(&self) -> u64 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[0..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_offset(&mut self, x: u64) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[0..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - /// Length in bytes of the segment. - pub fn length(&self) -> u32 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[8..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_length(&mut self, x: u32) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[8..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - /// Base-2 exponent of the alignment of the segment. - pub fn alignment_exponent(&self) -> u8 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[12..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set_alignment_exponent(&mut self, x: u8) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[12..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - pub fn _compression(&self) -> u8 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[13..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set__compression(&mut self, x: u8) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[13..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - - pub fn _encryption(&self) -> u16 { - let mut mem = ::core::mem::MaybeUninit::<::Scalar>::uninit(); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - ::flatbuffers::EndianScalar::from_little_endian(unsafe { - ::core::ptr::copy_nonoverlapping( - self.0[14..].as_ptr(), - mem.as_mut_ptr() as *mut u8, - ::core::mem::size_of::<::Scalar>(), - ); - mem.assume_init() - }) - } - - pub fn set__encryption(&mut self, x: u16) { - let x_le = ::flatbuffers::EndianScalar::to_little_endian(x); - // Safety: - // Created from a valid Table for this object - // Which contains a valid value in this slot - unsafe { - ::core::ptr::copy_nonoverlapping( - &x_le as *const _ as *const u8, - self.0[14..].as_mut_ptr(), - ::core::mem::size_of::<::Scalar>(), - ); - } - } - -} - -pub enum PostscriptOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// The `Postscript` is guaranteed by the file format to never exceed -/// 65528 bytes (i.e., u16::MAX - 8 bytes) in length, and is immediately -/// followed by an 8-byte `EndOfFile` struct. -/// -/// An initial read of a Vortex file defaults to at least 64KB (u16::MAX bytes) and therefore -/// is guaranteed to cover at least the Postscript. -/// -/// The reason for a postscript at all is to ensure minimal but all necessary footer information -/// can be read in two round trips. Since the DType is optional and possibly large, it lives in -/// its own segment. If the footer were arbitrary size, with a pointer to the DType segment, then -/// in the worst case we would need one round trip to read the footer length, one to read the full -/// footer and parse the DType offset, and a third to fetch the DType segment. -/// -/// The segments pointed to by the postscript have inline compression and encryption specs to avoid -/// the need to fetch encryption schemes up-front. -/// -/// New fields must be appended to preserve FlatBuffers field-order compatibility with old readers. -pub struct Postscript<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Postscript<'a> { - type Inner = Postscript<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Postscript<'a> { - pub const VT_DTYPE: ::flatbuffers::VOffsetT = 4; - pub const VT_LAYOUT: ::flatbuffers::VOffsetT = 6; - pub const VT_STATISTICS: ::flatbuffers::VOffsetT = 8; - pub const VT_FOOTER: ::flatbuffers::VOffsetT = 10; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Postscript { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args PostscriptArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = PostscriptBuilder::new(_fbb); - if let Some(x) = args.metadata { builder.add_metadata(x); } - if let Some(x) = args.footer { builder.add_footer(x); } - if let Some(x) = args.statistics { builder.add_statistics(x); } - if let Some(x) = args.layout { builder.add_layout(x); } - if let Some(x) = args.dtype { builder.add_dtype(x); } - builder.finish() - } - - - /// Segment containing the root `DType` flatbuffer. - #[inline] - pub fn dtype(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_DTYPE, None)} - } - /// Segment containing the root `Layout` flatbuffer (required). - #[inline] - pub fn layout(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_LAYOUT, None)} - } - /// Segment containing the file-level `Statistics` flatbuffer. - #[inline] - pub fn statistics(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_STATISTICS, None)} - } - /// Segment containing the 'Footer' flatbuffer (required) - #[inline] - pub fn footer(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Postscript::VT_FOOTER, None)} - } - /// User-defined metadata segments keyed by string. Keys must be unique, non-empty, and at most - /// 64 UTF-8 bytes; readers reject postscripts that violate these limits. - #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Postscript::VT_METADATA, None)} - } -} - -impl ::flatbuffers::Verifiable for Postscript<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset>("dtype", Self::VT_DTYPE, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("layout", Self::VT_LAYOUT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("statistics", Self::VT_STATISTICS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("footer", Self::VT_FOOTER, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("metadata", Self::VT_METADATA, false)? - .finish(); - Ok(()) - } -} -pub struct PostscriptArgs<'a> { - pub dtype: Option<::flatbuffers::WIPOffset>>, - pub layout: Option<::flatbuffers::WIPOffset>>, - pub statistics: Option<::flatbuffers::WIPOffset>>, - pub footer: Option<::flatbuffers::WIPOffset>>, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, -} -impl<'a> Default for PostscriptArgs<'a> { - #[inline] - fn default() -> Self { - PostscriptArgs { - dtype: None, - layout: None, - statistics: None, - footer: None, - metadata: None, - } - } -} - -pub struct PostscriptBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptBuilder<'a, 'b, A> { - #[inline] - pub fn add_dtype(&mut self, dtype: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_DTYPE, dtype); - } - #[inline] - pub fn add_layout(&mut self, layout: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_LAYOUT, layout); - } - #[inline] - pub fn add_statistics(&mut self, statistics: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_STATISTICS, statistics); - } - #[inline] - pub fn add_footer(&mut self, footer: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Postscript::VT_FOOTER, footer); - } - #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Postscript::VT_METADATA, metadata); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - PostscriptBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Postscript<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Postscript"); - ds.field("dtype", &self.dtype()); - ds.field("layout", &self.layout()); - ds.field("statistics", &self.statistics()); - ds.field("footer", &self.footer()); - ds.field("metadata", &self.metadata()); - ds.finish() - } -} -pub enum PostscriptMetadataOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// A keyed user-defined metadata segment. -pub struct PostscriptMetadata<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for PostscriptMetadata<'a> { - type Inner = PostscriptMetadata<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> PostscriptMetadata<'a> { - pub const VT_KEY: ::flatbuffers::VOffsetT = 4; - pub const VT_SEGMENT: ::flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - PostscriptMetadata { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args PostscriptMetadataArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = PostscriptMetadataBuilder::new(_fbb); - if let Some(x) = args.segment { builder.add_segment(x); } - if let Some(x) = args.key { builder.add_key(x); } - builder.finish() - } - - - #[inline] - pub fn key(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(PostscriptMetadata::VT_KEY, None).unwrap()} - } - #[inline] - pub fn segment(&self) -> PostscriptSegment<'a> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(PostscriptMetadata::VT_SEGMENT, None).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for PostscriptMetadata<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("key", Self::VT_KEY, true)? - .visit_field::<::flatbuffers::ForwardsUOffset>("segment", Self::VT_SEGMENT, true)? - .finish(); - Ok(()) - } -} -pub struct PostscriptMetadataArgs<'a> { - pub key: Option<::flatbuffers::WIPOffset<&'a str>>, - pub segment: Option<::flatbuffers::WIPOffset>>, -} -impl<'a> Default for PostscriptMetadataArgs<'a> { - #[inline] - fn default() -> Self { - PostscriptMetadataArgs { - key: None, // required field - segment: None, // required field - } - } -} - -pub struct PostscriptMetadataBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptMetadataBuilder<'a, 'b, A> { - #[inline] - pub fn add_key(&mut self, key: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(PostscriptMetadata::VT_KEY, key); - } - #[inline] - pub fn add_segment(&mut self, segment: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(PostscriptMetadata::VT_SEGMENT, segment); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptMetadataBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - PostscriptMetadataBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, PostscriptMetadata::VT_KEY,"key"); - self.fbb_.required(o, PostscriptMetadata::VT_SEGMENT,"segment"); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for PostscriptMetadata<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("PostscriptMetadata"); - ds.field("key", &self.key()); - ds.field("segment", &self.segment()); - ds.finish() - } -} -pub enum PostscriptSegmentOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// A `PostscriptSegment` describes the location of a segment in the file without referencing any -/// specification objects. That is, encryption and compression are defined inline. -pub struct PostscriptSegment<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for PostscriptSegment<'a> { - type Inner = PostscriptSegment<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> PostscriptSegment<'a> { - pub const VT_OFFSET: ::flatbuffers::VOffsetT = 4; - pub const VT_LENGTH: ::flatbuffers::VOffsetT = 6; - pub const VT_ALIGNMENT_EXPONENT: ::flatbuffers::VOffsetT = 8; - pub const VT__COMPRESSION: ::flatbuffers::VOffsetT = 10; - pub const VT__ENCRYPTION: ::flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - PostscriptSegment { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args PostscriptSegmentArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = PostscriptSegmentBuilder::new(_fbb); - builder.add_offset(args.offset); - if let Some(x) = args._encryption { builder.add__encryption(x); } - if let Some(x) = args._compression { builder.add__compression(x); } - builder.add_length(args.length); - builder.add_alignment_exponent(args.alignment_exponent); - builder.finish() - } - - - #[inline] - pub fn offset(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(PostscriptSegment::VT_OFFSET, Some(0)).unwrap()} - } - #[inline] - pub fn length(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(PostscriptSegment::VT_LENGTH, Some(0)).unwrap()} - } - #[inline] - pub fn alignment_exponent(&self) -> u8 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(PostscriptSegment::VT_ALIGNMENT_EXPONENT, Some(0)).unwrap()} - } - #[inline] - pub fn _compression(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(PostscriptSegment::VT__COMPRESSION, None)} - } - #[inline] - pub fn _encryption(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(PostscriptSegment::VT__ENCRYPTION, None)} - } -} - -impl ::flatbuffers::Verifiable for PostscriptSegment<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("offset", Self::VT_OFFSET, false)? - .visit_field::("length", Self::VT_LENGTH, false)? - .visit_field::("alignment_exponent", Self::VT_ALIGNMENT_EXPONENT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("_compression", Self::VT__COMPRESSION, false)? - .visit_field::<::flatbuffers::ForwardsUOffset>("_encryption", Self::VT__ENCRYPTION, false)? - .finish(); - Ok(()) - } -} -pub struct PostscriptSegmentArgs<'a> { - pub offset: u64, - pub length: u32, - pub alignment_exponent: u8, - pub _compression: Option<::flatbuffers::WIPOffset>>, - pub _encryption: Option<::flatbuffers::WIPOffset>>, -} -impl<'a> Default for PostscriptSegmentArgs<'a> { - #[inline] - fn default() -> Self { - PostscriptSegmentArgs { - offset: 0, - length: 0, - alignment_exponent: 0, - _compression: None, - _encryption: None, - } - } -} - -pub struct PostscriptSegmentBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PostscriptSegmentBuilder<'a, 'b, A> { - #[inline] - pub fn add_offset(&mut self, offset: u64) { - self.fbb_.push_slot::(PostscriptSegment::VT_OFFSET, offset, 0); - } - #[inline] - pub fn add_length(&mut self, length: u32) { - self.fbb_.push_slot::(PostscriptSegment::VT_LENGTH, length, 0); - } - #[inline] - pub fn add_alignment_exponent(&mut self, alignment_exponent: u8) { - self.fbb_.push_slot::(PostscriptSegment::VT_ALIGNMENT_EXPONENT, alignment_exponent, 0); - } - #[inline] - pub fn add__compression(&mut self, _compression: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(PostscriptSegment::VT__COMPRESSION, _compression); - } - #[inline] - pub fn add__encryption(&mut self, _encryption: ::flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(PostscriptSegment::VT__ENCRYPTION, _encryption); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PostscriptSegmentBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - PostscriptSegmentBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for PostscriptSegment<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("PostscriptSegment"); - ds.field("offset", &self.offset()); - ds.field("length", &self.length()); - ds.field("alignment_exponent", &self.alignment_exponent()); - ds.field("_compression", &self._compression()); - ds.field("_encryption", &self._encryption()); - ds.finish() - } -} -pub enum FileStatisticsOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// The `FileStatistics` object contains file-level statistics for the Vortex file. -pub struct FileStatistics<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for FileStatistics<'a> { - type Inner = FileStatistics<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> FileStatistics<'a> { - pub const VT_FIELD_STATS: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - FileStatistics { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args FileStatisticsArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = FileStatisticsBuilder::new(_fbb); - if let Some(x) = args.field_stats { builder.add_field_stats(x); } - builder.finish() - } - - - /// Statistics for each field in the root schema. If the root schema is not a struct, there will - /// be a single entry in this array. - #[inline] - pub fn field_stats(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(FileStatistics::VT_FIELD_STATS, None)} - } -} - -impl ::flatbuffers::Verifiable for FileStatistics<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("field_stats", Self::VT_FIELD_STATS, false)? - .finish(); - Ok(()) - } -} -pub struct FileStatisticsArgs<'a> { - pub field_stats: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, -} -impl<'a> Default for FileStatisticsArgs<'a> { - #[inline] - fn default() -> Self { - FileStatisticsArgs { - field_stats: None, - } - } -} - -pub struct FileStatisticsBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FileStatisticsBuilder<'a, 'b, A> { - #[inline] - pub fn add_field_stats(&mut self, field_stats: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(FileStatistics::VT_FIELD_STATS, field_stats); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FileStatisticsBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - FileStatisticsBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for FileStatistics<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("FileStatistics"); - ds.field("field_stats", &self.field_stats()); - ds.finish() - } -} -pub enum FooterOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// The `Registry` object stores dictionary-encoded configuration for segments, -/// compression schemes, encryption schemes, etc. -pub struct Footer<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Footer<'a> { - type Inner = Footer<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Footer<'a> { - pub const VT_ARRAY_SPECS: ::flatbuffers::VOffsetT = 4; - pub const VT_LAYOUT_SPECS: ::flatbuffers::VOffsetT = 6; - pub const VT_SEGMENT_SPECS: ::flatbuffers::VOffsetT = 8; - pub const VT_COMPRESSION_SPECS: ::flatbuffers::VOffsetT = 10; - pub const VT_ENCRYPTION_SPECS: ::flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Footer { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args FooterArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = FooterBuilder::new(_fbb); - if let Some(x) = args.encryption_specs { builder.add_encryption_specs(x); } - if let Some(x) = args.compression_specs { builder.add_compression_specs(x); } - if let Some(x) = args.segment_specs { builder.add_segment_specs(x); } - if let Some(x) = args.layout_specs { builder.add_layout_specs(x); } - if let Some(x) = args.array_specs { builder.add_array_specs(x); } - builder.finish() - } - - - #[inline] - pub fn array_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_ARRAY_SPECS, None)} - } - #[inline] - pub fn layout_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_LAYOUT_SPECS, None)} - } - #[inline] - pub fn segment_specs(&self) -> Option<::flatbuffers::Vector<'a, SegmentSpec>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, SegmentSpec>>>(Footer::VT_SEGMENT_SPECS, None)} - } - #[inline] - pub fn compression_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_COMPRESSION_SPECS, None)} - } - #[inline] - pub fn encryption_specs(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Footer::VT_ENCRYPTION_SPECS, None)} - } -} - -impl ::flatbuffers::Verifiable for Footer<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("array_specs", Self::VT_ARRAY_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("layout_specs", Self::VT_LAYOUT_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, SegmentSpec>>>("segment_specs", Self::VT_SEGMENT_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("compression_specs", Self::VT_COMPRESSION_SPECS, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("encryption_specs", Self::VT_ENCRYPTION_SPECS, false)? - .finish(); - Ok(()) - } -} -pub struct FooterArgs<'a> { - pub array_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub layout_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub segment_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, SegmentSpec>>>, - pub compression_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub encryption_specs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, -} -impl<'a> Default for FooterArgs<'a> { - #[inline] - fn default() -> Self { - FooterArgs { - array_specs: None, - layout_specs: None, - segment_specs: None, - compression_specs: None, - encryption_specs: None, - } - } -} - -pub struct FooterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FooterBuilder<'a, 'b, A> { - #[inline] - pub fn add_array_specs(&mut self, array_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_ARRAY_SPECS, array_specs); - } - #[inline] - pub fn add_layout_specs(&mut self, layout_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_LAYOUT_SPECS, layout_specs); - } - #[inline] - pub fn add_segment_specs(&mut self, segment_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , SegmentSpec>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_SEGMENT_SPECS, segment_specs); - } - #[inline] - pub fn add_compression_specs(&mut self, compression_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_COMPRESSION_SPECS, compression_specs); - } - #[inline] - pub fn add_encryption_specs(&mut self, encryption_specs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Footer::VT_ENCRYPTION_SPECS, encryption_specs); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FooterBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - FooterBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Footer<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Footer"); - ds.field("array_specs", &self.array_specs()); - ds.field("layout_specs", &self.layout_specs()); - ds.field("segment_specs", &self.segment_specs()); - ds.field("compression_specs", &self.compression_specs()); - ds.field("encryption_specs", &self.encryption_specs()); - ds.finish() - } -} -pub enum ArraySpecOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// An `ArraySpec` describes the type of a particular array. -/// -/// These are identified by a globally unique string identifier, and looked up in the Vortex registry -/// at read-time. -pub struct ArraySpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for ArraySpec<'a> { - type Inner = ArraySpec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> ArraySpec<'a> { - pub const VT_ID: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - ArraySpec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ArraySpecArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ArraySpecBuilder::new(_fbb); - if let Some(x) = args.id { builder.add_id(x); } - builder.finish() - } - - - #[inline] - pub fn id(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(ArraySpec::VT_ID, None).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for ArraySpec<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, true)? - .finish(); - Ok(()) - } -} -pub struct ArraySpecArgs<'a> { - pub id: Option<::flatbuffers::WIPOffset<&'a str>>, -} -impl<'a> Default for ArraySpecArgs<'a> { - #[inline] - fn default() -> Self { - ArraySpecArgs { - id: None, // required field - } - } -} - -pub struct ArraySpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArraySpecBuilder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArraySpec::VT_ID, id); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArraySpecBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ArraySpecBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, ArraySpec::VT_ID,"id"); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for ArraySpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("ArraySpec"); - ds.field("id", &self.id()); - ds.finish() - } -} -pub enum LayoutSpecOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// A `LayoutSpec` describes the type of a particular layout. -/// -/// These are identified by a globally unique string identifier, and looked up in the Vortex registry -/// at read-time. -pub struct LayoutSpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for LayoutSpec<'a> { - type Inner = LayoutSpec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> LayoutSpec<'a> { - pub const VT_ID: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - LayoutSpec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args LayoutSpecArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = LayoutSpecBuilder::new(_fbb); - if let Some(x) = args.id { builder.add_id(x); } - builder.finish() - } - - - #[inline] - pub fn id(&self) -> &'a str { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(LayoutSpec::VT_ID, None).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for LayoutSpec<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, true)? - .finish(); - Ok(()) - } -} -pub struct LayoutSpecArgs<'a> { - pub id: Option<::flatbuffers::WIPOffset<&'a str>>, -} -impl<'a> Default for LayoutSpecArgs<'a> { - #[inline] - fn default() -> Self { - LayoutSpecArgs { - id: None, // required field - } - } -} - -pub struct LayoutSpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutSpecBuilder<'a, 'b, A> { - #[inline] - pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(LayoutSpec::VT_ID, id); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutSpecBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - LayoutSpecBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - self.fbb_.required(o, LayoutSpec::VT_ID,"id"); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for LayoutSpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("LayoutSpec"); - ds.field("id", &self.id()); - ds.finish() - } -} -pub enum CompressionSpecOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// Definition of a compression scheme. -pub struct CompressionSpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for CompressionSpec<'a> { - type Inner = CompressionSpec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> CompressionSpec<'a> { - pub const VT_SCHEME: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - CompressionSpec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args CompressionSpecArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = CompressionSpecBuilder::new(_fbb); - builder.add_scheme(args.scheme); - builder.finish() - } - - - #[inline] - pub fn scheme(&self) -> CompressionScheme { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(CompressionSpec::VT_SCHEME, Some(CompressionScheme::None)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for CompressionSpec<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("scheme", Self::VT_SCHEME, false)? - .finish(); - Ok(()) - } -} -pub struct CompressionSpecArgs { - pub scheme: CompressionScheme, -} -impl<'a> Default for CompressionSpecArgs { - #[inline] - fn default() -> Self { - CompressionSpecArgs { - scheme: CompressionScheme::None, - } - } -} - -pub struct CompressionSpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> CompressionSpecBuilder<'a, 'b, A> { - #[inline] - pub fn add_scheme(&mut self, scheme: CompressionScheme) { - self.fbb_.push_slot::(CompressionSpec::VT_SCHEME, scheme, CompressionScheme::None); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> CompressionSpecBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - CompressionSpecBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for CompressionSpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("CompressionSpec"); - ds.field("scheme", &self.scheme()); - ds.finish() - } -} -pub enum EncryptionSpecOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct EncryptionSpec<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for EncryptionSpec<'a> { - type Inner = EncryptionSpec<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> EncryptionSpec<'a> { - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - EncryptionSpec { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - _args: &'args EncryptionSpecArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = EncryptionSpecBuilder::new(_fbb); - builder.finish() - } - -} - -impl ::flatbuffers::Verifiable for EncryptionSpec<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .finish(); - Ok(()) - } -} -pub struct EncryptionSpecArgs { -} -impl<'a> Default for EncryptionSpecArgs { - #[inline] - fn default() -> Self { - EncryptionSpecArgs { - } - } -} - -pub struct EncryptionSpecBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> EncryptionSpecBuilder<'a, 'b, A> { - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> EncryptionSpecBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - EncryptionSpecBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for EncryptionSpec<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("EncryptionSpec"); - ds.finish() - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `Postscript` -/// 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_postscript_unchecked`. -pub fn root_as_postscript(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `Postscript` 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_postscript_unchecked`. -pub fn size_prefixed_root_as_postscript(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `Postscript` 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_postscript_unchecked`. -pub fn root_as_postscript_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) -} -#[inline] -/// Verifies, with the given verifier options, that a buffer of -/// bytes contains a size prefixed `Postscript` 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_postscript_unchecked`. -pub fn size_prefixed_root_as_postscript_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a Postscript and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `Postscript`. -pub unsafe fn root_as_postscript_unchecked(buf: &[u8]) -> Postscript<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed Postscript and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `Postscript`. -pub unsafe fn size_prefixed_root_as_postscript_unchecked(buf: &[u8]) -> Postscript<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } -} -#[inline] -pub fn finish_postscript_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { - fbb.finish(root, None); -} - -#[inline] -pub fn finish_size_prefixed_postscript_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { - fbb.finish_size_prefixed(root, None); -} diff --git a/vortex-flatbuffers/src/generated/layout.rs b/vortex-flatbuffers/src/generated/layout.rs deleted file mode 100644 index 0c7c7557b74..00000000000 --- a/vortex-flatbuffers/src/generated/layout.rs +++ /dev/null @@ -1,260 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; - - -pub enum LayoutOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// A `Layout` is a recursive data structure describing the physical layout of Vortex arrays in random access storage. -/// As a starting, concrete example, the first three Layout encodings are defined as: -/// -/// 1. encoding == 1, `Flat` -> one buffer, zero child Layouts -/// 2. encoding == 2, `Chunked` -> zero buffers, one or more child Layouts (used for chunks of rows) -/// 3. encoding == 3, `Columnar` -> zero buffers, one or more child Layouts (used for columns of structs) -/// -/// The `row_count` represents the number of rows represented by this Layout. This is very useful for -/// pruning the Layout tree based on row filters. -/// -/// The `metadata` field is fully opaque at this layer, and allows the Layout implementation corresponding to -/// `encoding` to embed additional information that may be useful for the reader. For example, the `ChunkedLayout` -/// uses the first byte of the `metadata` array as a boolean to indicate whether the first child Layout represents -/// the statistics table for the other chunks. -pub struct Layout<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Layout<'a> { - type Inner = Layout<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Layout<'a> { - pub const VT_ENCODING: ::flatbuffers::VOffsetT = 4; - pub const VT_ROW_COUNT: ::flatbuffers::VOffsetT = 6; - pub const VT_METADATA: ::flatbuffers::VOffsetT = 8; - pub const VT_CHILDREN: ::flatbuffers::VOffsetT = 10; - pub const VT_SEGMENTS: ::flatbuffers::VOffsetT = 12; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Layout { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args LayoutArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = LayoutBuilder::new(_fbb); - builder.add_row_count(args.row_count); - if let Some(x) = args.segments { builder.add_segments(x); } - if let Some(x) = args.children { builder.add_children(x); } - if let Some(x) = args.metadata { builder.add_metadata(x); } - builder.add_encoding(args.encoding); - builder.finish() - } - - - /// The ID of the encoding used for this Layout. - #[inline] - pub fn encoding(&self) -> u16 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Layout::VT_ENCODING, Some(0)).unwrap()} - } - /// The number of rows of data represented by this Layout. - #[inline] - pub fn row_count(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Layout::VT_ROW_COUNT, Some(0)).unwrap()} - } - /// Any additional metadata this layout needs to interpret its children. - /// This does not include data-specific metadata, which the layout should store in a segment. - #[inline] - pub fn metadata(&self) -> Option<::flatbuffers::Vector<'a, u8>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Layout::VT_METADATA, None)} - } - /// The children of this Layout. - #[inline] - pub fn children(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Layout::VT_CHILDREN, None)} - } - /// Identifiers for each `SegmentSpec` of data required by this layout. - #[inline] - pub fn segments(&self) -> Option<::flatbuffers::Vector<'a, u32>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u32>>>(Layout::VT_SEGMENTS, None)} - } -} - -impl ::flatbuffers::Verifiable for Layout<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("encoding", Self::VT_ENCODING, false)? - .visit_field::("row_count", Self::VT_ROW_COUNT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("metadata", Self::VT_METADATA, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("children", Self::VT_CHILDREN, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u32>>>("segments", Self::VT_SEGMENTS, false)? - .finish(); - Ok(()) - } -} -pub struct LayoutArgs<'a> { - pub encoding: u16, - pub row_count: u64, - pub metadata: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, - pub children: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, - pub segments: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u32>>>, -} -impl<'a> Default for LayoutArgs<'a> { - #[inline] - fn default() -> Self { - LayoutArgs { - encoding: 0, - row_count: 0, - metadata: None, - children: None, - segments: None, - } - } -} - -pub struct LayoutBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> LayoutBuilder<'a, 'b, A> { - #[inline] - pub fn add_encoding(&mut self, encoding: u16) { - self.fbb_.push_slot::(Layout::VT_ENCODING, encoding, 0); - } - #[inline] - pub fn add_row_count(&mut self, row_count: u64) { - self.fbb_.push_slot::(Layout::VT_ROW_COUNT, row_count, 0); - } - #[inline] - pub fn add_metadata(&mut self, metadata: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_METADATA, metadata); - } - #[inline] - pub fn add_children(&mut self, children: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_CHILDREN, children); - } - #[inline] - pub fn add_segments(&mut self, segments: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u32>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Layout::VT_SEGMENTS, segments); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> LayoutBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - LayoutBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Layout<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Layout"); - ds.field("encoding", &self.encoding()); - ds.field("row_count", &self.row_count()); - ds.field("metadata", &self.metadata()); - ds.field("children", &self.children()); - ds.field("segments", &self.segments()); - ds.finish() - } -} -#[inline] -/// Verifies that a buffer of bytes contains a `Layout` -/// 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_layout_unchecked`. -pub fn root_as_layout(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(buf) -} -#[inline] -/// Verifies that a buffer of bytes contains a size prefixed -/// `Layout` 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_layout_unchecked`. -pub fn size_prefixed_root_as_layout(buf: &[u8]) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(buf) -} -#[inline] -/// Verifies, with the given options, that a buffer of bytes -/// contains a `Layout` 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_layout_unchecked`. -pub fn root_as_layout_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(opts, buf) -} -#[inline] -/// Verifies, with the given verifier options, that a buffer of -/// bytes contains a size prefixed `Layout` 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_layout_unchecked`. -pub fn size_prefixed_root_as_layout_with_opts<'b, 'o>( - opts: &'o ::flatbuffers::VerifierOptions, - buf: &'b [u8], -) -> Result, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a Layout and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid `Layout`. -pub unsafe fn root_as_layout_unchecked(buf: &[u8]) -> Layout<'_> { - unsafe { ::flatbuffers::root_unchecked::(buf) } -} -#[inline] -/// Assumes, without verification, that a buffer of bytes contains a size prefixed Layout and returns it. -/// # Safety -/// Callers must trust the given bytes do indeed contain a valid size prefixed `Layout`. -pub unsafe fn size_prefixed_root_as_layout_unchecked(buf: &[u8]) -> Layout<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } -} -#[inline] -pub fn finish_layout_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { - fbb.finish(root, None); -} - -#[inline] -pub fn finish_size_prefixed_layout_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { - fbb.finish_size_prefixed(root, None); -} diff --git a/vortex-flatbuffers/src/generated/message.rs b/vortex-flatbuffers/src/generated/message.rs deleted file mode 100644 index b3e4be76ef7..00000000000 --- a/vortex-flatbuffers/src/generated/message.rs +++ /dev/null @@ -1,768 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify -// @generated -extern crate alloc; - -use crate::array::*; -use crate::dtype::*; - -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_MESSAGE_VERSION: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_MESSAGE_VERSION: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_MESSAGE_VERSION: [MessageVersion; 1] = [ - MessageVersion::V0, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct MessageVersion(pub u8); -#[allow(non_upper_case_globals)] -impl MessageVersion { - pub const V0: Self = Self(0); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 0; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::V0, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::V0 => Some("V0"), - _ => None, - } - } -} -impl ::core::fmt::Debug for MessageVersion { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for MessageVersion { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for MessageVersion { - type Output = MessageVersion; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for MessageVersion { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for MessageVersion { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for MessageVersion {} -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MIN_MESSAGE_HEADER: u8 = 0; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -pub const ENUM_MAX_MESSAGE_HEADER: u8 = 3; -#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] -#[allow(non_camel_case_types)] -pub const ENUM_VALUES_MESSAGE_HEADER: [MessageHeader; 4] = [ - MessageHeader::NONE, - MessageHeader::ArrayMessage, - MessageHeader::BufferMessage, - MessageHeader::DTypeMessage, -]; - -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] -#[repr(transparent)] -pub struct MessageHeader(pub u8); -#[allow(non_upper_case_globals)] -impl MessageHeader { - pub const NONE: Self = Self(0); - pub const ArrayMessage: Self = Self(1); - pub const BufferMessage: Self = Self(2); - pub const DTypeMessage: Self = Self(3); - - pub const ENUM_MIN: u8 = 0; - pub const ENUM_MAX: u8 = 3; - pub const ENUM_VALUES: &'static [Self] = &[ - Self::NONE, - Self::ArrayMessage, - Self::BufferMessage, - Self::DTypeMessage, - ]; - /// Returns the variant's name or "" if unknown. - pub fn variant_name(self) -> Option<&'static str> { - match self { - Self::NONE => Some("NONE"), - Self::ArrayMessage => Some("ArrayMessage"), - Self::BufferMessage => Some("BufferMessage"), - Self::DTypeMessage => Some("DTypeMessage"), - _ => None, - } - } -} -impl ::core::fmt::Debug for MessageHeader { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - if let Some(name) = self.variant_name() { - f.write_str(name) - } else { - f.write_fmt(format_args!("", self.0)) - } - } -} -impl<'a> ::flatbuffers::Follow<'a> for MessageHeader { - type Inner = Self; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = unsafe { ::flatbuffers::read_scalar_at::(buf, loc) }; - Self(b) - } -} - -impl ::flatbuffers::Push for MessageHeader { - type Output = MessageHeader; - #[inline] - unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - unsafe { ::flatbuffers::emplace_scalar::(dst, self.0) }; - } -} - -impl ::flatbuffers::EndianScalar for MessageHeader { - type Scalar = u8; - #[inline] - fn to_little_endian(self) -> u8 { - self.0.to_le() - } - #[inline] - #[allow(clippy::wrong_self_convention)] - fn from_little_endian(v: u8) -> Self { - let b = u8::from_le(v); - Self(b) - } -} - -impl<'a> ::flatbuffers::Verifiable for MessageHeader { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - u8::run_verifier(v, pos) - } -} - -impl ::flatbuffers::SimpleToVerifyInSlice for MessageHeader {} -pub struct MessageHeaderUnionTableOffset {} - -pub enum ArrayMessageOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// Indicates the message body contains a flatbuffer Array message, followed by array buffers. -pub struct ArrayMessage<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for ArrayMessage<'a> { - type Inner = ArrayMessage<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> ArrayMessage<'a> { - pub const VT_ROW_COUNT: ::flatbuffers::VOffsetT = 4; - pub const VT_ENCODINGS: ::flatbuffers::VOffsetT = 6; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - ArrayMessage { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args ArrayMessageArgs<'args> - ) -> ::flatbuffers::WIPOffset> { - let mut builder = ArrayMessageBuilder::new(_fbb); - if let Some(x) = args.encodings { builder.add_encodings(x); } - builder.add_row_count(args.row_count); - builder.finish() - } - - - /// The row count of the array. - #[inline] - pub fn row_count(&self) -> u32 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(ArrayMessage::VT_ROW_COUNT, Some(0)).unwrap()} - } - /// The encodings referenced by the array. - #[inline] - pub fn encodings(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(ArrayMessage::VT_ENCODINGS, None)} - } -} - -impl ::flatbuffers::Verifiable for ArrayMessage<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("row_count", Self::VT_ROW_COUNT, false)? - .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("encodings", Self::VT_ENCODINGS, false)? - .finish(); - Ok(()) - } -} -pub struct ArrayMessageArgs<'a> { - pub row_count: u32, - pub encodings: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, -} -impl<'a> Default for ArrayMessageArgs<'a> { - #[inline] - fn default() -> Self { - ArrayMessageArgs { - row_count: 0, - encodings: None, - } - } -} - -pub struct ArrayMessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayMessageBuilder<'a, 'b, A> { - #[inline] - pub fn add_row_count(&mut self, row_count: u32) { - self.fbb_.push_slot::(ArrayMessage::VT_ROW_COUNT, row_count, 0); - } - #[inline] - pub fn add_encodings(&mut self, encodings: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(ArrayMessage::VT_ENCODINGS, encodings); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayMessageBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - ArrayMessageBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for ArrayMessage<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("ArrayMessage"); - ds.field("row_count", &self.row_count()); - ds.field("encodings", &self.encodings()); - ds.finish() - } -} -pub enum BufferMessageOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// Indicates the body contains a regular byte buffer. -pub struct BufferMessage<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for BufferMessage<'a> { - type Inner = BufferMessage<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> BufferMessage<'a> { - pub const VT_ALIGNMENT_EXPONENT: ::flatbuffers::VOffsetT = 4; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - BufferMessage { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args BufferMessageArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = BufferMessageBuilder::new(_fbb); - builder.add_alignment_exponent(args.alignment_exponent); - builder.finish() - } - - - #[inline] - pub fn alignment_exponent(&self) -> u8 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(BufferMessage::VT_ALIGNMENT_EXPONENT, Some(0)).unwrap()} - } -} - -impl ::flatbuffers::Verifiable for BufferMessage<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("alignment_exponent", Self::VT_ALIGNMENT_EXPONENT, false)? - .finish(); - Ok(()) - } -} -pub struct BufferMessageArgs { - pub alignment_exponent: u8, -} -impl<'a> Default for BufferMessageArgs { - #[inline] - fn default() -> Self { - BufferMessageArgs { - alignment_exponent: 0, - } - } -} - -pub struct BufferMessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> BufferMessageBuilder<'a, 'b, A> { - #[inline] - pub fn add_alignment_exponent(&mut self, alignment_exponent: u8) { - self.fbb_.push_slot::(BufferMessage::VT_ALIGNMENT_EXPONENT, alignment_exponent, 0); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> BufferMessageBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - BufferMessageBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for BufferMessage<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("BufferMessage"); - ds.field("alignment_exponent", &self.alignment_exponent()); - ds.finish() - } -} -pub enum DTypeMessageOffset {} -#[derive(Copy, Clone, PartialEq)] - -/// Indicates the body contains a flatbuffer DType message. -pub struct DTypeMessage<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for DTypeMessage<'a> { - type Inner = DTypeMessage<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> DTypeMessage<'a> { - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - DTypeMessage { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - _args: &'args DTypeMessageArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = DTypeMessageBuilder::new(_fbb); - builder.finish() - } - -} - -impl ::flatbuffers::Verifiable for DTypeMessage<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .finish(); - Ok(()) - } -} -pub struct DTypeMessageArgs { -} -impl<'a> Default for DTypeMessageArgs { - #[inline] - fn default() -> Self { - DTypeMessageArgs { - } - } -} - -pub struct DTypeMessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> DTypeMessageBuilder<'a, 'b, A> { - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> DTypeMessageBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - DTypeMessageBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for DTypeMessage<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("DTypeMessage"); - ds.finish() - } -} -pub enum MessageOffset {} -#[derive(Copy, Clone, PartialEq)] - -pub struct Message<'a> { - pub _tab: ::flatbuffers::Table<'a>, -} - -impl<'a> ::flatbuffers::Follow<'a> for Message<'a> { - type Inner = Message<'a>; - #[inline] - unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } } - } -} - -impl<'a> Message<'a> { - pub const VT_VERSION: ::flatbuffers::VOffsetT = 4; - pub const VT_HEADER_TYPE: ::flatbuffers::VOffsetT = 6; - pub const VT_HEADER: ::flatbuffers::VOffsetT = 8; - pub const VT_BODY_SIZE: ::flatbuffers::VOffsetT = 10; - - #[inline] - pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { - Message { _tab: table } - } - #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>( - _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>, - args: &'args MessageArgs - ) -> ::flatbuffers::WIPOffset> { - let mut builder = MessageBuilder::new(_fbb); - builder.add_body_size(args.body_size); - if let Some(x) = args.header { builder.add_header(x); } - builder.add_header_type(args.header_type); - builder.add_version(args.version); - builder.finish() - } - - - #[inline] - pub fn version(&self) -> MessageVersion { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_VERSION, Some(MessageVersion::V0)).unwrap()} - } - #[inline] - pub fn header_type(&self) -> MessageHeader { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_HEADER_TYPE, Some(MessageHeader::NONE)).unwrap()} - } - #[inline] - pub fn header(&self) -> Option<::flatbuffers::Table<'a>> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Message::VT_HEADER, None)} - } - #[inline] - pub fn body_size(&self) -> u64 { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::(Message::VT_BODY_SIZE, Some(0)).unwrap()} - } - #[inline] - #[allow(non_snake_case)] - pub fn header_as_array_message(&self) -> Option> { - if self.header_type() == MessageHeader::ArrayMessage { - self.header().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { ArrayMessage::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn header_as_buffer_message(&self) -> Option> { - if self.header_type() == MessageHeader::BufferMessage { - self.header().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { BufferMessage::init_from_table(t) } - }) - } else { - None - } - } - - #[inline] - #[allow(non_snake_case)] - pub fn header_as_dtype_message(&self) -> Option> { - if self.header_type() == MessageHeader::DTypeMessage { - self.header().map(|t| { - // Safety: - // Created from a valid Table for this object - // Which contains a valid union in this slot - unsafe { DTypeMessage::init_from_table(t) } - }) - } else { - None - } - } - -} - -impl ::flatbuffers::Verifiable for Message<'_> { - #[inline] - fn run_verifier( - v: &mut ::flatbuffers::Verifier, pos: usize - ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> { - v.visit_table(pos)? - .visit_field::("version", Self::VT_VERSION, false)? - .visit_union::("header_type", Self::VT_HEADER_TYPE, "header", Self::VT_HEADER, false, |key, v, pos| { - match key { - MessageHeader::ArrayMessage => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("MessageHeader::ArrayMessage", pos), - MessageHeader::BufferMessage => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("MessageHeader::BufferMessage", pos), - MessageHeader::DTypeMessage => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("MessageHeader::DTypeMessage", pos), - _ => Ok(()), - } - })? - .visit_field::("body_size", Self::VT_BODY_SIZE, false)? - .finish(); - Ok(()) - } -} -pub struct MessageArgs { - pub version: MessageVersion, - pub header_type: MessageHeader, - pub header: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, - pub body_size: u64, -} -impl<'a> Default for MessageArgs { - #[inline] - fn default() -> Self { - MessageArgs { - version: MessageVersion::V0, - header_type: MessageHeader::NONE, - header: None, - body_size: 0, - } - } -} - -pub struct MessageBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> { - fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>, -} -impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MessageBuilder<'a, 'b, A> { - #[inline] - pub fn add_version(&mut self, version: MessageVersion) { - self.fbb_.push_slot::(Message::VT_VERSION, version, MessageVersion::V0); - } - #[inline] - pub fn add_header_type(&mut self, header_type: MessageHeader) { - self.fbb_.push_slot::(Message::VT_HEADER_TYPE, header_type, MessageHeader::NONE); - } - #[inline] - pub fn add_header(&mut self, header: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { - self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Message::VT_HEADER, header); - } - #[inline] - pub fn add_body_size(&mut self, body_size: u64) { - self.fbb_.push_slot::(Message::VT_BODY_SIZE, body_size, 0); - } - #[inline] - pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MessageBuilder<'a, 'b, A> { - let start = _fbb.start_table(); - MessageBuilder { - fbb_: _fbb, - start_: start, - } - } - #[inline] - pub fn finish(self) -> ::flatbuffers::WIPOffset> { - let o = self.fbb_.end_table(self.start_); - ::flatbuffers::WIPOffset::new(o.value()) - } -} - -impl ::core::fmt::Debug for Message<'_> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - let mut ds = f.debug_struct("Message"); - ds.field("version", &self.version()); - ds.field("header_type", &self.header_type()); - match self.header_type() { - MessageHeader::ArrayMessage => { - if let Some(x) = self.header_as_array_message() { - ds.field("header", &x) - } else { - ds.field("header", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - MessageHeader::BufferMessage => { - if let Some(x) = self.header_as_buffer_message() { - ds.field("header", &x) - } else { - ds.field("header", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - MessageHeader::DTypeMessage => { - if let Some(x) = self.header_as_dtype_message() { - ds.field("header", &x) - } else { - ds.field("header", &"InvalidFlatbuffer: Union discriminant does not match value.") - } - }, - _ => { - let x: Option<()> = None; - ds.field("header", &x) - }, - }; - ds.field("body_size", &self.body_size()); - ds.finish() - } -} -#[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, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root::(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, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root::(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, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::root_with_opts::>(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, ::flatbuffers::InvalidFlatbuffer> { - ::flatbuffers::size_prefixed_root_with_opts::>(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<'_> { - unsafe { ::flatbuffers::root_unchecked::(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<'_> { - unsafe { ::flatbuffers::size_prefixed_root_unchecked::(buf) } -} -#[inline] -pub fn finish_message_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( - fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, - root: ::flatbuffers::WIPOffset>) { - fbb.finish(root, None); -} - -#[inline] -pub fn finish_size_prefixed_message_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { - fbb.finish_size_prefixed(root, None); -} diff --git a/vortex-flatbuffers/src/lib.rs b/vortex-flatbuffers/src/lib.rs deleted file mode 100644 index 0ec7e1b7685..00000000000 --- a/vortex-flatbuffers/src/lib.rs +++ /dev/null @@ -1,205 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -//! A contiguously serialized Vortex array. -//! -//! See the `vortex-file` crate for non-contiguous serialization. - -#![deny(missing_docs)] - -#[cfg(feature = "array")] -#[allow(clippy::all)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[allow(clippy::many_single_char_names)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::absolute_paths)] -#[allow(clippy::borrow_as_ptr)] -#[allow(dead_code)] -#[allow(mismatched_lifetime_syntaxes)] -#[allow(non_snake_case)] -#[allow(non_camel_case_types)] -#[allow(unused_imports)] -#[allow(unused_lifetimes)] -#[allow(unused_qualifications)] -#[allow(missing_docs)] -#[rustfmt::skip] -#[path = "./generated/array.rs"] -/// A serialized array without its buffer (i.e. data). -/// -/// `array.fbs`: -/// ```flatbuffers -#[doc = include_str!("../flatbuffers/vortex-array/array.fbs")] -/// ``` -pub mod array; - -#[cfg(feature = "dtype")] -#[allow(clippy::all)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[allow(clippy::many_single_char_names)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::absolute_paths)] -#[allow(clippy::borrow_as_ptr)] -#[allow(dead_code)] -#[allow(mismatched_lifetime_syntaxes)] -#[allow(non_snake_case)] -#[allow(non_camel_case_types)] -#[allow(unused_imports)] -#[allow(unused_lifetimes)] -#[allow(unused_qualifications)] -#[allow(missing_docs)] -#[rustfmt::skip] -#[path = "./generated/dtype.rs"] -/// A serialized data type. -/// -/// `dtype.fbs`: -/// ```flatbuffers -#[doc = include_str!("../flatbuffers/vortex-dtype/dtype.fbs")] -/// ``` -pub mod dtype; - -#[cfg(feature = "file")] -#[allow(clippy::all)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[allow(clippy::many_single_char_names)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::absolute_paths)] -#[allow(clippy::borrow_as_ptr)] -#[allow(dead_code)] -#[allow(mismatched_lifetime_syntaxes)] -#[allow(non_snake_case)] -#[allow(non_camel_case_types)] -#[allow(unused_imports)] -#[allow(unused_lifetimes)] -#[allow(unused_qualifications)] -#[allow(missing_docs)] -#[rustfmt::skip] -#[path = "./generated/footer.rs"] -/// A file format footer containing a serialized `vortex-file` Layout. -/// -/// `footer.fbs`: -/// ```flatbuffers -#[doc = include_str!("../flatbuffers/vortex-file/footer.fbs")] -/// ``` -pub mod footer; - -#[cfg(feature = "layout")] -#[allow(clippy::all)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[allow(clippy::many_single_char_names)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::absolute_paths)] -#[allow(clippy::borrow_as_ptr)] -#[allow(dead_code)] -#[allow(mismatched_lifetime_syntaxes)] -#[allow(non_snake_case)] -#[allow(non_camel_case_types)] -#[allow(unused_imports)] -#[allow(unused_lifetimes)] -#[allow(unused_qualifications)] -#[allow(missing_docs)] -#[rustfmt::skip] -#[path = "./generated/layout.rs"] -/// Structures describing the physical layout of Vortex arrays in random access storage. -/// -/// `layout.fbs`: -/// ```flatbuffers -#[doc = include_str!("../flatbuffers/vortex-layout/layout.fbs")] -/// ``` -pub mod layout; - -#[cfg(feature = "ipc")] -#[allow(clippy::all)] -#[allow(clippy::derive_partial_eq_without_eq)] -#[allow(clippy::many_single_char_names)] -#[allow(clippy::unwrap_used)] -#[allow(clippy::absolute_paths)] -#[allow(clippy::borrow_as_ptr)] -#[allow(dead_code)] -#[allow(mismatched_lifetime_syntaxes)] -#[allow(non_snake_case)] -#[allow(non_camel_case_types)] -#[allow(unused_imports)] -#[allow(unused_lifetimes)] -#[allow(unused_qualifications)] -#[allow(missing_docs)] -#[rustfmt::skip] -#[path = "./generated/message.rs"] -/// A serialized sequence of arrays, each with its buffers. -/// -/// `message.fbs`: -/// ```flatbuffers -#[doc = include_str!("../flatbuffers/vortex-serde/message.fbs")] -/// ``` -pub mod message; - -use flatbuffers::FlatBufferBuilder; -use flatbuffers::Follow; -use flatbuffers::InvalidFlatbuffer; -use flatbuffers::Verifiable; -use flatbuffers::WIPOffset; -use flatbuffers::root; -use vortex_buffer::ByteBuffer; -use vortex_buffer::ConstByteBuffer; -use vortex_error::VortexResult; - -/// We define a const-aligned byte buffer for flatbuffers with 8-byte alignment. -/// -/// This is based on the assumption that the maximum primitive type is 8 bytes. -/// See: -pub type FlatBuffer = ConstByteBuffer<8>; - -/// Marker trait for types that can be the root of a FlatBuffer. -pub trait FlatBufferRoot {} - -/// Trait for reading a type from a FlatBuffer. -pub trait ReadFlatBuffer: Sized { - /// The FlatBuffer type that this type can be read from. - type Source<'a>: Verifiable + Follow<'a>; - /// The error type returned when reading fails. - type Error: From; - - /// Reads this type from a FlatBuffer source. - fn read_flatbuffer<'buf>( - fb: & as Follow<'buf>>::Inner, - ) -> Result; - - /// Reads this type from bytes representing a FlatBuffer source. - fn read_flatbuffer_bytes<'buf>(bytes: &'buf [u8]) -> Result - where - ::Source<'buf>: 'buf, - { - let fb = root::>(bytes)?; - Self::read_flatbuffer(&fb) - } -} - -/// Trait for writing a type to a FlatBuffer. -pub trait WriteFlatBuffer { - /// The FlatBuffer type that this type can be written to. - type Target<'a>; - - /// Writes this type to a FlatBuffer builder. - fn write_flatbuffer<'fb>( - &self, - fbb: &mut FlatBufferBuilder<'fb>, - ) -> VortexResult>>; -} - -/// Extension trait for types that can be written as FlatBuffer root objects. -pub trait WriteFlatBufferExt: WriteFlatBuffer + FlatBufferRoot { - /// Writes self as a FlatBuffer root object into a [`FlatBuffer`] byte buffer. - fn write_flatbuffer_bytes(&self) -> VortexResult; -} - -impl WriteFlatBufferExt for F { - fn write_flatbuffer_bytes(&self) -> VortexResult { - let mut fbb = FlatBufferBuilder::new(); - let root_offset = self.write_flatbuffer(&mut fbb)?; - fbb.finish_minimal(root_offset); - let (vec, start) = fbb.collapse(); - let end = vec.len(); - Ok(FlatBuffer::align_from( - ByteBuffer::from(vec).slice(start..end), - )) - } -} diff --git a/vortex-ipc/Cargo.toml b/vortex-ipc/Cargo.toml index eda6b7bc852..c8e32150e5f 100644 --- a/vortex-ipc/Cargo.toml +++ b/vortex-ipc/Cargo.toml @@ -22,9 +22,11 @@ pin-project-lite = { workspace = true } vortex-array = { workspace = true } vortex-buffer = { workspace = true } vortex-error = { workspace = true } -vortex-flatbuffers = { workspace = true, features = ["ipc"] } vortex-session = { workspace = true } +[build-dependencies] +vortex-build = { workspace = true } + [dev-dependencies] tokio = { workspace = true, features = ["full"] } vortex-array = { workspace = true, features = ["_test-harness"] } diff --git a/vortex-ipc/build.rs b/vortex-ipc/build.rs new file mode 100644 index 00000000000..4f3d2dd338d --- /dev/null +++ b/vortex-ipc/build.rs @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +fn main() { + vortex_build::flatbuffers() + .depends_on("vortex-array") + .compile(&["vortex-serde/message.fbs"]); +} diff --git a/vortex-flatbuffers/flatbuffers/vortex-serde/message.fbs b/vortex-ipc/flatbuffers/vortex-serde/message.fbs similarity index 100% rename from vortex-flatbuffers/flatbuffers/vortex-serde/message.fbs rename to vortex-ipc/flatbuffers/vortex-serde/message.fbs diff --git a/vortex-ipc/src/flatbuffers.rs b/vortex-ipc/src/flatbuffers.rs new file mode 100644 index 00000000000..cb997715191 --- /dev/null +++ b/vortex-ipc/src/flatbuffers.rs @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Bindings generated from this crate's `flatbuffers` schema. + +/// Where `flatc` resolves the `crate::flatbuffers::deps::*` paths it emits for `message.fbs`'s includes. +mod deps { + pub use vortex_array::flatbuffers::array; + pub use vortex_array::flatbuffers::dtype; +} + +/// A serialized sequence of arrays, each with its buffers. +/// +/// `message.fbs`: +/// ```flatbuffers +#[doc = include_str!("../flatbuffers/vortex-serde/message.fbs")] +/// ``` +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::borrow_as_ptr)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(clippy::many_single_char_names)] +#[allow(clippy::unwrap_used)] +#[allow(dead_code)] +#[allow(mismatched_lifetime_syntaxes)] +#[allow(missing_docs)] +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[allow(unsafe_op_in_unsafe_fn)] +#[allow(unused_imports)] +#[allow(unused_lifetimes)] +#[allow(unused_qualifications)] +pub mod message { + include!(concat!(env!("OUT_DIR"), "/flatbuffers/message.rs")); +} diff --git a/vortex-ipc/src/lib.rs b/vortex-ipc/src/lib.rs index acaef14532a..a7a9c2ad6e0 100644 --- a/vortex-ipc/src/lib.rs +++ b/vortex-ipc/src/lib.rs @@ -11,6 +11,7 @@ //! before/after serialization, and streaming readers and writers that sit on top //! of any type implementing `VortexRead` or `VortexWrite` respectively. +pub mod flatbuffers; pub mod iterator; pub mod messages; pub mod stream; diff --git a/vortex-ipc/src/messages/decoder.rs b/vortex-ipc/src/messages/decoder.rs index 3992e0968b8..fda99c7d1d0 100644 --- a/vortex-ipc/src/messages/decoder.rs +++ b/vortex-ipc/src/messages/decoder.rs @@ -8,6 +8,7 @@ use bytes::Buf; use flatbuffers::root; use flatbuffers::root_unchecked; use vortex_array::ArrayId; +use vortex_array::flatbuffers::FlatBuffer; use vortex_array::serde::SerializedArray; use vortex_buffer::AlignedBuf; use vortex_buffer::Alignment; @@ -16,12 +17,12 @@ use vortex_error::VortexExpect; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::message as fb; -use vortex_flatbuffers::message::MessageHeader; -use vortex_flatbuffers::message::MessageVersion; use vortex_session::registry::ReadContext; +use crate::flatbuffers::message as fb; +use crate::flatbuffers::message::MessageHeader; +use crate::flatbuffers::message::MessageVersion; + /// A message decoded from an IPC stream. #[derive(Debug)] pub enum DecoderMessage { diff --git a/vortex-ipc/src/messages/encoder.rs b/vortex-ipc/src/messages/encoder.rs index 4b2a0b7007e..4b056052b3a 100644 --- a/vortex-ipc/src/messages/encoder.rs +++ b/vortex-ipc/src/messages/encoder.rs @@ -7,15 +7,16 @@ use flatbuffers::FlatBufferBuilder; use vortex_array::ArrayContext; use vortex_array::ArrayRef; use vortex_array::dtype::DType; +use vortex_array::flatbuffers::FlatBuffer; +use vortex_array::flatbuffers::WriteFlatBufferExt; use vortex_array::serde::SerializeOptions; use vortex_buffer::ByteBuffer; use vortex_error::VortexResult; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::WriteFlatBufferExt; -use vortex_flatbuffers::message as fb; use vortex_session::VortexSession; +use crate::flatbuffers::message as fb; + /// An IPC message ready to be passed to the encoder. pub enum EncoderMessage<'a> { Array(&'a ArrayRef), diff --git a/vortex-json/Cargo.toml b/vortex-json/Cargo.toml index 0b9061f61ab..c8f1d075b5a 100644 --- a/vortex-json/Cargo.toml +++ b/vortex-json/Cargo.toml @@ -24,7 +24,6 @@ vortex-array = { workspace = true, default-features = false } vortex-arrow = { workspace = true } vortex-edition = { workspace = true } vortex-error = { workspace = true, default-features = false } -vortex-proto = { workspace = true, features = ["expr"] } vortex-session = { workspace = true } [dev-dependencies] diff --git a/vortex-json/src/json_to_variant.rs b/vortex-json/src/json_to_variant.rs index 68067ee6e46..32d0f3eda4e 100644 --- a/vortex-json/src/json_to_variant.rs +++ b/vortex-json/src/json_to_variant.rs @@ -16,6 +16,7 @@ use vortex_array::arrays::ExtensionArray; use vortex_array::arrays::ScalarFnArray; use vortex_array::dtype::DType; use vortex_array::expr::Expression; +use vortex_array::proto::expr as pb; use vortex_array::scalar_fn::Arity; use vortex_array::scalar_fn::ChildName; use vortex_array::scalar_fn::ExecutionArgs; @@ -28,7 +29,6 @@ use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_ensure; use vortex_error::vortex_err; -use vortex_proto::expr as pb; use vortex_session::VortexSession; use vortex_session::registry::CachedId; diff --git a/vortex-layout/Cargo.toml b/vortex-layout/Cargo.toml index 99d8c605941..87ce67dea4b 100644 --- a/vortex-layout/Cargo.toml +++ b/vortex-layout/Cargo.toml @@ -11,6 +11,9 @@ license = { workspace = true } readme = { workspace = true } repository = { workspace = true } rust-version = { workspace = true } + +# Exports the `flatbuffers` schema directory to dependent build scripts. +links = "vortex-layout" version = { workspace = true } [package.metadata.docs.rs] @@ -44,7 +47,6 @@ vortex-arrow = { workspace = true } vortex-btrblocks = { workspace = true } vortex-buffer = { workspace = true } vortex-error = { workspace = true } -vortex-flatbuffers = { workspace = true, features = ["layout"] } vortex-io = { workspace = true } vortex-mask = { workspace = true } vortex-metrics = { workspace = true } @@ -54,6 +56,9 @@ vortex-sequence = { workspace = true } vortex-session = { workspace = true } vortex-utils = { workspace = true, features = ["dashmap"] } +[build-dependencies] +vortex-build = { workspace = true } + [dev-dependencies] divan = { workspace = true } futures = { workspace = true, features = ["executor"] } diff --git a/vortex-layout/build.rs b/vortex-layout/build.rs new file mode 100644 index 00000000000..625b0bb97a7 --- /dev/null +++ b/vortex-layout/build.rs @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +fn main() { + vortex_build::flatbuffers().compile(&["vortex-layout/layout.fbs"]); +} diff --git a/vortex-flatbuffers/flatbuffers/vortex-layout/layout.fbs b/vortex-layout/flatbuffers/vortex-layout/layout.fbs similarity index 100% rename from vortex-flatbuffers/flatbuffers/vortex-layout/layout.fbs rename to vortex-layout/flatbuffers/vortex-layout/layout.fbs diff --git a/vortex-layout/src/children.rs b/vortex-layout/src/children.rs index 274ef124a60..a1a582f72c2 100644 --- a/vortex-layout/src/children.rs +++ b/vortex-layout/src/children.rs @@ -9,16 +9,16 @@ use flatbuffers::Follow; use itertools::Itertools; use once_cell::sync::OnceCell; use vortex_array::dtype::DType; +use vortex_array::flatbuffers::FlatBuffer; use vortex_error::VortexResult; use vortex_error::vortex_bail; use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::layout as fbl; use vortex_session::VortexSession; use vortex_session::registry::ReadContext; use crate::LayoutBuildContext; use crate::LayoutRef; +use crate::flatbuffers::layout as fbl; use crate::layouts::foreign::new_foreign_layout; use crate::segments::SegmentId; use crate::session::LayoutRegistry; diff --git a/vortex-layout/src/flatbuffers.rs b/vortex-layout/src/flatbuffers.rs index a807db578af..14a1acf6f5d 100644 --- a/vortex-layout/src/flatbuffers.rs +++ b/vortex-layout/src/flatbuffers.rs @@ -1,304 +1,29 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -use std::env; -use std::sync::LazyLock; - -use flatbuffers::FlatBufferBuilder; -use flatbuffers::VerifierOptions; -use flatbuffers::WIPOffset; -use flatbuffers::root_with_opts; -use vortex_array::dtype::DType; -use vortex_error::VortexResult; -use vortex_error::vortex_err; -use vortex_flatbuffers::FlatBuffer; -use vortex_flatbuffers::FlatBufferRoot; -use vortex_flatbuffers::WriteFlatBuffer; -use vortex_flatbuffers::layout; -use vortex_session::VortexSession; -use vortex_session::registry::ReadContext; - -use crate::DynLayout; -use crate::LayoutBuildContext; -use crate::LayoutContext; -use crate::LayoutRef; -use crate::children::ViewedLayoutChildren; -use crate::layouts::foreign::new_foreign_layout; -use crate::segments::SegmentId; -use crate::session::LayoutSessionExt; - -static LAYOUT_VERIFIER: LazyLock = LazyLock::new(|| { - VerifierOptions { - // Overridden - max_tables: env::var("VORTEX_MAX_LAYOUT_TABLES") - .ok() - .and_then(|lmt| lmt.parse::().ok()) - .unwrap_or(1000000), - max_depth: env::var("VORTEX_MAX_LAYOUT_DEPTH") - .ok() - .and_then(|lmt| lmt.parse::().ok()) - .unwrap_or(64), - // Defaults from flatbuffers - max_apparent_size: 1 << 31, - ignore_missing_null_terminator: false, - } -}); - -/// Parse a [`LayoutRef`] from a layout flatbuffer. -pub fn layout_from_flatbuffer( - flatbuffer: FlatBuffer, - dtype: &DType, - layout_ctx: &ReadContext, - ctx: &ReadContext, - session: &VortexSession, -) -> VortexResult { - layout_from_flatbuffer_with_options(flatbuffer, dtype, layout_ctx, ctx, session, false) -} - -/// Parse a [`LayoutRef`] from a layout flatbuffer with unknown-encoding behavior control. -pub fn layout_from_flatbuffer_with_options( - flatbuffer: FlatBuffer, - dtype: &DType, - layout_ctx: &ReadContext, - ctx: &ReadContext, - session: &VortexSession, - allow_unknown: bool, -) -> VortexResult { - let layout_session = session.layouts(); - let layouts = layout_session.registry(); - let fb_layout = root_with_opts::(&LAYOUT_VERIFIER, &flatbuffer)?; - let encoding_id = layout_ctx - .resolve(fb_layout.encoding()) - .ok_or_else(|| vortex_err!("Invalid encoding ID: {}", fb_layout.encoding()))?; - let encoding = layouts.get(&encoding_id); - - if encoding.is_none() && allow_unknown { - return foreign_layout_from_fb(fb_layout, dtype, layout_ctx); - } - let encoding = - encoding.ok_or_else(|| vortex_err!("Invalid encoding ID: {}", fb_layout.encoding()))?; - - // SAFETY: we validate the flatbuffer above in the `root` call, and extract a loc. - let viewed_children = unsafe { - ViewedLayoutChildren::new_unchecked( - flatbuffer.clone(), - fb_layout._tab.loc(), - ctx.clone(), - layout_ctx.clone(), - layouts.clone(), - allow_unknown, - session.clone(), - ) - }; - - let build_ctx = LayoutBuildContext { - session, - array_read_ctx: ctx, - }; - let layout = encoding.build( - dtype, - fb_layout.row_count(), - fb_layout - .metadata() - .map(|m| m.bytes()) - .unwrap_or_else(|| &[]), - fb_layout - .segments() - .unwrap_or_default() - .iter() - .map(SegmentId::from) - .collect(), - &viewed_children, - &build_ctx, - )?; - - Ok(layout) -} - -fn foreign_layout_from_fb( - fb_layout: layout::Layout<'_>, - dtype: &DType, - layout_ctx: &ReadContext, -) -> VortexResult { - let encoding_id = layout_ctx - .resolve(fb_layout.encoding()) - .ok_or_else(|| vortex_err!("Invalid encoding ID: {}", fb_layout.encoding()))?; - - let children = fb_layout - .children() - .unwrap_or_default() - .iter() - .map(|child| foreign_layout_from_fb(child, dtype, layout_ctx)) - .collect::>>()?; - - Ok(new_foreign_layout( - encoding_id, - dtype.clone(), - fb_layout.row_count(), - fb_layout - .metadata() - .map(|m| m.bytes().to_vec()) - .unwrap_or_default(), - fb_layout - .segments() - .unwrap_or_default() - .iter() - .map(SegmentId::from) - .collect(), - children, - )) -} - -impl dyn DynLayout + '_ { - /// Serialize the layout into a [`FlatBufferBuilder`]. - pub fn flatbuffer_writer<'a>( - &'a self, - ctx: &'a LayoutContext, - ) -> impl WriteFlatBuffer = layout::Layout<'a>> + FlatBufferRoot + 'a { - LayoutFlatBufferWriter { layout: self, ctx } - } -} - -/// An adapter struct for writing a layout to a FlatBuffer. -struct LayoutFlatBufferWriter<'a> { - layout: &'a dyn DynLayout, - ctx: &'a LayoutContext, -} - -impl FlatBufferRoot for LayoutFlatBufferWriter<'_> {} - -impl WriteFlatBuffer for LayoutFlatBufferWriter<'_> { - type Target<'fb> = layout::Layout<'fb>; - - fn write_flatbuffer<'fb>( - &self, - fbb: &mut FlatBufferBuilder<'fb>, - ) -> VortexResult>> { - // First we recurse into the children and write them out - let child_layouts = self.layout.children()?; - let children = child_layouts - .iter() - .map(|layout| { - LayoutFlatBufferWriter { - layout: layout.as_ref(), - ctx: self.ctx, - } - .write_flatbuffer(fbb) - }) - .collect::>>()?; - let children = (!children.is_empty()).then(|| fbb.create_vector(&children)); - - // Next we write out the metadata if it's non-empty. - let metadata = self.layout.metadata(); - let metadata = (!metadata.is_empty()).then(|| fbb.create_vector(&metadata)); - - let segments = self - .layout - .segment_ids() - .into_iter() - .map(|s| *s) - .collect::>(); - let segments = (!segments.is_empty()).then(|| fbb.create_vector(&segments)); - - // Dictionary-encode the layout ID - let encoding = self.ctx.intern(&self.layout.encoding_id()).ok_or_else(|| { - vortex_err!( - "Layout encoding {} not permitted by ctx", - self.layout.encoding_id() - ) - })?; - - Ok(layout::Layout::create( - fbb, - &layout::LayoutArgs { - encoding, - row_count: self.layout.row_count(), - metadata, - children, - segments, - }, - )) - } -} - -#[cfg(test)] -mod tests { - use flatbuffers::FlatBufferBuilder; - use vortex_array::array_session; - use vortex_array::dtype::DType; - use vortex_array::dtype::Nullability; - use vortex_flatbuffers::layout as fbl; - use vortex_session::registry::ReadContext; - - use super::layout_from_flatbuffer_with_options; - use crate::LayoutEncodingId; - use crate::session::LayoutSession; - - #[expect(clippy::disallowed_methods, reason = "test-only id")] - #[test] - fn unknown_layout_encoding_allow_unknown() { - let mut fbb = FlatBufferBuilder::new(); - - let child_metadata = fbb.create_vector(&[9u8]); - let child = fbl::Layout::create( - &mut fbb, - &fbl::LayoutArgs { - encoding: 1, - row_count: 3, - metadata: Some(child_metadata), - children: None, - segments: None, - }, - ); - - let children = fbb.create_vector(&[child]); - let metadata = fbb.create_vector(&[1u8, 2, 3]); - let segments = fbb.create_vector(&[7u32]); - let root = fbl::Layout::create( - &mut fbb, - &fbl::LayoutArgs { - encoding: 0, - row_count: 10, - metadata: Some(metadata), - children: Some(children), - segments: Some(segments), - }, - ); - fbb.finish_minimal(root); - let (buf, start) = fbb.collapse(); - let layout_buffer = vortex_flatbuffers::FlatBuffer::align_from( - vortex_buffer::ByteBuffer::from(buf).slice(start..), - ); - - let layout_ctx = ReadContext::new([ - LayoutEncodingId::new("vortex.test.foreign_layout"), - LayoutEncodingId::new("vortex.test.foreign_child_layout"), - ]); - let array_ctx = ReadContext::new([]); - let session = array_session().with::(); - - let layout = layout_from_flatbuffer_with_options( - layout_buffer, - &DType::Variant(Nullability::Nullable), - &layout_ctx, - &array_ctx, - &session, - true, - ) - .unwrap(); - - assert_eq!(layout.encoding_id().as_ref(), "vortex.test.foreign_layout"); - assert_eq!(layout.row_count(), 10); - assert_eq!(layout.metadata(), vec![1, 2, 3]); - assert_eq!(layout.segment_ids().len(), 1); - assert_eq!(*layout.segment_ids()[0], 7); - assert_eq!(layout.nchildren(), 1); - - let child = layout.slot(0).unwrap().unwrap(); - assert_eq!( - child.encoding_id().as_ref(), - "vortex.test.foreign_child_layout" - ); - assert_eq!(child.metadata(), vec![9]); - } +//! Bindings generated from this crate's `flatbuffers` schema. + +/// Structures describing the physical layout of Vortex arrays in random access storage. +/// +/// `layout.fbs`: +/// ```flatbuffers +#[doc = include_str!("../flatbuffers/vortex-layout/layout.fbs")] +/// ``` +#[allow(clippy::all)] +#[allow(clippy::absolute_paths)] +#[allow(clippy::borrow_as_ptr)] +#[allow(clippy::derive_partial_eq_without_eq)] +#[allow(clippy::many_single_char_names)] +#[allow(clippy::unwrap_used)] +#[allow(dead_code)] +#[allow(mismatched_lifetime_syntaxes)] +#[allow(missing_docs)] +#[allow(non_camel_case_types)] +#[allow(non_snake_case)] +#[allow(unsafe_op_in_unsafe_fn)] +#[allow(unused_imports)] +#[allow(unused_lifetimes)] +#[allow(unused_qualifications)] +pub mod layout { + include!(concat!(env!("OUT_DIR"), "/flatbuffers/layout.rs")); } diff --git a/vortex-layout/src/lib.rs b/vortex-layout/src/lib.rs index 0dd7527ba28..4a2ac636391 100644 --- a/vortex-layout/src/lib.rs +++ b/vortex-layout/src/lib.rs @@ -19,10 +19,10 @@ pub mod plan; pub use children::*; pub use encoding::*; -pub use flatbuffers::*; pub use layout::*; pub use reader::*; pub use reader_context::*; +pub use serde::*; pub use strategy::*; use vortex_session::registry::Interner; pub use vtable::*; @@ -30,13 +30,14 @@ pub mod aliases; mod children; pub mod display; mod encoding; -mod flatbuffers; +pub mod flatbuffers; mod layout; mod reader; mod reader_context; pub mod scan; pub mod segments; pub mod sequence; +mod serde; pub mod session; mod strategy; #[cfg(test)] diff --git a/vortex-layout/src/serde.rs b/vortex-layout/src/serde.rs new file mode 100644 index 00000000000..0995a7535cd --- /dev/null +++ b/vortex-layout/src/serde.rs @@ -0,0 +1,304 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use std::env; +use std::sync::LazyLock; + +use flatbuffers::FlatBufferBuilder; +use flatbuffers::VerifierOptions; +use flatbuffers::WIPOffset; +use flatbuffers::root_with_opts; +use vortex_array::dtype::DType; +use vortex_array::flatbuffers::FlatBuffer; +use vortex_array::flatbuffers::FlatBufferRoot; +use vortex_array::flatbuffers::WriteFlatBuffer; +use vortex_error::VortexResult; +use vortex_error::vortex_err; +use vortex_session::VortexSession; +use vortex_session::registry::ReadContext; + +use crate::DynLayout; +use crate::LayoutBuildContext; +use crate::LayoutContext; +use crate::LayoutRef; +use crate::children::ViewedLayoutChildren; +use crate::flatbuffers::layout; +use crate::layouts::foreign::new_foreign_layout; +use crate::segments::SegmentId; +use crate::session::LayoutSessionExt; + +static LAYOUT_VERIFIER: LazyLock = LazyLock::new(|| { + VerifierOptions { + // Overridden + max_tables: env::var("VORTEX_MAX_LAYOUT_TABLES") + .ok() + .and_then(|lmt| lmt.parse::().ok()) + .unwrap_or(1000000), + max_depth: env::var("VORTEX_MAX_LAYOUT_DEPTH") + .ok() + .and_then(|lmt| lmt.parse::().ok()) + .unwrap_or(64), + // Defaults from flatbuffers + max_apparent_size: 1 << 31, + ignore_missing_null_terminator: false, + } +}); + +/// Parse a [`LayoutRef`] from a layout flatbuffer. +pub fn layout_from_flatbuffer( + flatbuffer: FlatBuffer, + dtype: &DType, + layout_ctx: &ReadContext, + ctx: &ReadContext, + session: &VortexSession, +) -> VortexResult { + layout_from_flatbuffer_with_options(flatbuffer, dtype, layout_ctx, ctx, session, false) +} + +/// Parse a [`LayoutRef`] from a layout flatbuffer with unknown-encoding behavior control. +pub fn layout_from_flatbuffer_with_options( + flatbuffer: FlatBuffer, + dtype: &DType, + layout_ctx: &ReadContext, + ctx: &ReadContext, + session: &VortexSession, + allow_unknown: bool, +) -> VortexResult { + let layout_session = session.layouts(); + let layouts = layout_session.registry(); + let fb_layout = root_with_opts::(&LAYOUT_VERIFIER, &flatbuffer)?; + let encoding_id = layout_ctx + .resolve(fb_layout.encoding()) + .ok_or_else(|| vortex_err!("Invalid encoding ID: {}", fb_layout.encoding()))?; + let encoding = layouts.get(&encoding_id); + + if encoding.is_none() && allow_unknown { + return foreign_layout_from_fb(fb_layout, dtype, layout_ctx); + } + let encoding = + encoding.ok_or_else(|| vortex_err!("Invalid encoding ID: {}", fb_layout.encoding()))?; + + // SAFETY: we validate the flatbuffer above in the `root` call, and extract a loc. + let viewed_children = unsafe { + ViewedLayoutChildren::new_unchecked( + flatbuffer.clone(), + fb_layout._tab.loc(), + ctx.clone(), + layout_ctx.clone(), + layouts.clone(), + allow_unknown, + session.clone(), + ) + }; + + let build_ctx = LayoutBuildContext { + session, + array_read_ctx: ctx, + }; + let layout = encoding.build( + dtype, + fb_layout.row_count(), + fb_layout + .metadata() + .map(|m| m.bytes()) + .unwrap_or_else(|| &[]), + fb_layout + .segments() + .unwrap_or_default() + .iter() + .map(SegmentId::from) + .collect(), + &viewed_children, + &build_ctx, + )?; + + Ok(layout) +} + +fn foreign_layout_from_fb( + fb_layout: layout::Layout<'_>, + dtype: &DType, + layout_ctx: &ReadContext, +) -> VortexResult { + let encoding_id = layout_ctx + .resolve(fb_layout.encoding()) + .ok_or_else(|| vortex_err!("Invalid encoding ID: {}", fb_layout.encoding()))?; + + let children = fb_layout + .children() + .unwrap_or_default() + .iter() + .map(|child| foreign_layout_from_fb(child, dtype, layout_ctx)) + .collect::>>()?; + + Ok(new_foreign_layout( + encoding_id, + dtype.clone(), + fb_layout.row_count(), + fb_layout + .metadata() + .map(|m| m.bytes().to_vec()) + .unwrap_or_default(), + fb_layout + .segments() + .unwrap_or_default() + .iter() + .map(SegmentId::from) + .collect(), + children, + )) +} + +impl dyn DynLayout + '_ { + /// Serialize the layout into a [`FlatBufferBuilder`]. + pub fn flatbuffer_writer<'a>( + &'a self, + ctx: &'a LayoutContext, + ) -> impl WriteFlatBuffer = layout::Layout<'a>> + FlatBufferRoot + 'a { + LayoutFlatBufferWriter { layout: self, ctx } + } +} + +/// An adapter struct for writing a layout to a FlatBuffer. +struct LayoutFlatBufferWriter<'a> { + layout: &'a dyn DynLayout, + ctx: &'a LayoutContext, +} + +impl FlatBufferRoot for LayoutFlatBufferWriter<'_> {} + +impl WriteFlatBuffer for LayoutFlatBufferWriter<'_> { + type Target<'fb> = layout::Layout<'fb>; + + fn write_flatbuffer<'fb>( + &self, + fbb: &mut FlatBufferBuilder<'fb>, + ) -> VortexResult>> { + // First we recurse into the children and write them out + let child_layouts = self.layout.children()?; + let children = child_layouts + .iter() + .map(|layout| { + LayoutFlatBufferWriter { + layout: layout.as_ref(), + ctx: self.ctx, + } + .write_flatbuffer(fbb) + }) + .collect::>>()?; + let children = (!children.is_empty()).then(|| fbb.create_vector(&children)); + + // Next we write out the metadata if it's non-empty. + let metadata = self.layout.metadata(); + let metadata = (!metadata.is_empty()).then(|| fbb.create_vector(&metadata)); + + let segments = self + .layout + .segment_ids() + .into_iter() + .map(|s| *s) + .collect::>(); + let segments = (!segments.is_empty()).then(|| fbb.create_vector(&segments)); + + // Dictionary-encode the layout ID + let encoding = self.ctx.intern(&self.layout.encoding_id()).ok_or_else(|| { + vortex_err!( + "Layout encoding {} not permitted by ctx", + self.layout.encoding_id() + ) + })?; + + Ok(layout::Layout::create( + fbb, + &layout::LayoutArgs { + encoding, + row_count: self.layout.row_count(), + metadata, + children, + segments, + }, + )) + } +} + +#[cfg(test)] +mod tests { + use flatbuffers::FlatBufferBuilder; + use vortex_array::array_session; + use vortex_array::dtype::DType; + use vortex_array::dtype::Nullability; + use vortex_session::registry::ReadContext; + + use super::layout_from_flatbuffer_with_options; + use crate::LayoutEncodingId; + use crate::flatbuffers::layout as fbl; + use crate::session::LayoutSession; + + #[expect(clippy::disallowed_methods, reason = "test-only id")] + #[test] + fn unknown_layout_encoding_allow_unknown() { + let mut fbb = FlatBufferBuilder::new(); + + let child_metadata = fbb.create_vector(&[9u8]); + let child = fbl::Layout::create( + &mut fbb, + &fbl::LayoutArgs { + encoding: 1, + row_count: 3, + metadata: Some(child_metadata), + children: None, + segments: None, + }, + ); + + let children = fbb.create_vector(&[child]); + let metadata = fbb.create_vector(&[1u8, 2, 3]); + let segments = fbb.create_vector(&[7u32]); + let root = fbl::Layout::create( + &mut fbb, + &fbl::LayoutArgs { + encoding: 0, + row_count: 10, + metadata: Some(metadata), + children: Some(children), + segments: Some(segments), + }, + ); + fbb.finish_minimal(root); + let (buf, start) = fbb.collapse(); + let layout_buffer = vortex_array::flatbuffers::FlatBuffer::align_from( + vortex_buffer::ByteBuffer::from(buf).slice(start..), + ); + + let layout_ctx = ReadContext::new([ + LayoutEncodingId::new("vortex.test.foreign_layout"), + LayoutEncodingId::new("vortex.test.foreign_child_layout"), + ]); + let array_ctx = ReadContext::new([]); + let session = array_session().with::(); + + let layout = layout_from_flatbuffer_with_options( + layout_buffer, + &DType::Variant(Nullability::Nullable), + &layout_ctx, + &array_ctx, + &session, + true, + ) + .unwrap(); + + assert_eq!(layout.encoding_id().as_ref(), "vortex.test.foreign_layout"); + assert_eq!(layout.row_count(), 10); + assert_eq!(layout.metadata(), vec![1, 2, 3]); + assert_eq!(layout.segment_ids().len(), 1); + assert_eq!(*layout.segment_ids()[0], 7); + assert_eq!(layout.nchildren(), 1); + + let child = layout.slot(0).unwrap().unwrap(); + assert_eq!( + child.encoding_id().as_ref(), + "vortex.test.foreign_child_layout" + ); + assert_eq!(child.metadata(), vec![9]); + } +} diff --git a/vortex-proto/Cargo.toml b/vortex-proto/Cargo.toml deleted file mode 100644 index ba0202c2ea0..00000000000 --- a/vortex-proto/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# SPDX-FileCopyrightText: Copyright the Vortex contributors - -[package] -name = "vortex-proto" -authors = { workspace = true } -categories = { workspace = true } -description = "Protocol buffer definitions for Vortex types" -edition = { workspace = true } -homepage = { workspace = true } -include = { workspace = true } -keywords = { workspace = true } -license = { workspace = true } -readme = "README.md" -repository = { workspace = true } -rust-version = { workspace = true } -version = { workspace = true } - -[package.metadata.docs.rs] -all-features = true - -[package.metadata.cargo-shear] -ignored = ["prost-types"] - -[dependencies] -prost = { workspace = true } -prost-types = { workspace = true } - -[features] -default = ["expr"] -dtype = [] -expr = ["dtype", "scalar"] -scalar = ["dtype"] - -[lints] -workspace = true diff --git a/vortex-proto/README.md b/vortex-proto/README.md deleted file mode 100644 index 8471d4fae21..00000000000 --- a/vortex-proto/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# vortex-proto - -This crate contains Protocol Buffers definitions that can be used to convert other crates in this workspace back -and forth into protobuf messages. - -## Regenerating the bindings - -Run the `cargo xtask generate-proto` script. diff --git a/vortex-proto/src/generated/REUSE.toml b/vortex-proto/src/generated/REUSE.toml deleted file mode 100644 index 42719440df8..00000000000 --- a/vortex-proto/src/generated/REUSE.toml +++ /dev/null @@ -1,6 +0,0 @@ -version = 1 - -[[annotations]] -path = "*.rs" -SPDX-FileCopyrightText = "Copyright the Vortex contributors" -SPDX-License-Identifier = "Apache-2.0" diff --git a/vortex-proto/src/generated/vortex.dtype.rs b/vortex-proto/src/generated/vortex.dtype.rs deleted file mode 100644 index 37ffec0a426..00000000000 --- a/vortex-proto/src/generated/vortex.dtype.rs +++ /dev/null @@ -1,208 +0,0 @@ -// This file is @generated by prost-build. -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Null {} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Bool { - #[prost(bool, tag = "1")] - pub nullable: bool, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Primitive { - #[prost(enumeration = "PType", tag = "1")] - pub r#type: i32, - #[prost(bool, tag = "2")] - pub nullable: bool, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Decimal { - #[prost(uint32, tag = "1")] - pub precision: u32, - #[prost(int32, tag = "2")] - pub scale: i32, - #[prost(bool, tag = "3")] - pub nullable: bool, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Utf8 { - #[prost(bool, tag = "1")] - pub nullable: bool, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Binary { - #[prost(bool, tag = "1")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Struct { - #[prost(string, repeated, tag = "1")] - pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub dtypes: ::prost::alloc::vec::Vec, - #[prost(bool, tag = "3")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct List { - #[prost(message, optional, boxed, tag = "1")] - pub element_type: ::core::option::Option<::prost::alloc::boxed::Box>, - #[prost(bool, tag = "2")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FixedSizeList { - #[prost(message, optional, boxed, tag = "1")] - pub element_type: ::core::option::Option<::prost::alloc::boxed::Box>, - #[prost(uint32, tag = "2")] - pub size: u32, - #[prost(bool, tag = "3")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Extension { - #[prost(string, tag = "1")] - pub id: ::prost::alloc::string::String, - #[prost(message, optional, boxed, tag = "2")] - pub storage_dtype: ::core::option::Option<::prost::alloc::boxed::Box>, - #[prost(bytes = "vec", optional, tag = "3")] - pub metadata: ::core::option::Option<::prost::alloc::vec::Vec>, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Variant { - #[prost(bool, tag = "1")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Union { - #[prost(string, repeated, tag = "1")] - pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "2")] - pub dtypes: ::prost::alloc::vec::Vec, - /// length must equal dtypes.len(); each value must fit in uint8 - #[prost(int32, repeated, tag = "3")] - pub type_ids: ::prost::alloc::vec::Vec, - #[prost(bool, tag = "4")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Map { - #[prost(message, optional, boxed, tag = "1")] - pub key_type: ::core::option::Option<::prost::alloc::boxed::Box>, - #[prost(message, optional, boxed, tag = "2")] - pub value_type: ::core::option::Option<::prost::alloc::boxed::Box>, - #[prost(bool, tag = "3")] - pub keys_sorted: bool, - #[prost(bool, tag = "4")] - pub nullable: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct DType { - #[prost( - oneof = "d_type::DtypeType", - tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13" - )] - pub dtype_type: ::core::option::Option, -} -/// Nested message and enum types in `DType`. -pub mod d_type { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum DtypeType { - #[prost(message, tag = "1")] - Null(super::Null), - #[prost(message, tag = "2")] - Bool(super::Bool), - #[prost(message, tag = "3")] - Primitive(super::Primitive), - #[prost(message, tag = "4")] - Decimal(super::Decimal), - #[prost(message, tag = "5")] - Utf8(super::Utf8), - #[prost(message, tag = "6")] - Binary(super::Binary), - #[prost(message, tag = "7")] - Struct(super::Struct), - #[prost(message, tag = "8")] - List(::prost::alloc::boxed::Box), - #[prost(message, tag = "9")] - Extension(::prost::alloc::boxed::Box), - /// This is after `Extension` for backwards compatibility. - #[prost(message, tag = "10")] - FixedSizeList(::prost::alloc::boxed::Box), - #[prost(message, tag = "11")] - Variant(super::Variant), - #[prost(message, tag = "12")] - Union(super::Union), - #[prost(message, tag = "13")] - Map(::prost::alloc::boxed::Box), - } -} -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct Field { - #[prost(oneof = "field::FieldType", tags = "1")] - pub field_type: ::core::option::Option, -} -/// Nested message and enum types in `Field`. -pub mod field { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum FieldType { - #[prost(string, tag = "1")] - Name(::prost::alloc::string::String), - } -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct FieldPath { - #[prost(message, repeated, tag = "1")] - pub path: ::prost::alloc::vec::Vec, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum PType { - U8 = 0, - U16 = 1, - U32 = 2, - U64 = 3, - I8 = 4, - I16 = 5, - I32 = 6, - I64 = 7, - F16 = 8, - F32 = 9, - F64 = 10, -} -impl PType { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::U8 => "U8", - Self::U16 => "U16", - Self::U32 => "U32", - Self::U64 => "U64", - Self::I8 => "I8", - Self::I16 => "I16", - Self::I32 => "I32", - Self::I64 => "I64", - Self::F16 => "F16", - Self::F32 => "F32", - Self::F64 => "F64", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "U8" => Some(Self::U8), - "U16" => Some(Self::U16), - "U32" => Some(Self::U32), - "U64" => Some(Self::U64), - "I8" => Some(Self::I8), - "I16" => Some(Self::I16), - "I32" => Some(Self::I32), - "I64" => Some(Self::I64), - "F16" => Some(Self::F16), - "F32" => Some(Self::F32), - "F64" => Some(Self::F64), - _ => None, - } - } -} diff --git a/vortex-proto/src/generated/vortex.expr.rs b/vortex-proto/src/generated/vortex.expr.rs deleted file mode 100644 index a44328623e3..00000000000 --- a/vortex-proto/src/generated/vortex.expr.rs +++ /dev/null @@ -1,209 +0,0 @@ -// This file is @generated by prost-build. -/// Captures a generic representation of expressions in Vortex. -/// Expression deserializers can be registered with a Vortex session to handle parsing this into -/// an in-memory expression for execution. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Expr { - #[prost(string, tag = "1")] - pub id: ::prost::alloc::string::String, - #[prost(message, repeated, tag = "2")] - pub children: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", optional, tag = "3")] - pub metadata: ::core::option::Option<::prost::alloc::vec::Vec>, -} -/// Captures a serialized aggregate function with its ID and options metadata. -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct AggregateFn { - #[prost(string, tag = "1")] - pub id: ::prost::alloc::string::String, - #[prost(bytes = "vec", optional, tag = "2")] - pub metadata: ::core::option::Option<::prost::alloc::vec::Vec>, -} -/// Options for numeric aggregate functions (`vortex.sum`, `vortex.min`, `vortex.max`), -/// controlling how NaN values in floating-point inputs are handled. -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct NumericalAggregateOpts { - #[prost(bool, tag = "1")] - pub skip_nans: bool, -} -/// Options for `vortex.literal` -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct LiteralOpts { - #[prost(message, optional, tag = "1")] - pub value: ::core::option::Option, -} -/// Options for `vortex.pack` -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct PackOpts { - #[prost(string, repeated, tag = "1")] - pub paths: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(bool, tag = "2")] - pub nullable: bool, -} -/// Options for `vortex.getitem` -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct GetItemOpts { - #[prost(string, tag = "1")] - pub path: ::prost::alloc::string::String, -} -/// Options for `vortex.variant_get` -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct VariantGetOpts { - #[prost(message, repeated, tag = "1")] - pub path: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "2")] - pub dtype: ::core::option::Option, -} -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct VariantPathElement { - #[prost(oneof = "variant_path_element::Element", tags = "1, 2")] - pub element: ::core::option::Option, -} -/// Nested message and enum types in `VariantPathElement`. -pub mod variant_path_element { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Element { - #[prost(string, tag = "1")] - Field(::prost::alloc::string::String), - #[prost(uint64, tag = "2")] - Index(u64), - } -} -/// Options for `vortex.json_to_variant` -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct JsonToVariantOpts { - #[prost(message, repeated, tag = "1")] - pub shredding: ::prost::alloc::vec::Vec, -} -/// One (path, dtype) shredding directive for `vortex.json_to_variant`. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ShreddingSpecField { - #[prost(message, repeated, tag = "1")] - pub path: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "2")] - pub dtype: ::core::option::Option, -} -/// Options for `vortex.binary` -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct BinaryOpts { - #[prost(enumeration = "binary_opts::BinaryOp", tag = "1")] - pub op: i32, -} -/// Nested message and enum types in `BinaryOpts`. -pub mod binary_opts { - #[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - Hash, - PartialOrd, - Ord, - ::prost::Enumeration - )] - #[repr(i32)] - pub enum BinaryOp { - Eq = 0, - NotEq = 1, - Gt = 2, - Gte = 3, - Lt = 4, - Lte = 5, - And = 6, - Or = 7, - Add = 8, - Sub = 9, - Mul = 10, - Div = 11, - } - impl BinaryOp { - /// String value of the enum field names used in the ProtoBuf definition. - /// - /// The values are not transformed in any way and thus are considered stable - /// (if the ProtoBuf definition does not change) and safe for programmatic use. - pub fn as_str_name(&self) -> &'static str { - match self { - Self::Eq => "Eq", - Self::NotEq => "NotEq", - Self::Gt => "Gt", - Self::Gte => "Gte", - Self::Lt => "Lt", - Self::Lte => "Lte", - Self::And => "And", - Self::Or => "Or", - Self::Add => "Add", - Self::Sub => "Sub", - Self::Mul => "Mul", - Self::Div => "Div", - } - } - /// Creates an enum from field names used in the ProtoBuf definition. - pub fn from_str_name(value: &str) -> ::core::option::Option { - match value { - "Eq" => Some(Self::Eq), - "NotEq" => Some(Self::NotEq), - "Gt" => Some(Self::Gt), - "Gte" => Some(Self::Gte), - "Lt" => Some(Self::Lt), - "Lte" => Some(Self::Lte), - "And" => Some(Self::And), - "Or" => Some(Self::Or), - "Add" => Some(Self::Add), - "Sub" => Some(Self::Sub), - "Mul" => Some(Self::Mul), - "Div" => Some(Self::Div), - _ => None, - } - } - } -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct BetweenOpts { - #[prost(bool, tag = "1")] - pub lower_strict: bool, - #[prost(bool, tag = "2")] - pub upper_strict: bool, -} -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct LikeOpts { - #[prost(bool, tag = "1")] - pub negated: bool, - #[prost(bool, tag = "2")] - pub case_insensitive: bool, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CastOpts { - #[prost(message, optional, tag = "1")] - pub target: ::core::option::Option, -} -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct FieldNames { - #[prost(string, repeated, tag = "1")] - pub names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, -} -#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)] -pub struct SelectOpts { - #[prost(oneof = "select_opts::Opts", tags = "1, 2")] - pub opts: ::core::option::Option, -} -/// Nested message and enum types in `SelectOpts`. -pub mod select_opts { - #[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)] - pub enum Opts { - #[prost(message, tag = "1")] - Include(super::FieldNames), - #[prost(message, tag = "2")] - Exclude(super::FieldNames), - } -} -/// Options for `vortex.case_when` -/// Encodes num_when_then_pairs and has_else into a single u32 (num_children). -/// num_children = num_when_then_pairs * 2 + (has_else ? 1 : 0) -/// has_else = num_children % 2 == 1 -/// num_when_then_pairs = num_children / 2 -#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)] -pub struct CaseWhenOpts { - #[prost(uint32, tag = "1")] - pub num_children: u32, -} diff --git a/vortex-proto/src/generated/vortex.scalar.rs b/vortex-proto/src/generated/vortex.scalar.rs deleted file mode 100644 index 7ea4e529104..00000000000 --- a/vortex-proto/src/generated/vortex.scalar.rs +++ /dev/null @@ -1,61 +0,0 @@ -// This file is @generated by prost-build. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Scalar { - #[prost(message, optional, tag = "1")] - pub dtype: ::core::option::Option, - #[prost(message, optional, boxed, tag = "2")] - pub value: ::core::option::Option<::prost::alloc::boxed::Box>, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ScalarValue { - #[prost( - oneof = "scalar_value::Kind", - tags = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12" - )] - pub kind: ::core::option::Option, -} -/// Nested message and enum types in `ScalarValue`. -pub mod scalar_value { - #[derive(Clone, PartialEq, ::prost::Oneof)] - pub enum Kind { - #[prost(enumeration = "::prost_types::NullValue", tag = "1")] - NullValue(i32), - #[prost(bool, tag = "2")] - BoolValue(bool), - #[prost(sint64, tag = "3")] - Int64Value(i64), - #[prost(uint64, tag = "4")] - Uint64Value(u64), - #[prost(float, tag = "5")] - F32Value(f32), - #[prost(double, tag = "6")] - F64Value(f64), - #[prost(string, tag = "7")] - StringValue(::prost::alloc::string::String), - #[prost(bytes, tag = "8")] - BytesValue(::prost::alloc::vec::Vec), - #[prost(message, tag = "9")] - ListValue(super::ListValue), - #[prost(uint64, tag = "10")] - F16Value(u64), - /// Variant scalars carry a row-specific nested scalar. - /// See RFC 0015: - #[prost(message, tag = "11")] - VariantValue(::prost::alloc::boxed::Box), - #[prost(message, tag = "12")] - UnionValue(::prost::alloc::boxed::Box), - } -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ListValue { - #[prost(message, repeated, tag = "1")] - pub values: ::prost::alloc::vec::Vec, -} -/// A present union value. Outer-null unions use ScalarValue.null_value instead. -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UnionValue { - #[prost(uint32, tag = "1")] - pub type_id: u32, - #[prost(message, optional, boxed, tag = "2")] - pub value: ::core::option::Option<::prost::alloc::boxed::Box>, -} diff --git a/vortex-proto/src/lib.rs b/vortex-proto/src/lib.rs deleted file mode 100644 index 0f5ac2b213a..00000000000 --- a/vortex-proto/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -#![allow(clippy::all, clippy::nursery, clippy::absolute_paths)] - -#[cfg(feature = "dtype")] -#[rustfmt::skip] -#[path = "./generated/vortex.dtype.rs"] -pub mod dtype; - -#[cfg(feature = "scalar")] -#[rustfmt::skip] -#[path = "./generated/vortex.scalar.rs"] -pub mod scalar; - -#[cfg(feature = "expr")] -#[rustfmt::skip] -#[path = "./generated/vortex.expr.rs"] -pub mod expr; diff --git a/vortex-tui/src/inspect.rs b/vortex-tui/src/inspect.rs index 122c3ceec9a..038d57e4559 100644 --- a/vortex-tui/src/inspect.rs +++ b/vortex-tui/src/inspect.rs @@ -27,7 +27,7 @@ use vortex::file::MAGIC_BYTES; use vortex::file::MAX_POSTSCRIPT_SIZE; use vortex::file::OpenOptionsSessionExt; use vortex::file::VERSION; -use vortex::flatbuffers::footer as fb; +use vortex::file::flatbuffers::footer as fb; use vortex::layout::LayoutRef; use vortex::session::VortexSession; diff --git a/vortex/Cargo.toml b/vortex/Cargo.toml index 8a8a92e43ee..49fc0a44ddf 100644 --- a/vortex/Cargo.toml +++ b/vortex/Cargo.toml @@ -32,8 +32,7 @@ vortex-decimal-byte-parts = { workspace = true } vortex-edition = { workspace = true } vortex-error = { workspace = true } vortex-fastlanes = { workspace = true } -vortex-file = { workspace = true, optional = true } -vortex-flatbuffers = { workspace = true } +vortex-file = { workspace = true, optional = true, default-features = true } vortex-fsst = { workspace = true } vortex-io = { workspace = true } vortex-ipc = { workspace = true } @@ -42,7 +41,6 @@ vortex-mask = { workspace = true } vortex-metrics = { workspace = true } vortex-parquet-variant = { workspace = true } vortex-pco = { workspace = true } -vortex-proto = { workspace = true, default-features = true } vortex-runend = { workspace = true } vortex-scan = { workspace = true } vortex-sequence = { workspace = true } diff --git a/vortex/src/lib.rs b/vortex/src/lib.rs index 6e69e341cd0..f171522faee 100644 --- a/vortex/src/lib.rs +++ b/vortex/src/lib.rs @@ -172,9 +172,13 @@ pub mod file { pub use vortex_file::*; } -/// Generated flatbuffer bindings used by Vortex serialization. +/// Traits for reading and writing Vortex types as flatbuffers, plus the generated bindings for the +/// core array and dtype schemas. +/// +/// Bindings for the other schemas live alongside the types they describe, in +/// `layout::flatbuffers`, `file::flatbuffers` and `ipc::flatbuffers`. pub mod flatbuffers { - pub use vortex_flatbuffers::*; + pub use vortex_array::flatbuffers::*; } /// Async and blocking IO abstractions used by file readers and writers. @@ -210,7 +214,7 @@ pub mod metrics { /// Generated protocol buffer bindings used by Vortex metadata. pub mod proto { - pub use vortex_proto::*; + pub use vortex_array::proto::*; } /// Scalar values and typed scalar views. diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 5ac04804c95..e6a11eb9b24 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -23,14 +23,12 @@ test = false anyhow = { workspace = true } clap = { workspace = true, features = ["derive"] } git2 = { workspace = true } -prost-build = { workspace = true } toml = { workspace = true } vortex-edition = { workspace = true } vortex-json = { workspace = true } vortex-spatial = { workspace = true } vortex-tensor = { workspace = true } vortex-zstd = { workspace = true } -xshell = { workspace = true } [lints] workspace = true diff --git a/xtask/README.md b/xtask/README.md index 5e551b34d19..fbfbcd7e5b6 100644 --- a/xtask/README.md +++ b/xtask/README.md @@ -2,22 +2,17 @@ This crate is not published and is only used by developers. -It automates a number of tasks that a project maintainer might need to do, for example -code generation. +It automates a number of tasks that a project maintainer might need to do. You can run `cargo xtask -h` to get a list of supported commands. ## Current commands -### `generate-fbs` - -This will generate the `src/generated` Rust files in the `vortex-flatbuffers` crate. This -must be run every time changes are made to one of the .fbs files, or if any are added/deleted. - -### `generate-proto` - -This will generate the `src/generated` Rust files in the `vortex-proto` crate. This must -be run every time changes are made to one of the .fbs files, or if any are added/deleted. +### `generate-editions` +Regenerates the edition records under `vortex/editions`. +### `check-editions` +Checks that frozen edition records never change, comparing against `--base` (default +`origin/develop`). diff --git a/xtask/src/generate_fbs.rs b/xtask/src/generate_fbs.rs deleted file mode 100644 index 4c5349a4e3b..00000000000 --- a/xtask/src/generate_fbs.rs +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -use std::path::PathBuf; - -use xshell::Shell; -use xshell::cmd; - -static FLATC_BIN: &str = "flatc"; - -pub fn generate_fbs() -> anyhow::Result<()> { - let sh = Shell::new()?; - - let files = vec![ - "./flatbuffers/vortex-array/array.fbs", - "./flatbuffers/vortex-dtype/dtype.fbs", - "./flatbuffers/vortex-file/footer.fbs", - "./flatbuffers/vortex-layout/layout.fbs", - "./flatbuffers/vortex-serde/message.fbs", - ]; - - // CD to vortex-flatbuffers project - sh.change_dir(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../vortex-flatbuffers")); - - cmd!( - sh, - "{FLATC_BIN} --rust --filename-suffix '' -I ./flatbuffers/ -o ./src/generated {files...}" - ) - .run()?; - - Ok(()) -} diff --git a/xtask/src/generate_proto.rs b/xtask/src/generate_proto.rs deleted file mode 100644 index 14dfd26bc1a..00000000000 --- a/xtask/src/generate_proto.rs +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: Copyright the Vortex contributors - -use std::path::PathBuf; - -pub fn generate_proto() -> anyhow::Result<()> { - let vortex_proto = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../vortex-proto"); - let proto_files = vec![ - vortex_proto.join("proto").join("dtype.proto"), - vortex_proto.join("proto").join("scalar.proto"), - vortex_proto.join("proto").join("expr.proto"), - ]; - - for file in &proto_files { - if !file.exists() { - anyhow::bail!("proto file not found: {file:?}"); - } - } - - let out_dir = vortex_proto.join("src").join("generated"); - std::fs::create_dir_all(&out_dir)?; - - prost_build::Config::new() - .out_dir(out_dir) - .compile_protos(&proto_files, &[vortex_proto.join("proto")])?; - - Ok(()) -} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 8cc582be233..c6b491281d6 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -3,15 +3,11 @@ mod check_editions; mod generate_editions; -mod generate_fbs; -mod generate_proto; use clap::Parser; use crate::check_editions::check_editions; use crate::generate_editions::generate_editions; -use crate::generate_fbs::generate_fbs; -use crate::generate_proto::generate_proto; #[derive(clap::Parser)] struct Xtask { @@ -31,12 +27,6 @@ enum Commands { /// Subcommand to regenerate the edition records under `vortex/editions`. #[command(name = "generate-editions")] Editions, - /// Subcommand to regenerate flatbuffers language bindings for the Rust project. - #[command(name = "generate-fbs")] - Flatbuffers, - /// Subcommand to regenerate protobuf language bindings for the Rust project. - #[command(name = "generate-proto")] - Proto, } fn main() -> anyhow::Result<()> { @@ -44,8 +34,6 @@ fn main() -> anyhow::Result<()> { match cli.command { Commands::CheckEditions { base } => check_editions(&base)?, Commands::Editions => generate_editions()?, - Commands::Flatbuffers => generate_fbs()?, - Commands::Proto => generate_proto()?, } Ok(()) }