diff --git a/.github/runs-on.yml b/.github/runs-on.yml index b946f8031ec..819f2a91a52 100644 --- a/.github/runs-on.yml +++ b/.github/runs-on.yml @@ -1,15 +1,15 @@ _extends: .github-private images: - ubuntu24-full-x64-pre-v2: + ubuntu26-full-x64-pre-v2: platform: "linux" arch: "x64" - name: "vortex-ci-v2-x64-*" + name: "vortex-ci-v2-ubuntu26-x64-*" owner: "245040174862" - ubuntu24-full-arm64-pre-v2: + ubuntu26-full-arm64-pre-v2: platform: "linux" arch: "arm64" - name: "vortex-ci-v2-arm64-*" + name: "vortex-ci-v2-ubuntu26-arm64-*" owner: "245040174862" windows25-full-x64-pre: platform: "windows" diff --git a/.github/vercel-cli/package-lock.json b/.github/vercel-cli/package-lock.json index 4793a9390d9..250f3b3e4ae 100644 --- a/.github/vercel-cli/package-lock.json +++ b/.github/vercel-cli/package-lock.json @@ -781,9 +781,9 @@ } }, "node_modules/@napi-rs/wasm-runtime": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.5.tgz", - "integrity": "sha512-HshSvXzmBxNzqejd3k/KemgQ3hdREUYFRRrgxOZ+gPljDIsO2SDZrVZMd4Z/HsxudQbE62OVyVFE8z9BCurfjA==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", "license": "MIT", "optional": true, "dependencies": { @@ -797,8 +797,8 @@ "url": "https://github.com/sponsors/Brooooooklyn" }, "peerDependencies": { - "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.4", - "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4" + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" } }, "node_modules/@nodelib/fs.scandir": { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47d01053937..71ee3ad11cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,7 @@ jobs: if: github.event.pull_request.draft != true runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-small/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=lightweight-checks', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-small/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=lightweight-checks', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 10 steps: @@ -98,20 +98,21 @@ jobs: # benchmarks-database fact row. The golden vectors are a frozen artifact (see the note inside # the JSON); this job fails if a change to scripts/_measurement_id.py drifts the hash, which # would break ON CONFLICT idempotency against the rows already in production. - - name: Pytest - measurement_id, benchmark reporting and ingestion + - name: Pytest - measurement_id, benchmark reporting, ingestion and CodSpeed shards if: "!cancelled()" run: | uv run --no-project --with pytest --with pandas --with numpy --with orjson \ --with tabulate --with xxhash \ pytest scripts/tests/test_measurement_id.py \ - scripts/tests/test_benchmark_reporting.py scripts/tests/test_post_ingest.py + scripts/tests/test_benchmark_reporting.py scripts/tests/test_post_ingest.py \ + scripts/tests/test_codspeed_shards.py python-test: name: "Python (test)" if: github.event.pull_request.draft != true runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-large/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=python-test', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-large/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=python-test', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 env: @@ -155,72 +156,6 @@ jobs: uv run --all-packages make check working-directory: docs/ - python-windows: - name: "Python (windows-x64)" - if: github.event.pull_request.draft != true - timeout-minutes: 60 - runs-on: >- - ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/pool=windows-x64-pre/extras=s3-cache', github.run_id) - || 'windows-latest' }} - steps: - - uses: runs-on/action@v2 - if: github.repository == 'vortex-data/vortex' - with: - sccache: s3 - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - name: Setup (Windows) - run: | - echo "C:\rust\cargo\bin" >> $env:GITHUB_PATH - - uses: ./.github/actions/setup-prebuild - with: - enable-sccache: "true" - - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7 - with: - python-version: "3.11" - - # Mirrors the wheel build in package.yml, which spells the Windows interpreter - # `python` because maturin has no `python3.11` executable to resolve there. - - name: Build wheel - uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 - with: - command: build - maturin-version: 1.15.0 - target: x86_64-pc-windows-msvc - args: > - --profile ci - --manifest-path vortex-python/Cargo.toml - --out dist - --interpreter python - env: - # Keep this constant to avoid pyo3 invalidating itself - PYO3_ENVIRONMENT_SIGNATURE: "cpython3" - # Also applies to host proc-macro links when Cargo receives an explicit target. - LINK: /Brepro - - # rust-test-windows excludes vortex-python, so this is the only check that the - # win_amd64 wheel imports and can round-trip a file. Runs outside the checkout so - # the repo-root `vortex/` crate directory cannot shadow the installed package. - - name: Import and round-trip the wheel - shell: bash - run: | - python -m pip install dist/*.whl - cd "$RUNNER_TEMP" - python - <<'PY' - import pyarrow as pa - - import vortex as vx - - table = pa.table({"a": [1, 2, 3], "b": ["x", "y", "z"]}) - vx.io.write(table, "smoke.vortex") - # Vortex reads utf8 back as string_view, so compare column-wise rather than by table. - round_tripped = vx.open("smoke.vortex").to_arrow().read_all() - assert round_tripped.column_names == table.column_names - assert round_tripped.column("a").to_pylist() == [1, 2, 3] - assert round_tripped.column("b").to_pylist() == ["x", "y", "z"] - print("vortex", vx.__version__, "round-tripped a file on Windows") - PY - python-cuda-test: name: "Python CUDA (test)" if: github.event.pull_request.draft != true && github.repository == 'vortex-data/vortex' @@ -264,7 +199,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-docs/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-docs', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-docs/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-docs', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -293,7 +228,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner={1}/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag={2}', github.run_id, matrix.config.runner, matrix.config.name) + && format('runs-on={0}/region=us-east-1/runner={1}/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag={2}', github.run_id, matrix.config.runner, matrix.config.name) || 'ubuntu-latest' }} strategy: fail-fast: false @@ -338,7 +273,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-min-deps', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-min-deps', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -358,7 +293,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-msrv', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-msrv', github.run_id) || 'ubuntu-latest' }} env: RUSTFLAGS: "-A warnings" @@ -382,7 +317,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-large/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-lint', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-large/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-lint', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -451,7 +386,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-lint-no-default', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-lint-no-default', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -468,17 +403,13 @@ jobs: run: | cargo hack --no-dev-deps --ignore-private clippy --profile ci --no-default-features -- -D warnings - rust-test-windows: - name: "Rust tests (windows-x64)" - env: - # Stable proc-macro DLL contents let dependent crates reuse sccache entries. - # duckdb_static.lib is built with /MT and thus requires crt-static - RUSTFLAGS: "-C link-arg=/Brepro -C target-feature=+crt-static" - # link.exe spends ~1.5 min on the test binaries after compilation finishes. - CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld + # One job for all Windows checks: a Windows instance takes 85-105s to boot, and + # the pool keeps only one instance hot. + windows: + name: "Windows (x64)" needs: duckdb-mirror if: github.event.pull_request.draft != true && !cancelled() && (needs.duckdb-mirror.result == 'success' || needs.duckdb-mirror.result == 'skipped') - timeout-minutes: 30 + timeout-minutes: 45 runs-on: >- ${{ github.repository == 'vortex-data/vortex' && format('runs-on={0}/region=us-east-1/pool=windows-x64-pre/extras=s3-cache', github.run_id) @@ -490,14 +421,25 @@ jobs: with: sccache: s3 - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - name: Setup (Windows) - run: | - echo "C:\rust\cargo\bin" >> $env:GITHUB_PATH - - uses: ./.github/actions/setup-prebuild - with: - enable-sccache: "true" + - name: Setup (Windows) + run: | + echo "C:\rust\cargo\bin" >> $env:GITHUB_PATH + - parallel: + - uses: ./.github/actions/setup-prebuild + with: + enable-sccache: "true" + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7 + with: + python-version: "3.11" - name: Rust Tests (Windows) + id: tests + env: + # Stable proc-macro DLL contents let dependent crates reuse sccache entries. + # duckdb_static.lib is built with /MT and thus requires crt-static + RUSTFLAGS: "-C link-arg=/Brepro -C target-feature=+crt-static" + # link.exe spends ~1.5 min on the test binaries after compilation finishes. + CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: rust-lld run: | cargo nextest run --cargo-profile ci --locked --workspace --all-features --no-fail-fast ` --exclude vortex-bench ` @@ -509,6 +451,59 @@ jobs: --exclude compress-bench --exclude xtask --exclude vortex-datafusion ` --exclude gpu-scan-cli + # The test outputs fill the default disk, and the wheel build cannot reuse + # them: it uses other RUSTFLAGS and its own target directory. + - name: Delete the Rust test outputs + if: ${{ !cancelled() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }} + shell: cmd + run: if exist target\ci rmdir /s /q target\ci + + # Mirrors the wheel build in package.yml, which spells the Windows interpreter + # `python` because maturin has no `python3.11` executable to resolve there. + - name: Build wheel + id: wheel + # Build the wheel also when a Rust test fails, but not when the setup failed. + if: ${{ !cancelled() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }} + uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1 + with: + command: build + maturin-version: 1.15.0 + target: x86_64-pc-windows-msvc + args: > + --profile ci + --manifest-path vortex-python/Cargo.toml + --out dist + --interpreter python + env: + # Keep this constant to avoid pyo3 invalidating itself + PYO3_ENVIRONMENT_SIGNATURE: "cpython3" + # Also applies to host proc-macro links when Cargo receives an explicit target. + LINK: /Brepro + + # The Rust tests exclude vortex-python, so this is the only check that the + # win_amd64 wheel imports and can round-trip a file. Runs outside the checkout so + # the repo-root `vortex/` crate directory cannot shadow the installed package. + - name: Import and round-trip the wheel + if: ${{ !cancelled() && steps.wheel.outcome == 'success' }} + shell: bash + run: | + python -m pip install dist/*.whl + cd "$RUNNER_TEMP" + python - <<'PY' + import pyarrow as pa + + import vortex as vx + + table = pa.table({"a": [1, 2, 3], "b": ["x", "y", "z"]}) + vx.io.write(table, "smoke.vortex") + # Vortex reads utf8 back as string_view, so compare column-wise rather than by table. + round_tripped = vx.open("smoke.vortex").to_arrow().read_all() + assert round_tripped.column_names == table.column_names + assert round_tripped.column("a").to_pylist() == [1, 2, 3] + assert round_tripped.column("b").to_pylist() == ["x", "y", "z"] + print("vortex", vx.__version__, "round-tripped a file on Windows") + PY + - name: sccache stats if: always() && github.repository == 'vortex-data/vortex' run: sccache --show-stats @@ -518,8 +513,8 @@ jobs: uses: ./.github/actions/alert-incident-io with: api-key: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }} - alert-title: "Rust tests (windows-x64) failed on develop" - deduplication-key: ci-rust-test-windows-x64-failure + alert-title: "Windows (x64) failed on develop" + deduplication-key: ci-windows-x64-failure rust-test-linux-arm64: name: "Rust tests (linux-arm64)" @@ -528,7 +523,7 @@ jobs: github.event.pull_request.draft != true && !cancelled() && (needs.duckdb-mirror.result == 'success' || needs.duckdb-mirror.result == 'skipped') && github.repository == 'vortex-data/vortex' timeout-minutes: 30 - runs-on: runs-on=${{ github.run_id }}/region=us-east-1/runner=arm64-ci-test/image=ubuntu24-full-arm64-pre-v2/extras=s3-cache/tag=rust-test-linux-arm64 + runs-on: runs-on=${{ github.run_id }}/region=us-east-1/runner=arm64-ci-test/image=ubuntu26-full-arm64-pre-v2/extras=s3-cache/tag=rust-test-linux-arm64 steps: - parallel: - uses: runs-on/action@v2 @@ -572,17 +567,17 @@ jobs: - name: avx2 runner: amd64-ci-medium family: c6a.2xlarge - image: ubuntu24-full-x64-pre-v2 + image: ubuntu26-full-x64-pre-v2 expect: "sse2,popcnt,bmi1,bmi2,avx,avx2" - name: avx512 runner: amd64-ci-medium family: c6i.2xlarge - image: ubuntu24-full-x64-pre-v2 + image: ubuntu26-full-x64-pre-v2 expect: "sse2,popcnt,bmi1,bmi2,avx,avx2,avx512f,avx512bw,avx512vbmi2,avx512vpopcntdq" - name: sve runner: arm64-medium family: c8g.2xlarge - image: ubuntu24-full-arm64-pre-v2 + image: ubuntu26-full-arm64-pre-v2 expect: "neon,sve,sve2,sve2-bitperm" runs-on: >- runs-on=${{ github.run_id }}/region=us-east-1/runner=${{ matrix.config.runner }}/family=${{ matrix.config.family }}/spot=price-capacity-optimized/image=${{ matrix.config.image }}/extras=s3-cache/tag=rust-test-cpu-features-${{ matrix.config.name }} @@ -612,7 +607,7 @@ jobs: if: github.event.pull_request.draft != true runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=java', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=java', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 steps: @@ -662,7 +657,7 @@ jobs: if: github.event.pull_request.draft != true && !cancelled() && (needs.duckdb-mirror.result == 'success' || needs.duckdb-mirror.result == 'skipped') runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-sql-logic-test/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=sql-logic-test', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-sql-logic-test/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=sql-logic-test', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 steps: @@ -691,7 +686,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=c-cxx-generated', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=c-cxx-generated', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -833,7 +828,7 @@ jobs: if: github.event.pull_request.draft != true && !cancelled() runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=integration-smoke', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=integration-smoke', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 steps: diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index aa7a06f3c5e..c405a4bb861 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -47,107 +47,129 @@ jobs: # Only this workflow defines the CUDA benchmark jobs. - ".github/workflows/codspeed.yml" - bench-codspeed: + # CodSpeed rejects an upload with too many benchmarks, so the simulation benchmarks run in + # shards of at most 800. The planner reads only Cargo.toml files and the committed benchmark + # counts, so this job needs no Rust toolchain and takes seconds. + plan-codspeed: + name: "Plan Codspeed shards" if: github.event.pull_request.draft != true + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + active: ${{ steps.plan.outputs.active }} + shards: ${{ steps.plan.outputs.shards }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - id: plan + run: python3 scripts/codspeed_shards.py plan >> "$GITHUB_OUTPUT" + + bench-codspeed: + needs: [plan-codspeed] strategy: matrix: - include: - # Distribute both compilation and simulation work across shards. Rebalance - # these groups as new benchmarks are added, using CI build and run durations. - - { shard: 1, name: "Array compute", packages: "vortex-array", array-group: "compute", features: "--features _test-harness" } - - { shard: 2, name: "Array selection", packages: "vortex-array", array-group: "selection", features: "--features _test-harness" } - - { shard: 3, name: "Array dictionaries", packages: "vortex-array", array-group: "dictionary", features: "--features _test-harness" } - - { shard: 4, name: "Array builders & views", packages: "vortex-array", array-group: "builders", features: "--features _test-harness" } - - { shard: 5, name: "Core & encodings", packages: "vortex-buffer vortex-mask vortex-compute vortex-file vortex-alp vortex-datetime-parts" } - - { shard: 6, name: "Main library & storage", packages: "vortex vortex-compressor vortex-row" } - - { shard: 7, name: "FastLanes & decimals", packages: "vortex-decimal-byte-parts vortex-fastlanes", features: "--features _test-harness" } - - { shard: 8, name: "Encodings & layout", packages: "vortex-elias-fano vortex-pco vortex-sparse vortex-layout" } - - { shard: 9, name: "Strings, tensor & spatial", packages: "vortex-fsst vortex-tensor vortex-spatial", features: "--features _test-harness" } - name: "Benchmark with Codspeed (Shard #${{ matrix.shard }} - ${{ matrix.name }})" - timeout-minutes: 30 - # Each CodSpeed runner is pinned to one instance type, because results depend on the CPU. + # Fixed slots, so that each one can be a required check. The plan fills as many as it + # needs; an unused slot runs no steps and succeeds. Keep in sync with MAX_SHARDS in + # scripts/codspeed_shards.py. + shard: [1, 2, 3, 4, 5] + name: "Benchmark with Codspeed (Shard ${{ matrix.shard }})" + timeout-minutes: 60 + env: + SHARD_ACTIVE: ${{ contains(fromJSON(needs.plan-codspeed.outputs.active), matrix.shard) }} + # Each CodSpeed runner is pinned to one instance type, because results depend on the CPU. An + # unused slot takes a GitHub-hosted runner instead. runs-on: >- - ${{ github.repository == 'vortex-data/vortex' + ${{ contains(fromJSON(needs.plan-codspeed.outputs.active), matrix.shard) + && github.repository == 'vortex-data/vortex' && format('runs-on={0}/region=us-east-1/runner=amd64-codspeed-simulation/tag=bench-codspeed-{1}', github.run_id, matrix.shard) || 'ubuntu-latest' }} steps: - uses: runs-on/action@v2 - if: github.repository == 'vortex-data/vortex' + if: env.SHARD_ACTIVE == 'true' && github.repository == 'vortex-data/vortex' with: sccache: s3 - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - - uses: ./.github/actions/setup-prebuild - with: - enable-sccache: ${{ github.repository == 'vortex-data/vortex' && 'true' || 'false' }} - - uses: ./.github/actions/system-info - - name: Install Codspeed - uses: taiki-e/cache-cargo-install-action@66c9585ef5ca780ee69399975a5e911f47905995 - with: - tool: cargo-codspeed - - name: Select array benchmarks - if: matrix.array-group - id: select + - name: Select shard + id: shard env: - ARRAY_GROUP: ${{ matrix.array-group }} + SHARDS: ${{ needs.plan-codspeed.outputs.shards }} + SHARD: ${{ matrix.shard }} run: | python3 - <<'EOF' >> "$GITHUB_OUTPUT" - import os, pathlib, tomllib + import json, os - groups = { - "dictionary": ("dict_", "chunked_dict_", "patches_"), - "selection": ("take_", "filter_", "piecewise_sequence_"), - "compute": ("aggregate_", "cast_", "expr_", "binary_ops", "compare", "kleene_bool", "like", "list_sum", "widen"), - } - manifest = tomllib.loads(pathlib.Path("vortex-array/Cargo.toml").read_text()) - benches = [] - for bench in manifest["bench"]: - name = bench["name"] - # Unclassified and newly added targets stay covered by the builders shard. - group = next((group for group, prefixes in groups.items() if name.startswith(prefixes)), "builders") - if group == os.environ["ARRAY_GROUP"]: - benches.append(name) - if not benches: - raise SystemExit("array shard has no benchmark targets") - print("benches=" + " ".join(f"--bench {name}" for name in benches)) + shard = json.loads(os.environ["SHARDS"]).get(os.environ["SHARD"]) + if shard is None: + print("active=false") + else: + print("active=true") + print(f"build-args={shard['build-args']}") + print(f"exclude-allocations={str(shard['exclude-allocations']).lower()}") EOF - - name: Build benchmarks - env: - RUSTFLAGS: "-C target-feature=+avx2 -C force-frame-pointers=yes -C link-arg=-fuse-ld=mold" - # Benchmarks carrying `#[cpu_features]` belong to a walltime leg below and are - # skipped here. Untagged ones run as they always have, under bare names, so this - # job's CodSpeed history is unaffected. - VORTEX_BENCH_VARIANT: simulation - run: cargo codspeed build --locked ${{ matrix.features }} $(printf -- '-p %s ' ${{ matrix.packages }}) ${{ steps.select.outputs.benches }} --profile bench - - name: Run benchmarks - uses: CodSpeedHQ/action@78102a468f96d8e0ccb92d0ec49425753fc42062 # v5 - env: - # codspeed-divan-compat 6 runs each benchmark in a new process by default. Simulation - # measures one iteration without warmup, so each benchmark then also pays for a cold - # allocator and cold caches. This adds about 15 µs to each benchmark and hides small - # changes in short benchmarks. Run all benchmarks of a target in one process, as before. - CODSPEED_PROCESS_ISOLATION: "false" - # Allocators return freed memory to the OS and grow their heaps with system calls. A - # system call inside a measured iteration is left out of the measure, so CodSpeed reports - # that benchmark as dominated by system calls. Keep freed memory mapped instead. - # - # mimalloc, which every benchmark binary uses, returns memory 10 ms after it is freed. - # The simulation runs many times slower than native code, so that delay can end inside a - # later benchmark's measured iteration. - MIMALLOC_PURGE_DELAY: "-1" - # glibc `malloc`, which C dependencies such as zstd use, shrinks its heap after large - # frees and grows it again with `brk`. Shrink only when 1 GiB is free at the top of the - # heap, and grow in 64 MiB steps so that a later benchmark rarely needs to grow it. - MALLOC_TRIM_THRESHOLD_: "1073741824" - MALLOC_TOP_PAD_: "67108864" + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + if: steps.shard.outputs.active == 'true' + - uses: ./.github/actions/setup-prebuild + if: steps.shard.outputs.active == 'true' with: - run: cargo codspeed run - token: ${{ secrets.CODSPEED_TOKEN }} - mode: "simulation" - # Exclude deferred allocator cleanup from the affected array shards. - # Allocation-focused benchmarks in the core shard still measure allocator time. - exclude-allocations: ${{ matrix.array-group == 'dictionary' || matrix.array-group == 'selection' }} - # Cached package restoration fails on dangling libc6-dbg documentation symlinks. - cache-instruments: "false" + enable-sccache: ${{ github.repository == 'vortex-data/vortex' && 'true' || 'false' }} + - parallel: + - uses: ./.github/actions/system-info + if: steps.shard.outputs.active == 'true' + - name: Install Codspeed + if: steps.shard.outputs.active == 'true' + uses: taiki-e/cache-cargo-install-action@66c9585ef5ca780ee69399975a5e911f47905995 + with: + tool: cargo-codspeed + # The CodSpeed action does its setup (CLI install, its Valgrind package, runner start-up) + # inside the step that runs the benchmarks, so it starts alongside the build and its + # command waits for the build to report an exit status before running anything. + - parallel: + - name: Build benchmarks + if: steps.shard.outputs.active == 'true' + env: + RUSTFLAGS: "-C target-feature=+avx2 -C force-frame-pointers=yes -C link-arg=-fuse-ld=mold" + # Benchmarks carrying `#[cpu_features]` belong to a walltime leg below and are + # skipped here. Untagged ones run as they always have, under bare names, so this + # job's CodSpeed history is unaffected. + VORTEX_BENCH_VARIANT: simulation + BUILD_STATUS: ${{ runner.temp }}/codspeed-build-status + run: | + trap 'echo $? > "$BUILD_STATUS"' EXIT + cargo codspeed build --locked ${{ steps.shard.outputs.build-args }} --profile bench + - name: Run benchmarks + if: steps.shard.outputs.active == 'true' + uses: CodSpeedHQ/action@78102a468f96d8e0ccb92d0ec49425753fc42062 # v5 + env: + # codspeed-divan-compat 6 runs each benchmark in a new process by default. Simulation + # measures one iteration without warmup, so each benchmark then also pays for a cold + # allocator and cold caches. This adds about 15 µs to each benchmark and hides small + # changes in short benchmarks. Run all benchmarks of a target in one process, as before. + CODSPEED_PROCESS_ISOLATION: "false" + # Allocators return freed memory to the OS and grow their heaps with system calls. A + # system call inside a measured iteration is left out of the measure, so CodSpeed reports + # that benchmark as dominated by system calls. Keep freed memory mapped instead. + # + # mimalloc, which every benchmark binary uses, returns memory 10 ms after it is freed. + # The simulation runs many times slower than native code, so that delay can end inside a + # later benchmark's measured iteration. + MIMALLOC_PURGE_DELAY: "-1" + # glibc `malloc`, which C dependencies such as zstd use, shrinks its heap after large + # frees and grows it again with `brk`. Shrink only when 1 GiB is free at the top of the + # heap, and grow in 64 MiB steps so that a later benchmark rarely needs to grow it. + MALLOC_TRIM_THRESHOLD_: "1073741824" + MALLOC_TOP_PAD_: "67108864" + with: + run: | + BUILD_STATUS='${{ runner.temp }}/codspeed-build-status' + until [ -s "$BUILD_STATUS" ]; do sleep 2; done + if [ "$(cat "$BUILD_STATUS")" != 0 ]; then + echo "Benchmark build failed; nothing to run." >&2 + exit 1 + fi + cargo codspeed run + token: ${{ secrets.CODSPEED_TOKEN }} + mode: "simulation" + exclude-allocations: ${{ steps.shard.outputs.exclude-allocations }} + # Cached package restoration fails on dangling libc6-dbg documentation symlinks. + cache-instruments: "false" bench-codspeed-python: name: "Benchmark with Codspeed (Python)" @@ -176,28 +198,41 @@ jobs: with: enable-sccache: ${{ github.repository == 'vortex-data/vortex' && 'true' || 'false' }} - uses: ./.github/actions/system-info - # Build the extension before measurement, so the benchmark step does not compile it. - - name: Build Python extension - run: uv sync --all-packages - # Simulation runs all of the benchmark process on Valgrind, so write the input files first. - - name: Write benchmark data - working-directory: vortex-python - env: - VORTEX_BENCH_DATA_DIR: ${{ runner.temp }}/vortex-bench-data - run: uv run --all-packages --no-sync python -m benchmark.data "$VORTEX_BENCH_DATA_DIR" - - name: Run benchmarks - uses: CodSpeedHQ/action@78102a468f96d8e0ccb92d0ec49425753fc42062 # v5 - env: - VORTEX_BENCH_DATA_DIR: ${{ runner.temp }}/vortex-bench-data - # Drive scans on the calling thread. Background workers wake every 100 ms to check - # for shutdown. Under simulation, those timer wakeups can dominate the measured work. - VORTEX_MAX_THREADS: "0" - with: - run: cd vortex-python && uv run --all-packages --no-sync pytest benchmark/ --codspeed - token: ${{ secrets.CODSPEED_TOKEN }} - mode: "simulation" - # Cached package restoration fails on dangling libc6-dbg documentation symlinks. - cache-instruments: "false" + # As in `bench-codspeed`, the CodSpeed action's setup runs alongside the build, and its + # command waits for the build to report an exit status. + - parallel: + # Build the extension before measurement, so the benchmark step does not compile it. + # Simulation runs all of the benchmark process on Valgrind, so write the input files + # first too. + - name: Build Python extension and write benchmark data + env: + VORTEX_BENCH_DATA_DIR: ${{ runner.temp }}/vortex-bench-data + BUILD_STATUS: ${{ runner.temp }}/codspeed-build-status + run: | + trap 'echo $? > "$BUILD_STATUS"' EXIT + uv sync --all-packages + cd vortex-python + uv run --all-packages --no-sync python -m benchmark.data "$VORTEX_BENCH_DATA_DIR" + - name: Run benchmarks + uses: CodSpeedHQ/action@78102a468f96d8e0ccb92d0ec49425753fc42062 # v5 + env: + VORTEX_BENCH_DATA_DIR: ${{ runner.temp }}/vortex-bench-data + # Drive scans on the calling thread. Background workers wake every 100 ms to check + # for shutdown. Under simulation, those timer wakeups can dominate the measured work. + VORTEX_MAX_THREADS: "0" + with: + run: | + BUILD_STATUS='${{ runner.temp }}/codspeed-build-status' + until [ -s "$BUILD_STATUS" ]; do sleep 2; done + if [ "$(cat "$BUILD_STATUS")" != 0 ]; then + echo "Python extension build failed; nothing to run." >&2 + exit 1 + fi + cd vortex-python && uv run --all-packages --no-sync pytest benchmark/ --codspeed + token: ${{ secrets.CODSPEED_TOKEN }} + mode: "simulation" + # Cached package restoration fails on dangling libc6-dbg documentation symlinks. + cache-instruments: "false" # Compile on smaller VMs from the same CPU family as the measurement hosts. Globally # enabled features also affect build scripts, so the build host must support them. @@ -262,7 +297,7 @@ jobs: for package in meta["packages"] for target in package["targets"] if "bench" in target["kind"] - and "cpu_features]" in pathlib.Path(target["src_path"]).read_text() + and "#[vortex_bench_support::cpu_features" in pathlib.Path(target["src_path"]).read_text() ) if not tagged: raise SystemExit("no benchmark carries `#[cpu_features]`; this job has nothing to measure") @@ -407,16 +442,10 @@ jobs: bench-codspeed-cuda: if: github.repository == 'vortex-data/vortex' needs: [bench-codspeed-cuda-build] - strategy: - matrix: - include: - - { shard: 1, name: "Bitpacked", benches: "bitpacked_cuda" } - - { shard: 2, name: "Dynamic dispatch", benches: "dynamic_dispatch_cuda" } - - { shard: 3, name: "Standalone kernels", benches: "alp_cuda date_time_parts_cuda delta_cuda dict_cuda fsst_cuda runend_cuda" } - name: "Benchmark with Codspeed (CUDA Shard #${{ matrix.shard }} - ${{ matrix.name }})" - timeout-minutes: 30 + name: "Benchmark with Codspeed (CUDA)" + timeout-minutes: 60 runs-on: >- - runs-on=${{ github.run_id }}/region=us-east-1/runner=gpu-codspeed/tag=bench-codspeed-cuda-${{ matrix.shard }} + runs-on=${{ github.run_id }}/region=us-east-1/runner=gpu-codspeed/tag=bench-codspeed-cuda steps: - uses: runs-on/action@v2 with: @@ -450,6 +479,12 @@ jobs: env: CARGO_MANIFEST_DIR: ${{ github.workspace }}/vortex-cuda with: - run: cargo codspeed run $(printf -- '--bench %s ' ${{ matrix.benches }}) + # Name the benchmarks: the artifact directory also holds libvortex_cub.so, which a bare + # `cargo codspeed run` would try to execute as a benchmark. + run: >- + cargo codspeed run + --bench bitpacked_cuda --bench dynamic_dispatch_cuda --bench alp_cuda + --bench date_time_parts_cuda --bench delta_cuda --bench dict_cuda + --bench fsst_cuda --bench runend_cuda token: ${{ secrets.CODSPEED_TOKEN }} mode: "walltime" diff --git a/.github/workflows/compat-gen-upload.yml b/.github/workflows/compat-gen-upload.yml index 63346a7dac5..e927a7e7b97 100644 --- a/.github/workflows/compat-gen-upload.yml +++ b/.github/workflows/compat-gen-upload.yml @@ -25,7 +25,7 @@ jobs: dry-run: runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=compat-gen-dry-run', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=compat-gen-dry-run', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 permissions: @@ -78,7 +78,7 @@ jobs: if: inputs.confirm_upload == 'yes' runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=compat-gen-upload', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=compat-gen-upload', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 environment: compat-upload diff --git a/.github/workflows/compat-validation.yml b/.github/workflows/compat-validation.yml index 355043c3625..56ff88d1f84 100644 --- a/.github/workflows/compat-validation.yml +++ b/.github/workflows/compat-validation.yml @@ -25,7 +25,7 @@ jobs: compat-test: runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=compat-validation', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=compat-validation', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 steps: diff --git a/.github/workflows/develop-bench.yml b/.github/workflows/develop-bench.yml index f02f456435a..be17f19bad0 100644 --- a/.github/workflows/develop-bench.yml +++ b/.github/workflows/develop-bench.yml @@ -18,7 +18,7 @@ jobs: # forever. With the long `family` list and the longest benchmark id, this label is close. runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.8xlarge+c8g.8xlarge+c8gn.8xlarge+m8gd.8xlarge+m8g.8xlarge+r8gd.8xlarge+r8g.8xlarge+x8g.8xlarge+i8g.8xlarge/image=ubuntu24-full-arm64-pre-v2/extras=s3-cache/tag={1}', github.run_id, matrix.benchmark.id) + && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.8xlarge+c8g.8xlarge+c8gn.8xlarge+m8gd.8xlarge+m8g.8xlarge+r8gd.8xlarge+r8g.8xlarge+x8g.8xlarge+i8g.8xlarge/image=ubuntu26-full-arm64-pre-v2/extras=s3-cache/tag={1}', github.run_id, matrix.benchmark.id) || 'ubuntu-latest' }} strategy: fail-fast: false @@ -68,7 +68,7 @@ jobs: timeout-minutes: 120 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.metal-24xl/image=ubuntu24-full-arm64-pre-v2/extras=s3-cache/tag={1}{2}', github.run_id, matrix.benchmark.id, matrix.benchmark.variant_id) + && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.metal-24xl/image=ubuntu26-full-arm64-pre-v2/extras=s3-cache/tag={1}{2}', github.run_id, matrix.benchmark.id, matrix.benchmark.variant_id) || 'ubuntu-latest' }} strategy: fail-fast: false diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 1c9bc93d5f0..bcaadc8a882 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -126,6 +126,8 @@ jobs: fsst_like_fuzz: name: "FSST LIKE Fuzz" needs: build_cpu_fuzzers + # Temporarily disabled. The report and fix jobs below are skipped with it. + if: false uses: ./.github/workflows/run-fuzzer.yml with: fuzz_target: fsst_like diff --git a/.github/workflows/musl.yml b/.github/workflows/musl.yml index f005e07e558..722bebc304d 100644 --- a/.github/workflows/musl.yml +++ b/.github/workflows/musl.yml @@ -28,7 +28,7 @@ jobs: timeout-minutes: 90 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-large/image=ubuntu24-full-x64-pre-v2/tag=rust-build-musl', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-large/image=ubuntu26-full-x64-pre-v2/tag=rust-build-musl', github.run_id) || 'ubuntu-latest' }} container: image: ghcr.io/rust-lang/rust:1-alpine3.24 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index c12b12b8d8e..a6e0b8f1b78 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -182,9 +182,9 @@ jobs: matrix: include: - target: x86_64-unknown-linux-gnu - runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=prepare-java-linux-amd64 + runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=prepare-java-linux-amd64 - target: aarch64-unknown-linux-gnu - runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=arm64-medium/image=ubuntu24-full-arm64-pre-v2/extras=s3-cache/tag=prepare-java-linux-arm64 + runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=arm64-medium/image=ubuntu26-full-arm64-pre-v2/extras=s3-cache/tag=prepare-java-linux-arm64 runs-on: ${{ matrix.runner }} steps: - uses: runs-on/action@v2 diff --git a/.github/workflows/pr-bench-runner.yml b/.github/workflows/pr-bench-runner.yml index 1689f8e7fa0..4e7f73b2af2 100644 --- a/.github/workflows/pr-bench-runner.yml +++ b/.github/workflows/pr-bench-runner.yml @@ -48,7 +48,7 @@ jobs: # forever. With the long `family` list and the longest benchmark id, this label is close. runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.8xlarge+c8g.8xlarge+c8gn.8xlarge+m8gd.8xlarge+m8g.8xlarge+r8gd.8xlarge+r8g.8xlarge+x8g.8xlarge+i8g.8xlarge/image=ubuntu24-full-arm64-pre-v2/tag={1}{2}', github.run_id, inputs.benchmark_id, github.event.pull_request.head.repo.fork == false && '/extras=s3-cache' || '') + && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.8xlarge+c8g.8xlarge+c8gn.8xlarge+m8gd.8xlarge+m8g.8xlarge+r8gd.8xlarge+r8g.8xlarge+x8g.8xlarge+i8g.8xlarge/image=ubuntu26-full-arm64-pre-v2/tag={1}{2}', github.run_id, inputs.benchmark_id, github.event.pull_request.head.repo.fork == false && '/extras=s3-cache' || '') || 'ubuntu-latest' }} steps: - uses: runs-on/action@v2 @@ -93,7 +93,7 @@ jobs: timeout-minutes: 120 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.metal-24xl/image=ubuntu24-full-arm64-pre-v2/tag={1}{2}', github.run_id, inputs.benchmark_id, github.event.pull_request.head.repo.fork == false && '/extras=s3-cache' || '') + && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.metal-24xl/image=ubuntu26-full-arm64-pre-v2/tag={1}{2}', github.run_id, inputs.benchmark_id, github.event.pull_request.head.repo.fork == false && '/extras=s3-cache' || '') || 'ubuntu-latest' }} steps: # `extras=s3-cache` points ACTIONS_RESULTS_URL at the RunsOn artifact proxy, but only diff --git a/.github/workflows/publish-dry-runs.yml b/.github/workflows/publish-dry-runs.yml index 8e12b1e97fb..1c8f5733241 100644 --- a/.github/workflows/publish-dry-runs.yml +++ b/.github/workflows/publish-dry-runs.yml @@ -28,7 +28,7 @@ jobs: if: github.event.pull_request.draft != true runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=python-wheel-build', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-ci-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=python-wheel-build', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 steps: @@ -82,9 +82,9 @@ jobs: matrix: include: - target: x86_64-unknown-linux-gnu - runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=check-java-publish-build-amd64 + runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=check-java-publish-build-amd64 - target: aarch64-unknown-linux-gnu - runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=arm64-medium/image=ubuntu24-full-arm64-pre-v2/extras=s3-cache/tag=check-java-publish-build-arm64 + runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=arm64-medium/image=ubuntu26-full-arm64-pre-v2/extras=s3-cache/tag=check-java-publish-build-arm64 runs-on: ${{ matrix.runner }} steps: - parallel: @@ -123,7 +123,7 @@ jobs: timeout-minutes: 30 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-xsmall/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-publish-dry-run', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-xsmall/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-publish-dry-run', github.run_id) || 'ubuntu-latest' }} steps: - parallel: diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 21f60f2255d..c3713473a3f 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -31,12 +31,12 @@ jobs: # cargo-zigbuild with glibc 2.31 pinning, matching the Python wheel # and JNI builds. - target: aarch64-unknown-linux-gnu - runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=release-vx-aarch64-linux - fallback_runner: ubuntu-24.04 + runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=release-vx-aarch64-linux + fallback_runner: ubuntu-26.04 archive: tgz - target: x86_64-unknown-linux-gnu - runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=release-vx-amd64-linux - fallback_runner: ubuntu-24.04 + runner: runs-on=${{ github.run_id }}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=release-vx-amd64-linux + fallback_runner: ubuntu-26.04 archive: tgz steps: - uses: runs-on/action@v2 diff --git a/.github/workflows/rust-instrumented.yml b/.github/workflows/rust-instrumented.yml index a90110cb7d4..db04cd4ca5d 100644 --- a/.github/workflows/rust-instrumented.yml +++ b/.github/workflows/rust-instrumented.yml @@ -36,7 +36,7 @@ jobs: - suite: tests runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-large/volume=200gb/image=ubuntu24-full-x64-pre-v2/tag=rust-coverage-suite-{1}', github.run_id, matrix.suite) + && format('runs-on={0}/region=us-east-1/runner=amd64-large/volume=200gb/image=ubuntu26-full-x64-pre-v2/tag=rust-coverage-suite-{1}', github.run_id, matrix.suite) || 'ubuntu-latest' }} env: RUSTFLAGS: "-Cinstrument-coverage -A warnings" @@ -113,7 +113,7 @@ jobs: id-token: write runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=cxx-coverage', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=cxx-coverage', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -158,7 +158,7 @@ jobs: name: "Rust tests (${{ matrix.sanitizer }})" runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/extras=s3-cache/tag=rust-test-sanitizer', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/extras=s3-cache/tag=rust-test-sanitizer', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 env: @@ -238,7 +238,7 @@ jobs: RUST_LIB_BACKTRACE: 0 runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/tag=rust-ffi-test-sanitizer', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/tag=rust-ffi-test-sanitizer', github.run_id) || 'ubuntu-latest' }} steps: - parallel: @@ -287,7 +287,7 @@ jobs: if: github.event.pull_request.draft != true runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu24-full-x64-pre-v2/tag=rust-miri', github.run_id) + && format('runs-on={0}/region=us-east-1/runner=amd64-medium/image=ubuntu26-full-x64-pre-v2/tag=rust-miri', github.run_id) || 'ubuntu-latest' }} timeout-minutes: 30 env: diff --git a/.github/workflows/s3-measurements.yml b/.github/workflows/s3-measurements.yml index f52b0c0d857..5e6156b2540 100644 --- a/.github/workflows/s3-measurements.yml +++ b/.github/workflows/s3-measurements.yml @@ -29,7 +29,7 @@ concurrency: jobs: collect: timeout-minutes: 780 - runs-on: runs-on=${{ github.run_id }}/runner=bench-dedicated/family=c8gd.16xlarge/spot=false/image=ubuntu24-full-arm64-pre-v2/tag=s3-measure/extras=s3-cache + runs-on: runs-on=${{ github.run_id }}/runner=bench-dedicated/family=c8gd.16xlarge/spot=false/image=ubuntu26-full-arm64-pre-v2/tag=s3-measure/extras=s3-cache env: AWS_REGION: us-east-1 REMOTE_ROOT: s3://vortex-ci-benchmark-datasets/s3-measurements/${{ github.run_id }}-${{ github.run_attempt }} diff --git a/.github/workflows/sql-bench-matrix.yml b/.github/workflows/sql-bench-matrix.yml index f95a6c1ff3d..7697aaa9af6 100644 --- a/.github/workflows/sql-bench-matrix.yml +++ b/.github/workflows/sql-bench-matrix.yml @@ -49,7 +49,7 @@ jobs: FLAT_LAYOUT_INLINE_ARRAY_NODE: "1" runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.8xlarge+c8g.8xlarge+c8gn.8xlarge+m8gd.8xlarge+m8g.8xlarge+r8gd.8xlarge+r8g.8xlarge+x8g.8xlarge+i8g.8xlarge/image=ubuntu24-full-arm64-pre-v2/tag=build{1}', github.run_id, (inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false) && '/extras=s3-cache' || '') + && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family=c8gd.8xlarge+c8g.8xlarge+c8gn.8xlarge+m8gd.8xlarge+m8g.8xlarge+r8gd.8xlarge+r8g.8xlarge+x8g.8xlarge+i8g.8xlarge/image=ubuntu26-full-arm64-pre-v2/tag=build{1}', github.run_id, (inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false) && '/extras=s3-cache' || '') || 'ubuntu-latest' }} steps: - uses: runs-on/action@v2 @@ -112,7 +112,7 @@ jobs: runs-on: >- ${{ github.repository == 'vortex-data/vortex' - && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family={1}/image=ubuntu24-full-arm64-pre-v2/tag={2}{3}', github.run_id, inputs.machine_type, matrix.id, (inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false) && '/extras=s3-cache' || '') + && format('runs-on={0}/region=us-east-1/runner=bench-dedicated/family={1}/image=ubuntu26-full-arm64-pre-v2/tag={2}{3}', github.run_id, inputs.machine_type, matrix.id, (inputs.mode != 'pr' || github.event.pull_request.head.repo.fork == false) && '/extras=s3-cache' || '') || 'ubuntu-latest' }} steps: - uses: runs-on/action@v2 diff --git a/Cargo.lock b/Cargo.lock index f80c03f000b..b65dfc5765b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -375,7 +375,7 @@ dependencies = [ "snap", "strum_macros 0.28.0", "uuid", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -573,7 +573,7 @@ dependencies = [ "arrow-select 58.4.1", "flatbuffers", "lz4_flex 0.13.1", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -589,7 +589,7 @@ dependencies = [ "arrow-select 59.3.2", "flatbuffers", "lz4_flex 0.14.0", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -1155,9 +1155,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.118.0" +version = "1.119.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4a89786db8ee6dff2c9302a354ef081354fcb0f527e16ee3cb249a6a5cb6df7" +checksum = "3c414f25ec4aa9dc18f5cc8f55e18848bb509fcda4ce7c77bee6072e95806bc9" dependencies = [ "arc-swap", "aws-credential-types", @@ -1180,9 +1180,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.120.0" +version = "1.121.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521c6a11a25f1244efddf947523f277a51a63f0a7ec228f0f62d826e88106366" +checksum = "bc638bb4355e6514334dcc3228cd4622f5ee54d704bd6a9010a5a91d7856d9d9" dependencies = [ "arc-swap", "aws-credential-types", @@ -1205,9 +1205,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.123.0" +version = "1.124.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8754d38d29448bd1d4aa4a6312ed010dfa296b3436eb2c551cc6e42fc6a66a38" +checksum = "3f8a0dd8fbde04ba58ad722113c7addb11bf94cf549b1ea0eb9ea427fb87198a" dependencies = [ "arc-swap", "aws-credential-types", @@ -2441,9 +2441,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04" dependencies = [ "cfg-if", ] @@ -2793,7 +2793,7 @@ dependencies = [ "tokio", "url", "uuid", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -3056,7 +3056,7 @@ dependencies = [ "tokio", "tokio-util", "url", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -4297,9 +4297,9 @@ checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "encoding_rs" -version = "0.8.43" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "844dfa6d76a4e6b9d98e03ae5ead89fbedd02cbd1206b7817d6d3dca62326967" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" dependencies = [ "cfg-if", "core_detect", @@ -6290,7 +6290,7 @@ dependencies = [ "tokio", "tracing", "xxhash-rust", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -6842,9 +6842,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "logos" @@ -8147,7 +8147,7 @@ dependencies = [ "thrift 0.17.0", "tokio", "twox-hash", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -8180,7 +8180,7 @@ dependencies = [ "snap", "thrift 0.23.0", "twox-hash", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -8214,7 +8214,7 @@ dependencies = [ "snap", "tokio", "twox-hash", - "zstd 0.13.3", + "zstd 0.13.4", ] [[package]] @@ -8724,9 +8724,9 @@ dependencies = [ [[package]] name = "pyo3-log" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f64083bd3a16a353d9d62335808e8e13d0552d2a2b83fdb084496192dcfa9fcd" +checksum = "b91aabf1c0d674a2e3b0b55daab6cef1308ce6f0ad3697ae56f4f68db54c98a1" dependencies = [ "arc-swap", "log", @@ -11827,6 +11827,7 @@ dependencies = [ "vortex", "vortex-array", "vortex-arrow", + "vortex-json", "vortex-utils", ] @@ -13323,9 +13324,9 @@ dependencies = [ [[package]] name = "zip" -version = "9.1.3" +version = "9.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1156b39d142a34b999c2310a50455e0cb3760bf7efad0122f796d813bee26ccb" +checksum = "848dad21639597378c3be94c59fd4de683f0f6d8a5387575896e1245737d4f37" dependencies = [ "aes", "bzip2", @@ -13376,11 +13377,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +checksum = "cdb02c3132d251ab1606e9fc913a7da6c6ed08cc263df15edf082e1dc497d157" dependencies = [ - "zstd-safe 7.3.0", + "zstd-safe 7.4.0", ] [[package]] @@ -13394,9 +13395,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "7.3.0" +version = "7.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" +checksum = "1c8ea04668f5de8d8d51051714ba560c9536519cadcdb8829bba4fe2ad159b03" dependencies = [ "zstd-sys", ] diff --git a/bench-orchestrator/bench_orchestrator/ci_matrix/catalog.py b/bench-orchestrator/bench_orchestrator/ci_matrix/catalog.py index 5c649f3aeac..da6e77bd08f 100644 --- a/bench-orchestrator/bench_orchestrator/ci_matrix/catalog.py +++ b/bench-orchestrator/bench_orchestrator/ci_matrix/catalog.py @@ -295,7 +295,10 @@ benchmark=Benchmark.JOB, name="JOB on NVME", # DuckDB only: DataFusion spends minutes per pass on the 17x queries' join orders. - runs={"pr-full": JOB_DUCKDB}, + runs={ + "pr-full": JOB_DUCKDB, + "develop": JOB_DUCKDB, + }, ), BenchmarkCase( id="vortex-queries", diff --git a/bench-orchestrator/bench_orchestrator/cli.py b/bench-orchestrator/bench_orchestrator/cli.py index cd8654b9fe2..959eee6a26a 100644 --- a/bench-orchestrator/bench_orchestrator/cli.py +++ b/bench-orchestrator/bench_orchestrator/cli.py @@ -22,7 +22,6 @@ from .comparison import analyzer from .comparison.reporter import pivot_comparison_table from .config import ( - BENCHMARK_SCAN_V2, Benchmark, BenchmarkTarget, BuildConfig, @@ -33,6 +32,7 @@ parse_formats_json, parse_targets_json, resolve_axis_targets, + uses_scan_v2, ) from .data_cache import S3DataCache, cached_dataset from .runner.builder import BenchmarkBuilder @@ -401,7 +401,7 @@ def run( console.print(f" Targets: {', '.join(map(str, config.targets))}") console.print(f" Iterations: {iterations}") if any(target.engine in {Engine.DATAFUSION, Engine.DUCKDB} for target in config.targets): - console.print(f" Vortex scan: {'V2' if BENCHMARK_SCAN_V2[benchmark] else 'V1'}") + console.print(f" Vortex scan: {'V2' if uses_scan_v2(benchmark) else 'V1'}") if label: console.print(f" Label: {label}") console.print() diff --git a/bench-orchestrator/bench_orchestrator/config.py b/bench-orchestrator/bench_orchestrator/config.py index cc8b31bc2a9..4089ee05edd 100644 --- a/bench-orchestrator/bench_orchestrator/config.py +++ b/bench-orchestrator/bench_orchestrator/config.py @@ -92,23 +92,19 @@ class Benchmark(Enum): } -# Whether each benchmark runs its Vortex scans on the planner-driven V2 scan (`True`) or on V1. -# Every benchmark is listed so its scan version is explicit. -BENCHMARK_SCAN_V2: dict[Benchmark, bool] = { - Benchmark.APPIAN: False, - Benchmark.TPCH: True, - Benchmark.TPCDS: True, - Benchmark.CLICKBENCH: True, - Benchmark.CLICKBENCH_SORTED: False, - Benchmark.FINEWEB: True, - Benchmark.GHARCHIVE: False, - Benchmark.JOB: False, - Benchmark.POLARSIGNALS: False, - Benchmark.PUBLIC_BI: False, - Benchmark.STATPOPGEN: False, - Benchmark.SPATIALBENCH: False, - Benchmark.VORTEX_QUERIES: False, -} +# Benchmarks whose Vortex scans still run on the V1 scan. The orchestrator runs every other +# benchmark on the planner-driven V2 scan, overriding the benchmark binaries' V1 default. +BENCHMARK_SCAN_V1: frozenset[Benchmark] = frozenset( + { + Benchmark.POLARSIGNALS, + Benchmark.STATPOPGEN, + } +) + + +def uses_scan_v2(benchmark: Benchmark) -> bool: + """Return whether `benchmark` runs its Vortex scans on the V2 scan.""" + return benchmark not in BENCHMARK_SCAN_V1 def engines_for_benchmark(benchmark: Benchmark) -> frozenset[Engine]: diff --git a/bench-orchestrator/bench_orchestrator/runner/executor.py b/bench-orchestrator/bench_orchestrator/runner/executor.py index 171a7c7479f..dcb9b1935bd 100644 --- a/bench-orchestrator/bench_orchestrator/runner/executor.py +++ b/bench-orchestrator/bench_orchestrator/runner/executor.py @@ -14,7 +14,7 @@ from rich.console import Console from rich.progress import Progress, SpinnerColumn, TextColumn -from ..config import BENCHMARK_SCAN_V2, Benchmark, Engine, Format +from ..config import Benchmark, Engine, Format, uses_scan_v2 console = Console() @@ -55,7 +55,7 @@ def build_command( if self.backend in {Engine.DATAFUSION, Engine.DUCKDB}: cmd.extend(["--formats", ",".join(fmt.value for fmt in formats)]) - cmd.extend(["--scan-v2", str(BENCHMARK_SCAN_V2[benchmark]).lower()]) + cmd.extend(["--scan-v1", str(not uses_scan_v2(benchmark)).lower()]) if self.backend == Engine.DUCKDB: cmd.append("--delete-duckdb-database") diff --git a/bench-orchestrator/tests/test_executor.py b/bench-orchestrator/tests/test_executor.py index 0d5cb38a0f0..9d97acffc1f 100644 --- a/bench-orchestrator/tests/test_executor.py +++ b/bench-orchestrator/tests/test_executor.py @@ -6,7 +6,7 @@ from pathlib import Path import pytest -from bench_orchestrator.config import BENCHMARK_SCAN_V2, Benchmark, Engine, Format +from bench_orchestrator.config import BENCHMARK_SCAN_V1, Benchmark, Engine, Format from bench_orchestrator.runner.executor import BenchmarkExecutor @@ -47,8 +47,8 @@ def test_build_command_serializes_vortex_spatial_native_format() -> None: assert cmd[cmd.index("--formats") + 1] == "parquet,vortex,vortex-spatial-native" -def test_every_benchmark_has_a_scan_version() -> None: - assert set(BENCHMARK_SCAN_V2) == set(Benchmark) +def test_scan_v1_benchmarks_are_explicit() -> None: + assert BENCHMARK_SCAN_V1 == {Benchmark.POLARSIGNALS, Benchmark.STATPOPGEN} @pytest.mark.parametrize("engine", [Engine.DATAFUSION, Engine.DUCKDB]) @@ -58,7 +58,8 @@ def test_build_command_selects_scan_version(engine: Engine, benchmark: Benchmark cmd = executor.build_command(benchmark=benchmark, formats=[Format.VORTEX]) - assert cmd[cmd.index("--scan-v2") + 1] == str(BENCHMARK_SCAN_V2[benchmark]).lower() + expected = "true" if benchmark in BENCHMARK_SCAN_V1 else "false" + assert cmd[cmd.index("--scan-v1") + 1] == expected def test_build_command_omits_formats_for_lance_backend() -> None: @@ -72,7 +73,7 @@ def test_build_command_omits_formats_for_lance_backend() -> None: assert cmd[0] == "/tmp/lance-bench" assert "--formats" not in cmd - assert "--scan-v2" not in cmd + assert "--scan-v1" not in cmd assert cmd[cmd.index("--queries") + 1] == "3" diff --git a/bench-orchestrator/tests/test_matrix.py b/bench-orchestrator/tests/test_matrix.py index 3e5ebcc1d9f..681482e870c 100644 --- a/bench-orchestrator/tests/test_matrix.py +++ b/bench-orchestrator/tests/test_matrix.py @@ -38,7 +38,7 @@ ) PR_FULL_IDS = (*REGULAR_IDS[:-1], "job-nvme", "vortex-queries") EXPECTED_IDS = { - "develop": REGULAR_IDS, + "develop": PR_FULL_IDS, "pr": tuple( benchmark_id for benchmark_id in REGULAR_IDS diff --git a/benchmarks/bench-support/src/lib.rs b/benchmarks/bench-support/src/lib.rs index 912605c781e..988df34b529 100644 --- a/benchmarks/bench-support/src/lib.rs +++ b/benchmarks/bench-support/src/lib.rs @@ -12,10 +12,10 @@ use quote::quote; use syn::ItemFn; use syn::parse_macro_input; -/// Measure this benchmark on every walltime CPU-feature leg instead of in simulation. +/// Measure this benchmark on walltime CPU-feature legs instead of in simulation. /// -/// Takes no argument: the benchmark runs on all of them. Write it *above* `#[divan::bench]`, -/// whose arguments it fills in — the name is qualified with the leg that produced it, both as +/// Runs on every leg except those named in `exclude = ["neon", ...]`. Write it above +/// `#[divan::bench]`, whose arguments it fills in. The name is qualified with the leg, both as /// a `::` component the CI filter selects on and as a suffix on the leaf name CodSpeed /// reports under, so the legs report one series each rather than fighting over a shared name. /// `ignore` takes the benchmark out of the sharded simulation job. A plain `cargo bench` runs @@ -30,22 +30,25 @@ use syn::parse_macro_input; /// Spell it out in full rather than importing it: benchmark files are read a function at a /// time, and the path says where the behaviour comes from. /// -/// This is for code that is written once and *compiled* differently per feature set — a +/// This is for code that is written once and *compiled* differently per feature set: a /// shipped entry point that selects its kernel through `cfg(target_feature)`, or a scalar /// loop whose auto-vectorization depends on the build. A hand-written kernel for one /// instruction set extension is a different thing: it cannot run on the other legs, so it /// does not belong here. Keep those on `#[cfg(not(codspeed))]` for local A/B runs. #[proc_macro_attribute] pub fn cpu_features(attr: TokenStream, item: TokenStream) -> TokenStream { - if !attr.is_empty() { - let attr = TokenStream2::from(attr); - return syn::Error::new_spanned( - attr, - "`#[cpu_features]` takes no argument; a tagged benchmark runs on every feature-set leg", - ) - .to_compile_error() - .into(); - } + let excluded = if attr.is_empty() { + quote!(false) + } else { + let argument = parse_macro_input!(attr as syn::MetaNameValue); + if !argument.path.is_ident("exclude") { + return syn::Error::new_spanned(argument, "expected `exclude = [\"feature\", ...]`") + .to_compile_error() + .into(); + } + let features = argument.value; + quote!((#features).contains(&env!("VORTEX_BENCH_VARIANT"))) + }; let mut function = parse_macro_input!(item as ItemFn); @@ -117,7 +120,7 @@ pub fn cpu_features(attr: TokenStream, item: TokenStream) -> TokenStream { #name, env!("VORTEX_BENCH_SUFFIX"), ), - ignore = env!("VORTEX_BENCH_VARIANT") == "simulation", + ignore = env!("VORTEX_BENCH_VARIANT") == "simulation" || #excluded, ) }; diff --git a/benchmarks/datafusion-bench/src/main.rs b/benchmarks/datafusion-bench/src/main.rs index 765b34fafcf..e2acd536fdc 100644 --- a/benchmarks/datafusion-bench/src/main.rs +++ b/benchmarks/datafusion-bench/src/main.rs @@ -120,9 +120,9 @@ struct Args { #[arg(long, value_delimiter = ',', value_parser = value_parser!(Format))] formats: Vec, - /// Use the planner-driven V2 Vortex scan. - #[arg(long, default_value_t = false, action = clap::ArgAction::Set)] - scan_v2: bool, + /// Use the V1 Vortex scan. Pass `--scan-v1 false` to use the planner-driven V2 scan. + #[arg(long, default_value_t = true, action = clap::ArgAction::Set)] + scan_v1: bool, #[arg(long = "opt", value_delimiter = ',', value_parser = value_parser!(Opt))] options: Vec, @@ -136,7 +136,7 @@ async fn main() -> anyhow::Result<()> { vortex_bench::configure_allocator(); let args = Args::parse(); let opts = Opts::from(args.options); - let scan_v2 = args.scan_v2; + let scan_v2 = !args.scan_v1; set_join_set_tracer(get_static_tracer())?; setup_logging_and_tracing(args.verbose, args.tracing)?; diff --git a/benchmarks/duckdb-bench/src/main.rs b/benchmarks/duckdb-bench/src/main.rs index 5a9a0f2f4c9..bac918790b3 100644 --- a/benchmarks/duckdb-bench/src/main.rs +++ b/benchmarks/duckdb-bench/src/main.rs @@ -103,9 +103,9 @@ struct Args { )] reuse: bool, - /// Use the planner-driven V2 Vortex scan. - #[arg(long, default_value_t = false, action = clap::ArgAction::Set)] - scan_v2: bool, + /// Use the V1 Vortex scan. Pass `--scan-v1 false` to use the planner-driven V2 scan. + #[arg(long, default_value_t = true, action = clap::ArgAction::Set)] + scan_v1: bool, } #[global_allocator] @@ -116,7 +116,7 @@ fn main() -> anyhow::Result<()> { let args = Args::parse(); let opts = Opts::from(args.options); - vortex_duckdb::set_scan_v2(args.scan_v2); + vortex_duckdb::set_scan_v2(!args.scan_v1); setup_logging_and_tracing(args.verbose, args.tracing)?; diff --git a/docs/developer-guide/benchmarking.md b/docs/developer-guide/benchmarking.md index 91dd8a77b00..8fcc9d756e2 100644 --- a/docs/developer-guide/benchmarking.md +++ b/docs/developer-guide/benchmarking.md @@ -1,292 +1,235 @@ # Benchmarking -Vortex has two categories of benchmarks: microbenchmarks for individual operations, and SQL -benchmarks for end-to-end query performance. +Vortex uses microbenchmarks for individual operations and SQL benchmarks for end-to-end query +performance. ## Microbenchmarks -Microbenchmarks use the Divan framework and live in `benches/` directories within individual crates. -Every microbenchmark binary **must** use `mimalloc` as its global allocator (see -[Use `mimalloc` as the global allocator](#use-mimalloc-as-the-global-allocator)). - -Run microbenchmarks for a specific crate with: +Rust microbenchmarks use Divan and live in each crate's `benches/` directory. Run a crate's +benchmarks with: ```bash cargo bench -p ``` -## Best Practices - -### Separate setup from profiled code +### Separate setup from measured work -Always use `bencher.with_inputs(|| ...)` so fixture construction is excluded from timing: +Use `with_inputs` to construct fixtures outside the timed closure: ```rust bencher - .with_inputs(|| bench_fixture())) - .bench_refs(|(array, indices)| { - array.take(indices.to_array()).unwrap() - }); + .with_inputs(|| bench_fixture()) + .bench_refs(|(array, indices)| array.take(indices.to_array()).unwrap()); ``` -### Exclude `Drop` from measurements - -Divan measures only the closure body, **not** the `Drop` of its return value. -Structure your benchmark so that expensive drops happen via the return value or -via bench_refs inputs. - -- **Return the value** from the closure — Divan will drop it after timing stops: - - ```rust - bencher - .with_inputs(|| make_big_vec()) - .bench_values(|v| transform(v)) // drop of the result is NOT timed - ``` +Initialize one-time process state before `divan::main()`. Lazy session setup or regex initialization +inside the first measured iteration can dominate the operation, especially under simulation, which +measures one cold iteration. See `vortex-array/benches/like.rs` for an example of initializing this +state before measurement. -- **Use `bench_refs`** — the input is dropped after the entire sample loop, not per-iteration: +### Exclude destruction when it is not part of the operation - ```rust - bencher - .with_inputs(|| make_big_vec()) - .bench_refs(|v| v.sort()) // v is dropped outside the timed region - ``` +Divan drops the closure's return value after timing stops. Return the result instead of discarding +it inside the closure: -Structure your benchmark so that expensive drops happen via the return value or via `bench_refs` inputs. - -### Black-box inputs to prevent compiler optimization - -The compiler can constant-fold or eliminate work if it can prove that inputs are known at -compile time. +```rust +bencher + .with_inputs(|| make_big_vec()) + .bench_values(|v| transform(v)); +``` -Values provided through `with_inputs` are automatically black-boxed by Divan — no action -needed: +Use `bench_refs` when the operation mutates an input in place. Divan keeps the input alive until the +sample ends, so its destruction is outside the timed region: ```rust -// ✓ `array` and `indices` are automatically black-boxed by Divan bencher - .with_inputs(|| (&prebuilt_array, &prebuilt_indices)) - .bench_refs(|(array, indices)| array.take(indices.to_array()).unwrap()); + .with_inputs(|| make_big_vec()) + .bench_refs(|v| v.sort()); ``` -### Captured variables +Other values dropped inside the closure contribute to the measurement. Keep those drops only when +they are part of the cost being measured, such as an allocate-and-free benchmark. + +### Prevent the compiler from removing work -Variables captured from the surrounding scope are _not_ black-boxed. Wrap them with -`divan::black_box()` or pass them through `with_inputs` instead: +The compiler can fold or remove work when it knows the inputs. Divan black-boxes inputs from +`with_inputs` and the closure's return value to prevent that optimization. Captured values do not +receive that protection: ```rust let array = make_array(); - -// ✗ `array` is captured — the compiler may optimize based on its known contents bencher.bench(|| process(&array)); +``` + +Pass the input through `with_inputs` instead: -// ✓ Option A: pass through with_inputs +```rust +let array = make_array(); bencher .with_inputs(|| &array) .bench_refs(|array| process(array)); +``` -// ✓ Option B: explicit black_box on the capture +An explicit `black_box` also protects a captured input: + +```rust bencher.bench(|| process(divan::black_box(&array))); ``` -### Return values and manual loops - -Return values are automatically black-boxed. You only need explicit -`black_box` for side-effect-free results inside manual loops: +Inside a manual loop, black-box each result so the compiler cannot discard earlier iterations: ```rust -bencher - .with_inputs(|| (&array, SESSION.create_execution_ctx())) - .bench_refs(|(array, ctx)| { - for idx in 0..len { - divan::black_box(array.execute_scalar(idx, ctx).unwrap()); - } - }); +bencher.bench(|| { + for value in divan::black_box(&values) { + divan::black_box(process(value)); + } +}); ``` -### Use deterministic, seeded RNG +### Choose reproducible inputs -Always use `StdRng::seed_from_u64(N)` for reproducible data generation: +Use a seeded generator such as `StdRng::seed_from_u64(0)` for random data. Unseeded random data can +change the measured work between runs even when the code stays the same. -```rust -let mut rng = StdRng::seed_from_u64(0); -``` +Choose inputs that exercise useful work. A zero-byte allocation or a compaction with nothing to move +can measure mostly the benchmark harness. For tiny operations, repeat a fixed amount of work and +black-box each result. Size inputs by bytes when comparing element types of different widths. + +Keep each iteration below 1 ms so the suite remains practical to run. This is the cost of one +closure invocation, not the total time of the benchmark binary. Check the per-iteration `HEAD` +value in the CodSpeed report before merging a new benchmark. Reduce the input size, split a larger +workload into parameterized cases, or keep it local if it cannot fit this budget. + +For CPU kernels, keep the working set within the runner's L2 cache unless memory bandwidth is the +intended measurement. `vortex-array/benches/filter_fixed_width.rs` shows how sizing by bytes keeps +different element widths above the harness cost without making the widest types too slow. -### Parameterize with `args`, `consts`, and `types` +### Parameterize workloads -Use Divan's parameterization features and define parameter arrays as named constants: +Use Divan's `args`, `consts`, and `types` for distinct workloads. Keep shared parameter lists in named +constants: ```rust const NUM_INDICES: &[usize] = &[1_000, 10_000, 100_000]; const VECTOR_SIZE: &[usize] = &[16, 256, 2048, 8192]; #[divan::bench(args = NUM_INDICES, consts = VECTOR_SIZE)] -fn my_bench(bencher: Bencher, num_indices: usize) { ... } +fn my_bench(bencher: Bencher, num_indices: usize) { /* ... */ } ``` -### Keep per-iteration execution time under 1 ms - -**1 ms is the maximum, not a soft target.** Each individual iteration of the benchmarked -closure must complete in less than 1 ms. This is to keep benchmarks snappy, locally and on -CI. - -A benchmark that needs longer than that is measuring too much work at once. Shrink the -input size until a single iteration fits, split it into smaller parameterized cases, or -gate it with `#[cfg(not(codspeed))]` if it genuinely cannot be made to fit. - -The number to check against the budget is the per-iteration time, not the time the whole -benchmark binary takes. CodSpeed reports exactly that: its performance report on a pull -request lists the per-iteration time under `HEAD` for every benchmark the pull request adds -or changes, so check any new benchmark there before merging. - -### Keep per-iteration work above the harness floor - -The budget has a floor as well as a ceiling. CodSpeed runs each benchmark once and adds a fixed -cost of roughly half a microsecond of reported time around the closure. A closure that does tens -of nanoseconds of real work, such as one small allocation or a fast path that finds nothing to -do, reports mostly that floor, and the floor moves by more than 10% between runs of identical -code. Such benchmarks flag regressions on pull requests that do not touch Rust at all. - -Aim for at least a few microseconds of real work per iteration: - -- When the operation itself is tiny, repeat it a fixed number of times inside the closure and - black-box each result, as `vortex-buffer/benches/allocation.rs` does. -- Drop degenerate inputs, such as a zero-byte allocation or a compaction with nothing to move. -- Size inputs by bytes rather than element count so narrow and wide types land in the same - range, as `vortex-array/benches/filter_fixed_width.rs` does. - -Benchmarks tagged `#[cpu_features]` run on the walltime legs instead, where the floor is timer -resolution and per-iteration jitter. Give each sample of those at least tens of microseconds, -with more work per iteration or with a fixed `sample_size` (see -[How CodSpeed measures a benchmark](#how-codspeed-measures-a-benchmark)). Keep the working set -inside the L2 cache of the leg machines (1 MiB on the Graviton leg) when the benchmark is about -kernel code rather than memory bandwidth. - -### Gate CodSpeed-incompatible benchmarks - -Use `#[cfg(not(codspeed))]` for benchmarks that are incompatible with CodSpeed. - -### Keep third-party and frozen baselines out of CodSpeed - -A benchmark of code that Vortex does not own, such as an arrow-rs kernel over the same data, or -of a frozen copy of an old Vortex implementation, cannot regress because of a pull request, so a -change in its number is never actionable. On the walltime legs these baselines were among the -noisiest series in the suite. Keep them for local `cargo bench` comparisons, but gate them with -`#[cfg(not(codspeed))]` and leave them untagged, as `vortex-compute/benches/lane_kernels.rs` and -`vortex-buffer/benches/collect_bool.rs` do. - -### How CodSpeed measures a benchmark - -Divan runs the benchmark closure in _iterations_ and groups them into _samples_. The _sample size_ -is the number of iterations in one sample. Divan times each sample as a whole and reports the time -per iteration. - -CodSpeed measures a benchmark with one of two instruments. Benchmarks without `#[cpu_features]` -run in _simulation_. Benchmarks with `#[cpu_features]` run on the _walltime legs_. - -**Simulation.** [CodSpeed's CPU simulation](https://codspeed.io/docs/instruments/cpu) runs each -benchmark **exactly once** and estimates CPU cycles from the instruction trace, including cache -and memory access costs. As a result: - -- `sample_count` and `sample_size` have no effect. -- System load does not change the result, because the estimate does not come from a clock. Some - benchmarks still switch between two values on code that did not change (see - [Known unstable benchmarks](#known-unstable-benchmarks)). -- System calls are not measured. A benchmark that depends on I/O or kernel calls **must** use the - [walltime instrument](https://codspeed.io/docs/instruments/walltime) or be gated with - `#[cfg(not(codspeed))]`. The simulation job keeps mimalloc and glibc from returning freed - memory to the OS, so that allocator system calls do not land in a measured iteration. - -**Walltime legs.** A walltime leg is one CI job that measures wall-clock time on a dedicated -machine for one CPU feature set (AVX2, AVX-512 or NEON). `.github/workflows/codspeed.yml` defines -the legs. On each leg: - -- Divan takes 1000 samples (`DIVAN_SAMPLE_COUNT` in the workflow). -- Divan picks the sample size from the first sample. If the first sample takes more than 100 times - the timer precision (about 3 µs), divan keeps one iteration per sample. The first sample is cold - and slow, so most walltime benchmarks run with one iteration per sample. -- CodSpeed compares the **fastest** sample of the pull request run with the fastest sample of the - base run, not the median. - -With one iteration per sample, the fastest sample is the single fastest iteration out of 1000, so -one unusually fast iteration decides the result. A benchmark close to the 3 µs limit can also get a -different sample size in each run, and each sample size reports a different time. - -For a short walltime benchmark, set `sample_size` in `#[divan::bench]` so that one sample takes -tens of microseconds, as `vortex-buffer/benches/collect_bool.rs` and -`encodings/fastlanes/benches/bitpack_blocked.rs` do. CodSpeed then compares the average of several -iterations, and the sample size is the same in every run. Write the value as a literal: the -simulation build ignores the setting, so a named constant is unused under `--cfg codspeed`. - -Do not set `DIVAN_SAMPLE_SIZE` in the workflow instead. The variable overrides the setting of every -benchmark, and divan keeps the inputs and outputs of a whole sample alive until the sample ends. A -large global sample size changes the memory behavior of the benchmarks that allocate large -outputs. - ### Use `mimalloc` as the global allocator -Every microbenchmark binary **must** use `mimalloc` as its global allocator. This includes the -CUDA and DuckDB benchmarks. Put these lines in the main file of each benchmark target, and keep -them when you rewrite the file: +Every microbenchmark binary must use `mimalloc`, including CUDA and DuckDB benchmarks: ```rust use mimalloc::MiMalloc; + #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; ``` -The cost of the system allocator depends on its state, which differs between runner images and -between runs. Allocation inside a timed region made several simulation benchmarks flip between two -values on pull requests that did not change the measured code. `mimalloc` does the same work every -time, and one allocator for every binary means that no benchmark measures a different allocator -from its neighbors. Each crate with benchmarks already has the `mimalloc` dev-dependency. - -## What Not to Do - -The mistakes below have made CodSpeed report regressions on pull requests that did not change the -measured code. Such reports teach reviewers to ignore CodSpeed, and then real regressions pass -unnoticed. When a section above explains a rule, the rule links to that section. - -- **Do not write a benchmark that does tens of nanoseconds of work, or that uses degenerate input - such as a zero-byte allocation.** See - [Keep per-iteration work above the harness floor](#keep-per-iteration-work-above-the-harness-floor). -- **Do not leave a walltime benchmark of a few microseconds to divan's sample-size tuning.** See - [How CodSpeed measures a benchmark](#how-codspeed-measures-a-benchmark). -- **Do not judge a walltime benchmark by its median alone.** CodSpeed compares the fastest sample, - so a benchmark with a stable median can still report a 12% change. See - [How CodSpeed measures a benchmark](#how-codspeed-measures-a-benchmark). -- **Do not measure code that a pull request cannot change.** See - [Keep third-party and frozen baselines out of CodSpeed](#keep-third-party-and-frozen-baselines-out-of-codspeed). -- **Do not leave one-time process setup to the first measured iteration.** In simulation, each - benchmark runs one cold iteration. Lazy statics, such as the session id interner or the state - that the first regex compilation creates, then initialize inside whichever benchmark runs - first, often with system calls. Run the operation once in `main()` before `divan::main()`, as - `vortex-array/benches/like.rs` and `vortex-array/benches/run_end_filter.rs` do. -- **Do not drop the `mimalloc` global allocator when you rewrite a benchmark file.** See - [Use `mimalloc` as the global allocator](#use-mimalloc-as-the-global-allocator). -- **Do not read a one-time change in later benchmarks as a regression after you add or remove - benchmarks.** All benchmarks of one binary run in one process and share its allocator state, so - a change to the earlier benchmarks can move the later ones once. -- **Do not acknowledge a flagged benchmark in CodSpeed without a cause.** If the pull request - cannot reach the flagged code, open the log of the CodSpeed job and compare the divan table of - the run with the table of the base run. If the median did not move, the report comes from the - fastest-sample comparison. Fix the benchmark, or add it to the list below. - -### Known unstable benchmarks - -The benchmarks below switch between a fast state and a slow state for a whole run, on code that -did not change. The cause is not known. For the NEON `threshold` and `filter` cases, a larger -iteration does not help, because the slow state also slows the work for each element, not only a -fixed cost for each call. A report on one of these benchmarks is not evidence of a regression -unless the pull request changes the code that the benchmark measures. - -| Benchmark | Instrument | Observed values | -| --- | --- | --- | -| `bitpacking_take`: `threshold[8, 64, 80]` | NEON leg | 1.4 to 2 times slower in 15% to 30% of runs | -| `bitpacking_filter`: `filter[8, 64, 80]` | NEON leg | 1.4 to 2 times slower in 15% to 30% of runs | -| `binary_ops`: `mul_u64_nonnull` | NEON leg | About 20 µs, or about 40 µs in 17% of runs | -| `row_fn_utf8_input`: `starts_with[8 and 64, VarBin]` | AVX2 and AVX-512 legs | 12% to 17% slower in 40% to 50% of runs | -| `bitpacking_take`: `isolated_runs[u32, (16, 0)]` | Simulation | 78 µs or 88 µs | -| `chunk_array_builder`: `chunked_opt_bool_canonical_into[(1000, 10)]` | Simulation | 55 µs or 65.5 µs | +Each crate with benchmarks already has the dev-dependency. A consistent allocator removes one source +of differences between binaries, but allocation can still depend on process state and earlier +benchmarks. Keep the allocator declaration when rewriting a benchmark file. + +The simulation workflow disables mimalloc purging and limits glibc heap trimming to keep allocator +system calls out of measured iterations. These settings reduce noise but do not make allocation +independent of process history. A target's simulation benchmarks share one process, so adding, +removing, or reordering earlier benchmarks can change the allocator state seen by later ones. + +## CodSpeed + +[`.github/workflows/codspeed.yml`](https://github.com/vortex-data/vortex/blob/develop/.github/workflows/codspeed.yml) +defines the measurement jobs. Rust CPU benchmarks use two instruments: + +- [CPU simulation](https://codspeed.io/docs/instruments/cpu) runs benchmarks without + `#[vortex_bench_support::cpu_features]`. It estimates cycles from one execution's instruction + trace, including cache and memory access costs. Divan's sampling settings have no effect. +- [Walltime](https://codspeed.io/docs/instruments/walltime) runs CPU feature variants on dedicated + AVX2, AVX-512, and NEON machines. It measures elapsed time, so sampling and machine state matter. + +### Give short benchmarks enough measured work + +Simulation has a fixed harness cost. A single small allocation can take only tens of nanoseconds, +so most of its reported time can come from that cost. Aim for at least a few microseconds of useful +work per iteration. `vortex-buffer/benches/allocation.rs` repeats allocate-and-drop pairs a fixed +number of times and black-boxes each result to keep the operation visible above this cost. + +For walltime, Divan groups iterations into samples and reports time per iteration. CodSpeed compares +the fastest sample, so a stable median alone does not establish a repeatable benchmark. CI collects +1000 samples, but one unusually fast sample can still decide the result. + +Divan chooses the sample size from early timing measurements. A cold first iteration can be slow +enough that Divan keeps one iteration per sample even when later iterations are much faster. With +1000 single-iteration samples, the CodSpeed result is then the single fastest iteration. A case +near Divan's sampling cutoff can also get a different sample size in each run. + +For a short walltime benchmark, set a fixed `sample_size` so each sample takes at least tens of +microseconds. This averages several iterations and avoids changes caused by Divan choosing a +different sample size between runs: + +```rust +#[vortex_bench_support::cpu_features] +#[divan::bench(args = [64, 80], sample_size = 64)] +fn filter(bencher: Bencher, selected_per_chunk: usize) { + // ... +} +``` + +For example, the AVX2 bitpacked filter varied by 9.36% across 30 processes on three matching hosts +with one iteration per sample. Setting `sample_size = 64` reduced that spread to 1.45% with the same +executable. [PR #11110](https://github.com/vortex-data/vortex/pull/11110) records the configuration +and measurements. + +Choose the sample size for the operation. Do not set a large global `DIVAN_SAMPLE_SIZE`: Divan keeps +sample inputs and outputs alive until the sample ends, so batching changes memory use for operations +that allocate. Use a literal in the attribute because simulation ignores the setting and can leave +a named constant unused. + +### Keep incompatible benchmarks out of automatic runs + +Simulation excludes system-call time. Use walltime for operations that depend on I/O or kernel calls. +Memory mapping and disabling background workers do not remove runtime polling on the calling thread. +Moving an operation entirely into memory changes what the benchmark measures. + +Use automatic reports to track maintained Vortex entry points. Keep third-party kernels and frozen +implementations available for local comparisons, gated with `#[cfg(not(codspeed))]` and without +`#[vortex_bench_support::cpu_features]`. These baselines help compare implementations locally, but +unexplained changes in their automatic results do not identify a change in maintained Vortex code. + +Use `#[cfg(not(codspeed))]` for a Rust benchmark that cannot produce useful CodSpeed measurements. +For a tagged benchmark, `#[vortex_bench_support::cpu_features(exclude = ["neon"])]` skips the named +walltime leg while keeping the other legs and local runs. When only one input case is unreliable, +filter the benchmark's argument list instead. Record the reason beside the exclusion and keep the +supporting measurements in the PR. Keep CI commands independent of individual benchmark names. + +### Investigate reports on unchanged code + +Check the exact base and head commits and the measurement instrument before attributing a change. +An old comparison base can include unrelated changes. For walltime, compare the Divan tables in the +job logs, including the minimum and the median. For simulation, inspect the callgraph for changes in +measured work, allocation, or runtime polling. + +If the median stays stable while the minimum moves, investigate sampling before treating the alert +as an operation becoming slower. If several later benchmarks shift after an earlier benchmark is +added or removed, investigate shared allocator state. Neither pattern proves the cause on its own. +Simulation avoids clock noise, but changes in allocation or runtime polling can still change the +instruction trace on unchanged code. + +Repeat the same executable in fresh processes on matching hardware to check measurement noise, then +compare independent builds to check sensitivity to code placement. Keep commands, sampling settings, +and environment fixed. One repeatable executable does not establish that unrelated source changes +cannot affect its measurements. + +Record the executable identity, base and head commits, hardware, commands, and environment with the +results. Use the instrument's metric, such as minimum sample time for walltime, rather than process +elapsed time. Check spread across processes with `max / min - 1`. Include enough repeats and hosts +to expose occasional slow states, rather than relying on several samples from one process. + +If a case remains noisy after fixing setup and sampling, exclude it from automatic runs with the +evidence in the PR. Before restoring it, demonstrate repeatability and check that a deliberate +increase in measured work remains visible. Stable results are not useful if the measurement no +longer responds to a real regression. Do not raise the regression threshold to hide noise. ## SQL Benchmarks diff --git a/docs/developer-guide/integrations/datafusion.md b/docs/developer-guide/integrations/datafusion.md index 7a21575cc68..eb85dcbc1ee 100644 --- a/docs/developer-guide/integrations/datafusion.md +++ b/docs/developer-guide/integrations/datafusion.md @@ -1,8 +1,53 @@ # DataFusion -The `vortex-datafusion` crate integrates Vortex as a native file format in Apache DataFusion. -It registers a `FileFormat` and `FileSource` so that DataFusion's query planner can discover, -partition, and scan Vortex files using the same machinery it uses for Parquet and CSV. +Vortex provides a +[`vortex-datafusion`](https://crates.io/crates/vortex-datafusion) crate for +`.vortex` file support in DataFusion. + +## Setup and registration + +Add the dependency: + +```toml +[dependencies] +vortex-datafusion = "" +``` + +Register the Vortex format with a `SessionContext`: + +:::{literalinclude} ../../../vortex-datafusion/src/persistent/tests.rs +:language: rust +:dedent: +:start-after: [setup] +:end-before: [setup] +::: + +Create an external table and query it: + +:::{literalinclude} ../../../vortex-datafusion/src/persistent/tests.rs +:language: rust +:dedent: +:start-after: [create] +:end-before: [create] +::: + +You can also register a `ListingTable` directly: + +:::{literalinclude} ../../../vortex-datafusion/examples/vortex_table.rs +:language: rust +:dedent: +:start-after: [register] +:end-before: [register] +::: + +Write query results to Vortex using `INSERT INTO`: + +:::{literalinclude} ../../../vortex-datafusion/src/persistent/tests.rs +:language: rust +:dedent: +:start-after: [write] +:end-before: [write] +::: ## Registration @@ -25,18 +70,6 @@ Layout readers are cached across partitions using a shared concurrent map keyed This avoids redundant footer parsing when the same file is accessed by multiple partitions or repeated queries. -## Threading Model - -DataFusion runs on Tokio, and the Vortex integration operates entirely within that async -context. The Vortex session is configured with `with_tokio()` to capture the current Tokio -runtime handle. All I/O -- file opens, segment reads, object store fetches -- is dispatched as -Tokio tasks and scheduled across Tokio's multi-threaded executor. - -DataFusion's physical executor manages parallelism by assigning partitions to its own task pool. -Each partition opens its files and drives a `ScanBuilder` that returns an async stream of -record batches. Multiple partitions execute concurrently, with DataFusion controlling the degree -of parallelism. - ## Filter and Projection Pushdown The integration converts DataFusion physical expressions into Vortex expressions using an @@ -65,13 +98,3 @@ schema. Vortex arrays produced by the scan are converted to Arrow `RecordBatch`es for consumption by DataFusion. Batches are sliced to respect DataFusion's configured batch size preference. - -## Future Work - -The current integration builds directly on the `ScanBuilder` and layout reader APIs. Future work -will migrate it to use the [Scan API](/concepts/scanning) `Source` trait, which will simplify -the integration by providing a standard interface for file discovery, partitioning, and pushdown -that is shared across all engine integrations. - -Better support for dynamic expressions would enable use-cases like top-k queries, where the scan's -filter expression is updated during execution as the query engine discovers tighter bounds. diff --git a/docs/developer-guide/internals/execution.md b/docs/developer-guide/internals/execution.md index 15ba16a8135..51083d6260f 100644 --- a/docs/developer-guide/internals/execution.md +++ b/docs/developer-guide/internals/execution.md @@ -401,6 +401,65 @@ Rules of thumb: - Treat `execute` as the fallback. If no reduce rule or parent kernel applies, the encoding decodes itself and uses `ExecuteSlot` or `AppendChild` to tell the scheduler what to do next. +## Executing Scalar Functions + +When no reduce rule or parent kernel handles a `ScalarFnArray`, the executor calls its +`VTable::execute`, as for any other encoding. That passes the array's children as inputs to the +function's `ScalarFnVTable::execute_step`, which returns a `ScalarFnExecutionResult`: + +- `ScalarFnExecutionResult::done(array)` -- the function's result. +- `ScalarFnExecutionResult::execute_input::(i)` -- a request to execute input `i` until it + matches the `Matcher` `M`. The `ScalarFnArray` turns this into `ExecuteSlot(i, M::matches)`, + so the scheduler executes the input on its explicit stack and then calls `execute_step` again + with the executed input in its place. + +`Not` handles constant and canonical boolean inputs, and asks for anything else to be executed +to columnar form: + +```rust +fn execute_step( + &self, + _options: &EmptyOptions, + args: &dyn ExecutionArgs, + _ctx: &mut ExecutionCtx, +) -> VortexResult { + match not_columnar(&args.get(0)?, args.row_count())? { + Some(result) => Ok(ScalarFnExecutionResult::done(result)), + None => Ok(ScalarFnExecutionResult::execute_input::(0)), + } +} +``` + +Because the scheduler executes inputs, a deep tree such as `not(not(not(chunked)))` runs without +recursion, and each input gets its reduce rules and parent kernels applied before it is forced. +Only request an input that does not already match `M`; such a request cannot make progress and +fails with an error. + +### Migrating from `execute` to `execute_step` + +`ScalarFnVTable::execute` is the older API. It runs the function over its inputs and executes +any input it cannot use inline. `execute_step` replaces it. Until every function is migrated, +`execute` stays a required method, and `execute_step` defaults to calling it and returning its +result as `done`. + +Vortex only calls `execute` through that default. The iterative executor calls `execute_step`, +and `ScalarFnRef::execute`, used for example by `scalar_at` on a `ScalarFnArray`, is also +defined in terms of `execute_step`: on an input request it executes that input one step and +returns the function lazily over it as a new `ScalarFnArray`. So once a function implements +`execute_step`, its `execute` is never called. + +To migrate a function: + +1. Implement `execute_step`. Return `done` for inputs the function can compute over directly. +2. Where `execute` executed an input itself (for example + `child.execute::(ctx)?` followed by a retry), return + `execute_input::(i)` with the matcher the function needs, such as `AnyColumnar` or + `AnyCanonical`. +3. Replace the body of `execute` with `vortex_panic!`, as `Not` does. + +Once every function is migrated, `execute` will be removed from the trait and `execute_step` +will become required. + ## Future Work The execution model is designed to support additional function types beyond scalar functions: diff --git a/docs/developer-guide/language-bindings.md b/docs/developer-guide/language-bindings.md index 8905364910b..8c305a3f96b 100644 --- a/docs/developer-guide/language-bindings.md +++ b/docs/developer-guide/language-bindings.md @@ -67,14 +67,13 @@ layout plugins, and extension DTypes. ## Per-Language Status -| Language | Current Tier | Target Tier | Technology | Notes | -|---------------|--------------|-------------|------------|-----------------------------------------------| -| Rust | 3 | 3 | Native | Future: stable plugin API via C ABI | -| Python | ~2 | 3 | PyO3 | Already has native expressions + array access | -| C | ~1 | 2 | cbindgen | Foundation ABI for all non-Rust bindings | -| C++ | ~1 | 2 | cxx -> C | Migrate from cxx to wrap C API | -| Java (JNI) | ~1 | 1 | JNI | Broad JDK compatibility, Arrow-based | -| Java (Panama) | — | 2 | Panama FFI | Direct C ABI access, requires JDK 22+ | +| Language | Current Tier | Technology | +|---------------|--------------|------------| +| Rust | 3 | Native | +| Python | ~2 | PyO3 | +| C | ~1 | cbindgen | +| C++ | ~1 | C API | +| Java (JNI) | ~1 | JNI | ### Rust @@ -96,21 +95,8 @@ evolves with the project and should be statically linked. In the future, a subse be flagged as stable for use via dynamic linking. The target is Tier 2, which requires array tree inspection, compute execution, and stabilized error handling and memory ownership conventions. -### C++ - -C++ bindings currently use [cxx](https://cxx.rs) for Rust interop. The plan is to migrate to -wrapping the C API directly, providing RAII wrappers and CMake integration. Target is Tier 2. - ### Java (JNI) Java JNI bindings provide Tier ~1 capabilities today (Arrow I/O and basic scan). JNI will remain at Tier 1 for broad JDK compatibility. This is the current integration point for Spark and Trino connectors. - -### Java (Panama) - -A new binding layer using Java's Foreign Function & Memory API (Panama) to call the C API -directly. Panama enables native array access without JNI overhead, targeting Tier 2. Requires -JDK 22+. Trino already supports JDK 22 and can adopt Panama immediately. Spark targets older LTS -releases and will not support Panama for some time, so the JNI path remains essential for Spark -integration. diff --git a/docs/specs/versioning/using-editions.md b/docs/specs/versioning/using-editions.md index 7f345db4084..24cacfdd233 100644 --- a/docs/specs/versioning/using-editions.md +++ b/docs/specs/versioning/using-editions.md @@ -35,6 +35,21 @@ currently enables `core2026.08.3`. Calling `enable_edition` replaces the enabled same family. Set the selection before starting the write, because that is when the writer captures the permitted wire IDs. +The Java and Python bindings select an edition by its name. In Java, enable the edition on the +session before you open a writer: + +```java +Session session = Session.create(); +session.enableEdition("core2025.10.0"); +``` + +In Python, set the edition on the write options, or pass it to `write`: + +```python +options = vortex.io.VortexWriteOptions.default().with_edition("core2025.10.0") +vortex.io.write(array, "data.vortex", edition="core2025.10.0") +``` + An edition declaration describes permitted formats, but registering it does not install the code to read or write those formats. When constructing a session without the defaults, register the required implementations and declarations, then enable the target editions. See diff --git a/docs/user-guide/datafusion.md b/docs/user-guide/datafusion.md index 0be982575b6..ca3ae86bda3 100644 --- a/docs/user-guide/datafusion.md +++ b/docs/user-guide/datafusion.md @@ -1,83 +1,12 @@ # DataFusion -The `vortex-datafusion` crate integrates Vortex as a native DataFusion `FileFormat`, supporting -both reads and writes with filter, projection, and limit pushdown. +> If you're a developer willing to integrate Vortex and Datafusion, see +> [`vortex-datafusion` developer +> guide](../developer-guide/integrations/datafusion) instead. -## Setup +Vortex provides a +[DataFusion CLI](https://github.com/vortex-data/vortex-datafusion-cli) which +allows you to query `.vortex` files via DataFusion. -Add the dependency: - -```toml -[dependencies] -vortex-datafusion = "" -``` - -Register the Vortex format with a `SessionContext`: - -:::{literalinclude} ../../vortex-datafusion/src/persistent/tests.rs -:language: rust -:dedent: -:start-after: [setup] -:end-before: [setup] -::: - -## Reading Vortex Files - -### SQL - -Create an external table and query it: - -:::{literalinclude} ../../vortex-datafusion/src/persistent/tests.rs -:language: rust -:dedent: -:start-after: [create] -:end-before: [create] -::: - -### Rust API - -You can also register a `ListingTable` directly: - -:::{literalinclude} ../../vortex-datafusion/examples/vortex_table.rs -:language: rust -:dedent: -:start-after: [register] -:end-before: [register] -::: - -## Writing Vortex Files - -Write query results to Vortex using `INSERT INTO`: - -:::{literalinclude} ../../vortex-datafusion/src/persistent/tests.rs -:language: rust -:dedent: -:start-after: [write] -:end-before: [write] -::: - -Partitioned writes are supported — DataFusion automatically creates subdirectories for each -partition value. - -## Querying - -Filters and projections are pushed down into the Vortex scan: - -:::{literalinclude} ../../vortex-datafusion/src/persistent/tests.rs -:language: rust -:dedent: -:start-after: [query] -:end-before: [query] -::: - -### Pushdown Support - -The integration pushes the following operations into the Vortex scan: - -- **Projections** — only referenced columns are read and decompressed. -- **Filters** — comparison (`=`, `<`, `>`), logical (`AND`, `OR`, `NOT`), `IN`, `LIKE`, - `IS NULL`, and cast expressions are evaluated during the scan. Unsupported filters fall back - to DataFusion post-scan evaluation. -- **Limits** — applied at the scan level when no filter is present. -- **File pruning** — files are eliminated without being opened based on partition values and - file-level column statistics (min/max). +You can also use [`vx`](../getting-started/query) +binary with `--query` argument. diff --git a/docs/user-guide/duckdb.md b/docs/user-guide/duckdb.md index fa2fc1fee3f..82c367a3e84 100644 --- a/docs/user-guide/duckdb.md +++ b/docs/user-guide/duckdb.md @@ -13,14 +13,31 @@ INSTALL vortex; LOAD vortex; ```sql SELECT * FROM 'data.vortex'; -# this syntax supports arguments like hive_partitioning=true + +# alternative syntax SELECT * FROM read_vortex('data.vortex'); + +# globbing is also supported +SELECT * FROM 'foo/*.vortex'; + +# you can pass lists of files +SELECT * FROM read_vortex(['1.vortex', '2.vortex']); + +# hive_partitioning is supported. +# assuming folder structure data/year=2000/1.vortex, data/year=2001/2.vortex +SELECT * FROM 'data/*/*.vortex'; + +# alternative syntax supports hive_partitioning, filename, and allow_empty +# parameters +SELECT * FROM read_vortex(['1.vortex', '2.vortex'], filename = true); ``` ## Writing files ```sql COPY (SELECT * FROM my_table) TO 'output.vortex'; +# you can also get file statistics +COPY (SELECT * FROM my_table) TO 'output.vortex' (FORMAT vortex, RETURN_STATS) ``` Make sure to call `LOAD vortex` before writing any files. Duckdb writes CSV diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index 27cca7a194d..08747fc3f20 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -1,6 +1,17 @@ # User Guides -Using Vortex with query engines, table formats, and data tools. +Vortex has an integration with +[DuckDB](https://duckdb.org), +[Apache Datafusion](https://datafusion.apache.org), +[Pandas](https://pandas.pydata.org), +[Polars](https://pola.rs), +[Ray](https://ray.io), +and [Apache Spark](https://spark.apache.org). +There is Python support via [vortex-python](./vortex-python.md), +including [pyarrow](https://arrow.apache.org/docs/python/index.html). +Work is in progress for +[Iceberg](https://lists.apache.org/thread/pb66o8gk8nqc6yormfld7pkt6rdfkvh7) +and [cuDF](https://github.com/NVIDIA/cudf/pull/24289). ```{toctree} --- @@ -15,5 +26,4 @@ pyarrow ray spark vortex-python -work-in-progress ``` diff --git a/docs/user-guide/work-in-progress.md b/docs/user-guide/work-in-progress.md deleted file mode 100644 index 8c8be097676..00000000000 --- a/docs/user-guide/work-in-progress.md +++ /dev/null @@ -1,19 +0,0 @@ -# Work In Progress - -The following integrations are under active development. - -## Iceberg - -Apache Iceberg table format support, enabling Vortex as a storage format for Iceberg tables. - -## Substrait - -Substrait plan consumption for portable query execution over Vortex data. - -## cuDF - -RAPIDS cuDF integration for GPU-accelerated DataFrames backed by Vortex arrays. - -## Trino - -Trino connector for querying Vortex tables via JNI. diff --git a/encodings/alp/src/alp/compute/between.rs b/encodings/alp/src/alp/compute/between.rs index 51cc5437c45..700b4a4cc20 100644 --- a/encodings/alp/src/alp/compute/between.rs +++ b/encodings/alp/src/alp/compute/between.rs @@ -6,6 +6,7 @@ use std::fmt::Debug; use num_traits::Bounded; use vortex_array::ArrayRef; use vortex_array::ArrayView; +use vortex_array::ExecutionCtx; use vortex_array::IntoArray; use vortex_array::arrays::ConstantArray; use vortex_array::builtins::ArrayBuiltins; @@ -14,6 +15,7 @@ use vortex_array::dtype::NativePType; use vortex_array::dtype::Nullability; use vortex_array::scalar::PValue; use vortex_array::scalar::Scalar; +use vortex_array::scalar_fn::fns::between::BetweenKernel; use vortex_array::scalar_fn::fns::between::BetweenOptions; use vortex_array::scalar_fn::fns::between::BetweenReduce; use vortex_array::scalar_fn::fns::between::StrictComparison; @@ -24,8 +26,13 @@ use crate::ALPFloat; use crate::Exponents; use crate::alp::array::ALPArrayExt; use crate::alp::array::ALPArraySlotsExt; +use crate::alp::compute::predicate::apply_patch_predicate; +use crate::alp::compute::predicate::constant_predicate; +use crate::alp::compute::predicate::encode_strictly_above; +use crate::alp::compute::predicate::encode_strictly_below; use crate::match_each_alp_float_ptype; +/// Rewrites a between over a patch-free array into a between over its encoded integers. impl BetweenReduce for ALP { fn between( array: ArrayView<'_, Self>, @@ -37,6 +44,7 @@ impl BetweenReduce for ALP { return Ok(None); }; + // Patched rows need their exact values, which the execute kernel below supplies. if array.patches().is_some() { return Ok(None); } @@ -56,6 +64,42 @@ impl BetweenReduce for ALP { } } +/// Answers a between over a patched array from its encoded integers, then re-evaluates the +/// patched rows on their exact values. +impl BetweenKernel for ALP { + fn between( + array: ArrayView<'_, Self>, + lower: &ArrayRef, + upper: &ArrayRef, + options: &BetweenOptions, + ctx: &mut ExecutionCtx, + ) -> VortexResult> { + let Some(patches) = array.patches() else { + return Ok(None); + }; + let (Some(lower), Some(upper)) = (lower.as_constant(), upper.as_constant()) else { + return Ok(None); + }; + + let nullability = + array.dtype().nullability() | lower.dtype().nullability() | upper.dtype().nullability(); + match_each_alp_float_ptype!(array.dtype().as_ptype(), |F| { + let lower = F::try_from(lower)?; + let upper = F::try_from(upper)?; + let encoded = between_impl::(array, lower, upper, nullability, options)?; + let lower_fn = options.lower_strict.to_predicate::(); + let upper_fn = options.upper_strict.to_predicate::(); + apply_patch_predicate( + encoded, + &patches, + |value: F| lower_fn(lower, value) & upper_fn(value, upper), + ctx, + ) + }) + .map(Some) + } +} + fn between_impl( array: ArrayView<'_, ALP>, lower: T, @@ -69,23 +113,22 @@ where { let exponents = array.exponents(); - // There are always compared - // the below bound is `value {< | <=} x`, either value encodes into the ALPInt domain - // in which case we can leave the comparison unchanged `enc(value) {< | <=} x` or it doesn't - // and we encode into value below enc_below(value) < value < x, in which case the comparison - // becomes enc(value) < x. See `alp_scalar_compare` for more details. - // note that if the value doesn't encode than value != x, so must use strict comparison. + // The lower bound is `value {< | <=} x`. Either `value` encodes into the ALPInt domain, in + // which case the comparison is unchanged as `enc(value) {< | <=} x`, or it does not and + // `enc_below(value) < value < x`, in which case the comparison becomes `enc(value) < x`. See + // `alp_scalar_compare` for more details. Note that if `value` does not encode then + // `value != x`, so the comparison must be strict. let Some((lower_enc, lower_strict)) = encode_lower_bound::(lower, exponents, options.lower_strict) else { - return Ok(ConstantArray::new(Scalar::bool(false, nullability), array.len()).into_array()); + return constant_predicate(array, false, nullability); }; - // the upper value `x { < | <= } value` similarly encodes or `x < value < enc_above(value())` + // The upper bound `x {< | <=} value` similarly encodes, or `x < value < enc_above(value)`. let Some((upper_enc, upper_strict)) = encode_upper_bound::(upper, exponents, options.upper_strict) else { - return Ok(ConstantArray::new(Scalar::bool(false, nullability), array.len()).into_array()); + return constant_predicate(array, false, nullability); }; let options = BetweenOptions { @@ -113,7 +156,12 @@ fn encode_lower_bound( Some( T::encode_single(lower, exponents) .map(|x| (x, strict)) - .unwrap_or_else(|| (T::encode_below(lower, exponents), StrictComparison::Strict)), + .unwrap_or_else(|| { + ( + encode_strictly_below(lower, exponents), + StrictComparison::Strict, + ) + }), ) } @@ -130,23 +178,33 @@ fn encode_upper_bound( Some( T::encode_single(upper, exponents) .map(|x| (x, strict)) - .unwrap_or_else(|| (T::encode_above(upper, exponents), StrictComparison::Strict)), + .unwrap_or_else(|| { + ( + encode_strictly_above(upper, exponents), + StrictComparison::Strict, + ) + }), ) } #[cfg(test)] mod tests { + use std::f32::consts::PI; use std::sync::LazyLock; + use rstest::rstest; use vortex_array::IntoArray; use vortex_array::VortexSessionExecute; + use vortex_array::arrays::BoolArray; use vortex_array::arrays::ConstantArray; use vortex_array::arrays::PrimitiveArray; use vortex_array::assert_arrays_eq; + use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::Nullability; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::between::BetweenOptions; use vortex_array::scalar_fn::fns::between::StrictComparison; + use vortex_error::VortexResult; use vortex_session::VortexSession; use crate::ALPArray; @@ -263,4 +321,100 @@ mod tests { assert_between(&encoded, 0.0, f32::INFINITY, &options, true); assert_between(&encoded, 0.0, f32::NEG_INFINITY, &options, false); } + + #[rstest] + #[case::negative_zero_lower(-0.0f32, 1.0f32, true)] + #[case::negative_zero_upper(-1.0f32, -0.0f32, false)] + #[case::subnormal_lower(f32::from_bits(1), 1.0f32, false)] + #[case::subnormal_upper(-1.0f32, -f32::from_bits(1), false)] + fn bounds_near_zero_use_total_order( + #[case] lower: f32, + #[case] upper: f32, + #[case] expected: bool, + ) { + let array = PrimitiveArray::from_iter([0.0f32; 10]); + let encoded = + alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx()).unwrap(); + assert!(encoded.patches().is_none()); + + let options = BetweenOptions { + lower_strict: StrictComparison::NonStrict, + upper_strict: StrictComparison::NonStrict, + }; + assert_between(&encoded, lower, upper, &options, expected); + } + + #[test] + fn nullable_constant_answer_keeps_validity() -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let array = PrimitiveArray::from_option_iter([Some(1.234f32), None, Some(1.234)]); + let encoded = alp_encode(array.as_view(), None, &mut ctx)?; + assert!(encoded.patches().is_none()); + + let options = BetweenOptions { + lower_strict: StrictComparison::NonStrict, + upper_strict: StrictComparison::NonStrict, + }; + let res = between_impl( + encoded.as_view(), + f32::NAN, + 2.0, + Nullability::Nullable, + &options, + )?; + let expected = BoolArray::from_iter([Some(false), None, Some(false)]); + assert_arrays_eq!(res, expected, &mut ctx); + Ok(()) + } + + #[rstest] + #[case(StrictComparison::NonStrict, StrictComparison::NonStrict)] + #[case(StrictComparison::Strict, StrictComparison::NonStrict)] + #[case(StrictComparison::NonStrict, StrictComparison::Strict)] + #[case(StrictComparison::Strict, StrictComparison::Strict)] + fn patched_matches_primitive( + #[case] lower_strict: StrictComparison, + #[case] upper_strict: StrictComparison, + ) -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let values: Vec> = (0..3000) + .map(|i| { + if i % 11 == 0 { + None + } else if i % 97 == 0 { + Some(PI * i as f32) + } else { + Some(i as f32 / 100.0) + } + }) + .collect(); + let array = PrimitiveArray::from_option_iter(values); + let encoded = alp_encode(array.as_view(), None, &mut ctx)?; + assert!(encoded.patches().is_some()); + let options = BetweenOptions { + lower_strict, + upper_strict, + }; + + for (lower, upper) in [ + (10.0f32, 20.0f32), + (PI * 97.0, PI * 1_067.0), + (f32::NEG_INFINITY, 5.0), + (f32::NAN, 5.0), + ] { + let lower = ConstantArray::new(lower, array.len()).into_array(); + let upper = ConstantArray::new(upper, array.len()).into_array(); + let actual = encoded.clone().into_array().between( + lower.clone(), + upper.clone(), + options.clone(), + )?; + let expected = array + .clone() + .into_array() + .between(lower, upper, options.clone())?; + assert_arrays_eq!(actual, expected, &mut ctx); + } + Ok(()) + } } diff --git a/encodings/alp/src/alp/compute/compare.rs b/encodings/alp/src/alp/compute/compare.rs index 457aacee172..9aeac65e9d9 100644 --- a/encodings/alp/src/alp/compute/compare.rs +++ b/encodings/alp/src/alp/compute/compare.rs @@ -1,8 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -use std::fmt::Debug; - use vortex_array::ArrayRef; use vortex_array::ArrayView; use vortex_array::ExecutionCtx; @@ -10,151 +8,132 @@ use vortex_array::IntoArray; use vortex_array::arrays::ConstantArray; use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::NativePType; +use vortex_array::dtype::Nullability; +use vortex_array::scalar::PValue; use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::binary::CompareKernel; use vortex_array::scalar_fn::fns::operators::CompareOperator; use vortex_array::scalar_fn::fns::operators::Operator; +use vortex_error::VortexExpect; use vortex_error::VortexResult; -use vortex_error::vortex_bail; -use vortex_error::vortex_err; use crate::ALP; use crate::ALPArrayExt; use crate::ALPArraySlotsExt; use crate::ALPFloat; +use crate::alp::compute::predicate::apply_patch_predicate; +use crate::alp::compute::predicate::constant_predicate; +use crate::alp::compute::predicate::encode_strictly_above; +use crate::alp::compute::predicate::encode_strictly_below; use crate::match_each_alp_float_ptype; -// TODO(joe): add fuzzing. - impl CompareKernel for ALP { fn compare( lhs: ArrayView<'_, Self>, rhs: &ArrayRef, operator: CompareOperator, - _ctx: &mut ExecutionCtx, + ctx: &mut ExecutionCtx, ) -> VortexResult> { - if lhs.patches().is_some() { - // TODO(joe): support patches + let Some(const_scalar) = rhs.as_constant() else { return Ok(None); - } - if lhs.dtype().is_nullable() || rhs.dtype().is_nullable() { - // TODO(joe): support nullability + }; + let Some(pscalar) = const_scalar.as_primitive_opt() else { + return Ok(None); + }; + if pscalar.ptype() != lhs.dtype().as_ptype() { return Ok(None); } - if let Some(const_scalar) = rhs.as_constant() { - let pscalar = const_scalar.as_primitive_opt().ok_or_else(|| { - vortex_err!( - "ALP Compare RHS had the wrong type {}, expected {}", - const_scalar, - const_scalar.dtype() - ) - })?; - - match_each_alp_float_ptype!(pscalar.ptype(), |T| { - match pscalar.typed_value::() { - Some(value) => return alp_scalar_compare(lhs, value, operator), - None => vortex_bail!( - "Failed to convert scalar {:?} to ALP type {:?}", - pscalar, - pscalar.ptype() - ), - } - }); - } - - Ok(None) + let nullability = lhs.dtype().nullability() | rhs.dtype().nullability(); + match_each_alp_float_ptype!(pscalar.ptype(), |T| { + let value = pscalar + .typed_value::() + .vortex_expect("compare adaptor strips null constants"); + alp_scalar_compare(lhs, value, operator, nullability, ctx).map(Some) + }) } } -/// We can compare a scalar to an ALPArray by encoding the scalar into the ALP domain and comparing -/// the encoded value to the encoded values in the ALPArray. There are fixups when the value doesn't -/// encode into the ALP domain. -fn alp_scalar_compare>( - alp: ArrayView, +/// Compares an ALP array to a constant without decoding it. +/// +/// A constant that round-trips through the exponents compares directly against the encoded +/// integers. Otherwise it falls strictly between two encodable values, so an ordering compares +/// against the nearest encodable neighbour and an equality has a constant answer. Patched rows +/// hold floats that ALP could not encode and are re-evaluated exactly. +fn alp_scalar_compare( + alp: ArrayView<'_, ALP>, value: F, operator: CompareOperator, -) -> VortexResult> + nullability: Nullability, + ctx: &mut ExecutionCtx, +) -> VortexResult where - F::ALPInt: Into, - ::ALPInt: Debug, + F: ALPFloat + NativePType, + F::ALPInt: NativePType + Into, { - // TODO(joe): support patches, this is checked above. - if alp.patches().is_some() { - return Ok(None); - } - let exponents = alp.exponents(); - // If the scalar doesn't fit into the ALP domain, - // it cannot be equal to any values in the encoded array. - let encoded = F::encode_single(value, alp.exponents()); - match encoded { - Some(encoded) => { - let s = ConstantArray::new(encoded, alp.len()); - Ok(Some( - alp.encoded() - .binary(s.into_array(), Operator::from(operator))?, - )) - } + let is_finite = !NativePType::is_infinite(value) && !NativePType::is_nan(value); + + let encoded = match F::encode_single(value, exponents) { + Some(encoded) => compare_encoded(alp, encoded, Operator::from(operator), nullability)?, None => match operator { - // Since this value is not encodable it cannot be equal to any value in the encoded - // array. - CompareOperator::Eq => Ok(Some(ConstantArray::new(false, alp.len()).into_array())), - // Since this value is not encodable it cannot be equal to any value in the encoded - // array, hence != to all values in the encoded array. - CompareOperator::NotEq => Ok(Some(ConstantArray::new(true, alp.len()).into_array())), + CompareOperator::Eq => constant_predicate(alp, false, nullability)?, + CompareOperator::NotEq => constant_predicate(alp, true, nullability)?, CompareOperator::Gt | CompareOperator::Gte => { - // Per IEEE 754 totalOrder semantics the ordering is -Nan < -Inf < Inf < Nan. - // All values in the encoded array are definitely finite - let is_not_finite = NativePType::is_infinite(value) || NativePType::is_nan(value); - if is_not_finite { - Ok(Some( - ConstantArray::new(value.is_sign_negative(), alp.len()).into_array(), - )) + if is_finite { + compare_encoded( + alp, + encode_strictly_above(value, exponents), + Operator::Gte, + nullability, + )? } else { - Ok(Some( - alp.encoded().binary( - ConstantArray::new(F::encode_above(value, exponents), alp.len()) - .into_array(), - // Since the encoded value is unencodable gte is equivalent to gt. - // Consider a value v, between two encodable values v_l (just less) and - // v_a (just above), then for all encodable values (u), v > u <=> v_g >= u - Operator::Gte, - )?, - )) + constant_predicate(alp, value.is_sign_negative(), nullability)? } } CompareOperator::Lt | CompareOperator::Lte => { - // Per IEEE 754 totalOrder semantics the ordering is -Nan < -Inf < Inf < Nan. - // All values in the encoded array are definitely finite - let is_not_finite = NativePType::is_infinite(value) || NativePType::is_nan(value); - if is_not_finite { - Ok(Some( - ConstantArray::new(value.is_sign_positive(), alp.len()).into_array(), - )) + if is_finite { + compare_encoded( + alp, + encode_strictly_below(value, exponents), + Operator::Lte, + nullability, + )? } else { - Ok(Some( - alp.encoded().binary( - ConstantArray::new(F::encode_below(value, exponents), alp.len()) - .into_array(), - // Since the encoded values unencodable lt is equivalent to lte. - // See Gt | Gte for further explanation. - Operator::Lte, - )?, - )) + constant_predicate(alp, value.is_sign_positive(), nullability)? } } }, - } + }; + + let Some(patches) = alp.patches() else { + return Ok(encoded); + }; + let predicate = operator.to_predicate::(); + apply_patch_predicate(encoded, &patches, |patch| predicate(patch, value), ctx) +} + +fn compare_encoded>( + alp: ArrayView<'_, ALP>, + encoded: I, + operator: Operator, + nullability: Nullability, +) -> VortexResult { + alp.encoded().binary( + ConstantArray::new(Scalar::primitive(encoded, nullability), alp.len()).into_array(), + operator, + ) } #[cfg(test)] mod tests { use std::f32::consts::E; + use std::f32::consts::PI; use std::sync::LazyLock; use rstest::rstest; use vortex_array::ArrayRef; + use vortex_array::IntoArray; use vortex_array::VortexSessionExecute; use vortex_array::arrays::BoolArray; use vortex_array::arrays::ConstantArray; @@ -165,11 +144,14 @@ mod tests { use vortex_array::dtype::Nullability; use vortex_array::dtype::PType; use vortex_array::scalar::Scalar; + use vortex_array::scalar_fn::fns::binary::CompareKernel; use vortex_array::scalar_fn::fns::operators::CompareOperator; use vortex_array::scalar_fn::fns::operators::Operator; + use vortex_error::VortexResult; use vortex_session::VortexSession; use super::*; + use crate::ALPArray; use crate::alp_encode; static SESSION: LazyLock = LazyLock::new(|| { @@ -178,16 +160,45 @@ mod tests { session }); - fn test_alp_compare>( - alp: ArrayView, - value: F, - operator: CompareOperator, - ) -> Option - where - F::ALPInt: Into, - ::ALPInt: Debug, - { - alp_scalar_compare(alp, value, operator).unwrap() + fn test_alp_compare(alp: ArrayView, value: f32, operator: CompareOperator) -> ArrayRef { + alp_scalar_compare( + alp, + value, + operator, + Nullability::NonNullable, + &mut SESSION.create_execution_ctx(), + ) + .unwrap() + } + + const ALL_OPERATORS: [CompareOperator; 6] = [ + CompareOperator::Eq, + CompareOperator::NotEq, + CompareOperator::Lt, + CompareOperator::Lte, + CompareOperator::Gt, + CompareOperator::Gte, + ]; + + /// Asserts the kernel engages for `encoded` and matches the comparison over `values`. + fn assert_matches_primitive( + encoded: &ALPArray, + values: &PrimitiveArray, + constant: Scalar, + ) -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let rhs = ConstantArray::new(constant, values.len()).into_array(); + for operator in ALL_OPERATORS { + let actual = + ::compare(encoded.as_view(), &rhs, operator, &mut ctx)? + .unwrap_or_else(|| panic!("ALP compare kernel must engage for {operator:?}")); + let expected = values + .clone() + .into_array() + .binary(rhs.clone(), Operator::from(operator))?; + assert_arrays_eq!(actual, expected, &mut ctx); + } + Ok(()) } #[test] @@ -203,15 +214,11 @@ mod tests { .unwrap(); assert_eq!(encoded_prim.as_slice::(), vec![1234; 1025]); - let r = alp_scalar_compare(encoded.as_view(), 1.3_f32, CompareOperator::Eq) - .unwrap() - .unwrap(); + let r = test_alp_compare(encoded.as_view(), 1.3_f32, CompareOperator::Eq); let expected = BoolArray::from_iter([false; 1025]); assert_arrays_eq!(r, expected, &mut ctx); - let r = alp_scalar_compare(encoded.as_view(), 1.234f32, CompareOperator::Eq) - .unwrap() - .unwrap(); + let r = test_alp_compare(encoded.as_view(), 1.234f32, CompareOperator::Eq); let expected = BoolArray::from_iter([true; 1025]); assert_arrays_eq!(r, expected, &mut ctx); } @@ -229,15 +236,11 @@ mod tests { .unwrap(); assert_eq!(encoded_prim.as_slice::(), vec![1234; 1025]); - let r_eq = alp_scalar_compare(encoded.as_view(), 1.234444_f32, CompareOperator::Eq) - .unwrap() - .unwrap(); + let r_eq = test_alp_compare(encoded.as_view(), 1.234444_f32, CompareOperator::Eq); let expected = BoolArray::from_iter([false; 1025]); assert_arrays_eq!(r_eq, expected, &mut ctx); - let r_neq = alp_scalar_compare(encoded.as_view(), 1.234444f32, CompareOperator::NotEq) - .unwrap() - .unwrap(); + let r_neq = test_alp_compare(encoded.as_view(), 1.234444f32, CompareOperator::NotEq); let expected = BoolArray::from_iter([true; 1025]); assert_arrays_eq!(r_neq, expected, &mut ctx); } @@ -256,30 +259,22 @@ mod tests { assert_eq!(encoded_prim.as_slice::(), vec![605; 10]); // !(0.0605_f32 >= 0.06051_f32); - let r_gte = alp_scalar_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Gte) - .unwrap() - .unwrap(); + let r_gte = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Gte); let expected = BoolArray::from_iter([false; 10]); assert_arrays_eq!(r_gte, expected, &mut ctx); // (0.0605_f32 > 0.06051_f32); - let r_gt = alp_scalar_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Gt) - .unwrap() - .unwrap(); + let r_gt = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Gt); let expected = BoolArray::from_iter([false; 10]); assert_arrays_eq!(r_gt, expected, &mut ctx); // 0.0605_f32 <= 0.06051_f32; - let r_lte = alp_scalar_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lte) - .unwrap() - .unwrap(); + let r_lte = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lte); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_lte, expected, &mut ctx); // 0.0605_f32 < 0.06051_f32; - let r_lt = alp_scalar_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lt) - .unwrap() - .unwrap(); + let r_lt = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lt); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_lt, expected, &mut ctx); } @@ -297,52 +292,144 @@ mod tests { .unwrap(); assert_eq!(encoded_prim.as_slice::(), vec![0; 10]); - let r_gte = - test_alp_compare(encoded.as_view(), -0.00000001_f32, CompareOperator::Gte).unwrap(); + let r_gte = test_alp_compare(encoded.as_view(), -0.00000001_f32, CompareOperator::Gte); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_gte, expected, &mut ctx); - let r_gte = test_alp_compare(encoded.as_view(), -0.0_f32, CompareOperator::Gte).unwrap(); + let r_gte = test_alp_compare(encoded.as_view(), -0.0_f32, CompareOperator::Gte); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_gte, expected, &mut ctx); - let r_gt = - test_alp_compare(encoded.as_view(), -0.0000000001f32, CompareOperator::Gt).unwrap(); + let r_gt = test_alp_compare(encoded.as_view(), -0.0000000001f32, CompareOperator::Gt); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_gt, expected, &mut ctx); - let r_gte = test_alp_compare(encoded.as_view(), -0.0_f32, CompareOperator::Gt).unwrap(); + let r_gte = test_alp_compare(encoded.as_view(), -0.0_f32, CompareOperator::Gt); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_gte, expected, &mut ctx); - let r_lte = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lte).unwrap(); + let r_lte = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lte); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_lte, expected, &mut ctx); - let r_lt = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lt).unwrap(); + let r_lt = test_alp_compare(encoded.as_view(), 0.06051_f32, CompareOperator::Lt); let expected = BoolArray::from_iter([true; 10]); assert_arrays_eq!(r_lt, expected, &mut ctx); - let r_lt = test_alp_compare(encoded.as_view(), -0.00001_f32, CompareOperator::Lt).unwrap(); + let r_lt = test_alp_compare(encoded.as_view(), -0.00001_f32, CompareOperator::Lt); let expected = BoolArray::from_iter([false; 10]); assert_arrays_eq!(r_lt, expected, &mut ctx); } + #[rstest] + #[case::encodable(1.5f32)] + #[case::patched_value(1_000_000.9f32)] + #[case::unencodable(1.234444f32)] + #[case::nan(f32::NAN)] + #[case::infinity(f32::INFINITY)] + fn compare_with_patches(#[case] constant: f32) -> VortexResult<()> { + let array = PrimitiveArray::from_iter([ + 1.234f32, + 1.5, + 19.0, + E, + 1_000_000.9, + f32::NAN, + f32::NEG_INFINITY, + ]); + let encoded = alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx())?; + assert!(encoded.patches().is_some()); + + assert_matches_primitive(&encoded, &array, constant.into()) + } + + #[rstest] + #[case::positive_zero(0.0f32)] + #[case::negative_zero(-0.0f32)] + #[case::positive_subnormal(f32::from_bits(1))] + #[case::negative_subnormal(-f32::from_bits(1))] + fn compare_near_zero(#[case] constant: f32) -> VortexResult<()> { + let array = PrimitiveArray::from_iter([0.0f32, 1.5, -1.5, 1.234, 0.0, -2.5]); + let encoded = alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx())?; + + assert_matches_primitive(&encoded, &array, constant.into()) + } + #[test] - fn compare_with_patches() { - let array = PrimitiveArray::from_iter([1.234f32, 1.5, 19.0, E, 1_000_000.9]); - let encoded = - alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx()).unwrap(); + fn compare_sliced_with_patches() -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let values: Vec = (0..3000) + .map(|i| { + if i % 97 == 0 { + PI * i as f32 + } else { + i as f32 / 100.0 + } + }) + .collect(); + let array = PrimitiveArray::from_iter(values); + let encoded = alp_encode(array.as_view(), None, &mut ctx)?; assert!(encoded.patches().is_some()); - // Not supported! - assert!( - alp_scalar_compare(encoded.as_view(), 1_000_000.9_f32, CompareOperator::Eq) - .unwrap() - .is_none() + let sliced = encoded.into_array().slice(1_000..2_500)?; + let expected_values = array.into_array().slice(1_000..2_500)?; + let rhs = ConstantArray::new(PI * 1_164.0, sliced.len()).into_array(); + for operator in ALL_OPERATORS { + let actual = sliced + .clone() + .binary(rhs.clone(), Operator::from(operator))?; + let expected = expected_values + .clone() + .binary(rhs.clone(), Operator::from(operator))?; + assert_arrays_eq!(actual, expected, &mut ctx); + } + Ok(()) + } + + #[rstest] + #[case::encodable(1.5f32)] + #[case::patched_value(1_000_000.9f32)] + #[case::unencodable(1.234444f32)] + #[case::nan(f32::NAN)] + #[case::neg_infinity(f32::NEG_INFINITY)] + fn compare_nullable(#[case] constant: f32) -> VortexResult<()> { + let array = PrimitiveArray::from_option_iter([ + Some(1.234f32), + None, + Some(1.5), + Some(1_000_000.9), + None, + Some(f32::NAN), + ]); + let encoded = alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx())?; + + assert_matches_primitive(&encoded, &array, constant.into())?; + assert_matches_primitive( + &encoded, + &array, + Scalar::primitive(constant, Nullability::Nullable), ) } + #[test] + fn compare_nullable_constant_result_keeps_validity() -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let array = PrimitiveArray::from_option_iter([Some(1.234f32), None, Some(1.234)]); + let encoded = alp_encode(array.as_view(), None, &mut ctx)?; + assert!(encoded.patches().is_none()); + + let actual = alp_scalar_compare( + encoded.as_view(), + 1.234444f32, + CompareOperator::Eq, + Nullability::Nullable, + &mut ctx, + )?; + let expected = BoolArray::from_iter([Some(false), None, Some(false)]); + assert_arrays_eq!(actual, expected, &mut ctx); + Ok(()) + } + #[test] fn compare_to_null() { let array = PrimitiveArray::from_iter([1.234f32; 10]); @@ -373,7 +460,7 @@ mod tests { let encoded = alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx()).unwrap(); - let r = test_alp_compare(encoded.as_view(), value, CompareOperator::Gt).unwrap(); + let r = test_alp_compare(encoded.as_view(), value, CompareOperator::Gt); let expected = BoolArray::from_iter([result; 10]); assert_arrays_eq!(r, expected, &mut SESSION.create_execution_ctx()); } @@ -388,7 +475,7 @@ mod tests { let encoded = alp_encode(array.as_view(), None, &mut SESSION.create_execution_ctx()).unwrap(); - let r = test_alp_compare(encoded.as_view(), value, CompareOperator::Lt).unwrap(); + let r = test_alp_compare(encoded.as_view(), value, CompareOperator::Lt); let expected = BoolArray::from_iter([result; 10]); assert_arrays_eq!(r, expected, &mut SESSION.create_execution_ctx()); } diff --git a/encodings/alp/src/alp/compute/mod.rs b/encodings/alp/src/alp/compute/mod.rs index 262d9ebf61b..5c604e685d7 100644 --- a/encodings/alp/src/alp/compute/mod.rs +++ b/encodings/alp/src/alp/compute/mod.rs @@ -7,6 +7,7 @@ mod compare; mod filter; mod mask; pub(crate) mod nan_count; +mod predicate; mod slice; mod take; diff --git a/encodings/alp/src/alp/compute/predicate.rs b/encodings/alp/src/alp/compute/predicate.rs new file mode 100644 index 00000000000..a94e0ae52b5 --- /dev/null +++ b/encodings/alp/src/alp/compute/predicate.rs @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Helpers shared by the ALP comparison and between kernels. +//! +//! Both kernels answer a predicate against the encoded integers and then correct the rows that +//! ALP could not encode, whose exact float values live in the patches. + +use num_traits::AsPrimitive; +use num_traits::One; +use num_traits::Saturating; +use vortex_array::ArrayRef; +use vortex_array::ArrayView; +use vortex_array::ExecutionCtx; +use vortex_array::IntoArray; +use vortex_array::arrays::BoolArray; +use vortex_array::arrays::ConstantArray; +use vortex_array::arrays::PrimitiveArray; +use vortex_array::dtype::DType; +use vortex_array::dtype::NativePType; +use vortex_array::dtype::Nullability; +use vortex_array::match_each_integer_ptype; +use vortex_array::patches::Patches; +use vortex_array::scalar::Scalar; +use vortex_array::validity::Validity; +use vortex_buffer::BitBuffer; +use vortex_buffer::BitBufferMut; +use vortex_error::VortexResult; + +use crate::ALP; +use crate::ALPFloat; +use crate::Exponents; + +/// A predicate that has the same answer for every row while keeping the array's validity. +pub(super) fn constant_predicate( + array: ArrayView<'_, ALP>, + value: bool, + nullability: Nullability, +) -> VortexResult { + let len = array.len(); + Ok(match array.validity()?.union_nullability(nullability) { + Validity::NonNullable | Validity::AllValid => { + ConstantArray::new(Scalar::bool(value, nullability), len).into_array() + } + Validity::AllInvalid => { + ConstantArray::new(Scalar::null(DType::Bool(nullability)), len).into_array() + } + validity @ Validity::Array(_) => { + BoolArray::new(BitBuffer::full(value, len), validity).into_array() + } + }) +} + +/// Returns the largest encoded integer that decodes strictly below `value`. +/// +/// `value` must be finite and must not round-trip through `exponents`. Rounding down is not +/// sufficient by itself: `floor(-0.0)` encodes to `0`, which decodes to `+0.0`, and in total +/// order `+0.0` is above `-0.0`. +pub(super) fn encode_strictly_below( + value: F, + exponents: Exponents, +) -> F::ALPInt { + let below = F::encode_below(value, exponents); + if NativePType::is_lt(F::decode_single(below, exponents), value) { + below + } else { + below.saturating_sub(F::ALPInt::one()) + } +} + +/// Returns the smallest encoded integer that decodes strictly above `value`. +/// +/// `value` must be finite and must not round-trip through `exponents`. +pub(super) fn encode_strictly_above( + value: F, + exponents: Exponents, +) -> F::ALPInt { + let above = F::encode_above(value, exponents); + if NativePType::is_gt(F::decode_single(above, exponents), value) { + above + } else { + above.saturating_add(F::ALPInt::one()) + } +} + +/// Re-evaluates `predicate` on each patched row of `result`, a boolean answer computed from the +/// encoded values alone. +pub(super) fn apply_patch_predicate( + result: ArrayRef, + patches: &Patches, + predicate: impl Fn(F) -> bool, + ctx: &mut ExecutionCtx, +) -> VortexResult { + let result = result.execute::(ctx)?; + let validity = result.validity()?; + let mut bits = result + .into_bit_buffer() + .try_into_mut() + .unwrap_or_else(|bits| BitBufferMut::copy_from(&bits)); + + let indices = patches.indices().clone().execute::(ctx)?; + let values = patches.values().clone().execute::(ctx)?; + let values = values.as_slice::(); + let offset = patches.offset(); + + match_each_integer_ptype!(indices.ptype(), |I| { + for (&index, &value) in indices.as_slice::().iter().zip(values) { + let index: usize = index.as_(); + // Patch indices are absolute; a slice keeps only those within its range. + if let Some(local) = index.checked_sub(offset) + && local < bits.len() + { + bits.set_to(local, predicate(value)); + } + } + }); + + Ok(BoolArray::new(bits.freeze(), validity).into_array()) +} diff --git a/encodings/alp/src/alp/plugin.rs b/encodings/alp/src/alp/plugin.rs index b72893efb32..c331adb4be9 100644 --- a/encodings/alp/src/alp/plugin.rs +++ b/encodings/alp/src/alp/plugin.rs @@ -38,6 +38,14 @@ impl ArrayPlugin for ALPPatchedPlugin { ArrayVTable::id(&ALP) } + fn read_ids(&self) -> Vec { + vec![self.id()] + } + + fn write_ids(&self) -> Vec { + vec![self.id()] + } + fn serialize( &self, array: &ArrayRef, diff --git a/encodings/alp/src/alp/rules.rs b/encodings/alp/src/alp/rules.rs index 3b888ae8269..fd8d67984af 100644 --- a/encodings/alp/src/alp/rules.rs +++ b/encodings/alp/src/alp/rules.rs @@ -11,6 +11,8 @@ use vortex_array::arrays::slice::SliceExecuteAdaptor; use vortex_array::optimizer::kernels::ArrayKernelsExt; use vortex_array::optimizer::rules::ParentRuleSet; use vortex_array::scalar_fn::ScalarFnVTable; +use vortex_array::scalar_fn::fns::between::Between; +use vortex_array::scalar_fn::fns::between::BetweenExecuteAdaptor; use vortex_array::scalar_fn::fns::between::BetweenReduceAdaptor; use vortex_array::scalar_fn::fns::binary::Binary; use vortex_array::scalar_fn::fns::binary::CompareExecuteAdaptor; @@ -24,6 +26,7 @@ use crate::ALP; pub(super) fn initialize(session: &VortexSession) { let kernels = session.kernels(); + kernels.register_execute_parent_kernel(Between.id(), ALP, BetweenExecuteAdaptor(ALP)); kernels.register_execute_parent_kernel(Binary.id(), ALP, CompareExecuteAdaptor(ALP)); kernels.register_execute_parent_kernel(Filter.id(), ALP, FilterExecuteAdaptor(ALP)); kernels.register_execute_parent_kernel(Mask.id(), ALP, MaskExecuteAdaptor(ALP)); diff --git a/encodings/datetime-parts/src/compute/compare.rs b/encodings/datetime-parts/src/compute/compare.rs index 9e997db8c10..0ea94834067 100644 --- a/encodings/datetime-parts/src/compute/compare.rs +++ b/encodings/datetime-parts/src/compute/compare.rs @@ -1,6 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Compares encoded timestamp parts with timestamp constants. +//! +//! The kernel splits a timestamp constant into days, seconds, and subseconds, then compares the +//! encoded children without decoding the column. The result retains the timestamp array's validity. + use vortex_array::ArrayRef; use vortex_array::ArrayView; use vortex_array::ExecutionCtx; @@ -18,6 +23,7 @@ use vortex_array::scalar_fn::fns::operators::CompareOperator; use vortex_array::scalar_fn::fns::operators::Operator; use vortex_array::validity::Validity; use vortex_error::VortexResult; +use vortex_error::vortex_ensure; use vortex_mask::AllOr; use crate::array::DateTimeParts; @@ -31,6 +37,13 @@ impl CompareKernel for DateTimeParts { operator: CompareOperator, ctx: &mut ExecutionCtx, ) -> VortexResult> { + vortex_ensure!( + lhs.dtype().eq_ignore_nullability(rhs.dtype()), + "Comparison requires equal dtypes ignoring nullability, got {} and {}", + lhs.dtype(), + rhs.dtype() + ); + let Some(rhs_const) = rhs.as_constant() else { return Ok(None); }; @@ -287,7 +300,7 @@ fn compare_dtp( } #[cfg(test)] -mod test { +mod tests { use std::sync::LazyLock; use rstest::rstest; @@ -685,6 +698,37 @@ mod test { assert_matches_temporal(nullable, unit, constants) } + #[rstest] + #[case::storage(Scalar::from(1500i64))] + #[case::different_unit(Scalar::extension::( + TimestampOptions { unit: TimeUnit::Nanoseconds, tz: None }, + Scalar::from(1_500_000_000i64), + ))] + fn test_comparison_rejects_mismatched_constant_dtype( + #[case] scalar: Scalar, + ) -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let temporal = TemporalArray::new_timestamp( + buffer![1600i64, 1400].into_array(), + TimeUnit::Milliseconds, + None, + ); + let array = DateTimeParts::try_from_temporal(temporal, &mut ctx)?; + let rhs = ConstantArray::new(scalar, array.len()).into_array(); + + assert!( + ::compare( + array.as_view(), + &rhs, + CompareOperator::Lt, + &mut ctx, + ) + .is_err() + ); + + Ok(()) + } + #[test] fn null_rows_stay_null_when_parts_differ() -> VortexResult<()> { let mut ctx = SESSION.create_execution_ctx(); diff --git a/encodings/decimal-byte-parts/src/decimal_byte_parts/plugin/mod.rs b/encodings/decimal-byte-parts/src/decimal_byte_parts/plugin/mod.rs index 3896cd51c96..c91c1e3c21a 100644 --- a/encodings/decimal-byte-parts/src/decimal_byte_parts/plugin/mod.rs +++ b/encodings/decimal-byte-parts/src/decimal_byte_parts/plugin/mod.rs @@ -55,7 +55,11 @@ impl ArrayPlugin for DecimalBytePartsPlugin { VTable::id(&DecimalByteParts) } - fn serialized_ids(&self) -> Vec { + fn read_ids(&self) -> Vec { + vec![decimal_byte_parts_v1_id(), decimal_byte_parts_v2_id()] + } + + fn write_ids(&self) -> Vec { vec![decimal_byte_parts_v1_id(), decimal_byte_parts_v2_id()] } diff --git a/encodings/fastlanes/benches/bitpacking_filter.rs b/encodings/fastlanes/benches/bitpacking_filter.rs index 6c8a283a6dd..d9d6ecac46f 100644 --- a/encodings/fastlanes/benches/bitpacking_filter.rs +++ b/encodings/fastlanes/benches/bitpacking_filter.rs @@ -69,8 +69,10 @@ fn fixture(selected_per_chunk: usize) -> (ArrayRef, Mask) { (packed, Mask::from_indices(LEN, indices)) } -#[vortex_bench_support::cpu_features] -#[divan::bench(args = [64, 80])] +// Batch short iterations to reduce variation in the fastest walltime sample. +// The NEON cases still vary on unchanged code, so keep those measurements local. +#[vortex_bench_support::cpu_features(exclude = ["neon"])] +#[divan::bench(args = [64, 80], sample_size = 64)] fn filter(bencher: Bencher, selected_per_chunk: usize) { let (packed, mask) = fixture(selected_per_chunk); diff --git a/encodings/fastlanes/benches/bitpacking_take.rs b/encodings/fastlanes/benches/bitpacking_take.rs index 4bf53292e8a..271dc955f64 100644 --- a/encodings/fastlanes/benches/bitpacking_take.rs +++ b/encodings/fastlanes/benches/bitpacking_take.rs @@ -83,8 +83,10 @@ fn threshold_fixture(selected_per_chunk: usize) -> (ArrayRef, ArrayRef) { (packed, indices) } -#[vortex_bench_support::cpu_features] -#[divan::bench(args = [64, 80])] +// Batch short iterations to reduce variation in the fastest walltime sample. +// The NEON cases still vary on unchanged code, so keep those measurements local. +#[vortex_bench_support::cpu_features(exclude = ["neon"])] +#[divan::bench(args = [64, 80], sample_size = 16)] fn threshold(bencher: Bencher, selected_per_chunk: usize) { let (packed, indices) = threshold_fixture(selected_per_chunk); diff --git a/encodings/fastlanes/src/bitpacking/plugin/mod.rs b/encodings/fastlanes/src/bitpacking/plugin/mod.rs index 31b1f06ec90..aec1375c341 100644 --- a/encodings/fastlanes/src/bitpacking/plugin/mod.rs +++ b/encodings/fastlanes/src/bitpacking/plugin/mod.rs @@ -64,7 +64,11 @@ impl ArrayPlugin for BitPackedPlugin { ArrayVTable::id(&BitPacked) } - fn serialized_ids(&self) -> Vec { + fn read_ids(&self) -> Vec { + vec![bitpacked_v1_id(), bitpacked_v2_id()] + } + + fn write_ids(&self) -> Vec { vec![bitpacked_v1_id(), bitpacked_v2_id()] } @@ -114,8 +118,12 @@ impl ArrayPlugin for BitPackedPatchedPlugin { ArrayVTable::id(&BitPacked) } - fn serialized_ids(&self) -> Vec { - BitPackedPlugin.serialized_ids() + fn read_ids(&self) -> Vec { + BitPackedPlugin.read_ids() + } + + fn write_ids(&self) -> Vec { + BitPackedPlugin.write_ids() } fn serialize( @@ -133,7 +141,7 @@ impl ArrayPlugin for BitPackedPatchedPlugin { session: &VortexSession, ) -> VortexResult { vortex_ensure!( - self.serialized_ids().contains(&parts.serialized_id), + self.read_ids().contains(&parts.serialized_id), "BitPacked plugin does not recognize serialized ID {}", parts.serialized_id, ); diff --git a/encodings/fastlanes/src/for_/plugin/mod.rs b/encodings/fastlanes/src/for_/plugin/mod.rs index a5478428072..0efbff59e83 100644 --- a/encodings/fastlanes/src/for_/plugin/mod.rs +++ b/encodings/fastlanes/src/for_/plugin/mod.rs @@ -52,7 +52,11 @@ impl ArrayPlugin for FoRPlugin { VTable::id(&FoR) } - fn serialized_ids(&self) -> Vec { + fn read_ids(&self) -> Vec { + vec![for_v1_id(), for_v2_id()] + } + + fn write_ids(&self) -> Vec { vec![for_v1_id(), for_v2_id()] } diff --git a/encodings/sequence/src/compute/compare.rs b/encodings/sequence/src/compute/compare.rs index e2f3a0186be..160c5eb7068 100644 --- a/encodings/sequence/src/compute/compare.rs +++ b/encodings/sequence/src/compute/compare.rs @@ -6,12 +6,11 @@ use vortex_array::ArrayView; use vortex_array::ExecutionCtx; use vortex_array::IntoArray; use vortex_array::arrays::BoolArray; -use vortex_array::arrays::ConstantArray; use vortex_array::dtype::Nullability; use vortex_array::scalar::PValue; -use vortex_array::scalar::Scalar; use vortex_array::scalar_fn::fns::binary::CompareKernel; use vortex_array::scalar_fn::fns::operators::CompareOperator; +use vortex_array::validity::Validity; use vortex_buffer::BitBufferMut; use vortex_error::VortexExpect; use vortex_error::VortexResult; @@ -26,11 +25,6 @@ impl CompareKernel for Sequence { operator: CompareOperator, _ctx: &mut ExecutionCtx, ) -> VortexResult> { - // TODO(joe): support other operators (NotEq, Lt, Lte, Gt, Gte) in encoded space. - if operator != CompareOperator::Eq { - return Ok(None); - } - let Some(constant) = rhs.as_constant() else { return Ok(None); }; @@ -40,33 +34,53 @@ impl CompareKernel for Sequence { .pvalue() .vortex_expect("null constant handled in adaptor"); - // Fall back for non-integer constants. - let Some(intersection) = find_intersection(lhs.base(), lhs.multiplier(), lhs.len(), value) - else { - return Ok(None); + let len = lhs.len(); + let bits = match operator { + // A sequence with a non-zero step holds each value at most once, so equality matches + // at most one row. Inequality is the negation of that answer. + CompareOperator::Eq | CompareOperator::NotEq => { + // Fall back for non-integer constants. + let Some(intersection) = + find_intersection(lhs.base(), lhs.multiplier(), len, value) + else { + return Ok(None); + }; + let negated = operator == CompareOperator::NotEq; + match intersection { + Intersection::None => BitBufferMut::full(negated, len), + Intersection::All => BitBufferMut::full(!negated, len), + Intersection::At(idx) => { + let mut bits = BitBufferMut::full(negated, len); + bits.set_to(idx, !negated); + bits + } + } + } + CompareOperator::Lt + | CompareOperator::Lte + | CompareOperator::Gt + | CompareOperator::Gte => { + // A sequence is monotonic, so the rows that satisfy an ordering comparison are + // contiguous and touch one end of the array. See `ordered_run`. + let Some(run) = ordered_run(lhs.base(), lhs.multiplier(), len, value, operator) + else { + return Ok(None); + }; + let mut bits = BitBufferMut::new_unset(len); + match run { + TrueRun::Prefix(end) => bits.fill_range(0, end, true), + TrueRun::Suffix(start) => bits.fill_range(start, len, true), + } + bits + } }; let nullability = lhs.dtype().nullability() | rhs.dtype().nullability(); let validity = match nullability { - Nullability::NonNullable => vortex_array::validity::Validity::NonNullable, - Nullability::Nullable => vortex_array::validity::Validity::AllValid, + Nullability::NonNullable => Validity::NonNullable, + Nullability::Nullable => Validity::AllValid, }; - - let array = match intersection { - Intersection::None => { - ConstantArray::new(Scalar::bool(false, nullability), lhs.len()).into_array() - } - Intersection::All => { - ConstantArray::new(Scalar::bool(true, nullability), lhs.len()).into_array() - } - Intersection::At(idx) => { - let mut buffer = BitBufferMut::new_unset(lhs.len()); - buffer.set(idx); - BoolArray::new(buffer.freeze(), validity).into_array() - } - }; - - Ok(Some(array)) + Ok(Some(BoolArray::new(bits.freeze(), validity).into_array())) } } @@ -121,6 +135,80 @@ pub(crate) fn find_intersection( }) } +/// The rows for which an ordering comparison holds. A sequence is monotonic, so they form a +/// prefix or a suffix. +#[derive(Debug, PartialEq, Eq)] +enum TrueRun { + /// Rows `0..end` hold. + Prefix(usize), + /// Rows `start..len` hold. + Suffix(usize), +} + +/// Finds the rows of a monotonic integer sequence for which `value[i] OP constant` holds. +/// +/// Counts the rows that come before `constant` in the direction of the sequence. Each operator +/// uses that count as the end of a prefix or the start of a suffix. For example, `2, 5, 8, 11` +/// has two rows before `8`, so `< 8` holds on rows `0..2`. +/// +/// The arithmetic runs in `i128`, so it is exact for all integer inputs. Returns `None` for a +/// non-integer step or constant. +fn ordered_run( + base: PValue, + multiplier: PValue, + len: usize, + constant: PValue, + operator: CompareOperator, +) -> Option { + let base = base.as_i128()?; + let step = multiplier.as_i128()?; + let constant = constant.as_i128()?; + + let clamp = |rows: i128| usize::try_from(rows.clamp(0, len as i128)).vortex_expect("clamped"); + + // All rows hold the same value, so the comparison is true for all rows or for none. + if step == 0 { + let holds = match operator { + CompareOperator::Lt => base < constant, + CompareOperator::Lte => base <= constant, + CompareOperator::Gt => base > constant, + CompareOperator::Gte => base >= constant, + CompareOperator::Eq | CompareOperator::NotEq => { + unreachable!("equality is answered by find_intersection") + } + }; + return Some(TrueRun::Prefix(if holds { len } else { 0 })); + } + + let ascending = step > 0; + let (distance, magnitude) = if ascending { + (constant - base, step) + } else { + (base - constant, -step) + }; + + // `magnitude` is positive, so `div_euclid` rounds down and a non-zero remainder rounds up. + let rows_strictly_before = + clamp(distance.div_euclid(magnitude) + i128::from(distance.rem_euclid(magnitude) != 0)); + let rows_at_or_before = clamp(distance.div_euclid(magnitude) + 1); + + // When ascending, the rows before `constant` are smaller than it. When descending, they are + // larger than it. The rows after are the complement, so they form the matching suffix. + Some(match (ascending, operator) { + (true, CompareOperator::Lt) => TrueRun::Prefix(rows_strictly_before), + (true, CompareOperator::Lte) => TrueRun::Prefix(rows_at_or_before), + (true, CompareOperator::Gt) => TrueRun::Suffix(rows_at_or_before), + (true, CompareOperator::Gte) => TrueRun::Suffix(rows_strictly_before), + (false, CompareOperator::Gt) => TrueRun::Prefix(rows_strictly_before), + (false, CompareOperator::Gte) => TrueRun::Prefix(rows_at_or_before), + (false, CompareOperator::Lt) => TrueRun::Suffix(rows_at_or_before), + (false, CompareOperator::Lte) => TrueRun::Suffix(rows_strictly_before), + (_, CompareOperator::Eq | CompareOperator::NotEq) => { + unreachable!("equality is answered by find_intersection") + } + }) +} + #[cfg(test)] mod tests { use std::sync::LazyLock; @@ -129,17 +217,22 @@ mod tests { use vortex_array::VortexSessionExecute; use vortex_array::arrays::BoolArray; use vortex_array::arrays::ConstantArray; + use vortex_array::arrays::PrimitiveArray; use vortex_array::assert_arrays_eq; use vortex_array::builtins::ArrayBuiltins; use vortex_array::dtype::Nullability::NonNullable; use vortex_array::dtype::Nullability::Nullable; use vortex_array::dtype::PType; use vortex_array::scalar::PValue; + use vortex_array::scalar::Scalar; + use vortex_array::scalar_fn::fns::binary::CompareKernel; + use vortex_array::scalar_fn::fns::operators::CompareOperator; use vortex_array::scalar_fn::fns::operators::Operator; use vortex_error::VortexResult; use vortex_session::VortexSession; use crate::Sequence; + use crate::SequenceArray; static SESSION: LazyLock = LazyLock::new(|| { let session = VortexSession::empty(); @@ -244,4 +337,97 @@ mod tests { Ok(()) } + + const ALL_OPERATORS: [CompareOperator; 6] = [ + CompareOperator::Eq, + CompareOperator::NotEq, + CompareOperator::Lt, + CompareOperator::Lte, + CompareOperator::Gt, + CompareOperator::Gte, + ]; + + /// Asserts the kernel engages for every operator and matches the comparison over the + /// materialized values. + fn assert_matches_primitive( + sequence: &SequenceArray, + constants: impl IntoIterator, + ) -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let values = sequence + .clone() + .into_array() + .execute::(&mut ctx)?; + for constant in constants { + let rhs = ConstantArray::new(constant, sequence.len()).into_array(); + for operator in ALL_OPERATORS { + let actual = ::compare( + sequence.as_view(), + &rhs, + operator, + &mut ctx, + )? + .unwrap_or_else(|| panic!("sequence compare must engage for {operator:?}")); + let expected = values + .clone() + .into_array() + .binary(rhs.clone(), Operator::from(operator))?; + assert_arrays_eq!(actual, expected, &mut ctx); + } + } + Ok(()) + } + + #[test] + fn ascending_matches_primitive() -> VortexResult<()> { + let sequence = Sequence::try_new_typed(2i64, 3, NonNullable, 10)?; + let constants = [i64::MIN, -100, 1, 2, 3, 4, 17, 28, 29, 30, i64::MAX]; + assert_matches_primitive(&sequence, constants.map(Scalar::from)) + } + + #[test] + fn descending_matches_primitive() -> VortexResult<()> { + let sequence = Sequence::try_new_typed(100i32, -7, Nullable, 8)?; + let constants = [i32::MIN, 0, 50, 51, 52, 79, 99, 100, 101, i32::MAX]; + assert_matches_primitive(&sequence, constants.map(Scalar::from)) + } + + #[test] + fn constant_sequence_matches_primitive() -> VortexResult<()> { + let sequence = Sequence::try_new_typed(42i32, 0, NonNullable, 5)?; + assert_matches_primitive(&sequence, [41i32, 42, 43].map(Scalar::from)) + } + + #[test] + fn single_row_matches_primitive() -> VortexResult<()> { + let sequence = Sequence::try_new_typed(5i16, 4, NonNullable, 1)?; + assert_matches_primitive(&sequence, [4i16, 5, 6].map(Scalar::from)) + } + + #[test] + fn descending_u8_matches_primitive() -> VortexResult<()> { + let sequence = Sequence::try_new( + PValue::from(200i32), + PValue::from(-3i32), + PType::U8, + NonNullable, + 60, + )?; + let constants = [0u8, 22, 23, 24, 25, 199, 200, 201, 255]; + assert_matches_primitive(&sequence, constants.map(Scalar::from)) + } + + #[test] + fn past_i64_max_matches_primitive() -> VortexResult<()> { + let step = (1u64 << 63) + 1; + let sequence = Sequence::try_new( + PValue::from(1u64 << 62), + PValue::from(step), + PType::U64, + NonNullable, + 2, + )?; + let constants = [0u64, 1 << 62, (1 << 62) + 1, (1 << 62) + step, u64::MAX]; + assert_matches_primitive(&sequence, constants.map(Scalar::from)) + } } diff --git a/java/vortex-jni/src/main/java/dev/vortex/api/Session.java b/java/vortex-jni/src/main/java/dev/vortex/api/Session.java index 843e93516b2..399498f030f 100644 --- a/java/vortex-jni/src/main/java/dev/vortex/api/Session.java +++ b/java/vortex-jni/src/main/java/dev/vortex/api/Session.java @@ -30,6 +30,16 @@ public static Session create() { return new Session(NativeSession.newSession()); } + /** + * Enable the edition with the name {@code edition}, for example {@code core2025.10.0}. The edition replaces the + * enabled edition of the same family. Only writers that start after this call use it. + * + *

Select an older edition to write files that older Vortex readers can read. + */ + public void enableEdition(String edition) { + NativeSession.enableEdition(pointer, edition); + } + /** Internal: returns the native pointer. Do not free directly. */ public long nativePointer() { return pointer; diff --git a/java/vortex-jni/src/main/java/dev/vortex/api/VortexColumnStatistics.java b/java/vortex-jni/src/main/java/dev/vortex/api/VortexColumnStatistics.java index 308ca64a0df..a84d455ee3b 100644 --- a/java/vortex-jni/src/main/java/dev/vortex/api/VortexColumnStatistics.java +++ b/java/vortex-jni/src/main/java/dev/vortex/api/VortexColumnStatistics.java @@ -6,7 +6,7 @@ import java.util.Optional; import java.util.OptionalLong; -/** Statistics and physical size reported for one top-level column after a Vortex write. */ +/** Statistics and physical size of one top-level column of a Vortex file, as stored in the file footer. */ public final class VortexColumnStatistics { private final int columnIndex; private final long compressedSize; @@ -17,10 +17,11 @@ public final class VortexColumnStatistics { private final Object upperBound; /** - * Construct native write statistics. + * Construct native column statistics. * *

This constructor is public so the JNI implementation can instantiate the value without reflective access. - * Applications should obtain instances from {@link VortexWriteSummary#columnStatistics()}. + * Applications should obtain instances from {@link VortexWriteSummary#columnStatistics()} or + * {@link dev.vortex.jni.NativeFiles#readStatistics(Session, String, java.util.Map)}. */ public VortexColumnStatistics( int columnIndex, diff --git a/java/vortex-jni/src/main/java/dev/vortex/jni/NativeFiles.java b/java/vortex-jni/src/main/java/dev/vortex/jni/NativeFiles.java index 8a969276e34..445b0ac7691 100644 --- a/java/vortex-jni/src/main/java/dev/vortex/jni/NativeFiles.java +++ b/java/vortex-jni/src/main/java/dev/vortex/jni/NativeFiles.java @@ -5,14 +5,15 @@ import com.google.common.base.Preconditions; import dev.vortex.api.Session; +import dev.vortex.api.VortexColumnStatistics; import dev.vortex.io.NativeReadable; import java.util.List; import java.util.Map; import java.util.Objects; /** - * Static utilities for discovering, deleting, and inspecting the metadata of Vortex files on an object store. The - * caller supplies a {@link Session}; its runtime handle is forwarded to the underlying object store. + * Static utilities for discovering, deleting, and inspecting the metadata and statistics of Vortex files on an object + * store. The caller supplies a {@link Session}; its runtime handle is forwarded to the underlying object store. */ public final class NativeFiles { static { @@ -60,6 +61,35 @@ public static Map readMetadata(Session session, NativeReadable r return readMetadataFromReadable(session.nativePointer(), readable, name, length); } + /** + * Read the per-column statistics stored in the footer of the Vortex file at {@code uri}, in Arrow schema order. + * Statistics the file does not store are empty in the returned values. + * + *

This opens the file on its own, but reads only the footer and no column data. + */ + public static List readStatistics( + Session session, String uri, Map options) { + return List.of(readStatistics(session.nativePointer(), uri, options)); + } + + /** + * Read the per-column statistics of a Vortex file through a caller-provided {@link NativeReadable}, instead of a + * native storage client. See {@link #readStatistics(Session, String, Map)}. + * + *

The readable must stay open for the duration of the call; native code never closes it. + * + *

{@link NativeReadable#name()} keys the file in the session's footer cache, exactly as it does when the + * readable is scanned, so reading statistics and then scanning the same file share one footer read. + */ + public static List readStatistics(Session session, NativeReadable readable) { + Objects.requireNonNull(readable, "readable"); + String name = readable.name(); + Preconditions.checkArgument(name != null && !name.isEmpty(), "readable reported an empty name"); + long length = readable.length(); + Preconditions.checkArgument(length >= 0, "readable for %s reported negative length", name); + return List.of(readStatisticsFromReadable(session.nativePointer(), readable, name, length)); + } + private static native List listFiles(long sessionPointer, String uri, Map options); private static native void delete(long sessionPointer, String[] uris, Map options); @@ -69,4 +99,10 @@ private static native Map readMetadata( private static native Map readMetadataFromReadable( long sessionPointer, Object readable, String name, long length); + + private static native VortexColumnStatistics[] readStatistics( + long sessionPointer, String uri, Map options); + + private static native VortexColumnStatistics[] readStatisticsFromReadable( + long sessionPointer, Object readable, String name, long length); } diff --git a/java/vortex-jni/src/main/java/dev/vortex/jni/NativeSession.java b/java/vortex-jni/src/main/java/dev/vortex/jni/NativeSession.java index 6ebdcacf237..3133a12336c 100644 --- a/java/vortex-jni/src/main/java/dev/vortex/jni/NativeSession.java +++ b/java/vortex-jni/src/main/java/dev/vortex/jni/NativeSession.java @@ -16,4 +16,10 @@ private NativeSession() {} /** Free a session previously returned by {@link #newSession()}. */ public static native void free(long pointer); + + /** + * Enable the edition with the name {@code edition}, for example {@code core2025.10.0}, for writes that start after + * this call. Throws a {@link RuntimeException} if the edition is not known. + */ + public static native void enableEdition(long pointer, String edition); } diff --git a/java/vortex-jni/src/test/java/dev/vortex/io/NativeIOBridgeTest.java b/java/vortex-jni/src/test/java/dev/vortex/io/NativeIOBridgeTest.java index 2fc0b47e30a..9b1d4722499 100644 --- a/java/vortex-jni/src/test/java/dev/vortex/io/NativeIOBridgeTest.java +++ b/java/vortex-jni/src/test/java/dev/vortex/io/NativeIOBridgeTest.java @@ -14,6 +14,7 @@ import dev.vortex.api.Scan; import dev.vortex.api.ScanOptions; import dev.vortex.api.Session; +import dev.vortex.api.VortexColumnStatistics; import dev.vortex.api.VortexWriteSummary; import dev.vortex.api.VortexWriter; import dev.vortex.arrow.ArrowAllocation; @@ -250,6 +251,25 @@ public void testMetadataRoundTripThroughBridge() throws IOException { } } + @Test + public void testStatisticsThroughBridge() throws IOException { + Path path = tempDir.resolve("bridge_statistics.vortex"); + BufferAllocator allocator = ArrowAllocation.rootAllocator(); + Session session = Session.create(); + + writePeopleFile(session, allocator, path); + + try (FileChannelReadable readable = new FileChannelReadable(path)) { + List statistics = NativeFiles.readStatistics(session, readable); + assertEquals(2, statistics.size()); + assertEquals(3L, statistics.get(0).valueCount()); + assertEquals("Alice", statistics.get(0).lowerBound().orElseThrow()); + assertEquals("Carol", statistics.get(0).upperBound().orElseThrow()); + assertEquals(25, statistics.get(1).lowerBound().orElseThrow()); + assertEquals(40, statistics.get(1).upperBound().orElseThrow()); + } + } + @Test public void testMultipleReadables() throws IOException { Path first = tempDir.resolve("bridge_a.vortex"); diff --git a/java/vortex-jni/src/test/java/dev/vortex/io/NativeWorkerAttachmentTest.java b/java/vortex-jni/src/test/java/dev/vortex/io/NativeWorkerAttachmentTest.java index 67f3269eb95..5447a38a160 100644 --- a/java/vortex-jni/src/test/java/dev/vortex/io/NativeWorkerAttachmentTest.java +++ b/java/vortex-jni/src/test/java/dev/vortex/io/NativeWorkerAttachmentTest.java @@ -89,11 +89,13 @@ void retiredWorkersDetachFromTheJvm() throws Exception { } boolean allStarted = started.await(30, TimeUnit.SECONDS); release.countDown(); - assertTrue(allStarted, "every writer should reach its first upcall on a worker"); for (VortexWriter writer : writers) { writer.close(); } + + assertTrue(allStarted, "every writer should reach its first upcall on a worker"); } + for (Sink sink : sinks) { assertTrue(sink.thread.isDaemon(), "a worker attached as a non-daemon thread keeps the JVM alive"); } diff --git a/java/vortex-jni/src/test/java/dev/vortex/jni/JNIWriterTest.java b/java/vortex-jni/src/test/java/dev/vortex/jni/JNIWriterTest.java index 9fcec319641..c81ec2132b1 100644 --- a/java/vortex-jni/src/test/java/dev/vortex/jni/JNIWriterTest.java +++ b/java/vortex-jni/src/test/java/dev/vortex/jni/JNIWriterTest.java @@ -16,6 +16,7 @@ import dev.vortex.api.Scan; import dev.vortex.api.ScanOptions; import dev.vortex.api.Session; +import dev.vortex.api.VortexColumnStatistics; import dev.vortex.api.VortexWriteSummary; import dev.vortex.api.VortexWriter; import dev.vortex.arrow.ArrowAllocation; @@ -32,6 +33,7 @@ import org.apache.arrow.c.ArrowSchema; import org.apache.arrow.c.Data; import org.apache.arrow.memory.BufferAllocator; +import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.vector.BigIntVector; import org.apache.arrow.vector.IntVector; import org.apache.arrow.vector.VarBinaryVector; @@ -226,6 +228,18 @@ public void close() {} } } + @Test + public void testCreateWriterReleasesSchemaExport() throws IOException { + String writePath = tempDir.resolve("test_schema_release.vortex").toUri().toString(); + Session session = Session.create(); + try (BufferAllocator allocator = new RootAllocator()) { + try (VortexWriter writer = VortexWriter.builder(session, writePath, personSchema(), allocator) + .build()) { + assertEquals(0, allocator.getAllocatedMemory()); + } + } + } + @Test public void testCreateWriterPlainLocalPath() throws IOException { Path outputPath = tempDir.resolve("test_create_plain_path.vortex"); @@ -422,6 +436,42 @@ public void testMapRoundTrip(boolean independentBuffers) throws IOException { assertEquals(3, rows); } + /** + * Editions before the aggregates, such as {@code core2025.10.0}, do not permit {@code vortex.min}. The writer then + * writes only the legacy file statistics, and these must still have the min, max and null count. + */ + @Test + public void testLegacyEditionWritesLegacyStatistics() throws IOException { + Path outputPath = tempDir.resolve("legacy_stats.vortex"); + String writePath = outputPath.toAbsolutePath().toUri().toString(); + BufferAllocator allocator = ArrowAllocation.rootAllocator(); + + Session session = Session.create(); + session.enableEdition("core2025.10.0"); + + VortexWriteSummary summary; + try (VortexWriter writer = VortexWriter.builder(session, writePath, personSchema(), allocator) + .build()) { + writePeopleBatch(writer, allocator); + summary = writer.finish(); + } + + assertEquals(3L, summary.rowCount()); + assertEquals(2, summary.columnStatistics().size()); + + // The string column has the bounded min and max, which fill the legacy min and max. + assertEquals(0L, summary.columnStatistics().get(0).nullValueCount().orElseThrow()); + assertEquals("Alice", summary.columnStatistics().get(0).lowerBound().orElseThrow()); + assertEquals("Carol", summary.columnStatistics().get(0).upperBound().orElseThrow()); + + assertEquals(0L, summary.columnStatistics().get(1).nullValueCount().orElseThrow()); + assertEquals(25, summary.columnStatistics().get(1).lowerBound().orElseThrow()); + assertEquals(40, summary.columnStatistics().get(1).upperBound().orElseThrow()); + + DataSource ds = DataSource.open(session, writePath); + assertEquals(new DataSource.RowCount.Exact(3L), ds.rowCount()); + } + /** Write a single three-row batch of {@link #personSchema()} data. */ private static void writePeopleBatch(VortexWriter writer, BufferAllocator allocator) throws IOException { try (VectorSchemaRoot root = VectorSchemaRoot.create(personSchema(), allocator)) { @@ -487,6 +537,40 @@ public void testFileWithoutMetadataReadsEmpty() throws IOException { assertTrue(NativeFiles.readMetadata(session, writePath, new HashMap<>()).isEmpty()); } + @Test + public void testFileStatisticsMatchWriteSummary() throws IOException { + Path outputPath = tempDir.resolve("test_statistics.vortex"); + String writePath = outputPath.toAbsolutePath().toUri().toString(); + + BufferAllocator allocator = ArrowAllocation.rootAllocator(); + Session session = Session.create(); + VortexWriteSummary summary; + try (VortexWriter writer = VortexWriter.builder(session, writePath, personSchema(), allocator) + .build()) { + writePeopleBatch(writer, allocator); + summary = writer.finish(); + } + + List statistics = NativeFiles.readStatistics(session, writePath, new HashMap<>()); + assertEquals(2, statistics.size()); + + VortexColumnStatistics name = statistics.get(0); + assertEquals(0, name.columnIndex()); + assertEquals(summary.columnStatistics().get(0).compressedSize(), name.compressedSize()); + assertEquals(3L, name.valueCount()); + assertEquals(0L, name.nullValueCount().orElseThrow()); + assertTrue(name.nanValueCount().isEmpty()); + assertEquals("Alice", name.lowerBound().orElseThrow()); + assertEquals("Carol", name.upperBound().orElseThrow()); + + VortexColumnStatistics age = statistics.get(1); + assertEquals(1, age.columnIndex()); + assertEquals(summary.columnStatistics().get(1).compressedSize(), age.compressedSize()); + assertEquals(3L, age.valueCount()); + assertEquals(25, age.lowerBound().orElseThrow()); + assertEquals(40, age.upperBound().orElseThrow()); + } + @Test public void testInvalidMetadataKeyRejectedAtCreate() { Path outputPath = tempDir.resolve("test_bad_metadata.vortex"); diff --git a/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/NestedSchemaPruning.java b/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/NestedSchemaPruning.java index 1863c5a3fe4..80660ff2bc1 100644 --- a/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/NestedSchemaPruning.java +++ b/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/NestedSchemaPruning.java @@ -5,8 +5,11 @@ import dev.vortex.api.Expression; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; import org.apache.spark.sql.types.ArrayType; import org.apache.spark.sql.types.DataType; import org.apache.spark.sql.types.StructField; @@ -142,6 +145,7 @@ private static Node struct( String path, int arrays) { StructField[] fields = read.fields(); + FieldLookup lookup = new FieldLookup(file, resolution.caseSensitive()); List names = new ArrayList<>(fields.length); List children = new ArrayList<>(fields.length); int[] slots = new int[fields.length]; @@ -151,7 +155,8 @@ private static Node struct( boolean filled = false; for (int i = 0; i < fields.length; i++) { String fieldPath = path.isEmpty() ? fields[i].name() : path + "." + fields[i].name(); - int index = fieldIndex(file, fields[i].name(), resolution, fieldPath); + int index = lookup.indexOf( + fields[i].name(), resolution.fileName(), path.isEmpty() ? "" : path + "."); if (index < 0) { if (!fields[i].nullable()) { throw new IllegalArgumentException(String.format( @@ -228,25 +233,48 @@ private static Node value( return new Node(null, null); } - private static int fieldIndex(StructType struct, String name, Resolution resolution, String path) { - int found = -1; - StructField[] fields = struct.fields(); - for (int i = 0; i < fields.length; i++) { - if (resolution.caseSensitive() - ? fields[i].name().equals(name) - : fields[i].name().equalsIgnoreCase(name)) { - if (found >= 0) { - throw new IllegalArgumentException(String.format( - Locale.ROOT, - "Ambiguous fields %s and %s for %s in %s under Spark's case sensitivity setting", - fields[found].name(), - fields[i].name(), - path, - resolution.fileName())); + /** + * Finds the fields of one file struct by name under Spark's case sensitivity, with one map lookup per field, so + * resolving a wide schema stays linear in its width. + */ + private static final class FieldLookup { + private final StructField[] fields; + private final Map indices; + + /** The second field that matches a name, for names that more than one field matches. */ + private final Map duplicates; + + FieldLookup(StructType struct, boolean caseSensitive) { + this.fields = struct.fields(); + this.indices = caseSensitive ? new HashMap<>() : new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + this.duplicates = caseSensitive ? new HashMap<>() : new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + + for (int i = 0; i < fields.length; i++) { + String name = fields[i].name(); + if (indices.putIfAbsent(name, i) != null) { + duplicates.putIfAbsent(name, i); } - found = i; } } - return found; + + /** Returns the position of the field {@code name} resolves to, or -1 if the struct does not carry it. */ + int indexOf(String name, String fileName, String prefix) { + Integer index = indices.get(name); + if (index == null) { + return -1; + } + + Integer duplicate = duplicates.get(name); + if (duplicate != null) { + throw new IllegalArgumentException(String.format( + Locale.ROOT, + "Ambiguous columns %s and %s in %s under Spark's case sensitivity setting", + prefix + fields[index].name(), + prefix + fields[duplicate].name(), + fileName)); + } + + return index; + } } } diff --git a/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/VortexPartitionReader.java b/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/VortexPartitionReader.java index 1d8c93e0562..29efbead326 100644 --- a/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/VortexPartitionReader.java +++ b/java/vortex-spark/common/src/main/java/dev/vortex/spark/read/VortexPartitionReader.java @@ -167,6 +167,11 @@ private static StructType fileSchema(List fields) { } private static DataType sparkType(Field field) { + // Extension types can export as Arrow structs without supporting native struct projections. + if (field.getType() instanceof ArrowType.ExtensionType + || field.getMetadata().containsKey(ArrowType.ExtensionType.EXTENSION_METADATA_KEY_NAME)) { + return DataTypes.NullType; + } // Only names, nullability and struct and array shapes are matched against, so leaf types are left unconverted: // a file column Spark cannot read only fails a query that reads it. if (field.getType() instanceof ArrowType.List || field.getType() instanceof ArrowType.ListView) { diff --git a/java/vortex-spark/common/src/main/java/dev/vortex/spark/write/VortexOutputWriter.java b/java/vortex-spark/common/src/main/java/dev/vortex/spark/write/VortexOutputWriter.java index 915c7673162..cb940145226 100644 --- a/java/vortex-spark/common/src/main/java/dev/vortex/spark/write/VortexOutputWriter.java +++ b/java/vortex-spark/common/src/main/java/dev/vortex/spark/write/VortexOutputWriter.java @@ -18,6 +18,7 @@ import java.io.UncheckedIOException; import java.util.List; import java.util.Locale; +import org.apache.spark.TaskContext; import org.apache.spark.sql.catalyst.InternalRow; import org.apache.spark.sql.execution.datasources.OutputWriter; import org.apache.spark.sql.types.StructField; @@ -248,19 +249,19 @@ private static long arrowBytes(List vectors) { /** * Flushes the last batch and finalizes the file. * - *

After a failed {@link #write}, the rows appended since the last batch are dropped and this only releases - * resources: it does not throw, because Spark's abort closes a task's writers one after another and stops at the - * first that throws. The incomplete file is never committed, since Spark commits only after every write returned - * and {@link #write} refuses every row once one has failed. + *

After a failed {@link #write}, or in a task that has already failed, the last batch is dropped because the + * file is never committed. In both cases this releases everything and logs what fails instead of throwing, because + * Spark's abort closes a task's writers one after another and stops at the first that throws. */ @Override public void close() { if (closed) { return; } + boolean aborting = writeFailure != null || taskFailed(); IOException failure = null; VortexWriteSummary fileSummary = null; - if (writeFailure == null) { + if (!aborting) { try { writeBatch(); } catch (IOException e) { @@ -291,9 +292,9 @@ public void close() { } session = null; closed = true; - if (writeFailure != null) { + if (aborting) { if (failure != null) { - logger.warn("Failed to release the writer for {} after an earlier write failed", filePath, failure); + logger.warn("Failed to close the writer for {} in a failed task", filePath, failure); } return; } @@ -307,7 +308,7 @@ public void close() { /** * Returns the completed file's size, row count and observed batch memory usage without reopening it. * - * @throws IllegalStateException unless {@link #close()} completed successfully and no write failed + * @throws IllegalStateException unless {@link #close()} completed successfully outside a failed task */ public VortexOutputWriterSummary summary() { if (summary == null) { @@ -321,6 +322,12 @@ public String path() { return filePath; } + /** Spark marks a task failed before its abort closes the task's writers. */ + private static boolean taskFailed() { + TaskContext context = TaskContext.get(); + return context != null && context.isFailed(); + } + /** Package-private so tests can see what close leaves allocated. */ BufferAllocator allocator() { return allocator; diff --git a/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexJvmExitTest.java b/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexJvmExitTest.java index 6430ef0d43d..52c6fa12c5e 100644 --- a/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexJvmExitTest.java +++ b/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexJvmExitTest.java @@ -6,7 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.lang.management.ManagementFactory; import java.nio.file.Path; +import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.spark.sql.SparkSession; @@ -25,17 +27,21 @@ public final class VortexJvmExitTest { @Test public void jvmExitsAfterWrites() throws Exception { Path log = tempDir.resolve("child.log"); - Process child = new ProcessBuilder(List.of( - Path.of(System.getProperty("java.home"), "bin", "java").toString(), - "-Xmx512m", - "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED", - "--add-opens=java.base/java.nio=ALL-UNNAMED", - "--add-opens=java.base/sun.util.calendar=ALL-UNNAMED", - "--add-opens=java.base/sun.security.action=ALL-UNNAMED", - "-cp", - System.getProperty("java.class.path"), - VortexJvmExitTest.class.getName(), - tempDir.resolve("table").toUri().toString())) + + // The child needs the same module openings Spark needs in this JVM. + List command = new ArrayList<>(); + command.add(Path.of(System.getProperty("java.home"), "bin", "java").toString()); + command.add("-Xmx512m"); + ManagementFactory.getRuntimeMXBean().getInputArguments().stream() + .filter(arg -> arg.startsWith("--add-opens=")) + .forEach(command::add); + command.addAll(List.of( + "-cp", + System.getProperty("java.class.path"), + VortexJvmExitTest.class.getName(), + tempDir.resolve("table").toUri().toString())); + + Process child = new ProcessBuilder(command) .redirectErrorStream(true) .redirectOutput(log.toFile()) .start(); diff --git a/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexNestedSchemaResolutionTest.java b/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexNestedSchemaResolutionTest.java index 722715c20a9..4b910033b3d 100644 --- a/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexNestedSchemaResolutionTest.java +++ b/java/vortex-spark/common/src/test/java/dev/vortex/spark/VortexNestedSchemaResolutionTest.java @@ -4,6 +4,8 @@ package dev.vortex.spark; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import dev.vortex.api.Session; import dev.vortex.api.VortexWriter; @@ -23,10 +25,12 @@ import dev.vortex.relocated.org.apache.arrow.vector.types.pojo.Schema; import java.io.IOException; import java.math.BigDecimal; +import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; +import org.apache.spark.sql.AnalysisException; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row; import org.apache.spark.sql.SparkSession; @@ -167,6 +171,56 @@ public void unreadColumnSparkCannotRead(@TempDir Path tempDir) throws IOExceptio assertRows(path, "id BIGINT", data -> data, "[[7]]"); } + @Test + @DisplayName("Files whose structs differ in field order and in fields read by name in one query") + public void filesWithDifferentStructs(@TempDir Path tempDir) { + String parquet = tempDir.resolve("parquet").toString(); + String vortex = tempDir.resolve("vortex").toString(); + Dataset first = spark.range(0, 2).selectExpr("id", "named_struct('x', id + 10, 'y', id + 20) AS c"); + Dataset second = spark.range(2, 4) + .selectExpr("id", "IF(id = 3, NULL, named_struct('y', id + 20, 'z', id + 30, 'x', id + 10)) AS c"); + for (Dataset rows : List.of(first, second)) { + rows.write().mode("append").parquet(parquet); + rows.write().mode("append").format("vortex").save(vortex); + } + + String schema = "id BIGINT, c STRUCT"; + assertRows( + vortex, + schema, + data -> data.selectExpr("id", "c"), + "[[0,[10,20,null]], [1,[11,21,null]], [2,[12,22,32]], [3,null]]"); + assertMatchesParquet(parquet, vortex, schema, data -> data.selectExpr("id", "c")); + assertMatchesParquet(parquet, vortex, schema, data -> data.selectExpr("id", "c.y", "c.z")); + assertMatchesParquet( + parquet, vortex, schema, data -> data.where("c.x > 10").selectExpr("id", "c.y")); + } + + @Test + @DisplayName("A struct read over a field the file stores as another type fails and names the field") + public void structOverAnotherType(@TempDir Path tempDir) { + String path = tempDir.resolve("vortex").toString(); + spark.range(2) + .selectExpr("id", "named_struct('a', id) AS s") + .write() + .format("vortex") + .save(path); + + Exception thrown = assertThrows(Exception.class, () -> spark.read() + .schema("id BIGINT, s STRUCT>") + .format("vortex") + .load(path) + .selectExpr("id", "s.a.x") + .collectAsList()); + + String expected = "stores column s.a as bigint, which cannot be read as struct"; + boolean found = false; + for (Throwable cause = thrown; cause != null && !found; cause = cause.getCause()) { + found = cause.getMessage() != null && cause.getMessage().contains(expected); + } + assertTrue(found, () -> "expected a cause containing \"" + expected + "\" in " + thrown); + } + @Test @DisplayName("A struct field Spark cannot read does not fail a query that reads its siblings") public void unreadStructFieldSparkCannotRead(@TempDir Path tempDir) throws IOException { @@ -193,6 +247,28 @@ public void unreadStructFieldSparkCannotRead(@TempDir Path tempDir) throws IOExc assertRows(path, readSchema, data -> data.selectExpr("id", "s"), "[[0,[10,20]]]"); } + @Test + @DisplayName("Partition columns come from the path under Spark's case sensitivity, without reading data columns") + public void partitionColumns(@TempDir Path tempDir) throws IOException { + Schema schema = new Schema(List.of(Field.nullable("u", new ArrowType.Int(32, false)))); + for (String dir : List.of("data/p=7", "ambiguous/p=7/P=8")) { + Files.createDirectories(tempDir.resolve(dir)); + writeOneRow(tempDir.resolve(dir + "/f.vortex").toString(), schema, root -> { + ((UInt4Vector) root.getVector("u")).setSafe(0, 1); + }); + } + String path = tempDir.resolve("data").toString(); + assertRows(path, "p INT", data -> data.selectExpr("p AS id"), "[[7]]"); + assertRows(path, "P INT", data -> data.selectExpr("P AS id"), "[[7]]"); + assertEquals(1, spark.read().schema("p INT").format("vortex").load(path).count()); + String ambiguous = tempDir.resolve("ambiguous").toString(); + assertThrows(AnalysisException.class, () -> spark.read() + .schema("p INT") + .format("vortex") + .load(ambiguous) + .collectAsList()); + } + private static void writeOneRow(String path, Schema schema, Consumer fill) throws IOException { BufferAllocator allocator = ArrowAllocation.rootAllocator(); try (VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator); @@ -226,13 +302,18 @@ private void assertRows(String path, String schema, Function, Datas /** Asserts that {@code query} returns the same rows from Vortex as from Parquet, with pruning off and on. */ private void assertMatchesParquet(String schema, Function, Dataset> query) { + assertMatchesParquet(parquetPath, vortexPath, schema, query); + } + + private void assertMatchesParquet( + String parquet, String vortex, String schema, Function, Dataset> query) { for (boolean pruning : new boolean[] {false, true}) { spark.conf().set(PRUNING, pruning); - List expected = query.apply(spark.read().schema(schema).parquet(parquetPath)) + List expected = query.apply(spark.read().schema(schema).parquet(parquet)) .orderBy("id") .collectAsList(); List actual = query.apply( - spark.read().schema(schema).format("vortex").load(vortexPath)) + spark.read().schema(schema).format("vortex").load(vortex)) .orderBy("id") .collectAsList(); assertEquals(expected, actual, schema + " with pruning " + (pruning ? "on" : "off")); diff --git a/java/vortex-spark/common/src/test/java/dev/vortex/spark/write/VortexOutputWriterAbortTest.java b/java/vortex-spark/common/src/test/java/dev/vortex/spark/write/VortexOutputWriterAbortTest.java index 65b7abe6883..579608816d7 100644 --- a/java/vortex-spark/common/src/test/java/dev/vortex/spark/write/VortexOutputWriterAbortTest.java +++ b/java/vortex-spark/common/src/test/java/dev/vortex/spark/write/VortexOutputWriterAbortTest.java @@ -21,8 +21,9 @@ import org.apache.spark.sql.SparkSession; import org.apache.spark.sql.types.DataTypes; import org.apache.spark.sql.types.StructType; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; /** * Spark's concurrent partition writer closes its open writers one after another when a task aborts and stops at the @@ -36,8 +37,11 @@ final class VortexOutputWriterAbortTest { @TempDir Path tempDir; - @Test - void aFailedWriteLetsAbortCloseEveryPartitionWriter() throws IOException { + // With one-row batches an oversized row fails in write, otherwise in the close that flushes it. With one in every + // partition, the closes during abort fail too. + @ParameterizedTest + @CsvSource({"1, false", "2048, false", "2048, true"}) + void aFailedWriteLetsAbortCloseEveryPartitionWriter(String batchSize, boolean everyPartition) throws IOException { SparkSession spark = SparkSession.builder() .master("local[1,1]") .appName("VortexOutputWriterAbortTest") @@ -50,7 +54,7 @@ void aFailedWriteLetsAbortCloseEveryPartitionWriter() throws IOException { List stranded = new ArrayList<>(); try { // The order Spark closes its writers in decides whether the failed one comes first, so fail each in turn. - for (int failed = 0; failed < PARTITIONS; failed++) { + for (int failed = 0; failed < (everyPartition ? 1 : PARTITIONS); failed++) { WRITERS.clear(); ALLOCATORS.clear(); List rows = new ArrayList<>(); @@ -58,13 +62,18 @@ void aFailedWriteLetsAbortCloseEveryPartitionWriter() throws IOException { rows.add(RowFactory.create("small", p)); } // Larger than the allocator limit set below, so appending it fails. - rows.add(RowFactory.create("x".repeat(2 << 20), failed)); - Path output = tempDir.resolve("failed=" + failed); + for (int p = 0; p < PARTITIONS; p++) { + if (everyPartition || p == failed) { + rows.add(RowFactory.create("x".repeat(2 << 20), p)); + } + } + Path output = tempDir.resolve(batchSize + "-" + everyPartition + "-failed=" + failed); Exception thrown = assertThrows(Exception.class, () -> spark.createDataFrame(rows, schema) .coalesce(1) .write() .format("dev.vortex.spark.write.LimitedVortexFileFormat") + .option("vortex.write.batch.size", batchSize) .partitionBy("p") .save(output.toString())); diff --git a/scripts/codspeed_bench_counts.json b/scripts/codspeed_bench_counts.json new file mode 100644 index 00000000000..3c45eb9b7ec --- /dev/null +++ b/scripts/codspeed_bench_counts.json @@ -0,0 +1,168 @@ +{ + "vortex": { + "common_encoding_tree_throughput": 8, + "pipeline": 0, + "single_encoding_throughput": 28, + "take_union": 4 + }, + "vortex-alp": { + "alp_compress": 96 + }, + "vortex-array": { + "aggregate_grouped": 18, + "aggregate_max": 15, + "aggregate_sum": 14, + "binary_ops": 7, + "bool_zip": 2, + "cast_decimal": 6, + "cast_primitive": 6, + "chunk_array_builder": 32, + "chunked_dict_builder": 24, + "chunked_fsl_canonicalize": 6, + "compare": 9, + "compare_sorted": 3, + "copy_to_canonical_width": 0, + "dict_compare": 27, + "dict_compress": 70, + "dict_mask": 16, + "dict_unreferenced_mask": 10, + "expr_case_when": 28, + "expr_large_struct_pack": 4, + "expr_optimize": 1, + "filter_bool": 61, + "filter_fixed_width": 31, + "filter_fsl": 4, + "filter_list": 12, + "interleave": 18, + "kleene_bool": 14, + "like": 7, + "list_contains_set": 4, + "list_length": 6, + "list_sum": 11, + "listview_builder_extend": 4, + "listview_rebuild": 9, + "listview_zip": 2, + "patches_lookup": 10, + "piecewise_sequence_take_primitive": 15, + "primitive_zip": 2, + "probe": 6, + "row_fn_bool_retry": 0, + "row_fn_output": 0, + "row_fn_utf8_input": 0, + "run_end_compress": 77, + "run_end_decode": 29, + "run_end_decode_primitive": 12, + "run_end_filter": 8, + "run_end_null_count": 24, + "run_end_sum": 1, + "run_end_take": 5, + "scalar_at_struct": 2, + "scalar_construction": 10, + "scalar_fn_probe": 8, + "scalar_subtract": 0, + "search_sorted": 2, + "slice_dict_primitive": 3, + "take_chunked": 27, + "take_filter": 32, + "take_fsl": 12, + "take_patches": 36, + "take_primitive": 25, + "take_struct": 3, + "take_varbin": 1, + "validity_is_valid": 4, + "varbinview_compact": 4, + "varbinview_fill_null": 2, + "varbinview_try_new": 6, + "varbinview_zip": 2, + "widen": 46 + }, + "vortex-buffer": { + "allocation": 35, + "collect_bool": 4, + "cpu_dispatch": 6, + "take_bits": 0, + "vortex_bitbuffer": 101, + "vortex_buffer": 40 + }, + "vortex-compressor": { + "dict_encode": 0, + "float_stats": 4, + "integer_stats": 4, + "stats_calc": 0 + }, + "vortex-compute": { + "lane_kernels": 10 + }, + "vortex-datetime-parts": { + "split_temporal": 4 + }, + "vortex-decimal-byte-parts": { + "dbp_assemble": 0, + "dbp_compute": 28, + "dbp_split": 0 + }, + "vortex-elias-fano": { + "unary": 20 + }, + "vortex-fastlanes": { + "bitpack_blocked": 0, + "bitpack_blocked_decompress": 0, + "bitpack_compare": 4, + "bitpack_compare_sweep": 232, + "bitpacking_filter": 0, + "bitpacking_take": 54, + "canonicalize_bench": 32, + "cast_bitpacked": 6, + "compute_between": 33, + "for_decode": 0, + "for_encode": 0 + }, + "vortex-file": { + "split_collection": 3 + }, + "vortex-fsst": { + "chunked_dict_fsst_builder": 12, + "fsst_compress": 66, + "fsst_like": 14, + "fsst_take": 24, + "fsst_url_compare": 8 + }, + "vortex-layout": { + "aggregate_partial_merge": 3, + "bloom_filter": 8, + "pipeline_scan": 9, + "zone_map_prune": 15 + }, + "vortex-mask": { + "intersect_by_rank": 26, + "mask_iteration": 30, + "rank": 4, + "valid_counts": 6 + }, + "vortex-pco": { + "scalar": 4 + }, + "vortex-row": { + "row_encode": 10 + }, + "vortex-sparse": { + "sparse_canonical": 4, + "sparse_pushdown": 5 + }, + "vortex-spatial": { + "area": 4, + "binary_predicates": 15, + "collect": 5, + "convex_hull": 3, + "distance": 4, + "envelope": 7, + "length": 3, + "make_line": 3, + "predicate_bbox": 8 + }, + "vortex-tensor": { + "cosine_similarity": 9, + "inner_product": 6, + "l2_norm": 6 + } +} diff --git a/scripts/codspeed_shards.py b/scripts/codspeed_shards.py new file mode 100644 index 00000000000..f33ed67faf1 --- /dev/null +++ b/scripts/codspeed_shards.py @@ -0,0 +1,231 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright the Vortex contributors + +"""Plan the CodSpeed simulation shards. + +CodSpeed rejects an upload with too many benchmarks and recommends fewer than 1,000 per upload, so +the simulation benchmarks are split into shards of at most `CAP` benchmarks each. The plan only +reads `Cargo.toml` files and `codspeed_bench_counts.json`, so it needs no Rust toolchain and runs +in a few seconds before the shard jobs start. + + python3 scripts/codspeed_shards.py plan >> "$GITHUB_OUTPUT" + python3 scripts/codspeed_shards.py counts job-log.txt [...] > scripts/codspeed_bench_counts.json + +The second form regenerates the counts from the logs of CodSpeed simulation jobs. +""" + +import argparse +import collections +import json +import math +import re +import sys +import tomllib +from pathlib import Path +from typing import TypedDict + +REPO_ROOT = Path(__file__).resolve().parents[1] +COUNTS_PATH = REPO_ROOT / "scripts" / "codspeed_bench_counts.json" + +# Most benchmarks per shard, leaving headroom under CodSpeed's recommended 1,000. +CAP = 800 + +# Shard slots in the `bench-codspeed` matrix of `.github/workflows/codspeed.yml`. The slots are fixed +# so that each one can be a required check; slots the plan does not use succeed without running. +MAX_SHARDS = 5 + +# Benchmarks measured for a target missing from the counts file, until the file is regenerated. +DEFAULT_COUNT = 100 + +# The packages whose benchmarks run in simulation, with the features each one builds with. +PACKAGES: dict[str, tuple[str, ...]] = { + "vortex": (), + "vortex-alp": (), + "vortex-array": ("_test-harness",), + "vortex-buffer": (), + "vortex-compressor": (), + "vortex-compute": (), + "vortex-datetime-parts": (), + "vortex-decimal-byte-parts": (), + "vortex-elias-fano": (), + "vortex-fastlanes": ("_test-harness",), + "vortex-file": (), + "vortex-fsst": ("_test-harness",), + "vortex-layout": (), + "vortex-mask": (), + "vortex-pco": (), + "vortex-row": (), + "vortex-sparse": (), + "vortex-spatial": ("_test-harness",), + "vortex-tensor": (), +} + +# vortex-array targets measured without allocator time: deferred allocator cleanup dominates them. +# CodSpeed only compares a benchmark against a base measured with the same setting, so these must +# never share a shard with other benchmarks. +EXCLUDE_ALLOCATIONS_PREFIXES = ("dict_", "chunked_dict_", "patches_", "take_", "filter_", "piecewise_sequence_") + +Target = tuple[str, str] # (package, bench target) + +# One entry of the GitHub Actions matrix. +Shard = TypedDict( + "Shard", + {"shard": int, "benchmarks": int, "packages": str, "build-args": str, "exclude-allocations": bool}, +) + + +def excludes_allocations(target: Target) -> bool: + package, name = target + return package == "vortex-array" and name.startswith(EXCLUDE_ALLOCATIONS_PREFIXES) + + +def discover_targets(root: Path = REPO_ROOT) -> list[Target]: + """Return the `[[bench]]` targets of every package in `PACKAGES`.""" + members = tomllib.loads((root / "Cargo.toml").read_text())["workspace"]["members"] + targets = [] + for member in members: + for manifest_dir in sorted(root.glob(member)): + manifest_path = manifest_dir / "Cargo.toml" + if not manifest_path.is_file(): + continue + manifest = tomllib.loads(manifest_path.read_text()) + package = manifest.get("package", {}).get("name") + if package in PACKAGES: + targets.extend((package, bench["name"]) for bench in manifest.get("bench", [])) + missing = set(PACKAGES) - {package for package, _ in targets} + if missing: + raise SystemExit(f"no benchmark targets found for {sorted(missing)}") + return sorted(targets) + + +def load_counts(path: Path = COUNTS_PATH) -> dict[Target, int]: + raw = json.loads(path.read_text()) + return {(package, name): count for package, benches in raw.items() for name, count in benches.items()} + + +def pack(items: list[tuple[str, list[Target], int]], cap: int) -> list[list[tuple[str, list[Target], int]]]: + """Pack `(key, targets, count)` items into as few bins of at most `cap` as greedy allows. + + Largest item first, each into the currently lightest bin; a new bin opens only when the + lightest one cannot take the item. + """ + total = sum(count for _, _, count in items) + bins: list[list[tuple[str, list[Target], int]]] = [[] for _ in range(max(1, math.ceil(total / cap)))] + for item in sorted(items, key=lambda item: (-item[2], item[0])): + lightest = min(bins, key=lambda b: sum(count for _, _, count in b)) + if sum(count for _, _, count in lightest) + item[2] > cap: + lightest = [] + bins.append(lightest) + lightest.append(item) + return [b for b in bins if b] + + +def plan(counts: dict[Target, int], cap: int = CAP) -> list[Shard]: + """Split targets into shards of at most `cap` benchmarks. + + Targets that exclude allocations and the rest are packed separately. Within each pool, a + package's targets stay together unless the package alone exceeds `cap`, in which case its + targets are packed one by one. + """ + for target, count in counts.items(): + if count > cap: + raise SystemExit(f"{target[0]}::{target[1]} alone has {count} benchmarks; split it below {cap}") + + pools: dict[bool, dict[str, list[Target]]] = collections.defaultdict(lambda: collections.defaultdict(list)) + for target in sorted(counts): + pools[excludes_allocations(target)][target[0]].append(target) + + shards: list[Shard] = [] + for exclude in sorted(pools): + items = [] + for package, targets in sorted(pools[exclude].items()): + total = sum(counts[t] for t in targets) + if total <= cap: + items.append((package, targets, total)) + else: + items.extend((f"{t[0]}::{t[1]}", [t], counts[t]) for t in targets) + for shard_items in pack(items, cap): + targets = sorted(t for _, ts, _ in shard_items for t in ts) + packages = sorted({package for package, _ in targets}) + features = sorted(f"{package}/{feature}" for package in packages for feature in PACKAGES[package]) + args = [f"--features {','.join(features)}"] if features else [] + args += [f"-p {package}" for package in packages] + args += [f"--bench {name}" for name in sorted({name for _, name in targets})] + shards.append( + { + "shard": len(shards) + 1, + "benchmarks": sum(counts[t] for t in targets), + "packages": " ".join(packages), + "build-args": " ".join(args), + "exclude-allocations": exclude, + } + ) + if len(shards) > MAX_SHARDS: + raise SystemExit( + f"{len(shards)} shards needed but the workflow has {MAX_SHARDS} slots; add slots to the " + "`bench-codspeed` matrix and MAX_SHARDS together" + ) + return shards + + +def github_outputs(shards: list[Shard]) -> dict[str, str]: + """Return the `plan-codspeed` job outputs: the used slots, and each slot's shard by number.""" + by_slot = {str(shard["shard"]): shard for shard in shards} + return { + "active": json.dumps([shard["shard"] for shard in shards]), + "shards": json.dumps(by_slot, separators=(",", ":")), + } + + +def counts_from_logs(paths: list[Path]) -> dict[str, dict[str, int]]: + """Count the `Measured:` lines per target in CodSpeed simulation job logs.""" + counts: dict[str, dict[str, int]] = collections.defaultdict(dict) + for path in paths: + current = None + for line in path.read_text(errors="replace").splitlines(): + if match := re.search(r"\bRunning (\S+) (\S+)$", line): + current = (match.group(1), match.group(2)) + if current[0] in PACKAGES: + counts[current[0]].setdefault(current[1], 0) + else: + current = None + elif "Done running" in line: + current = None + elif current and "Measured: " in line: + counts[current[0]][current[1]] += 1 + return {package: dict(sorted(benches.items())) for package, benches in sorted(counts.items())} + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + sub = parser.add_subparsers(dest="command", required=True) + sub.add_parser("plan", help="print the shard plan as GITHUB_OUTPUT lines") + counts_parser = sub.add_parser("counts", help="regenerate benchmark counts from CodSpeed job logs") + counts_parser.add_argument("logs", nargs="+", type=Path) + args = parser.parse_args() + + if args.command == "counts": + json.dump(counts_from_logs(args.logs), sys.stdout, indent=2) + sys.stdout.write("\n") + return + + known = load_counts() + counts = {} + for target in discover_targets(): + if target not in known: + print( + f"::warning::{target[0]}::{target[1]} is missing from {COUNTS_PATH.name}; assuming " + f"{DEFAULT_COUNT} benchmarks. Regenerate the counts with `codspeed_shards.py counts`.", + file=sys.stderr, + ) + counts[target] = known.get(target, DEFAULT_COUNT) + shards = plan(counts) + for shard in shards: + print(f"shard {shard['shard']}: {shard['benchmarks']} benchmarks, {shard['packages']}", file=sys.stderr) + for name, value in github_outputs(shards).items(): + print(f"{name}={value}") + + +if __name__ == "__main__": + main() diff --git a/scripts/tests/test_codspeed_shards.py b/scripts/tests/test_codspeed_shards.py new file mode 100644 index 00000000000..b753362ba4d --- /dev/null +++ b/scripts/tests/test_codspeed_shards.py @@ -0,0 +1,135 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright the Vortex contributors + +"""Tests for the CodSpeed shard planner in `scripts/codspeed_shards.py`. + +Run with: + + uv run --no-project --with pytest pytest scripts/tests/test_codspeed_shards.py +""" + +import importlib.util +import json +import re +from pathlib import Path +from types import ModuleType + +import pytest + +REPO_ROOT = Path(__file__).resolve().parents[2] +MODULE_PATH = REPO_ROOT / "scripts" / "codspeed_shards.py" + + +def _load() -> ModuleType: + spec = importlib.util.spec_from_file_location("codspeed_shards", MODULE_PATH) + assert spec is not None and spec.loader is not None + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module + + +shards = _load() + + +def _targets(shard: dict[str, object]) -> set[str]: + return set(re.findall(r"--bench (\S+)", str(shard["build-args"]))) + + +def test_every_target_lands_in_exactly_one_shard_under_the_cap(): + counts = shards.load_counts() + plan = shards.plan(counts) + seen = [name for shard in plan for name in _targets(shard)] + assert sorted(seen) == sorted({name for _, name in counts}) + assert len(seen) == len(set(seen)) + assert all(shard["benchmarks"] <= shards.CAP for shard in plan) + assert sum(shard["benchmarks"] for shard in plan) == sum(counts.values()) + + +def test_allocator_exclusion_never_shares_a_shard(): + counts = { + ("vortex-array", "take_primitive"): 10, + ("vortex-array", "dict_compress"): 10, + ("vortex-array", "compare"): 10, + ("vortex-buffer", "buffer"): 10, + } + plan = shards.plan(counts, cap=100) + excluded = [s for s in plan if s["exclude-allocations"]] + assert [_targets(s) for s in excluded] == [{"take_primitive", "dict_compress"}] + assert all(not (_targets(s) & {"take_primitive", "dict_compress"}) for s in plan if not s["exclude-allocations"]) + + +def test_package_stays_together_under_the_cap_and_splits_over_it(): + counts = { + ("vortex-buffer", "a"): 30, + ("vortex-buffer", "b"): 30, + ("vortex-fastlanes", "c"): 60, + ("vortex-fastlanes", "d"): 60, + ("vortex-mask", "e"): 50, + } + plan = shards.plan(counts, cap=100) + by_target = {name: s["shard"] for s in plan for name in _targets(s)} + assert by_target["a"] == by_target["b"] + assert by_target["c"] != by_target["d"] + assert all(s["benchmarks"] <= 100 for s in plan) + + +def test_build_args_name_only_the_features_of_selected_packages(): + counts = {("vortex-buffer", "a"): 1, ("vortex-fsst", "b"): 1} + (shard,) = shards.plan(counts, cap=100) + assert ( + shard["build-args"] + == "--features vortex-fsst/_test-harness -p vortex-buffer -p vortex-fsst --bench a --bench b" + ) + + (shard,) = shards.plan({("vortex-buffer", "a"): 1}, cap=100) + assert shard["build-args"] == "-p vortex-buffer --bench a" + + +def test_target_over_the_cap_is_rejected(): + with pytest.raises(SystemExit, match="split it below"): + shards.plan({("vortex-buffer", "a"): 101}, cap=100) + + +def test_more_shards_than_slots_is_rejected(): + counts = {("vortex-buffer", f"t{i}"): 100 for i in range(shards.MAX_SHARDS + 1)} + with pytest.raises(SystemExit, match="slots"): + shards.plan(counts, cap=100) + + +def test_github_outputs_key_shards_by_slot(): + plan = shards.plan({("vortex-buffer", "a"): 1, ("vortex-array", "take_x"): 1}, cap=100) + outputs = shards.github_outputs(plan) + assert json.loads(outputs["active"]) == [1, 2] + by_slot = json.loads(outputs["shards"]) + assert sorted(by_slot) == ["1", "2"] + assert by_slot["2"]["exclude-allocations"] is True + + +def test_workflow_matrix_has_max_shards_slots(): + workflow = (REPO_ROOT / ".github" / "workflows" / "codspeed.yml").read_text() + slots = re.search(r"^\s+shard: \[([\d, ]+)\]$", workflow, re.MULTILINE) + assert slots is not None + assert [int(s) for s in slots.group(1).split(",")] == list(range(1, shards.MAX_SHARDS + 1)) + + +def test_plan_is_deterministic(): + counts = shards.load_counts() + assert json.dumps(shards.plan(counts)) == json.dumps(shards.plan(dict(reversed(list(counts.items()))))) + + +def test_counts_file_covers_every_discovered_target(): + known = shards.load_counts() + assert set(shards.discover_targets()) <= set(known), "regenerate scripts/codspeed_bench_counts.json" + + +def test_counts_from_logs(tmp_path: Path): + log = tmp_path / "job.txt" + log.write_text( + "2026-01-01T00:00:00.0Z Running vortex-buffer buffer\n" + "2026-01-01T00:00:00.0Z Measured: vortex-buffer/benches/buffer.rs::a\n" + "2026-01-01T00:00:00.0Z Measured: vortex-buffer/benches/buffer.rs::b\n" + "2026-01-01T00:00:00.0Z Done running buffer\n" + "2026-01-01T00:00:00.0Z Running post-execution phase...\n" + "2026-01-01T00:00:00.0Z Measured: ignored\n" + ) + assert shards.counts_from_logs([log]) == {"vortex-buffer": {"buffer": 2}} diff --git a/uv.lock b/uv.lock index 33154e38287..e1b9619a0a5 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 5 requires-python = ">=3.11" resolution-markers = [ "python_full_version >= '3.14' and sys_platform == 'win32'", @@ -309,30 +309,30 @@ dev = [{ name = "pandas-stubs", specifier = ">=2.3.3.251201" }] [[package]] name = "boto3" -version = "1.43.121" +version = "1.43.118" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "botocore" }, { name = "jmespath" }, { name = "s3transfer" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/50/5c/41fb4571d14c1cfc87543a1e6f491f36f89c1ceac966aeddd61651ee4ba3/boto3-1.43.121.tar.gz", hash = "sha256:0599bdde7d0c03d914d9247b0a328ea48c15b0b3b5fb31a153857fa5bc7a4fd3", size = 112685, upload-time = "2026-10-28T19:19:00.615Z" } +sdist = { url = "https://files.pythonhosted.org/packages/96/8b/5694c8433b5202f34a82def4edee274f7df1eba2919c66d9d389d2202ec8/boto3-1.43.118.tar.gz", hash = "sha256:c0620f799e0f0c222ba42c337b65cdbcd3da38a3121187f634d8926cbbb28a9c", size = 112649, upload-time = "2026-10-22T19:22:09.629Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/31/57/a5fda6560d519037cc7df6dd116d5d66e7914be2f562e8c7b1ef888161a2/boto3-1.43.121-py3-none-any.whl", hash = "sha256:fc41ea80507416c30a3f7bdea3682124551ec0c36405c0d8149efaf65d9628e7", size = 140041, upload-time = "2026-10-28T19:18:58.973Z" }, + { url = "https://files.pythonhosted.org/packages/bb/a3/65bb3d64928f3c2da17640b92044084150317f02adf22442cb0c52af2a8b/boto3-1.43.118-py3-none-any.whl", hash = "sha256:ab8f3d2c622ef039338b4f228d97ea55f1abd573d84bb9b9a5ee8cb6780c0ccd", size = 140045, upload-time = "2026-10-22T19:22:08.353Z" }, ] [[package]] name = "botocore" -version = "1.43.121" +version = "1.43.118" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "jmespath" }, { name = "python-dateutil" }, { name = "urllib3" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/c6/98/1a07ef43bc267080b40709eba041fb39353f341401064912935b7e92bc07/botocore-1.43.121.tar.gz", hash = "sha256:69eb571c74ff140cc3a716aed3bc25d09eb7b12de4ea2f990c03785a634f9dcf", size = 16475471, upload-time = "2026-10-28T19:18:54.938Z" } +sdist = { url = "https://files.pythonhosted.org/packages/d4/b8/3e55154ddaf1a6d1d4ddda85c0e5983205a3b7657edacd8ebba8c6fd774c/botocore-1.43.118.tar.gz", hash = "sha256:7f3f9d88cc9e847587690f82a42e3c3c292c3026c92c1e60d68a9310018e003f", size = 16420126, upload-time = "2026-10-22T19:22:04.81Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ad/a8/5a0730dda5e076588c45c8ce73a56d1fc630accb994bfad0503c6825daf5/botocore-1.43.121-py3-none-any.whl", hash = "sha256:39bfd17e69f3370350e6aac2072df64045d002f9878e09115e85b87c772bd473", size = 16174916, upload-time = "2026-10-28T19:18:52.083Z" }, + { url = "https://files.pythonhosted.org/packages/9c/ce/61b39a8e7a69af5ea43c1c3e1b0065a4866b42ccddf107e16686a3143614/botocore-1.43.118-py3-none-any.whl", hash = "sha256:a45d7ae570674161e4a3542d8c68633bf7503f92d1de781ef7361b79488eda6f", size = 16122016, upload-time = "2026-10-22T19:22:00.414Z" }, ] [[package]] @@ -1274,160 +1274,160 @@ wheels = [ [[package]] name = "multidict" -version = "7.1.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f9/79/84ddb5ba16c4eb2c69c71db76ae3c579fe546e511f7170c7e27eedbab7c1/multidict-7.1.0.tar.gz", hash = "sha256:61a4e5d81b8d4e4ad61964b230129e7a2b914793d96289029078fc9009f074ec", size = 362341, upload-time = "2026-10-09T20:31:38.279Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/29/72/c68c86c078a3b3cfa254bce218fbeaf1f6617d4ace811558154ae63d2c20/multidict-7.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:41ff3202cc23c800507777df5a4805b402f262b31008c60fdc652aeb6db2f278", size = 165442, upload-time = "2026-10-09T13:59:19.146Z" }, - { url = "https://files.pythonhosted.org/packages/7c/af/988c71ec3a6fe143b2971ac8d57cd5aca7cc6da970bccd1e4c2254997a09/multidict-7.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:e50f7775b66c7802f4cb697e986c5acf30ec07301efee95b396c08114e890d67", size = 95611, upload-time = "2026-10-09T13:59:20.591Z" }, - { url = "https://files.pythonhosted.org/packages/30/5e/7d18eb5a75cf4bacb6b3ee689929dcb27d7ed8ca2d245e80e9b8056fcbf5/multidict-7.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:85cb3ced4fa84949cee12bfe78208b6ece7baf3cbd242b26dcaf773efff8d206", size = 98743, upload-time = "2026-10-09T13:59:21.841Z" }, - { url = "https://files.pythonhosted.org/packages/72/38/2aeff3de6ddf235094aad6f833e3df14d1b3175e328748508443cb2b5458/multidict-7.1.0-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:2128f3358335e0c83688ecb40c19d9d6606cd60784dfbf2e24e980ac2ba87b0d", size = 452832, upload-time = "2026-10-09T13:59:23.131Z" }, - { url = "https://files.pythonhosted.org/packages/eb/1f/94d8b7fc7d47bb43be1fc041bccc2784383d352258d4d0dd90ef55d1a2e5/multidict-7.1.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e2e718fa9d1d900decbc240a533d5d0baf0947ef464c78a8cd4fa32b4e8f590c", size = 475378, upload-time = "2026-10-09T13:59:24.661Z" }, - { url = "https://files.pythonhosted.org/packages/93/86/78f431ef2735fae7a773261ea26cff11e37cbbb4520bf3caed56ece006f1/multidict-7.1.0-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:ecc68f5e47bc6f6f889bbed5bc657b22bb2237ad9ccab8229cb5a0d64f4cb536", size = 442847, upload-time = "2026-10-09T13:59:26.276Z" }, - { url = "https://files.pythonhosted.org/packages/45/d3/1c5af82fe42f677f7c4dcaf487449511d754b84fc29f11a6d190cfb01836/multidict-7.1.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5f21fda91bd6c34455bd5c312e42aa1334da46cdafb4c533ecd01e0f7f19250b", size = 493652, upload-time = "2026-10-09T13:59:28.162Z" }, - { url = "https://files.pythonhosted.org/packages/c4/bc/414b4a83a12811329c046a7c1954d6f08a5eda63f8466939a6cb612da22b/multidict-7.1.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:7a90453a79423cd7145cc08fc92322dcd7aca4862258f533e03f473226d4b835", size = 506991, upload-time = "2026-10-09T13:59:29.701Z" }, - { url = "https://files.pythonhosted.org/packages/ec/ac/a91709d7153489a3b53661b62af371112b96fb083d10443e22d54665a1e1/multidict-7.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c54ae1b89e582aa25f213cd8b5eac0bda1724e79299f486baeb3f562bbf82ca5", size = 480392, upload-time = "2026-10-09T13:59:31.179Z" }, - { url = "https://files.pythonhosted.org/packages/72/63/a4fc53b6da419876f363fc6860f9fbaa48eb8066f458e907eb2989e9510b/multidict-7.1.0-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:7ff8dd079e7b5f3438332499233a2a5acfca0741fd0eb3d4ddba0c2d9bc04d19", size = 431248, upload-time = "2026-10-09T13:59:32.899Z" }, - { url = "https://files.pythonhosted.org/packages/3d/78/08af4a624b3b9d2f48af730c173394135d14afbf4b3de5ae6c80e0900fd1/multidict-7.1.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:e4ef15d0a29fc2da67fe8ba2301ecabd6f8733696cc2bf0a0cf96a144a20328c", size = 463657, upload-time = "2026-10-09T13:59:34.721Z" }, - { url = "https://files.pythonhosted.org/packages/58/ef/06e5c75b88506972c880d228fe96702cf0fa058ea31f157f5fcd5efcf006/multidict-7.1.0-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:5fa296f14068538fced53c6eec86520a2ef3d3d27a0fb134640d03e067986d5f", size = 436120, upload-time = "2026-10-09T13:59:36.135Z" }, - { url = "https://files.pythonhosted.org/packages/23/8d/a917004a1e8ceb325c4cf0583e418a40b7ff9519cbfe759bc6982cd3b4c1/multidict-7.1.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:6ab323f0c5490abaf35a78563e1043c7a772eb86d93f359ecc0fd286d1cd3807", size = 453859, upload-time = "2026-10-09T13:59:37.878Z" }, - { url = "https://files.pythonhosted.org/packages/1f/0b/d1cc417355625152b611790aa1f0bc780983ed8c0752f44087fc7dbe66c9/multidict-7.1.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:88ec4d16e9f58071c9896ea01c4da97cce9d01418fe844ff06eebb00e0a1386a", size = 481768, upload-time = "2026-10-09T13:59:39.39Z" }, - { url = "https://files.pythonhosted.org/packages/94/0b/8e79adf65cf5430497d1020504b7d86ebe90e3289a95bb6b252a630d761f/multidict-7.1.0-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:9161eb81b8062da824426d3700d4b0d287f0cb0b05923713adfe3bd25e7937ac", size = 426973, upload-time = "2026-10-09T13:59:40.932Z" }, - { url = "https://files.pythonhosted.org/packages/ae/4c/e84d6e05943600b16cd2745587e65a407f89b3a4a1f77081d456c5a07011/multidict-7.1.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:c564d0758748f38aec56a6b98c6801a427b3a63f39b7cac538b2b2d18ca32740", size = 489681, upload-time = "2026-10-09T13:59:42.663Z" }, - { url = "https://files.pythonhosted.org/packages/eb/98/01951236a01b3e15c037a4a796f329b5099374e46365d0bc65bb4a7b325d/multidict-7.1.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:c5e4a362a95b85301d262ef6bed06cc8e4a144ac7e2be874cb4c3c46ae89d754", size = 475655, upload-time = "2026-10-09T13:59:44.508Z" }, - { url = "https://files.pythonhosted.org/packages/d3/72/52be318cdb46732da8eb118c2e4212fe570724eaef817901f8b702af2016/multidict-7.1.0-cp311-cp311-win32.whl", hash = "sha256:5d19bb1ec12e385c09215d5d53a243c060c7e8a0aacdba16d933e22902ee380d", size = 81719, upload-time = "2026-10-09T13:59:46.158Z" }, - { url = "https://files.pythonhosted.org/packages/37/fd/1ed7b7d206ef7a6918ac3de515543ca4b49bc50131325ca1814c005daf3f/multidict-7.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:396ba9917fe489ec3a5942ae3e29e91324c8b9956f371f7e124c971c71379e7a", size = 93586, upload-time = "2026-10-09T13:59:47.618Z" }, - { url = "https://files.pythonhosted.org/packages/d8/1e/837877d218bfd2b656ca899ec9dd83e6eb82d8e1ef16e896d5abf3cb60cd/multidict-7.1.0-cp311-cp311-win_arm64.whl", hash = "sha256:b5ed78742502b8d90ff2816688d407a097c8b5cc6af4343fc5ad7a98df53a7cd", size = 92446, upload-time = "2026-10-09T13:59:48.996Z" }, - { url = "https://files.pythonhosted.org/packages/03/e1/215e7df354e2907f3af9d910c8136653cfec94796012a776359bc802a326/multidict-7.1.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:ccfb950359a80de0fcd2030ad60ac1b1a861462de3e2ef746697c9256659af21", size = 165426, upload-time = "2026-10-09T13:59:50.564Z" }, - { url = "https://files.pythonhosted.org/packages/a4/ec/461ba588b308ada2cd16907d6ea425ca4d417596b88c12814ad9a0bb7325/multidict-7.1.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:939d8cd2d8c35e3956f6bc858390b6ccb611e6152b4920d64ab5e98f3fcf39e4", size = 95943, upload-time = "2026-10-09T13:59:52.381Z" }, - { url = "https://files.pythonhosted.org/packages/c9/84/31444ef07ec13a33c42c2772d986129e137e69c4beb89ca64f2138988145/multidict-7.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f8e95c95039eab6a2dad8c83c38ab87fc5431d28849e0c8a7e2a4e70ba38710d", size = 98294, upload-time = "2026-10-09T13:59:54.066Z" }, - { url = "https://files.pythonhosted.org/packages/dc/10/aca13806d73d88b5b01e35e828e23a346cb1abad710a49dff0507702efc9/multidict-7.1.0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:05d12b4bac53abe0c65f3163af2b45894e2e1c0cc55493ac784d52a350047d88", size = 453301, upload-time = "2026-10-09T13:59:55.397Z" }, - { url = "https://files.pythonhosted.org/packages/96/8c/382d771bfb3a9282d98332d0e1f27fd1f8b4ae0e7175bd7e008ebf934900/multidict-7.1.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0e79ed92b1dece6bb57e9b46effd74d7a5d3d00187c85466d880ed184239a698", size = 478570, upload-time = "2026-10-09T13:59:56.899Z" }, - { url = "https://files.pythonhosted.org/packages/52/9c/e81b0c92449da3a1950a575c520d957d7be618777d170717a71e00558d7f/multidict-7.1.0-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:fab380fcff8b3555eb2bd04304fa4330909a771a9a9b0dc07666cfc23148a711", size = 443699, upload-time = "2026-10-09T13:59:58.465Z" }, - { url = "https://files.pythonhosted.org/packages/63/72/f8f5fee6960d1b580a7b046c7c5abccf67aa26fa5647927a91c9c835c2f8/multidict-7.1.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4b5c41e44da74383c924cc5d75ef0a268f301d69305b3c42bd17af685d55e412", size = 497332, upload-time = "2026-10-09T14:08:01.88Z" }, - { url = "https://files.pythonhosted.org/packages/e2/92/a25d7db3ca451b588e743e067ee80f2b475edf6467a56908454faf6a714c/multidict-7.1.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:3dbaa7f7c2f0ca8578895fc61fb8c8e50ebb405dad8982f92f4343285c7a3fda", size = 512457, upload-time = "2026-10-09T14:08:25.465Z" }, - { url = "https://files.pythonhosted.org/packages/7a/f3/374c0ab122bb98b1a62a8742b1e3f59563e4d609942005a4041861a0df67/multidict-7.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fed6b7705d49dd07e5e0dd5f5c873fc44047e92d714299b13245b5fecac49d01", size = 483000, upload-time = "2026-10-09T14:08:27.132Z" }, - { url = "https://files.pythonhosted.org/packages/46/1f/01c8522859771dc3cee840d5852233fe84c91aa982a1cd8ad594306d25cc/multidict-7.1.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:53daa47dd176db64bb35170e3d5d0ae2388c060121201883696278f055a0e70c", size = 430746, upload-time = "2026-10-09T14:08:28.715Z" }, - { url = "https://files.pythonhosted.org/packages/ab/f3/af90affc8cca6b4ee59b2ec354a20839005e829d14d155451009810ef1ce/multidict-7.1.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:542429c796430de924d03b68a6173bb6d79d5c4967d4e9a18de3e501cad55593", size = 466859, upload-time = "2026-10-09T20:27:24.139Z" }, - { url = "https://files.pythonhosted.org/packages/f8/97/1b6762f37f6331449e164af9d5500f0abb0f23670e81ba543441e0a6be1d/multidict-7.1.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:c44ca6d3cdf4cfcbcd4f928fdcbe87af5fd7319f6ad4169617b7fd6b4527c33c", size = 441952, upload-time = "2026-10-09T20:27:26.559Z" }, - { url = "https://files.pythonhosted.org/packages/bf/d2/4908177fbf22438799c04ba11a2853a99c69d028fccefe61f19e68caba0c/multidict-7.1.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:eb0228c809b2e7eb47921876050af0bc4214b351bad8d8112f70b6ed4288763c", size = 452810, upload-time = "2026-10-09T20:27:28.347Z" }, - { url = "https://files.pythonhosted.org/packages/8d/05/5031f44f680ec54fc182c4d71c9ab7c07216983946aa64ce6fdd56a52692/multidict-7.1.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:6ad60de1f4c702448fc8f1449f05e810f6b7957c08a5b3950c8a792dfb13b50a", size = 483934, upload-time = "2026-10-09T20:27:30.14Z" }, - { url = "https://files.pythonhosted.org/packages/da/3b/9b21d107dbe96fa7e6966ff9e5e10b9ac0d2d1c2cf1633098e4c700f865e/multidict-7.1.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:f79def86aee67b5ba01b2565f1610f262bf88ae53c379f93e5fa29c50fe793be", size = 427042, upload-time = "2026-10-09T20:27:32.433Z" }, - { url = "https://files.pythonhosted.org/packages/53/ce/5b01b1041580072866b30e39c6380bff269e72fb5ca41a7f2fb828ede943/multidict-7.1.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:248dabb89b5aa90b2f7e43e045f048f7e5392ec77b6446d80853ba7117d7bbdf", size = 492543, upload-time = "2026-10-09T20:27:34.459Z" }, - { url = "https://files.pythonhosted.org/packages/1e/6f/6508a23fcc7b1122e4f18409d7900ffeb3cd020cd080fe98aba3eabf9486/multidict-7.1.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:0747a83e7ae617793181a4763ee8b84863cec5c0bbbde70c4394e4c0276c36de", size = 475796, upload-time = "2026-10-09T20:27:36.289Z" }, - { url = "https://files.pythonhosted.org/packages/8f/b6/ebb6433f4aa55ac1fea4bf11e860e99611640d07cc92d21cb3f35608de22/multidict-7.1.0-cp312-cp312-win32.whl", hash = "sha256:1df055e51fe7491120cc84f3362bd43db186be78d0e4c476acad45e435af9ffb", size = 81250, upload-time = "2026-10-09T20:27:38.229Z" }, - { url = "https://files.pythonhosted.org/packages/61/0a/11240e5e7d2e986e288f4a6090f569ad00225b7c2c513d4096b36643f9ab/multidict-7.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:10202ba98cfb3f7eb60da7ca87a2c458a69b7d0d6e4d4388cd6773ebbce89085", size = 93817, upload-time = "2026-10-09T20:27:39.739Z" }, - { url = "https://files.pythonhosted.org/packages/e9/9b/a04ffd76db7cca2a60d347e839315e1ada63017c6c343fa90a23a5a55433/multidict-7.1.0-cp312-cp312-win_arm64.whl", hash = "sha256:0aa1ba3ff7cdda05a1242490612976b2ae1c90fc6200903ef8f53815dcb35c5d", size = 92312, upload-time = "2026-10-09T20:27:41.285Z" }, - { url = "https://files.pythonhosted.org/packages/60/34/22ee5f60d704e8edfe6e0a37ca1e2d1efe276560dc8f6f8caee35ea7a4f5/multidict-7.1.0-cp313-cp313-android_24_x86_64.whl", hash = "sha256:51d7f33be9a4a1a2801430846d72841deea0894eae8381a07e7d90e0f71b3c4b", size = 101454, upload-time = "2026-10-09T20:27:43.102Z" }, - { url = "https://files.pythonhosted.org/packages/3b/6d/7652943397171fd624de163d25fc6d2807852931c40c24776cfee3f857cc/multidict-7.1.0-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:2a964dfeb2aba3663f0536c809aa1ff385f065e89fae57e883fb7edfb4067c2f", size = 95823, upload-time = "2026-10-09T20:27:44.912Z" }, - { url = "https://files.pythonhosted.org/packages/a2/57/717d1aa4e901f58a7e93b945ed741c860d950f456b75be47123fef507ac2/multidict-7.1.0-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:d02cd23b5af182a49d635ee72be38053767711987a9fd82625b16b93828a0d8c", size = 97841, upload-time = "2026-10-09T20:27:46.616Z" }, - { url = "https://files.pythonhosted.org/packages/a8/74/d2d22d306225f3c53ea5a682abb8a43bc30057d6c78b5c94a74035450bfd/multidict-7.1.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:0179698c3c913eb64f32397083747fad20ed0f0a2b7469a08cd1a8a95d14d90e", size = 164661, upload-time = "2026-10-09T20:27:48.495Z" }, - { url = "https://files.pythonhosted.org/packages/55/f4/1e63fea41ba86768e18dbc1743e6780f75ad32d7a45e418740c6fb64589e/multidict-7.1.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ccf98ee859fe29f874ddd8e637f14ba59108a333492b521acb885a9095244a9c", size = 95489, upload-time = "2026-10-09T20:27:50.055Z" }, - { url = "https://files.pythonhosted.org/packages/8c/55/477c351b21b34fe948ffffa8b64cd0c246efd998fed3de922b217e632e59/multidict-7.1.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5fa1484f74d011addf2e5f5a0378ec41521989839a05d6051d8067d8ce732423", size = 97931, upload-time = "2026-10-09T20:27:51.598Z" }, - { url = "https://files.pythonhosted.org/packages/cc/dd/288508d7deb9489dd7c8e0b172d62dc1da8f3cb24877293ead42e6cc2047/multidict-7.1.0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:1fed3d721f75c25a9fcdd0e362af53f4b20acbcdc63081112f85419ba0ce3444", size = 453816, upload-time = "2026-10-09T20:27:53.217Z" }, - { url = "https://files.pythonhosted.org/packages/60/ed/172447dd09f06111f69d2cf22a018020b34a93a39ddf72cddfdb48323449/multidict-7.1.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:df03e392cae1e05462918abbae06d6100f1e53f67db971ff0ac6c07d9edf7321", size = 477779, upload-time = "2026-10-09T20:27:54.972Z" }, - { url = "https://files.pythonhosted.org/packages/e4/7d/e5b7755e84611ee846f0dc830cb1363ce10764b29247a01b857722fda653/multidict-7.1.0-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:379f477b98a1e9a77ddc3ccaa8c709d3fb4a288ff54b96e171e637b55b4adbae", size = 441299, upload-time = "2026-10-09T20:27:56.901Z" }, - { url = "https://files.pythonhosted.org/packages/1b/d6/e9c93da1644491610f09258349283421a279fdb3b383929b4d963698691c/multidict-7.1.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:40f586bc8a084a3671ddcae9e5fbd3228a596bfb63d9f0380f153f9a65b69f08", size = 496193, upload-time = "2026-10-09T20:27:58.788Z" }, - { url = "https://files.pythonhosted.org/packages/22/49/7fe19efed1b1c73e2f6ae65eba4e6528eeb26e10c970dc0bb0fc009a2aae/multidict-7.1.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:6e7f70d912a589e30290ed926f90ddbc3160998359cbad7c9ede1bcee481748c", size = 511469, upload-time = "2026-10-09T20:28:00.689Z" }, - { url = "https://files.pythonhosted.org/packages/4d/2e/7b708a72001323dc6b2930834d63e355870ea5b1ee8d1450e0fe1a24752b/multidict-7.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5129cc1f5fec6888e2db0be936dab67242e32c738811c8769aeea93aab4257a8", size = 481377, upload-time = "2026-10-09T20:28:03.011Z" }, - { url = "https://files.pythonhosted.org/packages/8b/60/3d23e7d2ebc7e7e6b1b205de0d5c2ce0652a9b2edef65eea3528758b5699/multidict-7.1.0-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:1401caec21fd7f002e79ab6806bbfd1f54bb3de6d5e12bd91c6685dce16ad2be", size = 429992, upload-time = "2026-10-09T20:28:04.846Z" }, - { url = "https://files.pythonhosted.org/packages/f6/e6/8e3bef78ea1929a3f2c395aa292799d4effd6ce1b5cfce42c1986a33e2b5/multidict-7.1.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:c81062e947f4b5a624135a843f6ac4b3c7fe6508300c9fb27347f022ba0c513d", size = 465635, upload-time = "2026-10-09T20:28:06.527Z" }, - { url = "https://files.pythonhosted.org/packages/44/6a/55fe5dd90c0e9ce60f5c4fa8ace27eeb1190d9cbb151929b04412f0c673a/multidict-7.1.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:c53be0dd676484a660acc56e4f1cd0dd74bc1255d12fa285e86a3fa9d5f22bf9", size = 441693, upload-time = "2026-10-09T20:28:08.443Z" }, - { url = "https://files.pythonhosted.org/packages/c2/a9/628913f71537dce7dbd6c4ee1ae5019976264427c55354ecc593b4b921b9/multidict-7.1.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:41e0c3350d08994ee8640c39884e16514e282f70ba40f5b2299582509a327774", size = 453808, upload-time = "2026-10-09T20:28:10.871Z" }, - { url = "https://files.pythonhosted.org/packages/25/d0/3ae3af653b5776d045f460582006d0b4d7dd41b078b3ab2e874bf4d1e22f/multidict-7.1.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:abeec7a89d698aa1c9b4c36bd5e3c746faef0867076e6a2ca27fa5077c4ece26", size = 483160, upload-time = "2026-10-09T20:28:12.892Z" }, - { url = "https://files.pythonhosted.org/packages/56/3e/2c13e111b9f4c6216aee0ac57ac39c53db7f97e42bb8490e60a06eaca352/multidict-7.1.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:23f6d325241b0db006ca2841309ed17622137e134930a740a8f1331ec4404791", size = 425896, upload-time = "2026-10-09T20:28:14.65Z" }, - { url = "https://files.pythonhosted.org/packages/45/13/15b4d614cf0d6838a7d89eb14f4820fdecfd1b7f529061d172a674912d41/multidict-7.1.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:034b0dc1b7fb8279599c5d8563f86abb4d2454735b06544ecab23c54572ad2bd", size = 491674, upload-time = "2026-10-09T20:28:16.508Z" }, - { url = "https://files.pythonhosted.org/packages/4f/97/3a6f8c75f12a607ff047e3db9a45dff6a558b1e31b89b2f0f27da0fedb6f/multidict-7.1.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5c8074ad4d67067c87bd0663dfda654f786336078c8fd7d2f6c1aa41de8494cc", size = 473989, upload-time = "2026-10-09T20:28:18.284Z" }, - { url = "https://files.pythonhosted.org/packages/3f/20/5e7726631e50b6afd26324a234851a06104b8ee30f01bc209140788b76c6/multidict-7.1.0-cp313-cp313-win32.whl", hash = "sha256:7b25c335fc53acf29d4d21dbc19fe39d2824201cdda0448623152cc5917bd259", size = 80952, upload-time = "2026-10-09T20:28:20.044Z" }, - { url = "https://files.pythonhosted.org/packages/4f/19/b26bdbef5bf5071ea5a3ba37c963af187fddb8b0a925bd39c0c5dd0ad04a/multidict-7.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:7de54b49e6da811b0321e412d14efdaa1ee0c0b6609296ea5b9022bc5b2bd843", size = 93554, upload-time = "2026-10-09T20:28:21.657Z" }, - { url = "https://files.pythonhosted.org/packages/35/d5/e9a8600d3868e3fdc4a4be1d15e594048508511c0398423df0ed18c11b5a/multidict-7.1.0-cp313-cp313-win_arm64.whl", hash = "sha256:aeba2c750102051aa51e087c2ccbc79f2724a41c94168f8731e36f54c453551a", size = 92039, upload-time = "2026-10-09T20:28:23.464Z" }, - { url = "https://files.pythonhosted.org/packages/2c/a7/c9f5c08348a6f903143b631546e22becf1b704a1304b17f7e1b9850308d2/multidict-7.1.0-cp314-cp314-android_24_x86_64.whl", hash = "sha256:128ea4142f81a79d430f3d0eb55206093e5eda03a12abbc7b03c34748ff6116b", size = 100435, upload-time = "2026-10-09T20:28:26.111Z" }, - { url = "https://files.pythonhosted.org/packages/82/60/92fe617008c74cc019483b1c59202c48738c6f637ad5b12b36f01e21db43/multidict-7.1.0-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:439a19f7fbbff232ce96682c57e27030b8ac3a4b8121484c94f04bf99d08bfff", size = 95267, upload-time = "2026-10-09T20:28:27.856Z" }, - { url = "https://files.pythonhosted.org/packages/17/78/82182f311d673f17de15bc7f7465c7ea5cbd2987ca3a6bf6546fa721e9d8/multidict-7.1.0-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:8090c35199d6b7bc6426bb8bdaf341e64f295cc2624a1fda7860c0837f1acc03", size = 97233, upload-time = "2026-10-09T20:28:29.817Z" }, - { url = "https://files.pythonhosted.org/packages/63/25/af4e482d053fd73b4b1d60de3ff5578c6cb1d319d39d3f2a454d65409835/multidict-7.1.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:b7cc5333fcbfb27327d12612ed72322f221b61c2b69deb1155078c964f86e1a1", size = 163070, upload-time = "2026-10-09T20:28:31.495Z" }, - { url = "https://files.pythonhosted.org/packages/df/d5/eaed52e199451dac445305fb2631d3f4e7ac9536aeef01f23622a1d93f90/multidict-7.1.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:b0e0040b0d8dd89bd0af9ab18901981e344ffba68bb30b8eabb4eab6c303279b", size = 94582, upload-time = "2026-10-09T20:28:33.263Z" }, - { url = "https://files.pythonhosted.org/packages/6b/e3/ff58ecad5161baa98dec05716e2745449446f2424a9c727464bf452f7fd1/multidict-7.1.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:33376418ab2846b931a72b36cfa16810befc4f49485d0b3f4dc054a4d6d00038", size = 97406, upload-time = "2026-10-09T20:28:34.981Z" }, - { url = "https://files.pythonhosted.org/packages/ac/a2/ae4eadf02d4bc035baa7cadf5548ca4fa441517193f76ce1aeb5ed276ae3/multidict-7.1.0-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:1101aea5c3eb1d26e090b931c693488af0db9f3d52e68be8d4cdd807dad9841d", size = 449908, upload-time = "2026-10-09T20:28:36.659Z" }, - { url = "https://files.pythonhosted.org/packages/91/55/bd5101ef760d1af4c3f246330b29b48ee22bfdd5a83150b713dd93b431e2/multidict-7.1.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f996b19ac89e0dae65821ce65f788619e4286f78c62d005ecd3b75b5d9c0892b", size = 471605, upload-time = "2026-10-09T20:28:38.561Z" }, - { url = "https://files.pythonhosted.org/packages/4d/8f/3dea8a28b0416ab71d47c8ce274bb3cacedde2d9838647ac67cdaa3d48e6/multidict-7.1.0-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:e0d91a4bcb59ac0d7af0d8e0da737332e1b7fe6831e53e47819b1b5349d431b2", size = 433523, upload-time = "2026-10-09T20:28:40.913Z" }, - { url = "https://files.pythonhosted.org/packages/24/97/805d2aa4f746cc43cf4b206f1b1bfe2566add95bbb145abd3d9cf61858bf/multidict-7.1.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:e96d67914ddbf5466e4476a1cd7ff30a332cbab85ed895207acc3e58c979b6a7", size = 488277, upload-time = "2026-10-09T20:28:42.851Z" }, - { url = "https://files.pythonhosted.org/packages/dd/7b/eac247b7e76f6010071c7c2401da5255eeffd1b2ac981925e533413d21ec/multidict-7.1.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:170ba61761f59ab92afcc86ce5534a3f3d0b07c38b339b950a83213f22dd86ec", size = 501888, upload-time = "2026-10-09T20:28:44.75Z" }, - { url = "https://files.pythonhosted.org/packages/87/58/de62e27b09dd15756265765945f68f1c0d1e23eaba09e2e109fbb4112425/multidict-7.1.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:33389fe084e5426d9fd85d7d9ca91a29cd0d88a83c7c96e411aca49a3f9967bc", size = 474883, upload-time = "2026-10-09T20:28:46.704Z" }, - { url = "https://files.pythonhosted.org/packages/21/fd/afb4e50ce3b44707b5ee39c6b5fa1573bdb50c4be660bb35b040362b5170/multidict-7.1.0-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:77024596b9046572c4e90b34c1ff212346756dc48933f90c53cf6e233660788d", size = 424327, upload-time = "2026-10-09T20:28:48.681Z" }, - { url = "https://files.pythonhosted.org/packages/23/70/96c9abf933c4edae53b8a1c8d3f038120a3a60d363f16c6d94eee9b04851/multidict-7.1.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ff15531a376dc6f35984443fd1429e4b150c36ce27633e7cc52a9e5318546e20", size = 459255, upload-time = "2026-10-09T20:28:50.562Z" }, - { url = "https://files.pythonhosted.org/packages/24/37/dbc1dba26dc1c9e42aa07ee01908131a67fee0e79ebe5c1d0e7fc00aad55/multidict-7.1.0-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:544f2642a456fa264614e975d921540ee8c3b368b04d5aa1ddbec33241b13e08", size = 432476, upload-time = "2026-10-09T20:28:52.361Z" }, - { url = "https://files.pythonhosted.org/packages/9c/0a/eac70cc1461668bad8253a2da727670a56293eaba112aeb4079af8cd37d9/multidict-7.1.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:08834fb8b20e1a985c70e8380a10940234b4162de62694458727330376e58b33", size = 450030, upload-time = "2026-10-09T20:28:54.252Z" }, - { url = "https://files.pythonhosted.org/packages/23/2d/eb40652ea74f96df859c7c5d38f9997f420b9dc404300dda0c5745327a6f/multidict-7.1.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:b4908e17867930b7ac77f89a18dc67308c67c511f037d8580489be86fb585912", size = 476169, upload-time = "2026-10-09T20:28:56.819Z" }, - { url = "https://files.pythonhosted.org/packages/44/d0/7454ab8335bc4ec9f8abcc4c83a314bab060f22db6da8436b396e07ed21a/multidict-7.1.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:9b24e1f93b9b586ec03bc7bea1bf021ec90bf2528c729195028a3ca1c266b3f9", size = 420459, upload-time = "2026-10-09T20:28:58.744Z" }, - { url = "https://files.pythonhosted.org/packages/60/7a/cedb46b287b720a2c4eda2448faf162612d0b718beb32581e35ccd9219b3/multidict-7.1.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:5c93473d0d7cd9bbb370973a9679a62f381c7050d7dff4ad6aaa92e8650f5a79", size = 483071, upload-time = "2026-10-09T20:29:01.114Z" }, - { url = "https://files.pythonhosted.org/packages/9a/11/e7ded22b008546dd30ae8c979aa5ac3282cad98876f7d5bbe93c1f2409a0/multidict-7.1.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:bf14cfcc30b097583d698a6e2b8b68c9bcffab277c485d481881958360c2938d", size = 467470, upload-time = "2026-10-09T20:29:03.388Z" }, - { url = "https://files.pythonhosted.org/packages/1d/f3/0136144cb0b1731fd93475cea75d974a55009358d3bf61dd55e2709a3dca/multidict-7.1.0-cp314-cp314-win32.whl", hash = "sha256:86bc779a0896e59e4be30a5be5cd6eeffd0b40b6f0e75e730218736b7bfc6f5c", size = 80205, upload-time = "2026-10-09T20:29:05.736Z" }, - { url = "https://files.pythonhosted.org/packages/74/d9/a62a690d780febc171026d3e3c5700fc8387aa3e5f77cd04ada33d23d3f4/multidict-7.1.0-cp314-cp314-win_amd64.whl", hash = "sha256:6c9fd50f636a8fa9cb6324cd3eac962fec2bc5bb432452a3b583583a1059acfc", size = 92923, upload-time = "2026-10-09T20:29:07.337Z" }, - { url = "https://files.pythonhosted.org/packages/84/08/eb7a1c34dc37c5f2c6aef52e6861e6f1cdfc6c685dcb72581eb218c00953/multidict-7.1.0-cp314-cp314-win_arm64.whl", hash = "sha256:e6906aa4bc62cde2c8aeb8a99a7b4401b241e274ae7b11df67d863d61ab3d5de", size = 92851, upload-time = "2026-10-09T20:29:09.15Z" }, - { url = "https://files.pythonhosted.org/packages/ff/3a/019abd746e8fbed9edd74b81259f20b278c011cef918868506d9b5bd6566/multidict-7.1.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:fabfdd4cf97db033196b51af46b8a681d4785c2a66347f2a5af1b4bbb1182629", size = 177429, upload-time = "2026-10-09T20:29:10.989Z" }, - { url = "https://files.pythonhosted.org/packages/f7/41/c8dda935231305d9b83c4a4cc5b5b9e323615328d4704f00ba2cf6d89916/multidict-7.1.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:a177a0ee5cf19931dcaeb3f662bc562754cfa4f4ace2351d9da24a954ef7db94", size = 102003, upload-time = "2026-10-09T20:29:12.78Z" }, - { url = "https://files.pythonhosted.org/packages/af/23/3c3e79a222eaaa59a32648cec34709d848657be5339f96876075731e7f8e/multidict-7.1.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:0ae91de396d5c4ac97cb24dbada3d5c91a51454781e0a70476b008f4e879e4f0", size = 104861, upload-time = "2026-10-09T20:29:14.591Z" }, - { url = "https://files.pythonhosted.org/packages/cd/5b/04637e7cea5729466fb89048520fde167c5404df1beedcc86f18aeabed7c/multidict-7.1.0-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:160bdb3520fdadcaa21e1b98aab2e011265070814ecab3804eb61674becbd400", size = 463221, upload-time = "2026-10-09T20:29:16.697Z" }, - { url = "https://files.pythonhosted.org/packages/2d/42/b121767de213a9774399c200cb877b19c2e1e5a0b0a6bc8407c7325fa37e/multidict-7.1.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6c2144785e42527404bbd5cfd11981fee4abe59a22aded0e498eb711a831d3f3", size = 502241, upload-time = "2026-10-09T20:29:18.657Z" }, - { url = "https://files.pythonhosted.org/packages/47/0a/1cccd17ebf39776df7d8a6c99d066fc3ac1823d044cfe86a22ebbf42b841/multidict-7.1.0-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:7d0b4fec6a8d02d7e95de5cfa913261820f1ce04bd4c0381924de0da523179b8", size = 457128, upload-time = "2026-10-09T20:29:20.589Z" }, - { url = "https://files.pythonhosted.org/packages/19/a9/0616d20dee16255f8737d9017288d9304dabf3695ac0071baca25d00c713/multidict-7.1.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:943a9bce22180ad0f4d32d1b402a0949a4ecfe5a1257b47f54a1b51981d81b86", size = 511842, upload-time = "2026-10-09T20:29:22.569Z" }, - { url = "https://files.pythonhosted.org/packages/91/68/5a406b82ecfeee50c097c05fd519c836a61815d81c4a9a8c523d90fb4b35/multidict-7.1.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f76ceb623f7ff50df46ac57e1587c479d87a5766319c4f43d0c0a5158896afab", size = 519852, upload-time = "2026-10-09T20:29:24.527Z" }, - { url = "https://files.pythonhosted.org/packages/d5/da/d42234f9d4f0e33885c70149112bf62aa4436045090c15cec0810ada0b2f/multidict-7.1.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:98beff85392ce435b28a0971ec21cade61ce8be8b632c9d855475a28ef92d31a", size = 500322, upload-time = "2026-10-09T20:29:26.569Z" }, - { url = "https://files.pythonhosted.org/packages/fb/c6/323e921a9812a6ea82978d4e1d9713e0b709023be037e6e4c14efe5472eb/multidict-7.1.0-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:71196ebb8d523148e5975396a444de02367f204b53b14e26794c96b2be0ed742", size = 444070, upload-time = "2026-10-09T20:29:28.52Z" }, - { url = "https://files.pythonhosted.org/packages/93/87/109b7170de2168294f3e562f9d10caaaf946628d614b5a57246279acc1a6/multidict-7.1.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:35534b366410a36bb3d6f788691e37a76e4d1da48326b0ada3e5032580dd76af", size = 484862, upload-time = "2026-10-09T20:29:30.504Z" }, - { url = "https://files.pythonhosted.org/packages/51/cf/7f1f63c9cf13f47036c0c64c607e6eee87c94076e3c6876abb6990ee62ad/multidict-7.1.0-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:b4674b12701c3fcbdf7f88b9e4479701c93bec5da9eb576140d5fcc0092990af", size = 457314, upload-time = "2026-10-09T20:29:32.6Z" }, - { url = "https://files.pythonhosted.org/packages/93/ce/7de8b4ee6a847cc951915c279fc388127ec32a7c14aa7a01c4ad692be575/multidict-7.1.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:0ead852a5e906a43fcb6784eeac480f6a67919a51d480c1f80d32ddf9d615475", size = 462672, upload-time = "2026-10-09T20:29:34.776Z" }, - { url = "https://files.pythonhosted.org/packages/f6/6c/02dd089475983b1f5b8729319caa0b02fa3a60b527f27c86b2d53c24ca11/multidict-7.1.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:afe36ca503c2ffe30fb6df82b20389fa3c4035b5d65888a61310921cf3ae91c5", size = 498109, upload-time = "2026-10-09T20:29:36.763Z" }, - { url = "https://files.pythonhosted.org/packages/47/d9/b9bdc59aa8e3eaf1f9e5d2460bbe0c428a01250d44417f8ccf965a8f6fa6/multidict-7.1.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:a5f0bebb10aae010d3c9ee3abaf83ab2069c718457aea09c15532355dd7e061f", size = 442260, upload-time = "2026-10-09T20:29:38.872Z" }, - { url = "https://files.pythonhosted.org/packages/fa/83/21b044885ab81bf5c03ec5c4c16aa449977e428c5c122e38969481cec1df/multidict-7.1.0-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:b9d9b7d72975521434368fe8aed3f6b522060bf271adabaa5ca6c87c0c08e168", size = 498916, upload-time = "2026-10-09T20:29:41.091Z" }, - { url = "https://files.pythonhosted.org/packages/95/8b/31686730092e349ee2255fa630945ca344fc62e76f0b18d65b0f3dbb0ecf/multidict-7.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:274023bf952f849e0d05eba28a4c1f65f9796430d2b09ec16539386c0f76554c", size = 493525, upload-time = "2026-10-09T20:29:43.192Z" }, - { url = "https://files.pythonhosted.org/packages/c7/d0/c9fddcd7ac42b70a46ac9cf15e21eb527874164e14d418fcb50ce7190a4b/multidict-7.1.0-cp314-cp314t-win32.whl", hash = "sha256:7e0bfa161df365ba3c88899ee3b7c94755200967284bdedef8c1b8b43e2c0f2b", size = 86481, upload-time = "2026-10-09T20:29:45.188Z" }, - { url = "https://files.pythonhosted.org/packages/24/ab/ce727c06680e72b5d381caa8587f561cb6fea1bfab6ba20c877019768a6f/multidict-7.1.0-cp314-cp314t-win_amd64.whl", hash = "sha256:34a35be8fb82d37087e8176aba907b9459f03d0e293c80f574c6337a436f4eaa", size = 99676, upload-time = "2026-10-09T20:29:47.441Z" }, - { url = "https://files.pythonhosted.org/packages/fa/e7/d116d7ce514d04d9bf63774ed55e8033e2ce15ab5655a597bb947c53dfb8/multidict-7.1.0-cp314-cp314t-win_arm64.whl", hash = "sha256:d7dd46a8fcd7653c09ebe67eae9d4cb6636c7a905d9cbaf587dabcbd4eca6013", size = 98726, upload-time = "2026-10-09T20:29:49.365Z" }, - { url = "https://files.pythonhosted.org/packages/28/42/963e2e38ffd79487b24775841cfe2abb85aa1fa08ee152afc4a9b64e1cdd/multidict-7.1.0-cp315-cp315-android_24_x86_64.whl", hash = "sha256:852c921217f330b3e81a822647ebadeae7e42cf503ec1992d0bfbc90121c09fb", size = 100450, upload-time = "2026-10-09T20:29:51.486Z" }, - { url = "https://files.pythonhosted.org/packages/b3/6e/fbc4721aa0eaea2dff3274ff44e94f60a89841bbb4cdaecd9faa4eb64aa7/multidict-7.1.0-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:cbec738d2ad551c6f70955d7eec95e339380ee1564e2afe86bfee05fed52ceec", size = 95440, upload-time = "2026-10-09T20:29:53.929Z" }, - { url = "https://files.pythonhosted.org/packages/76/66/045aee749b599560d5348bb1bee5c9d61d8b12f31d16e0594778ef3472de/multidict-7.1.0-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:a5f721a2437390ab69c10c6df5c142478d399af8dfb02e6d823cf2358e8a4748", size = 97496, upload-time = "2026-10-09T20:29:55.808Z" }, - { url = "https://files.pythonhosted.org/packages/97/79/f2916b81324d629eba363f760fba26cafef5cb437489c24969ada979508d/multidict-7.1.0-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:99cf27791129d37e191ff013bfc29bf6631c29edb21680c00978567b91fc5d6b", size = 163241, upload-time = "2026-10-09T20:29:57.813Z" }, - { url = "https://files.pythonhosted.org/packages/ce/f6/2aab2b2d7bf2d69204bde0cdabfefe4df3d1954f3f156bfc53714917e757/multidict-7.1.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:2ba6611fc93c4b169d0e0ea376ebf4b8a529933d1f5f2c2ec7d8f8b93ef58ec2", size = 94586, upload-time = "2026-10-09T20:30:00.201Z" }, - { url = "https://files.pythonhosted.org/packages/b6/83/cf690ab80a0db0f50b300a7141f45dbf1bbbb6b32457f74bb55f47d38f5c/multidict-7.1.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:c45629c0049fbdef932dbe408ac2b271fdc8c7d9962ca31160f4a0fc3455fe4f", size = 97573, upload-time = "2026-10-09T20:30:02.675Z" }, - { url = "https://files.pythonhosted.org/packages/ce/2e/951c1412c9803e8f87c8673305be1e448761c940cd867ccfdd3e6a551dfd/multidict-7.1.0-cp315-cp315-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:cf606cfe3f67984b4064ac605d71e1eba12515fbabf5bd5a34a8952b8800dc66", size = 453476, upload-time = "2026-10-09T20:30:04.622Z" }, - { url = "https://files.pythonhosted.org/packages/a1/55/12f9f95fc65470bf481ad3d1c0e0fc20094720d0af1985119656f2b4be25/multidict-7.1.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:50fdfcb03be719d9573597b095b1175d2e9d0b30d065791dfd9fca727c499442", size = 473078, upload-time = "2026-10-09T20:30:06.986Z" }, - { url = "https://files.pythonhosted.org/packages/87/31/ebe216194a68934de7053d582cde62c839bef4dbc4ae67e9bbccf80a61d2/multidict-7.1.0-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a8bba9d1f6db4ef2a6ebfc937a65d36e80e3aada00b382eaf56fea8f639322d5", size = 435633, upload-time = "2026-10-09T20:30:09.021Z" }, - { url = "https://files.pythonhosted.org/packages/46/e5/4aea764cd6a1d326d91f2bb92b1c8c39c3f5a8da624e7b20b88179dffb72/multidict-7.1.0-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:46d4af0afc6eb9867b3ae50605787c80b868e2f52eac3801246034925fe578b8", size = 488656, upload-time = "2026-10-09T20:30:11.119Z" }, - { url = "https://files.pythonhosted.org/packages/6e/f8/b1e5935233fa4b504b1a58b584fcdf03526635e4b5f268f716be9108a1a4/multidict-7.1.0-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5cc58ebb731200ddb64d55f1b345630fb5f7a8138cdbd242af9dce964a7cb03d", size = 502311, upload-time = "2026-10-09T20:30:13.396Z" }, - { url = "https://files.pythonhosted.org/packages/9a/8e/cde07147b6fc56b9ae0fe01d9c0bebd730b2be2c3052d3a5a117e13f561e/multidict-7.1.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4b87ad54e8d4adeb0a1f04889504d6ec7f04fb02609220810f51f1b6c66bc1cc", size = 477470, upload-time = "2026-10-09T20:30:15.894Z" }, - { url = "https://files.pythonhosted.org/packages/68/a1/11ac1880eacddcf698aa227ba9387cda60128e38034eda182cf4585109ee/multidict-7.1.0-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:44f7e5dd83a615636b80182bdf446ece57ed61d5d51854acc5d9840631136d4e", size = 430088, upload-time = "2026-10-09T20:30:18.972Z" }, - { url = "https://files.pythonhosted.org/packages/6a/5a/09926de0ec910704507a21c4f1ad76026aab9a5657ced868c57bbbe9324b/multidict-7.1.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:9bc5e7f843d14a167cdc26fe2d22f6f3aa2feb57919cf3ff034262a57d8d95d0", size = 460632, upload-time = "2026-10-09T20:30:21.45Z" }, - { url = "https://files.pythonhosted.org/packages/ed/36/cc51eb3ffb09f475326bbf868c6af2805fbbe9175122ce6d7a65aa06d6c1/multidict-7.1.0-cp315-cp315-musllinux_1_2_armv7l.whl", hash = "sha256:0631eb5f49f67de10bbdc3f64141326dbc62e8d319900966648381ce0845d8ca", size = 434056, upload-time = "2026-10-09T20:30:23.679Z" }, - { url = "https://files.pythonhosted.org/packages/6d/f4/9e0e4dce595573eba1555495ac9ca6b5f7f6e14cf6c3a5cd87ce5bd33d6f/multidict-7.1.0-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:d1b1b32f3c32f734dde8f36ac1df8e275e768a7b333241cd637cb2538628a4b4", size = 453014, upload-time = "2026-10-09T20:30:26.192Z" }, - { url = "https://files.pythonhosted.org/packages/96/14/993a7ac9f3592f5628a12f6bc2495f5cce5814b883170e06f487dede6969/multidict-7.1.0-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:159976f9c40f96e3fe0952b708846a43a76bacb114e9cc828816f5080bddd5ec", size = 476343, upload-time = "2026-10-09T20:30:28.532Z" }, - { url = "https://files.pythonhosted.org/packages/b0/da/c2147c1e225a676ee0c97f97bb935fb8a70821bc12df240491bf9f140801/multidict-7.1.0-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:81a0e08c64dfdad27dab687b96f572b23bafa1999a39d1b6f70b3ddbb73e8bd0", size = 426813, upload-time = "2026-10-09T20:30:31.015Z" }, - { url = "https://files.pythonhosted.org/packages/5f/fa/8858b260a6662035670759e7b3a7da9decc227296491749073e76202de93/multidict-7.1.0-cp315-cp315-musllinux_1_2_s390x.whl", hash = "sha256:4e11e7299079718c78f8147e7206c22fe35bab4466d38992420795288a0b8096", size = 483882, upload-time = "2026-10-09T20:30:33.509Z" }, - { url = "https://files.pythonhosted.org/packages/c2/43/d42dc515d56d506f437e8a19c4f604719a306f8d2b60f70a14be34ac9231/multidict-7.1.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:34d2ee98e15d5cfe782a431bc913fce3b58cf3fdb34fcb437aeb275cdf9007ab", size = 469953, upload-time = "2026-10-09T20:30:35.996Z" }, - { url = "https://files.pythonhosted.org/packages/5e/bd/1b6fb52f7e082b4d49b069d362169a2e6dbc43800f152f33c8f0e8933117/multidict-7.1.0-cp315-cp315-win32.whl", hash = "sha256:f376224572d1f5da1c871f969ab04765727f180e70d012d93e07bfc08442c64b", size = 80202, upload-time = "2026-10-09T20:30:38.121Z" }, - { url = "https://files.pythonhosted.org/packages/f2/26/5dec513dec950825529037703da89a597dc0b157e7b1b8d0304dd9e672cc/multidict-7.1.0-cp315-cp315-win_amd64.whl", hash = "sha256:67fcf28db77b385820881521db7435e9f1c607cfaf07db6eb78aa9d1146bde86", size = 92921, upload-time = "2026-10-09T20:30:40.507Z" }, - { url = "https://files.pythonhosted.org/packages/dd/eb/fd62025f8cd3dad6f936df8bd7ff2642e2fe3fe0166ef2fc75699ee57cac/multidict-7.1.0-cp315-cp315-win_arm64.whl", hash = "sha256:c7aafa4dd2f702ee2198005d6cba4309c1e25ed1c201d77beddefa47411bead8", size = 92848, upload-time = "2026-10-09T20:30:43.026Z" }, - { url = "https://files.pythonhosted.org/packages/42/f4/2dcd45731d2f57b87211a1dab1c29a72c6a4a527f370851c3e4cef5c4445/multidict-7.1.0-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:1348ddc076251cd542f4a99ccda4b7c1f8444e8ab489d3541a978ca5901c7c1f", size = 177634, upload-time = "2026-10-09T20:30:45.125Z" }, - { url = "https://files.pythonhosted.org/packages/6d/d6/d57b12a5bb19396a99ae66ec48ff69f764cc2c83e83bd9a003bd5ed5802a/multidict-7.1.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:9267bf8261a779abb2a6eab5f107f5db85b2d1745f2494081c731aaf28738ce3", size = 101954, upload-time = "2026-10-09T20:30:47.416Z" }, - { url = "https://files.pythonhosted.org/packages/46/8b/374e3f6e4581b8f8425712214cad854ff9370019483aaa49e6207c160adf/multidict-7.1.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:8a844b8b1685f38a2e8b2f3213b286e2a7abfe67508381780a0d4599ac337c1c", size = 105056, upload-time = "2026-10-09T20:30:49.618Z" }, - { url = "https://files.pythonhosted.org/packages/9e/0a/6c89e2179a84eaa78eec658b9a05f10d3e22654708d7b2e3ebdf0faa0614/multidict-7.1.0-cp315-cp315t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:18a447d46a3a2f1e61b365cbf5627db7030fdb707dad70c4f2760e5144166ecc", size = 467374, upload-time = "2026-10-09T20:30:51.933Z" }, - { url = "https://files.pythonhosted.org/packages/c5/62/431ed831b5e9b94c75ed0a410786d07176e879603601570eb25594039200/multidict-7.1.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:88811f890db240a1c82bf0bcd52973763707a552c8113ac3fcebca183afb2fa8", size = 504024, upload-time = "2026-10-09T20:30:54.701Z" }, - { url = "https://files.pythonhosted.org/packages/d4/dc/52e4204538a7824e407e531b742ff6f7a2ff614dd40382d29a62755699cb/multidict-7.1.0-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a60b720c329c0007feae692b7bf91cf17b3f9bd3727be96cc6f9a3336651041b", size = 460139, upload-time = "2026-10-09T20:30:57.193Z" }, - { url = "https://files.pythonhosted.org/packages/22/4c/0228d61a8fee69a7ac4d8d0426aa1810b9c36b679a8c51844de701230073/multidict-7.1.0-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b117ed1cd1a23df0902461c38093408b95971833dcee629112acda25b603c8d0", size = 513162, upload-time = "2026-10-09T20:30:59.662Z" }, - { url = "https://files.pythonhosted.org/packages/56/50/a0b28bf4f036897bbd44c8761fbb384c014c34f621687799d07345b62820/multidict-7.1.0-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:bbcae7a54050b7ad7bc7bf425ba63dea7d2cd31a92246ba787a2ce69a9b98dbc", size = 520312, upload-time = "2026-10-09T20:31:02.515Z" }, - { url = "https://files.pythonhosted.org/packages/4f/1d/ba96f77c24174eff9f6521cc7c83958f27598b924a9f7b6aca5d11c73f35/multidict-7.1.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4cba2b0b9235fe10e12301d6b4cfba0f353fa668d635f6e988b03623c2cd42ba", size = 502953, upload-time = "2026-10-09T20:31:05.187Z" }, - { url = "https://files.pythonhosted.org/packages/59/f2/14c3ffb649cf45a629ec38ca757a493f0caf729e3f3580816dc7779e4caa/multidict-7.1.0-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:535173fbcc3933d84f9929d49d7a59a0faec259ee07d07c34c7d2a980b4e3683", size = 451497, upload-time = "2026-10-09T20:31:07.597Z" }, - { url = "https://files.pythonhosted.org/packages/55/df/fa4f8f6ee2314bdd3e4bc830c25f1d8a737188198abeaf105c73454f0b95/multidict-7.1.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:ea027bdeca1d7e498237634ee4e3a852e2723eef39996dec0ff0f77dff8a2336", size = 486212, upload-time = "2026-10-09T20:31:10.178Z" }, - { url = "https://files.pythonhosted.org/packages/32/5e/3227762b04a8ff1a90359ee2c04af9ed095fe3892e101705fa4233b51514/multidict-7.1.0-cp315-cp315t-musllinux_1_2_armv7l.whl", hash = "sha256:507151e1e3dee95e9e8159e329aed4f75aa5205ecd6505a4f6be546890eafbe1", size = 459864, upload-time = "2026-10-09T20:31:13.044Z" }, - { url = "https://files.pythonhosted.org/packages/5e/04/58524c7e82176438a48704a687fb383cc943dd7075c67b5bea288043b504/multidict-7.1.0-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:9c10791e9f5ef132effc8fdce2009482c1cfb26618c5fc1b7952a47dd5eb632e", size = 465861, upload-time = "2026-10-09T20:31:15.503Z" }, - { url = "https://files.pythonhosted.org/packages/f8/d6/28e549b6ec0c829647de4c75cf32e4c7ea0d0e87b91dfb399292f630c365/multidict-7.1.0-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:f16ac8af2804855d3cae5fc3c5ab609c9fd0fc8ecacd92579c05ed3c173396fd", size = 498865, upload-time = "2026-10-09T20:31:18.548Z" }, - { url = "https://files.pythonhosted.org/packages/eb/ac/3006640586b4d33442c53989b78fc290c8eae5fab5b62a31ac7a4c220e69/multidict-7.1.0-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:b78de22bae456a976f33df34d598dfd16edc9a03df8f4cc8b7c17bdba4c97b4a", size = 449885, upload-time = "2026-10-09T20:31:21.03Z" }, - { url = "https://files.pythonhosted.org/packages/80/7e/1ece407cee9f9aff9ace9e44379ed937bccb790936ae448feb79a82c362e/multidict-7.1.0-cp315-cp315t-musllinux_1_2_s390x.whl", hash = "sha256:db77888081431aaa69f3fd3480891746ddce6c2a571f6201869a24e2f06cf423", size = 500237, upload-time = "2026-10-09T20:31:23.611Z" }, - { url = "https://files.pythonhosted.org/packages/9a/4c/c052b700ffcf689454848ee81ba87bedfdc10caff592c0d2a327c43939a5/multidict-7.1.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:c39dfcaa0bf23443474c0cb58d8d8aea9529c1841d99654cb38e4dada7b1948a", size = 495143, upload-time = "2026-10-09T20:31:26.237Z" }, - { url = "https://files.pythonhosted.org/packages/0a/ef/9ddad94c32fb0bdfc5ad0942d06ae6699bd30d261b0ff59b94810a133238/multidict-7.1.0-cp315-cp315t-win32.whl", hash = "sha256:16b21164797bde6f417066d02775975cc2e15ab8abf80efa55fe85e0b4894020", size = 86526, upload-time = "2026-10-09T20:31:28.734Z" }, - { url = "https://files.pythonhosted.org/packages/b3/ce/2efa1f32a07adfe041d48c6d04c08b6f9db66b8512c765983172399b2855/multidict-7.1.0-cp315-cp315t-win_amd64.whl", hash = "sha256:55392202cb374dd1a1f89a8ce1586644870d9e936752059d053e576acc50bc89", size = 99671, upload-time = "2026-10-09T20:31:31.282Z" }, - { url = "https://files.pythonhosted.org/packages/a9/b3/a44c301fe13716c5f2c08afd89a481018988cde4b337b36e28a2b0fcf3a3/multidict-7.1.0-cp315-cp315t-win_arm64.whl", hash = "sha256:f979a077d1c0a9a36dd4fab0d3a36b8de7b593bf935e13df85a380395b2c11ad", size = 98893, upload-time = "2026-10-09T20:31:33.62Z" }, - { url = "https://files.pythonhosted.org/packages/d0/86/a3de309c5e28ee85b314d0e3ba0e0dea6fd361c313322a05e67be4656e1e/multidict-7.1.0-py3-none-any.whl", hash = "sha256:d9ef29cfd98e17085b4f91bba8fa1570bec6787d5c52ce653ed33a58785585d0", size = 28087, upload-time = "2026-10-09T20:31:35.945Z" }, +version = "7.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7b/6b/29ef8e752f5854dcc267ded0652c475bec99b86f255957a0d4fcad657b18/multidict-7.2.1.tar.gz", hash = "sha256:e8af3e6f1bdbc31fd762b094133b478b89988eaebc63cbe82b1d9e3bbd15cede", size = 369994, upload-time = "2026-10-24T20:41:35.457Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/24/4347a7502ad47cb05a1b8d4e219514b4f0b1e38d4e4734c053c20328949f/multidict-7.2.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:fd24c4425fdb8e822601335602375c6d0cb020f7a368e1d5842eb7925a9c8748", size = 173141, upload-time = "2026-10-24T20:40:02.481Z" }, + { url = "https://files.pythonhosted.org/packages/8d/f2/2a8fcfe4c2c435101f9227b7f7ea81d786ffef993cadd2394e6926020ca9/multidict-7.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cecb2c778f00a65c6ca01410dd194d0e797a9eebb7c6dea0db87718719f293c7", size = 97197, upload-time = "2026-10-24T20:40:06.534Z" }, + { url = "https://files.pythonhosted.org/packages/7a/57/39be4ac4fa9c20e3af7dd7e89adf7dd404b4547fb4453c5c96082e197b9c/multidict-7.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0d852d3d9638f852158d7de7200dd77f7ff8d77fc8f3d396032f3d847883f631", size = 104843, upload-time = "2026-10-24T20:40:05.829Z" }, + { url = "https://files.pythonhosted.org/packages/63/da/6a5c78daa34e458ced17573b7527395c4c39ebb253220274382d361a1493/multidict-7.2.1-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:76a4f5132b8dc29eb3c768ee9b47e132a1d24fbc2e9259854c01af9beaff1d49", size = 490713, upload-time = "2026-10-24T20:40:41.715Z" }, + { url = "https://files.pythonhosted.org/packages/8a/75/b8252bc6411f7f4b9649b83e143789b7bc1dda44f656b09ce74f894ca027/multidict-7.2.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:295a15ccb8cfde9351dd6062b80af4e839460636b3c46813b4aa443905ded86a", size = 504189, upload-time = "2026-10-24T20:40:04.042Z" }, + { url = "https://files.pythonhosted.org/packages/c0/45/38e8191d0a7c7b56015dfc4c2910b731aa719c5ad3f369b2357567f03434/multidict-7.2.1-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:987f65f6c9321402bc7012f6c6d09ba501b88ddb1640f5b0b4a19f2caafe24a5", size = 465834, upload-time = "2026-10-24T20:40:08.058Z" }, + { url = "https://files.pythonhosted.org/packages/9f/55/378869573886f7efcac24d2c698938dadf973e0da40b812c8b0df847fc46/multidict-7.2.1-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:36b868758fb11cfa748c788b793994e73660abec90f83c780a678539c2c468bf", size = 522423, upload-time = "2026-10-24T20:40:07.427Z" }, + { url = "https://files.pythonhosted.org/packages/af/c5/8936fe02c11196994ac05c4876ad62336a66ef353ea2d1a2ca3adce71678/multidict-7.2.1-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5b944091cfa7da4f7a9bd2587569cd90c94b89ec4721f8e87fe62504f2432b67", size = 544512, upload-time = "2026-10-24T20:40:43.362Z" }, + { url = "https://files.pythonhosted.org/packages/d0/38/b8403d97ae5273002fa664c3c440c5cc186082fa0ba20fcc93885d13a686/multidict-7.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b7542fad2706595c1b1853b46f2c3c4ae5cc5a6252b7225f294d607a29e1bdf", size = 510054, upload-time = "2026-10-24T20:40:05.525Z" }, + { url = "https://files.pythonhosted.org/packages/18/5d/473e1436ea8577cdfb42371c0507a244d51f8d8ef08bea0f9e6e63906478/multidict-7.2.1-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:363e5db93fc3f65f3218a79fe108d217b9d264181a4e993c77552bfe275d0393", size = 452816, upload-time = "2026-10-24T20:40:09.49Z" }, + { url = "https://files.pythonhosted.org/packages/1e/b7/67376e6821fb28c21de1fb37731efd2e3a6a523bdefc4af6997bd043da7a/multidict-7.2.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:5deadf03fb4a7842696d551f9f9a06dd4445bb43ca06b5f9736e4e1885561333", size = 490712, upload-time = "2026-10-24T20:40:09.097Z" }, + { url = "https://files.pythonhosted.org/packages/1a/89/5144d8b36f133109ff36408089a475b9a3a3c1840176a39a9a8fb67a0000/multidict-7.2.1-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:0ec95a02f9f08246cc7f1d85ac425e4d5c233fd3f098f5be1b2cca16aa690186", size = 462856, upload-time = "2026-10-24T20:40:44.771Z" }, + { url = "https://files.pythonhosted.org/packages/ff/7f/38310388c4c5e351dfc419a04e4c7a26cde14b0e1019bc72bbd1b0d95613/multidict-7.2.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:3d6fce7cc4ef63d9a7633cbae43e737798412805a4c3ba876cdf472dc6ff9c51", size = 490108, upload-time = "2026-10-24T20:40:06.965Z" }, + { url = "https://files.pythonhosted.org/packages/ce/0d/94162600e5bbf24bf33398f3b33ae2f78211375313dbdaaf1513b2554a66/multidict-7.2.1-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:37b161535e92776788957a165fcf38a80b33c1efde7b18cab287db4e4574df78", size = 508935, upload-time = "2026-10-24T20:40:10.882Z" }, + { url = "https://files.pythonhosted.org/packages/1d/40/a0cae932493346cb0d442ffa380e65491fdae8df338d8cdf2f39695c0947/multidict-7.2.1-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:e47d058c2db95010f5d2e1f6037acebdfb0e2fa4507650e1041437985c91db38", size = 447620, upload-time = "2026-10-24T20:40:10.548Z" }, + { url = "https://files.pythonhosted.org/packages/5e/a5/6ec5cd1c15574aca277ab08920f7e78a6a1e1c15912bfaf59b48683230f7/multidict-7.2.1-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:7238f7135481926d52a94c18a8cca633a9e72c1cbfccd5796548298a479b0656", size = 523896, upload-time = "2026-10-24T20:40:46.258Z" }, + { url = "https://files.pythonhosted.org/packages/ae/60/d164a2583548561f7e596f13bbd1c3492ea33a77d499d3ceaa2acf76d850/multidict-7.2.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:c10ac5e3e76837180656079008f71add8339b00c3c26314092bcd1e8e449049f", size = 502961, upload-time = "2026-10-24T20:40:08.732Z" }, + { url = "https://files.pythonhosted.org/packages/30/6b/474aee537e0c87210ce8f4fd21558b461e8a8e74c79440de036022a9eeda/multidict-7.2.1-cp311-cp311-win32.whl", hash = "sha256:2b4d0c4e13d329ffee73d46128e32dd3b4aeb2f9c6ac9c8a89eb28d3b82dcea8", size = 84159, upload-time = "2026-10-24T20:40:12.222Z" }, + { url = "https://files.pythonhosted.org/packages/1f/02/41d769148f32c9bd535fd0ddd946c4e42f38acaddf7899f3bf49d9e67703/multidict-7.2.1-cp311-cp311-win_amd64.whl", hash = "sha256:a789e3d27fc5665cc0477f10a35a89383313e4c9cf8b5e6af7ea71f039cdcc0e", size = 94895, upload-time = "2026-10-24T20:40:12.036Z" }, + { url = "https://files.pythonhosted.org/packages/23/be/e04fcf29542d0db25cdec79acbe5662481c3ba6b760353c393f9c46156f2/multidict-7.2.1-cp311-cp311-win_arm64.whl", hash = "sha256:2022bd3194968a027f64ed16f9779e62e71a823a9df3971a7328c1d45dfeb9ab", size = 92384, upload-time = "2026-10-24T20:40:47.827Z" }, + { url = "https://files.pythonhosted.org/packages/27/21/53c299f1ea289f5fd438e70d4f1f053f59b4485f5a410bcc85eecb553394/multidict-7.2.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:cb43bb34346155d479acdc5423afccdff79ce1fc66adfcc9de995cbec8a13acf", size = 172948, upload-time = "2026-10-24T20:40:10.189Z" }, + { url = "https://files.pythonhosted.org/packages/9d/17/faacc27a01e364abed3c6218d8a32bc42fa0688c95f82c6b11e3ffe99a07/multidict-7.2.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:dbda2baafe08f8431fd3333be02c261023fd454607e3bde5e7dc00565f7bebcb", size = 98039, upload-time = "2026-10-24T20:40:13.633Z" }, + { url = "https://files.pythonhosted.org/packages/bf/e4/bd8838244fd1309165c79e74af9a6b9e9e42fd0f2c24c75bee665fc9ba69/multidict-7.2.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d37773029ba034a2cc970b6eeb67dad3bff9d894393c51f6bb1c6b4f563a032c", size = 103911, upload-time = "2026-10-24T20:40:13.517Z" }, + { url = "https://files.pythonhosted.org/packages/0c/39/21dbe0be29cd44de626736c6f0915c0b75f153e0155340a253f375ac5747/multidict-7.2.1-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:c85a0a54a19429a17ef449e967baffe7b5089cb4f6ef2894c9168a69fa024d05", size = 493430, upload-time = "2026-10-24T20:40:49.104Z" }, + { url = "https://files.pythonhosted.org/packages/72/13/c081a1af93258029471636ea1c741141ece10f1045578a5f73ba99b694a0/multidict-7.2.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fa0ecd064b0ae18d235283abb5adbc4e07304dba8f2aa7c0d61f28bebcc70d4c", size = 506972, upload-time = "2026-10-24T20:40:11.68Z" }, + { url = "https://files.pythonhosted.org/packages/3d/3e/e9982c6b1e0d4bb19c4551cd56e50c1fbe90492bdf7893adf8d1ea39f373/multidict-7.2.1-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:f278f118f9fdb5faba5a6792be397fbda094d1568efa4dfe8c3595ce4ce89eea", size = 470406, upload-time = "2026-10-24T20:40:14.984Z" }, + { url = "https://files.pythonhosted.org/packages/6d/2e/ab4136028044825995b3c9de4cf8f9ef82c2076b09b5c44c65e7e3eef0a1/multidict-7.2.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a3d28ac22fe658ad7486d1532b3a9084fbf65b428db31f47212c5b0b6da826f1", size = 524691, upload-time = "2026-10-24T20:40:15.205Z" }, + { url = "https://files.pythonhosted.org/packages/f7/ed/0a57de7a6b6444f301fc4cfc4b8eb0d1c36a33b8ff05717fab7700f205b1/multidict-7.2.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2f3cf710144b1859f4128051cc27ea86eee83caac5648cf2ca0c1b835261cbbe", size = 549512, upload-time = "2026-10-24T20:40:50.756Z" }, + { url = "https://files.pythonhosted.org/packages/43/50/6bd8600b4843f0a9d939e0cc0f4160f4c727bd6c69e4f7e294a1caa93db8/multidict-7.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb8c1a3480c130c3a6422d5f16f3cad6552bf08c2089dd288ba7134649183b5", size = 516796, upload-time = "2026-10-24T20:40:13.481Z" }, + { url = "https://files.pythonhosted.org/packages/c2/77/31e78862081f54a06115927c1c3d81b1a57522fa0209fe1992fac25c6e75/multidict-7.2.1-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b81ff0f2d375988152614eaea4d5023c98ecb08f77df4bb1d96762504bb86fca", size = 451174, upload-time = "2026-10-24T20:40:16.492Z" }, + { url = "https://files.pythonhosted.org/packages/e8/bf/30a0c0911e4b61accb9995165acfdc5107dd335ad3ce003007afaf168dec/multidict-7.2.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b4821bd30b38144d8ab75df56af0b07e9d71327c9cf94c0c7a1965f865bb9615", size = 492916, upload-time = "2026-10-24T20:40:16.619Z" }, + { url = "https://files.pythonhosted.org/packages/5a/80/2192317e096489e9361f732beeee2dd213b827de71b038011dd8176e262f/multidict-7.2.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:0eb7fa012ab47b13e96bffc1369642f520adcc4e3d3e170d7f1a2b39fb953bce", size = 468924, upload-time = "2026-10-24T20:40:52.584Z" }, + { url = "https://files.pythonhosted.org/packages/65/fe/92a104d1d9731a97053193a3f3646a2ee286929fdb7f9c2d5077de782b33/multidict-7.2.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:f9e78d98a29e969a001e953eb09167a48bbc71249e804dae5db987ee7e6531c9", size = 492920, upload-time = "2026-10-24T20:40:15.165Z" }, + { url = "https://files.pythonhosted.org/packages/c6/6b/165323c76d383afbf60da76a4e67f4b78635b09a77c2b83d7033e72d5ee8/multidict-7.2.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:eb5c4a5b1281985271b6c29be53f2c1a9decf11e30a0e2733439c4d9d61b9ebb", size = 510473, upload-time = "2026-10-24T20:40:17.824Z" }, + { url = "https://files.pythonhosted.org/packages/ff/61/e25786f40ab8a862102c198ad0e39cbca704aeeac096edd9cffc85122f8c/multidict-7.2.1-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:2c4e6a97f79699f33e6dc13bddb5631781ee79a4a94c1822116d100e7d5c136c", size = 445954, upload-time = "2026-10-24T20:40:18.14Z" }, + { url = "https://files.pythonhosted.org/packages/a5/bb/deb193198dd1913e8feb54bc83dd13a0cf5425b1aaf7ac913e980537aca6/multidict-7.2.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:5324411117bdb67cfaeb3d1d28fb783710fcca3d88b855696af99044d7219e4b", size = 528252, upload-time = "2026-10-24T20:40:54.068Z" }, + { url = "https://files.pythonhosted.org/packages/7b/9f/ae4d6c442e11aea5ff631f36e4e8d5ff4d1f4c330d2c2721cb729fa5eed6/multidict-7.2.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:d615377a8e7bfc4f1983ede3f411c2ac2b0f7c3053f262d0437b7d8bcc4485e3", size = 508675, upload-time = "2026-10-24T20:40:17.249Z" }, + { url = "https://files.pythonhosted.org/packages/06/ca/bff250b81ada0df548da2b9c0abaf12b4fd864f40ee39e983cd9bada5799/multidict-7.2.1-cp312-cp312-win32.whl", hash = "sha256:30572b61c7932e4d3c2ad1e580de7db1f35b7a35d36db38f89397ce3f2e69096", size = 84510, upload-time = "2026-10-24T20:40:19.481Z" }, + { url = "https://files.pythonhosted.org/packages/68/d5/64108a33c21bde81454b5a400d16baa1378a7d01599de64b131c3e3e3114/multidict-7.2.1-cp312-cp312-win_amd64.whl", hash = "sha256:781ca5dfc2f1d58e47f52216a0c1c7e1ba91ce8aa235459e20de2d402af77fb3", size = 95372, upload-time = "2026-10-24T20:40:19.679Z" }, + { url = "https://files.pythonhosted.org/packages/e0/00/b746ff0f4f70589be9eca08d37a211c3257d602e0ba95224dd0ee0577801/multidict-7.2.1-cp312-cp312-win_arm64.whl", hash = "sha256:9306e0c5595f91874e685be0a9eb743d48ba069c888eea051bec3c67c08b5b8d", size = 92629, upload-time = "2026-10-24T20:40:55.897Z" }, + { url = "https://files.pythonhosted.org/packages/33/f7/453ab156d423def05ac3a4a268f52975378520bf919ded61c9a8bb432b7d/multidict-7.2.1-cp313-cp313-android_24_x86_64.whl", hash = "sha256:fba33e264cdd2ec43b762b9960d1648478eecfc1ce6e8159e7573510f0412c0a", size = 103189, upload-time = "2026-10-24T20:40:18.599Z" }, + { url = "https://files.pythonhosted.org/packages/dc/f1/db4171d67615081b007ceab10af476cf7d66a09291fe43c11f1608f08d4a/multidict-7.2.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:f2087ee23a18d1d618a135eedcafba7dfc40c6be4e8e52d7f29a1c8a2344cfcc", size = 101149, upload-time = "2026-10-24T20:40:20.693Z" }, + { url = "https://files.pythonhosted.org/packages/be/7f/adae49eae252c26f2b7a2fe89984533e0bdb0072f29023c1f2ad7588886e/multidict-7.2.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:f5812cfcf7daf3ace5fedf6e2ef8d4b342c92fb8ea3a87c1aed2b50453271093", size = 103294, upload-time = "2026-10-24T20:40:21.094Z" }, + { url = "https://files.pythonhosted.org/packages/48/45/9fac67be204fc5570593f4dfa2395c542bd1643ffd090c8566de0d1d7f8e/multidict-7.2.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:57ac987ec5d26d89bbc48c03e486f659e1367d425c465552ac2e4c4af8219def", size = 171995, upload-time = "2026-10-24T20:40:57.102Z" }, + { url = "https://files.pythonhosted.org/packages/91/5f/7912bfb95ab00ed6bd588884ca44adf29f7f56de871247a535135af5a2b4/multidict-7.2.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:714fe5f3eabd153b1b6911d0b5d31cfc2b808ae6b9e59a32fab17a4e6cdad5a6", size = 97470, upload-time = "2026-10-24T20:40:19.915Z" }, + { url = "https://files.pythonhosted.org/packages/06/18/29874e132d78ce182305e818a1553c4ddae238471ba55903a1ea38b5c4ee/multidict-7.2.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:4bebc9587cc29359e3b045518a7a09264fa882a7d165b0d143fdac8eeb7ea948", size = 103438, upload-time = "2026-10-24T20:40:21.892Z" }, + { url = "https://files.pythonhosted.org/packages/20/9c/0b181fac73aa9d0f24bc38ce24f56a9cb08c96109c3703d2f79ef15c2c2b/multidict-7.2.1-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:12bbab225ce7f69df75409ab8005b11b4e9309fae863821e019e81b32e53a2a8", size = 493852, upload-time = "2026-10-24T20:40:22.383Z" }, + { url = "https://files.pythonhosted.org/packages/4f/2e/d9ee8ccc91fcde4ad9a6e8275b1df67c0e079349fe33fd30530706dc2707/multidict-7.2.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:335f715f8c111654f29e4bf19086bdf0245579d2b4f4f59ca8dd9b3003b859c1", size = 506390, upload-time = "2026-10-24T20:40:58.494Z" }, + { url = "https://files.pythonhosted.org/packages/3c/f6/eca9192c0e598655258b2a3d14120894aecc338982670ca7ff4d4168b226/multidict-7.2.1-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:9df532dd12c59a7a4d381646fc1bf5ccb4bcdbd01c0887d07ec769fae965ea9a", size = 469470, upload-time = "2026-10-24T20:40:21.363Z" }, + { url = "https://files.pythonhosted.org/packages/cf/1b/a4cc6da2651966c725298812d965b9d70918544214a5638c670837034f24/multidict-7.2.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9c9f285f788acf2448a57c9b93d31103ac69bd03f92907e2ffbb23c4e2b42eb6", size = 523167, upload-time = "2026-10-24T20:40:23.155Z" }, + { url = "https://files.pythonhosted.org/packages/20/64/f3df5b32600c6dfcc1a949f15c8de2b89e44053f5c78bea05c6240e10af8/multidict-7.2.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:21d86f2aa58aa428fb9909d6b8587b75eea827287e3515b8506dca86b55e2c7d", size = 547031, upload-time = "2026-10-24T20:40:23.769Z" }, + { url = "https://files.pythonhosted.org/packages/8f/85/15918b8f73aeb770c534f22b7dac256dc70b6fc7aa0571856c82b17bf3c5/multidict-7.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cd69c99affd1b4debc1f9a53058ea6e3a9b34f2e733840bb45891666cd8ede0a", size = 516056, upload-time = "2026-10-24T20:40:59.951Z" }, + { url = "https://files.pythonhosted.org/packages/d6/eb/b74b3441b572218dd24068b67bf4f1f71934cfa5938f55c299425b1c41c0/multidict-7.2.1-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fc45ff19520bc5321dcd9c6dd7df6f35ddd894eed35e5be65d1828a9c3f5e7fb", size = 449703, upload-time = "2026-10-24T20:40:22.96Z" }, + { url = "https://files.pythonhosted.org/packages/47/81/ac9bb12377260913c0384bdb60b2f9097b1ba580579a2f9697b9e21709f3/multidict-7.2.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:cba29f12cd717f1cbbe220edf005666f8df0453347217748331a0c2f7522eca4", size = 492340, upload-time = "2026-10-24T20:40:24.498Z" }, + { url = "https://files.pythonhosted.org/packages/b1/e9/bac55e20457d3e23879b65e8c46dca5ea90675eee73ca70e3fdc4984d53c/multidict-7.2.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:4f31ddf9c00e0e7db848b0236c717acbe8a51954d0d31b4d908c538ab3f0f5bc", size = 468205, upload-time = "2026-10-24T20:40:25.143Z" }, + { url = "https://files.pythonhosted.org/packages/ff/ce/1dc1e0f8bc28f41edee6fd0e2116f1d7b077e8fc04f50617e65f3938cbaa/multidict-7.2.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:7cb1a6bb70edcc06ea65cb9a35654f268ee39d9fc3a52240e6ba074db4d9c99e", size = 493634, upload-time = "2026-10-24T20:41:01.377Z" }, + { url = "https://files.pythonhosted.org/packages/70/e2/7a4e9f4e35d522715f8987a17d3a098582d0e879cfde621defa586330310/multidict-7.2.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:a2a322c8a6ca82a5a67ae6542e9c6a13ded9045cfd171dcccc5c213ac4fe0eab", size = 509128, upload-time = "2026-10-24T20:40:24.735Z" }, + { url = "https://files.pythonhosted.org/packages/60/cd/d142dc374de3585c57e2635659d45c3179cf47ded415794b2e7ead663373/multidict-7.2.1-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:678ac791b5820d9346eb13c8515fe0c9383659335e5cfc544bf6f54714ca1939", size = 444795, upload-time = "2026-10-24T20:40:25.846Z" }, + { url = "https://files.pythonhosted.org/packages/6d/41/7121157290d436282cf2405cda15d4448921231f7291679f5a3f47669bbe/multidict-7.2.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:0c454b677214fa604e9c4a38952c685dc88a62c96f5576a7ce550f213d1dc318", size = 526200, upload-time = "2026-10-24T20:40:26.763Z" }, + { url = "https://files.pythonhosted.org/packages/6f/fd/05e6e78a34023574db41c057676aa1c26925533fe0b60de9fb5ed5e1a101/multidict-7.2.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:3ca60708f0ca9d994f46790c5a5c774771e2f1dcb75b12c70a5582f915d0e721", size = 507752, upload-time = "2026-10-24T20:41:02.846Z" }, + { url = "https://files.pythonhosted.org/packages/41/50/3bccfa9f3003303fda37a1f7131ab90dcf36ef7fa9af6611151f4b2e316c/multidict-7.2.1-cp313-cp313-win32.whl", hash = "sha256:fa949c81e3865c10f981dea72fd8d418b59edd13a047a0aee89ae64790113d53", size = 84246, upload-time = "2026-10-24T20:40:26.077Z" }, + { url = "https://files.pythonhosted.org/packages/74/6b/3f90a565e6eb94266d197d91cca5833b34ab89768a24f7f07b29bc186e09/multidict-7.2.1-cp313-cp313-win_amd64.whl", hash = "sha256:ce0f884408938fbd72e764031d0e23a8f5e438a7bf73641089c7a6465cb84456", size = 95078, upload-time = "2026-10-24T20:40:27.34Z" }, + { url = "https://files.pythonhosted.org/packages/09/29/3acaf67a5d0f0ecce997f1f57cd14c8c634d05e1672df23b29d4f072262e/multidict-7.2.1-cp313-cp313-win_arm64.whl", hash = "sha256:554ee1d2e71fb5b4059c0c4ee35d8cbc8af2a3147036d65a454c53fea07ff4eb", size = 92390, upload-time = "2026-10-24T20:40:28.055Z" }, + { url = "https://files.pythonhosted.org/packages/de/0c/2eff3c4f36f45eddf11fb10b35069d9ebcef751b16483a585527061354ac/multidict-7.2.1-cp314-cp314-android_24_x86_64.whl", hash = "sha256:3d22ebb716ac79bf32c2a1d15250f017faef719114af4376e8dd814d6633cf0a", size = 102695, upload-time = "2026-10-24T20:41:04.31Z" }, + { url = "https://files.pythonhosted.org/packages/e2/46/4b8667914db791922e826a847f80324cb1f0acba9b05343fcb53c5a237f9/multidict-7.2.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:1d369ed297e79b417766327ece16bb7e89306c588df63c364a85d90d4aeac843", size = 101581, upload-time = "2026-10-24T20:40:27.297Z" }, + { url = "https://files.pythonhosted.org/packages/5a/40/80c50aa45b607086d43ff3d467c25450b85c7d9bb7e4bbcd521c3b030be9/multidict-7.2.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:a9cc121b5ee2c8b4bd4b6b526d5a26bb782f4d620463f73707691b2004b8c349", size = 103677, upload-time = "2026-10-24T20:40:28.633Z" }, + { url = "https://files.pythonhosted.org/packages/f3/e0/c822cf8d92f33f0d6fc0f733b6f5b287956133024765f31b7151b68f6198/multidict-7.2.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:02009b402129a73e1f3da68f48eb999afbacd29f25aef0d5052b84ff5c2786a2", size = 172007, upload-time = "2026-10-24T20:40:29.243Z" }, + { url = "https://files.pythonhosted.org/packages/0b/d8/b36e8bbc49a59f38e6411bdf96e07c29462460d77e59527309d72469b1f8/multidict-7.2.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:cb7fc8820b206932ec6d8f8985aeba6edfd2932e13b6c4bf2434d6bcbbeef3e1", size = 97224, upload-time = "2026-10-24T20:41:05.627Z" }, + { url = "https://files.pythonhosted.org/packages/8e/3f/c014da364e2f9707945f921864a6b5c615e88a0ec0518c7999b3b2092405/multidict-7.2.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:cadd02ca804d6ebe799a7af19197d9730094fe2cc74b70eb4f374f4b8c1886c1", size = 103824, upload-time = "2026-10-24T20:40:28.61Z" }, + { url = "https://files.pythonhosted.org/packages/c9/73/bcd1fff09ba644499fcd864e6f86a596e51e90f5504c326354bdba3bb8a0/multidict-7.2.1-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:846b17193f1c373d6f05ada894fadf56bce2473067caea0aab51828849894b31", size = 486848, upload-time = "2026-10-24T20:40:29.976Z" }, + { url = "https://files.pythonhosted.org/packages/52/12/d6731ea19a185f76a1dc6b76f239fa3567732c8575188b47f7a715742c21/multidict-7.2.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6efdeed2723431999cf3bcbc84c72dbe0f65d16bb1f84e15a657f5b60ff18ca6", size = 500914, upload-time = "2026-10-24T20:40:30.626Z" }, + { url = "https://files.pythonhosted.org/packages/71/db/332a5b62d4c2c26950aede813a0da97e42cbc16b656ac936eb2c6e01f58f/multidict-7.2.1-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:f9c118e866164ce05498d9106a4bd01e745321403cd6f0b77a0b2587768f8c06", size = 462069, upload-time = "2026-10-24T20:41:06.892Z" }, + { url = "https://files.pythonhosted.org/packages/64/8d/c8c6826dc3e9b742bd21f3e84e1d8c46daffb584f45fd93429541e5e7f11/multidict-7.2.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:dc6f3dcb08c4b41e64f2d6cf272b5686d9144db585b2e138a8b1664376ab3921", size = 515356, upload-time = "2026-10-24T20:40:29.998Z" }, + { url = "https://files.pythonhosted.org/packages/92/c8/c13ffe0d352c4caaa17da0a74e9203c718606c62a1d62f98439feb1783d5/multidict-7.2.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:27cc258247b13008742f0e239933ad01dec5ed4e6dfc63849e30e04e1aa5bc82", size = 539793, upload-time = "2026-10-24T20:40:31.55Z" }, + { url = "https://files.pythonhosted.org/packages/3b/8f/bff861e3bd5a7cc13bd1f040d22aee8aa32b4f2755bba29b0c31a1d2ae25/multidict-7.2.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:822a7fcd33f6922b650e1b26594f09d53c5d011fe655fea7ded27b2728ce2a1b", size = 506944, upload-time = "2026-10-24T20:40:32.258Z" }, + { url = "https://files.pythonhosted.org/packages/a4/2f/f40fc4a7070798e31630ae0be583e0857fcab71a1bf80c37481ded49c553/multidict-7.2.1-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0f30d6eaf3cb309b6c21096c6c2b4cf3800f195a78b1babae85f481ce851bdc2", size = 443550, upload-time = "2026-10-24T20:41:08.334Z" }, + { url = "https://files.pythonhosted.org/packages/ba/7e/068b48b20c1df58dddb7885f5e1befd6def91c7b6048f2644ccd81f57fa9/multidict-7.2.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:edffdb3950d3a8b769ddaec3a0962fb7b76b3c96f317f6b88500455a537dded2", size = 486514, upload-time = "2026-10-24T20:40:31.371Z" }, + { url = "https://files.pythonhosted.org/packages/fe/0d/a2f8b1fdd7cc2f497bb2fb0cc59dc7e2ced1fa4b0cd9b2912973e384ea77/multidict-7.2.1-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:8c3ff4f5c376df7126695a52af61e6084b69c9e52dcb9f4713e71ce9819e1bfd", size = 459258, upload-time = "2026-10-24T20:40:32.999Z" }, + { url = "https://files.pythonhosted.org/packages/36/aa/74652a34732f16a951fce9ca118e659f1a9dbe102ee52d9bcea4a8001dad/multidict-7.2.1-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:d5738cd929f2af8651ebb284467acb58b1ec0f2f4d42489cd0597172bc82e15b", size = 487418, upload-time = "2026-10-24T20:40:33.649Z" }, + { url = "https://files.pythonhosted.org/packages/dd/91/ae90df6402911d310cee3f44a73914ea555d5219b1976a8f2842dc247eac/multidict-7.2.1-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:81a5f84a76401c4330e6db4e170dddd58860b30c4e8a44a181e5c2809c7f9c9d", size = 502308, upload-time = "2026-10-24T20:41:09.776Z" }, + { url = "https://files.pythonhosted.org/packages/3c/f3/5a1ab9f594e652bece00f1243bf565063790838250054ef9310999c856f7/multidict-7.2.1-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:efe695cc2081633b02fcb95bc1b13070f6647c9ad52d42a8beeb3c2a7ea062dc", size = 439169, upload-time = "2026-10-24T20:40:32.896Z" }, + { url = "https://files.pythonhosted.org/packages/38/a4/8c4fd4ecbea568de3b4605dc7323488f65a204475e1aac98db9d36fdbfd3/multidict-7.2.1-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:0c52fdd8cb8194fcb6969a417149aa1d09d6e48b69fb1b34ee1b1e4cb51ec183", size = 519617, upload-time = "2026-10-24T20:40:34.488Z" }, + { url = "https://files.pythonhosted.org/packages/1a/b5/4964b2d8f8b4ff03df7f24e8dc7d0de534fad0430e553ff0693aa2bcfb75/multidict-7.2.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:02d9c04d395a36eeebe89e45f2269614a4675b8e83fddcba15bba2be903971e5", size = 499402, upload-time = "2026-10-24T20:40:35.035Z" }, + { url = "https://files.pythonhosted.org/packages/ee/f2/c7d5c514e066fc6f9b9a2a9583f46a3d8178c49b7e91cadcc59241f22c12/multidict-7.2.1-cp314-cp314-win32.whl", hash = "sha256:b97bffa5772b7e853303de094829fcd3a9bd49fddd70534651ee4933691f6587", size = 83635, upload-time = "2026-10-24T20:41:11.337Z" }, + { url = "https://files.pythonhosted.org/packages/08/8f/2ec03cddf5f283f979813f8c5d38f5df798e21cb07a124dfc311ed28d8e9/multidict-7.2.1-cp314-cp314-win_amd64.whl", hash = "sha256:6e22756c6e2d4f57ead0d2e6be179d8a16d661bee424b81de0c6c0c1305ec39f", size = 94544, upload-time = "2026-10-24T20:40:34.202Z" }, + { url = "https://files.pythonhosted.org/packages/2e/75/3e9803944df2233cd43924c04ef057160a75c35e87f4fc083de7c855ab74/multidict-7.2.1-cp314-cp314-win_arm64.whl", hash = "sha256:b63acdf4df5a78a15223bbb510bb3e0f8234dfa807610ccb8796d0842db2c801", size = 92767, upload-time = "2026-10-24T20:40:35.787Z" }, + { url = "https://files.pythonhosted.org/packages/96/6d/e3a4b4de34cde67f98887ac0c134e2436e1eafdcef62e81f9f8b7ac8e189/multidict-7.2.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:15da10cf11fd8d8716720c95b93180e94c8317405d89d08524c579ef360128ac", size = 183485, upload-time = "2026-10-24T20:40:36.397Z" }, + { url = "https://files.pythonhosted.org/packages/e6/b7/c5aa68302159285e544c7f1b687a48d2b000217b9a90aff880052d6cb867/multidict-7.2.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:c753b820738cddc097892fee95e7cd716fbdfc9640414c5e9ce9463ad125321b", size = 103109, upload-time = "2026-10-24T20:41:12.496Z" }, + { url = "https://files.pythonhosted.org/packages/54/b5/7574cad64ee957cb65a32ac4f842663fbe948c1749f688a93eef0677644c/multidict-7.2.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:69befda4b1ef57027ea95dc6ed733568642f330fb3203a3e5c5ef107d41e0a1f", size = 109785, upload-time = "2026-10-24T20:40:35.496Z" }, + { url = "https://files.pythonhosted.org/packages/38/7b/ced76f7d87cce5ed15ae404213c7f9fdc594d0caaedbbacc6b8cdfac81e6/multidict-7.2.1-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:8648dd5dc4d5db32b5936dc5e85e9a4d79db1135513d40d1f54ca15503750324", size = 511246, upload-time = "2026-10-24T20:40:37.078Z" }, + { url = "https://files.pythonhosted.org/packages/51/91/b598741d494865ed002df52f37f9e92bf9ab5a0524098a3f7667c1bd6ac6/multidict-7.2.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5efddcdbcb73f5485dca2b6624edc8ee063604b77bd3a3eb772826063965819f", size = 545199, upload-time = "2026-10-24T20:40:37.773Z" }, + { url = "https://files.pythonhosted.org/packages/e4/1d/2e3c15a07da380a7845e7d0969fde25cd6fca078a09bf30cf6deb06a3480/multidict-7.2.1-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:9c44bd978adddf39df5834c6a1efd7d075c84769a7a084168d035a2a276d9008", size = 489912, upload-time = "2026-10-24T20:41:13.782Z" }, + { url = "https://files.pythonhosted.org/packages/d6/5b/f6e2668e393430240da34a13503c190493dac8bef352ce7e26e831dc7949/multidict-7.2.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:cff7657e79224dea46f2f2e58eb99186656ca63ebe356212210c5c00e9beb814", size = 553445, upload-time = "2026-10-24T20:40:36.916Z" }, + { url = "https://files.pythonhosted.org/packages/05/ca/d7e0605545eebc8053167683fc6aa0d49114df2e75a2c474f2b65f8f083a/multidict-7.2.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:7fb3bc8d58e1b7c1d9fa1d995e30a4ce9dbe49f4c63c755a1ffdecdfbd026ccb", size = 573757, upload-time = "2026-10-24T20:40:38.554Z" }, + { url = "https://files.pythonhosted.org/packages/1b/de/9a74903ffdbe3712ba392166935c91785ccdff82dc4b6a15b28a4df52a14/multidict-7.2.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:66af55b07e4593790157e85f897f06983ded8a8692cb2fb048f3049c1d3fa172", size = 543116, upload-time = "2026-10-24T20:40:39.052Z" }, + { url = "https://files.pythonhosted.org/packages/8c/9d/8eb3ee4465610cd599b08b3320262a3448dcd03299565f4c725ee1504bbc/multidict-7.2.1-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ed6c107642a9acaa7ede32dcd428a6c87e302c5d555ecd3ec132ffa8c6155b4b", size = 478536, upload-time = "2026-10-24T20:41:15.442Z" }, + { url = "https://files.pythonhosted.org/packages/49/fa/346308a741f2c06b23da186022fd72a75b9923f4fe7c88705605e20506d2/multidict-7.2.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:bc9decb36abd00ed5d123db9df70eb9a0da45d6376d86d64f4a94bfd5a1b83fe", size = 526429, upload-time = "2026-10-24T20:40:38.392Z" }, + { url = "https://files.pythonhosted.org/packages/eb/10/96986b2404bba1bdb54e364e682a2a9fc97a93c9f6598a2c35c065cbe28f/multidict-7.2.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:5a7df927c7999d1d3196176a8d4139d3a0e1765936f5de8c768097275b2d617a", size = 488886, upload-time = "2026-10-24T20:40:39.949Z" }, + { url = "https://files.pythonhosted.org/packages/8c/5b/59b11e1e2f93d39b34c554bfe3beb35777aa976c35af078f23eda41fa809/multidict-7.2.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:4eb2650aa240b62ab0c6d87238bee5d14aa4d411c0d69ad61be53e026e0785ba", size = 510875, upload-time = "2026-10-24T20:40:40.484Z" }, + { url = "https://files.pythonhosted.org/packages/83/af/79e0036cc9ecc160235f3bcbd337524cb44ebd266cfc77e7532d9bd06850/multidict-7.2.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:83fbd7cfaca614975efdbdcd9e2df45f3e987e819216468fb73e1db6f0365b98", size = 539190, upload-time = "2026-10-24T20:41:17.519Z" }, + { url = "https://files.pythonhosted.org/packages/a0/b5/342db062f9ae8816c1b940360c251dff21afeb88a9c4b1694c2b3348f2db/multidict-7.2.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:a878fef2797a7c082aa47559af68299372edebc7367bd5128dff2d36e6d820e1", size = 474879, upload-time = "2026-10-24T20:40:39.953Z" }, + { url = "https://files.pythonhosted.org/packages/8a/60/1420f7daae59b331f5506e5b32a79f60fa475e636f53bf4e6cacad5782ec/multidict-7.2.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:f332b16911ffc668baec6aaf8f08a09e1af34a8ee87ccac26bd722589e264645", size = 549769, upload-time = "2026-10-24T20:40:41.241Z" }, + { url = "https://files.pythonhosted.org/packages/ce/af/c4b548057bee365137be7b1ed12cb6339b6911ad95d99a83d4b26e9bcb2a/multidict-7.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:81c6fc88ac9bf6920a0cdf22d3c383964167f12d35eb630463fc6d5ac89e460d", size = 535840, upload-time = "2026-10-24T20:40:41.927Z" }, + { url = "https://files.pythonhosted.org/packages/ba/df/70710e4bc50b29ced1ed69ec3a99124c56ac34747c6a64b05611f7b5856a/multidict-7.2.1-cp314-cp314t-win32.whl", hash = "sha256:0c7b4d8cc9e6ae7070b8129bdb840215552d4e2689ca765d37eb208a24919209", size = 90136, upload-time = "2026-10-24T20:41:18.854Z" }, + { url = "https://files.pythonhosted.org/packages/ac/cb/a330b1474608eef92e6a0a5861d61b8f2d3152d1a71b65dad8b56edea150/multidict-7.2.1-cp314-cp314t-win_amd64.whl", hash = "sha256:b5fb6b048931ea925b484f0c7c01b007981415a00a6c62ee74bbf8d229d39c08", size = 101163, upload-time = "2026-10-24T20:40:41.847Z" }, + { url = "https://files.pythonhosted.org/packages/66/fe/1563cd1336111755f79a60d06ffecd11dfbce5eb8c32ece9eae888d5fbef/multidict-7.2.1-cp314-cp314t-win_arm64.whl", hash = "sha256:e64b86d16158954825d12799271979c6944c1fd1d03575b2f22e869c3f7d00dc", size = 98630, upload-time = "2026-10-24T20:40:42.671Z" }, + { url = "https://files.pythonhosted.org/packages/03/fd/8048552a28d6ae6e1e11198b0605a4d98eee58e10527a35a9fbb3de5b6f6/multidict-7.2.1-cp315-cp315-android_24_x86_64.whl", hash = "sha256:f29885fef157a602d1816439e5da964c70ebcdbbcd4bb9d2d21b7e8bb5636604", size = 102703, upload-time = "2026-10-24T20:40:44.421Z" }, + { url = "https://files.pythonhosted.org/packages/f1/89/d16f1cb45c2c4d7dab10b199dad0c2907a7846326cbd141abb6c9dedc353/multidict-7.2.1-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:a92e3080d8889b0f7a80ea0c4a72181b4d4d5d3918a03136b4a459f51f5f59da", size = 101681, upload-time = "2026-10-24T20:41:20.058Z" }, + { url = "https://files.pythonhosted.org/packages/40/eb/2e14975652ca018dfed4bf14756f2aa9f71b74a0347aa52e8a4d0cac95a9/multidict-7.2.1-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:3ca4e2e9102d0788b94894a30a5e3561fd4818a0605d8748d8fe780f890aa069", size = 103843, upload-time = "2026-10-24T20:40:43.083Z" }, + { url = "https://files.pythonhosted.org/packages/46/76/9f80aa8013ac294dcbd9b51b0db0312d98f4db03dc92e56d6a404559332d/multidict-7.2.1-cp315-cp315-macosx_10_15_universal2.whl", hash = "sha256:a0f999155c22c8929cc492949c08c6fe7ec8079a5e1bfdeb34b9a3e4991959d0", size = 172121, upload-time = "2026-10-24T20:40:44.051Z" }, + { url = "https://files.pythonhosted.org/packages/82/96/ffc7c5ff41445b51dd71072b066f1189682c52fb32e46a58351f413ddf11/multidict-7.2.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:f15205c67d4c45250fcff5da077f0ae54102b5bc39e9ee8bab90d99e09a728c5", size = 97233, upload-time = "2026-10-24T20:40:46.192Z" }, + { url = "https://files.pythonhosted.org/packages/65/19/da52a85bde6db671d652b1d11113c507aa4021f2c8d431a5074108aa4d5e/multidict-7.2.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:f07f06db2e333b68dd52560b8b0b12b6f8bf6053cedebf9af4aecfecd2dc1b32", size = 103929, upload-time = "2026-10-24T20:41:21.262Z" }, + { url = "https://files.pythonhosted.org/packages/84/77/4c98e263f94cd5b27f89cdf3b5989bed698fe3a34a6812777620a8a4c518/multidict-7.2.1-cp315-cp315-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:d094951489bb7836342c005e790bd005e60b669aaf5c936b96dd5d68cbd2e23b", size = 490370, upload-time = "2026-10-24T20:40:44.571Z" }, + { url = "https://files.pythonhosted.org/packages/4f/e2/36a02b000bc0605061eebe4fbfe3ee9c39ebe644bbd053e1635d5a0f9286/multidict-7.2.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d0381074dc21225951278d7e4a7a2241f7fb86a4d8b94154dfee1411f49cf851", size = 502507, upload-time = "2026-10-24T20:40:45.371Z" }, + { url = "https://files.pythonhosted.org/packages/42/ea/1fbceb93d48c65a731bc2264c34d9374d3c811657b3616c480a3ff32b152/multidict-7.2.1-cp315-cp315-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2e279ad5a6e9347bc9e043fdbee180a0480c8fd52618c3258e983dd93d98ed49", size = 463742, upload-time = "2026-10-24T20:40:47.479Z" }, + { url = "https://files.pythonhosted.org/packages/a8/2c/e8e8e98bd831b74a4a011d007c6990cbebc834557825948a4c192855dd4d/multidict-7.2.1-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:e0f2b33a6ae233f4da38c77ea32f90aab2cb82ba819d7b6c4f1b68cd33d871b6", size = 515827, upload-time = "2026-10-24T20:41:22.557Z" }, + { url = "https://files.pythonhosted.org/packages/af/54/a777698e55878f569d3a9daa3658b6a5248608f99ca67fab94b5b94ceb95/multidict-7.2.1-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:57b5d0df4c60ab8b1159687610a1c3ae069ad2380d390a79dedff5c82318e714", size = 539980, upload-time = "2026-10-24T20:40:46.122Z" }, + { url = "https://files.pythonhosted.org/packages/63/a8/a00489f6ca40003a95c97e30b556eb136f510664fb9f605d8c1c9e38dd39/multidict-7.2.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2592fb6c335d67f1912bf72788c02fd5dab305fc3c8c7eab078a5bec1aaa0f88", size = 508202, upload-time = "2026-10-24T20:40:47.003Z" }, + { url = "https://files.pythonhosted.org/packages/90/7a/67c29db7d0daec8548ba8412d98c1f45f6416171eaa208c5682764e2a227/multidict-7.2.1-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:d4af0d863e72f3ea48e85d3aa1d1b426fd81e9544fd7976fc6d6753584a25b03", size = 448626, upload-time = "2026-10-24T20:40:49.019Z" }, + { url = "https://files.pythonhosted.org/packages/ff/7b/986c45a79400c784c7eb2a2e848f77bdb5b97f32cb8a03fb4cda67b5ea28/multidict-7.2.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:8148c2aaaf4b85d7872f024c8bb0c9b9797cc76b10588e3594a69cb01057472a", size = 487794, upload-time = "2026-10-24T20:41:24.08Z" }, + { url = "https://files.pythonhosted.org/packages/c6/a1/d1707dbd709fbd774eac819aa15bf825ae6abf4c4ffaee9eb77e429ba11b/multidict-7.2.1-cp315-cp315-musllinux_1_2_armv7l.whl", hash = "sha256:7726c53b1d59eb57b009a9e8759d4f71049ebdacf30642a198a197f80cea451c", size = 459403, upload-time = "2026-10-24T20:40:47.645Z" }, + { url = "https://files.pythonhosted.org/packages/f6/c8/56e3b24559ab63efc76c261e5aa6813616b2094886e9bb9de688cd1a386a/multidict-7.2.1-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:f62172cf387e92f4928b60e5936b02c06e3c8449ed7fb440978d6c9bcbfc85df", size = 489508, upload-time = "2026-10-24T20:40:48.541Z" }, + { url = "https://files.pythonhosted.org/packages/01/05/b1cbbdc23a7bcff56fb97d97e675892e9dd0bd941d8c6023c411ae6a1c26/multidict-7.2.1-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:03846be88267369908fcd9a91159358a3b142d740991c96e4f696d362fce516c", size = 502575, upload-time = "2026-10-24T20:40:50.968Z" }, + { url = "https://files.pythonhosted.org/packages/fe/f2/946fc151a8e9e17a71f4bd69d5893576addadc8e2528999dd3c1a742b48f/multidict-7.2.1-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:785ef2f3e372dabc131f228a275f97eca92ad17cfab1ab138790e330d99abe3e", size = 444323, upload-time = "2026-10-24T20:41:25.534Z" }, + { url = "https://files.pythonhosted.org/packages/75/98/548bccbea2dcfe90acc130fa46124527b1460d60ba188d9b368309105a9f/multidict-7.2.1-cp315-cp315-musllinux_1_2_s390x.whl", hash = "sha256:2bac371da2c3554a99ba126f545e79ab8e8d9426a3e41df81d00ad725c1e2cbf", size = 520113, upload-time = "2026-10-24T20:40:49.455Z" }, + { url = "https://files.pythonhosted.org/packages/4a/98/25a588db57a7b4b786150aad4cb1f2aaad7aca13d20df60643461b58944e/multidict-7.2.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:2d4cfbbb1023f0f6795b5395c400752fb23a5a09ba756aa9003886bbc47b3e12", size = 500566, upload-time = "2026-10-24T20:40:49.974Z" }, + { url = "https://files.pythonhosted.org/packages/df/49/e319d4dcd4da99f356ca963b41f9c3c48a71d76afe606d8e8f0c90827317/multidict-7.2.1-cp315-cp315-win32.whl", hash = "sha256:584ebfa26c9dcf3e465637a5a9afa2647bebb3022b50b1ff384834ba8e0380d1", size = 83644, upload-time = "2026-10-24T20:40:52.389Z" }, + { url = "https://files.pythonhosted.org/packages/fd/3e/06a59c05402c2ff04eac97ef00783510b82b71128c67455a20b1b0eeecb4/multidict-7.2.1-cp315-cp315-win_amd64.whl", hash = "sha256:873d35366cc115be02a1c858f9b22a1a9f6182b99aab2171ee5276af02a153e3", size = 94542, upload-time = "2026-10-24T20:41:27.144Z" }, + { url = "https://files.pythonhosted.org/packages/d2/99/90e4c68ea5ca6ae89c682e3fa463d3fa7ebda5f6e2209a1b1f7b8ab1aa91/multidict-7.2.1-cp315-cp315-win_arm64.whl", hash = "sha256:f2cc27ec6a53b1d39bab44d2b9dd21cc31e796d01b5e18a76d569721282bb264", size = 92767, upload-time = "2026-10-24T20:40:50.934Z" }, + { url = "https://files.pythonhosted.org/packages/2a/39/66a05f6ce31217ee9ed9417c19433c7498e9468a15fae4cafd920284ef21/multidict-7.2.1-cp315-cp315t-macosx_10_15_universal2.whl", hash = "sha256:522f7d2351743804cdf5c5a304bc45f9d55e935dd87706fae2dbeafe0fed0b49", size = 183697, upload-time = "2026-10-24T20:40:51.79Z" }, + { url = "https://files.pythonhosted.org/packages/f9/88/185b62ccface5a6295934b24bae589f7817f79f54cd41b19267574bc1349/multidict-7.2.1-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:a3d9a59bcdf8531d46b56bcd512017533510c25e955c2c546efd0743bd840940", size = 103097, upload-time = "2026-10-24T20:40:53.594Z" }, + { url = "https://files.pythonhosted.org/packages/23/d6/bae59cc28b4bec2019e5a2fb0262a077982f68200dde08180f079a918a62/multidict-7.2.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:6966806cf917cbbeb9a8b5c581db52e19c9af0ef5fe009db54c1f5799a6e003f", size = 110045, upload-time = "2026-10-24T20:41:28.396Z" }, + { url = "https://files.pythonhosted.org/packages/36/a7/bee9b9f0ff28b751fd79d1c7630d6f88a9dead6218ef2f0e566f5d54ab0e/multidict-7.2.1-cp315-cp315t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:74d3e015c28b43b6c1a108eec324ea2efb185c359c459216cabd4cb98f7f02f6", size = 513704, upload-time = "2026-10-24T20:40:52.409Z" }, + { url = "https://files.pythonhosted.org/packages/4e/80/0c2781349f44d137fa138820bb871598116758e9e27042aad2d75835dc5c/multidict-7.2.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2529873a3bf68c372532a9f8058bcf4199e78387e92cd6a01b73334bfe6a7e3f", size = 547454, upload-time = "2026-10-24T20:40:53.161Z" }, + { url = "https://files.pythonhosted.org/packages/16/60/8b97c48c728c980ab5d10abe12400d3a8633910a9cf99307f31100fe1366/multidict-7.2.1-cp315-cp315t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:223427392fdf993e198644ec40c404fd93f1cd2a61328d18842ecbf154d02c82", size = 490355, upload-time = "2026-10-24T20:40:55.976Z" }, + { url = "https://files.pythonhosted.org/packages/3d/e5/966b412dd21c58d13f378e60e15e08d13dae669b3a22ed31b1f582b0ec9d/multidict-7.2.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:90efd90a0f9b7ae3844a4fb3ae614321832d364ae19567b7cd312315fac4ec39", size = 553571, upload-time = "2026-10-24T20:41:29.67Z" }, + { url = "https://files.pythonhosted.org/packages/13/18/e0f099bdf895d1cc1dee64aecd4e761d4d537c4513875e765a6e5dda71b1/multidict-7.2.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d10e49b940e70e2a4e91f44098007dda0bacb78c3f8e31ba7a37ee2ce52269e6", size = 572533, upload-time = "2026-10-24T20:40:54.421Z" }, + { url = "https://files.pythonhosted.org/packages/25/e7/150bfda9b5a12defbcd0c48385fcceb3efb8257bd9872c8c11cf79643eb0/multidict-7.2.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba5e8d9310a794b853fb0e327d46a827b5b015576341219a591f88ed9d799c27", size = 544014, upload-time = "2026-10-24T20:40:54.676Z" }, + { url = "https://files.pythonhosted.org/packages/31/98/083d4980f3c3eb15663a91ddba983f1317d96e373ae86ac90e93c34140b2/multidict-7.2.1-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:a7d120bdde5b213e67ed7dc80ea3adf4f014453fbc20195d619ba2ceb34084f3", size = 485204, upload-time = "2026-10-24T20:40:58.116Z" }, + { url = "https://files.pythonhosted.org/packages/06/2f/6990b941b9315f24575afa4ec4dada55c27fa3558ddc5962ca94322e93f4/multidict-7.2.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:27166b6ec73eac37696d66b2c6efbd44b6d04b597d655070959df54dc7c71c0b", size = 528125, upload-time = "2026-10-24T20:41:31.176Z" }, + { url = "https://files.pythonhosted.org/packages/d6/69/4efe79c2aa7f8cb42a826dfbffbec129358d81828f63158108eaf2e54603/multidict-7.2.1-cp315-cp315t-musllinux_1_2_armv7l.whl", hash = "sha256:13268013a3db11a214ccb6920f778d175b765f69a40509610b92e43602272718", size = 494332, upload-time = "2026-10-24T20:40:55.762Z" }, + { url = "https://files.pythonhosted.org/packages/d5/86/3704dd04ab0098e509a3dbed132269aca7897dd1d352638a333df5ebfc7c/multidict-7.2.1-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:65e4448dadc7c94a8643bb41361e45f3a73d46e36a008a9bc03e9b525f4d7c80", size = 511543, upload-time = "2026-10-24T20:40:56.457Z" }, + { url = "https://files.pythonhosted.org/packages/90/bb/2efa33d97e8b18533cb89b356a5782b61c28f66e21fb662c9853f71f96f4/multidict-7.2.1-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:68b97b721d95b77d75e718d1b62a227fa4b3e647bd2a9fb39552d1a79ffb67c0", size = 538955, upload-time = "2026-10-24T20:40:59.701Z" }, + { url = "https://files.pythonhosted.org/packages/4f/aa/12510e431bbc652891297aeae4a5b19dc9532b477bbe1eb5642c933825e5/multidict-7.2.1-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:ec4ee5d2d624088775e61cada87bbe7629bfd936bfbd57f122a106970d8ab1ee", size = 481562, upload-time = "2026-10-24T20:41:32.578Z" }, + { url = "https://files.pythonhosted.org/packages/77/b0/3a9e0cc640a9f6031618f6b6415ba603040f68bce00ed36d659a2a8b6aba/multidict-7.2.1-cp315-cp315t-musllinux_1_2_s390x.whl", hash = "sha256:4b338b45dc26ca4bac702e1278754f78613d4d0081e14e94e44fe8e261bf1750", size = 548933, upload-time = "2026-10-24T20:40:57.407Z" }, + { url = "https://files.pythonhosted.org/packages/1d/c3/f4074a8e6c249cde81b5f29667161bdd4250f26174ac4bfbd45676f06b3a/multidict-7.2.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:9a53776adc1ba923c9e345fdea7b61553c44c17a9af5eba8d8def8c5dcac4dec", size = 537060, upload-time = "2026-10-24T20:40:57.916Z" }, + { url = "https://files.pythonhosted.org/packages/44/88/07382e85348d485db3f901ae7c0f3d33dd3562f6fe56d398631af0dad4c5/multidict-7.2.1-cp315-cp315t-win32.whl", hash = "sha256:fcfebcb537f419e415b6e2bfc77ddbd33abe3c036f0105410a25a14741df9c31", size = 90152, upload-time = "2026-10-24T20:41:01.076Z" }, + { url = "https://files.pythonhosted.org/packages/00/2f/45eb8700ee15716cc22f5b42592b4d5bc1ca65c880179c2c10e42fd6f0b4/multidict-7.2.1-cp315-cp315t-win_amd64.whl", hash = "sha256:25ebc4208d9098f77caeb16df895a0e56eb6c3b22870ac4e3ec43e0a9d6a33b6", size = 101193, upload-time = "2026-10-24T20:41:34.124Z" }, + { url = "https://files.pythonhosted.org/packages/7b/80/37d26f26d20b937344cfd68d9a1f57d8bc4f64adae416fc6828a7f8c8a10/multidict-7.2.1-cp315-cp315t-win_arm64.whl", hash = "sha256:4d61be3725016ef5db3543c95f1f062d7d150ba776582d959a982af88e75fa55", size = 98863, upload-time = "2026-10-24T20:40:59.146Z" }, + { url = "https://files.pythonhosted.org/packages/9d/96/1aaad0e5df33f1f5af21775c411349c0234a6edd581ea403bc81919a6eab/multidict-7.2.1-py3-none-any.whl", hash = "sha256:08ea94663d9e7c25d14d78222f7aee906c472d4837766bec62477c38f6e419dc", size = 28145, upload-time = "2026-10-24T20:40:59.159Z" }, ] [[package]] @@ -1824,30 +1824,30 @@ wheels = [ [[package]] name = "polars" -version = "2.0.0" +version = "2.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "polars-runtime-32" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/8e/e9/001f371ec6a1bb54893f599ceebd56e6144fed4091f09f09fec0021a9276/polars-2.0.0.tar.gz", hash = "sha256:62da109e27a19a9d36657ee25dc035c9d3f87e7bd610526fe467dc37ea7dc115", size = 778215, upload-time = "2026-10-06T11:51:29.679Z" } +sdist = { url = "https://files.pythonhosted.org/packages/b9/da/c27daf205a824f89f71172a75ad0098c5837a5a31ddeaac7f8737ea8574b/polars-2.1.0.tar.gz", hash = "sha256:9eee488d6e10773c028753dfc8dac647fd60a708108dcb818a733e85d33df253", size = 811508, upload-time = "2026-10-25T18:00:33.43Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ac/09/cc33bbd5463749c116b62c204d88bed6c02a6cb901eac7adab0d38651b07/polars-2.0.0-py3-none-any.whl", hash = "sha256:35d62f3541b7a6d4c360a2e2f07fccc0c2bcbd33b0ea51c83a25417a47a3f3ad", size = 876611, upload-time = "2026-10-06T11:44:04.327Z" }, + { url = "https://files.pythonhosted.org/packages/d5/d4/e696a46c74ec8cac6434764deaf72f7edcc2e91c2145a9b3f61900a7aa7a/polars-2.1.0-py3-none-any.whl", hash = "sha256:63c50ce3533f5a03d17c3a2a24f1d0e0c7eda98fbde4268a3cba900d34060e67", size = 911474, upload-time = "2026-10-25T17:58:26.863Z" }, ] [[package]] name = "polars-runtime-32" -version = "2.0.0" +version = "2.1.0" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/34/ad/dbb6f6d7070867951532bcfe5e6a648d8777b416b18cddabc07030404e8c/polars_runtime_32-2.0.0.tar.gz", hash = "sha256:b5f9afcc742b4a67eabd2c680ff0f12eb02ede9b4bf807bffabd6dbb9a58d5c7", size = 3591339, upload-time = "2026-10-06T11:51:31.076Z" } +sdist = { url = "https://files.pythonhosted.org/packages/e0/a6/46e09af693326735b1fba3a8bf5a725b57136fb1342e707e75d3113c826b/polars_runtime_32-2.1.0.tar.gz", hash = "sha256:c575f5f3cdb8a5f9be65477b9b4202b062593687fe62a0082add87fbd4571067", size = 3878004, upload-time = "2026-10-25T18:00:34.932Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/82/88/d35dec6c8928dfbaa1cccf9b626a1067da906e792c92d9f994ca825ab2b5/polars_runtime_32-2.0.0-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:ffb7ac6cf4e8c4a652df1951e3c3840c7c23a033603d5a9efd422fa8dd699d82", size = 52494314, upload-time = "2026-10-06T11:44:07.768Z" }, - { url = "https://files.pythonhosted.org/packages/5f/fd/2237bf53ffaff47cdf1edc6c10587a7a6444d4951150eeb08d84f3493ff8/polars_runtime_32-2.0.0-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:7012d8a0201bd95638545ce8f256c0efe2c5cab0f806eb043021dddde5a9498b", size = 47930083, upload-time = "2026-10-06T11:44:11.592Z" }, - { url = "https://files.pythonhosted.org/packages/0d/0d/85e3ed90417996fc09770be91b39979074fe2978fc15b431bf8a9459760d/polars_runtime_32-2.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8b85bb42e6009acc9629afcc70a83473fd468694d6a30ffb0ab376c8dd1a0a17", size = 50417889, upload-time = "2026-10-06T11:50:20.774Z" }, - { url = "https://files.pythonhosted.org/packages/83/88/e9fecfd49159da92f54ff2445883577a0f1bc195da53ecc9535c458d55dd/polars_runtime_32-2.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0d6ac584ea2b38913784db943879412380d92e28ab9cb88e20a77ba71ba3f911", size = 54475036, upload-time = "2026-10-06T11:50:24.411Z" }, - { url = "https://files.pythonhosted.org/packages/48/ad/b2abf732697b21467aaaeaac0f3bf7eee0d89c59ce8125f1ed41b28a2d97/polars_runtime_32-2.0.0-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:a6bf5e260e0a6f00d0f9181438fe9e45776df8c66cee9cba16e3675cc3888488", size = 50579474, upload-time = "2026-10-06T11:50:28.377Z" }, - { url = "https://files.pythonhosted.org/packages/7f/05/304deee59a95865e1b5e9ec7b066069b49093b81b768f473d9d3b165c686/polars_runtime_32-2.0.0-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:55c26eef325b6840584d91aac232e9cf3ac19e1b904594b9b54131be1edeab4d", size = 54413293, upload-time = "2026-10-06T11:50:31.828Z" }, - { url = "https://files.pythonhosted.org/packages/61/59/8c9fd7199f7c4eb1b64e640306a946a2e4a46337b3bbb33b840972c7d84b/polars_runtime_32-2.0.0-cp310-abi3-win_amd64.whl", hash = "sha256:7da1caf3c7b4f397fb213c984013a0c755557619a2d511899a1ff74392484078", size = 54229989, upload-time = "2026-10-06T11:50:35.206Z" }, - { url = "https://files.pythonhosted.org/packages/e2/93/43608026f38aa6ed4d22da8597706a61682ee403caef0021ce8e6dc73227/polars_runtime_32-2.0.0-cp310-abi3-win_arm64.whl", hash = "sha256:c30ba698c8904048df4a9bc3d6c5033cc2d0a7cbb0e13f4fd2de5a1947b61994", size = 48730655, upload-time = "2026-10-06T11:50:38.756Z" }, + { url = "https://files.pythonhosted.org/packages/7a/40/b424f3946c702ff48eef14e44d35df81a25a784f20f77355f39c746528fc/polars_runtime_32-2.1.0-cp311-abi3-macosx_10_12_x86_64.whl", hash = "sha256:de243b6e5a0b9f3abeaefe542136fcdc6dd8df5be3c988a40838d075314e246c", size = 52169672, upload-time = "2026-10-25T17:58:32.437Z" }, + { url = "https://files.pythonhosted.org/packages/fe/38/07066430ac655a8cab2f9e96ea1fec6ca1f20ec47844afe117662d43ace0/polars_runtime_32-2.1.0-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:317314d65949f1d58c4939adf83aa0d2cfaf8da50fd4a725a2de27bde2c10018", size = 47626883, upload-time = "2026-10-25T17:58:38.688Z" }, + { url = "https://files.pythonhosted.org/packages/49/a8/a773e20b451bbaab4d8267867b7c43a0c3aa67ebb6f781423a42a5a1af37/polars_runtime_32-2.1.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:777228cc8bf9cda36dee85ba74d13a25974ad4caffc5da93e10b1da9d810ce2d", size = 50033514, upload-time = "2026-10-25T17:58:44.261Z" }, + { url = "https://files.pythonhosted.org/packages/d2/e6/649c524252d32b24d0ba92278033823fa8e0040ee3748ce5afbeda107403/polars_runtime_32-2.1.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b838056cf365d7497971d9d9825c547766923338771c48c545b86ead2ebc572", size = 53863954, upload-time = "2026-10-25T17:58:48.737Z" }, + { url = "https://files.pythonhosted.org/packages/90/f7/2eb405bf5ead6373a33fa5dd4637fe996565a1f07ccce8911ed167673740/polars_runtime_32-2.1.0-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:04cfc3db1571b74ea4145944de7feceed4bfc9b26e5b2c265e27ad3b2d3866a9", size = 50204290, upload-time = "2026-10-25T17:58:53.33Z" }, + { url = "https://files.pythonhosted.org/packages/33/4d/d76cd42042605e079d6df91cc4fea09ed5f4cb836c72c952a17f585860a9/polars_runtime_32-2.1.0-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:af58b5f6e5cc44b578f2a93d752f87c135c3a53205b4360301bc3a9b89dfbfd1", size = 53794253, upload-time = "2026-10-25T17:58:57.99Z" }, + { url = "https://files.pythonhosted.org/packages/4d/4e/2a419d0def2908255dd1b7318c48430319859dc92ca156e2f81ff7bcd78b/polars_runtime_32-2.1.0-cp311-abi3-win_amd64.whl", hash = "sha256:f2fe32f48af2395cd6ec52a433a03970a69aab1dbb66a613729fd549ce92c904", size = 53926265, upload-time = "2026-10-25T17:59:03.13Z" }, + { url = "https://files.pythonhosted.org/packages/c8/1b/15ffba3264baf21d2f04c51f54b01159cb6f4fad4e84de1404be552d601f/polars_runtime_32-2.1.0-cp311-abi3-win_arm64.whl", hash = "sha256:0af30dd53a7725f703d0d21dd421a39e0165378bfaa41431008f286608376d71", size = 48636436, upload-time = "2026-10-25T17:59:08.476Z" }, ] [[package]] @@ -2216,15 +2216,14 @@ wheels = [ [[package]] name = "python-dateutil" -version = "3.0.0" +version = "2.9.0.post0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "six" }, - { name = "tzdata" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/0e/df/f15f80383f152452d8985b36d95cb8751f901a3e0ff4cd27f7e118f168e2/python_dateutil-3.0.0.tar.gz", hash = "sha256:7ebcb3c29a92f3ceafe79a7a48a5c45677e9e004bbeec5742ac0bbb00560b7a2", size = 271066, upload-time = "2026-10-21T23:41:45.075Z" } +sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432, upload-time = "2024-03-01T18:36:20.211Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/5a/17/cebee01d1c0c1441174cf0456ddc91b280d79acb65340c05e41d77866ee8/python_dateutil-3.0.0-py2.py3-none-any.whl", hash = "sha256:3c79630202e4152c6add678446984236efe4f57e84d8e892aab0637bab82e9fd", size = 94659, upload-time = "2026-10-21T23:41:43.431Z" }, + { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, ] [[package]] @@ -3005,38 +3004,38 @@ requires-dist = [{ name = "vortex-data", specifier = "==0.1.0" }] [[package]] name = "wcwidth" -version = "0.9.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/69/4a/82d61476a1ccc20d43d0805724c5de4baa4971131a8db1816705ef53fe16/wcwidth-0.9.3.tar.gz", hash = "sha256:dfe7cfbd4cb59db9fe0931bd6091ab4a95b3acc5d56bfb50fa9fef0ccba5dc5c", size = 956320, upload-time = "2026-10-20T16:02:43.488Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/5c/6d/eec61b5edeb88e3ea2a714184eade38335722c4246d94be567977fc20caa/wcwidth-0.9.3-cp310-abi3-macosx_10_9_x86_64.whl", hash = "sha256:3b119ef60177a92b4f298b80e98464c2922a1fba3ed77fe9a2bcb69edf1b9af4", size = 605400, upload-time = "2026-10-20T16:02:02.523Z" }, - { url = "https://files.pythonhosted.org/packages/8b/3c/714eba03905a23a46277cc96d3db8da6bd22d2cc0d09a4dead60a2bd1757/wcwidth-0.9.3-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:aab90ab489850f87633922c3064f6d0442d8f6ae5407a62f82bdb1f424179c05", size = 610124, upload-time = "2026-10-20T16:02:07.256Z" }, - { url = "https://files.pythonhosted.org/packages/90/ad/8566e7cc712bea55eab0bb6d19581b7c727a58fcdd55f02365b309aaaccd/wcwidth-0.9.3-cp310-abi3-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:9e1cbe18c18d152e1e68e4e2561dab6c2bc988f8fd337a1fb2e1e0809c3fa568", size = 762700, upload-time = "2026-10-20T16:02:17.508Z" }, - { url = "https://files.pythonhosted.org/packages/ea/7a/4e26574d032a1709bb1fd7d95d406b7b8f87363c60305a101e6e2d9285f5/wcwidth-0.9.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c12abd75ffcbad417e7770a6feb82413c102ccce5c435068c39a82e2218b00b3", size = 771850, upload-time = "2026-10-20T16:02:11.553Z" }, - { url = "https://files.pythonhosted.org/packages/b8/d6/48dad66d577417ef8594000506fa8619d45d7282e20b4cdc916fcc68f95a/wcwidth-0.9.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9ab8bfee107e08de09e15f9f6afb9fe0f64c8d64fd296d0d8557bafe71ea3f93", size = 770047, upload-time = "2026-10-20T16:02:19.092Z" }, - { url = "https://files.pythonhosted.org/packages/3f/61/5f1e02e588d289837d5312478cc9f0e7bca93f4c8a77807741f79fb6a31c/wcwidth-0.9.3-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:2f875a4c9e62df2ecfa70d99b24c551f2245609858e179c3a40e74631b2d08a4", size = 782210, upload-time = "2026-10-20T16:02:12.753Z" }, - { url = "https://files.pythonhosted.org/packages/e9/11/0da2720cba3f917148448c9bf73f3079d71f918308ee9e4d737a0b7acfd8/wcwidth-0.9.3-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:70a2ca239b85a219324968993c76c117fe423d4e1a7c9d860c999c66192f2570", size = 783172, upload-time = "2026-10-20T16:02:20.663Z" }, - { url = "https://files.pythonhosted.org/packages/f2/f6/b79407036ca4543bf708a6d4ca561f78620dc1e5443e685e094480c37753/wcwidth-0.9.3-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:537ea00b6792bb243cd09582322c54dbc848879e5d34ea4c5fee0147529685ab", size = 784806, upload-time = "2026-10-20T16:02:22.164Z" }, - { url = "https://files.pythonhosted.org/packages/3c/86/ada6c2244b08a86c871d42f7cd85b5226515b5f3fa7e604d1e6e45590275/wcwidth-0.9.3-cp310-abi3-win32.whl", hash = "sha256:f2f943c4ef14e9baba730740265f4e5bf5fc8473550e36cd92828cd5663561a6", size = 593154, upload-time = "2026-10-20T16:02:34.301Z" }, - { url = "https://files.pythonhosted.org/packages/5b/6e/46363d972b2b9f002fbfc3bf8e9ab0ff89f139c935a5f21d22016e7a2018/wcwidth-0.9.3-cp310-abi3-win_amd64.whl", hash = "sha256:569a0cdb826d3097b6dbacfaa45aa0002d72a2ba6fa8a63251ea43ac4dd7b6a4", size = 597685, upload-time = "2026-10-20T16:02:35.748Z" }, - { url = "https://files.pythonhosted.org/packages/69/3d/5583cac85e233514c3906d5476b6a74160bc4dc82729dabef3485dbf3d52/wcwidth-0.9.3-cp310-abi3-win_arm64.whl", hash = "sha256:80557db1f77148b78e1b3c2a9cc4ebc4feabef42aaf69a555565057031c32367", size = 598774, upload-time = "2026-10-20T16:02:30.016Z" }, - { url = "https://files.pythonhosted.org/packages/91/b2/53e0838babc6b87505b9504ce62b72c79403642f88d3e568e05d0ef04825/wcwidth-0.9.3-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:6f3e855d3a09af8b7b6d56e76bc270681032f8a37d527a8d5707a441958e3730", size = 606640, upload-time = "2026-10-20T16:02:04.01Z" }, - { url = "https://files.pythonhosted.org/packages/f0/fb/27c94facff5c4a39b954a41fac20c238647f0aad32452d0d9e33fc05e852/wcwidth-0.9.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1bbc8ebf133422cadfefea95a9f89d6c9e9a1ae19930bef7862a9b59b20bbad", size = 610956, upload-time = "2026-10-20T16:02:08.764Z" }, - { url = "https://files.pythonhosted.org/packages/38/61/38e6236356d25966d34636ef6f49ee83a66513e051c4a3b1e19c8b9ec806/wcwidth-0.9.3-cp314-cp314t-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:7a95d8c784cbccbbcb808eaadfd156cd282b2bdd95e89b32505e3443381ce61d", size = 775967, upload-time = "2026-10-20T16:02:23.765Z" }, - { url = "https://files.pythonhosted.org/packages/7b/87/c8f9295cd14a058dc27be0360fcc5ec70ce71b0d2e6a018871f585f23126/wcwidth-0.9.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:a44acbb23b525070a0b8c343dd7cab7a4020aff73b38804f7a66d6a66e16e3fc", size = 787147, upload-time = "2026-10-20T16:02:14.095Z" }, - { url = "https://files.pythonhosted.org/packages/c6/c0/238c135e283b1b0e16fef8b082d432dda1fe7e568d6dd85d5c7fc5e83859/wcwidth-0.9.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a7c0405a3bf3c564e481d6b2d55c99cc231bb68cf8f4a0995944bbce5ebf1a5d", size = 784548, upload-time = "2026-10-20T16:02:25.189Z" }, - { url = "https://files.pythonhosted.org/packages/a1/ed/33e3080fe32f6f8f86334b2c5adde243b9a3a3a46cef97694dbed73b9dc4/wcwidth-0.9.3-cp314-cp314t-win32.whl", hash = "sha256:457f986e4867111cb037ccbf0d97ae100b1ecad030d43a020e7207f1e29649d5", size = 600761, upload-time = "2026-10-20T16:02:37.097Z" }, - { url = "https://files.pythonhosted.org/packages/27/62/6684a59147c1f86d58d0138f3109f506a6761b815dcb3d86b74d9af3a723/wcwidth-0.9.3-cp314-cp314t-win_amd64.whl", hash = "sha256:f11789e520ade8017fa93b01a4b8985571bb433eaefc2f857b57e36875e2e1d8", size = 605316, upload-time = "2026-10-20T16:02:38.513Z" }, - { url = "https://files.pythonhosted.org/packages/94/24/3ebcfd772d273e43e28447dd1946d88b8625db57b6a23496ea4eb9e1dbb7/wcwidth-0.9.3-cp314-cp314t-win_arm64.whl", hash = "sha256:eef39f3260991d8767189d296f0116fa4b45ad9c3a9a16d5af9187fb66b27564", size = 606392, upload-time = "2026-10-20T16:02:31.333Z" }, - { url = "https://files.pythonhosted.org/packages/76/fe/f90b9444bbc2d566634f91756bd11c2bd39d50c2c9077551711b10d8d03f/wcwidth-0.9.3-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:52a13869704d43a4add59c68ebc892198e53063883114783bf0b7457e250e3f4", size = 606655, upload-time = "2026-10-20T16:02:05.816Z" }, - { url = "https://files.pythonhosted.org/packages/ab/63/edffb23938f4e27c28400c7d8d5a8715381d77f5db96bf80cf5dd6687f88/wcwidth-0.9.3-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:9470169fcb4e5340269175ebb3642dd5bfc8f82da8c86f29fc1fefc6c2b9bc1b", size = 611217, upload-time = "2026-10-20T16:02:10.252Z" }, - { url = "https://files.pythonhosted.org/packages/f9/e6/0e4b5c81c238fac47eb66902f058a39ccdeacd7b2c5ab0c559066f203262/wcwidth-0.9.3-cp315-cp315t-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:c4531d93344441a7948e665854f0c40e3a8342ee106436d1531efa7a9fa7641e", size = 778155, upload-time = "2026-10-20T16:02:27.141Z" }, - { url = "https://files.pythonhosted.org/packages/f2/16/745439326544b2a6d65facbdf8462ee9d31e09c64830a764d2526c6c80d6/wcwidth-0.9.3-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:658dcbce546e7f28ee361f88e4a8e591dd56f46bff6084e11b4ad8310ed99946", size = 786757, upload-time = "2026-10-20T16:02:15.569Z" }, - { url = "https://files.pythonhosted.org/packages/08/a4/47193dc9902c30e187d81feaa7a5bc2672c41fe07093ca1ce5381395b85c/wcwidth-0.9.3-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:e9362be098c43d076aa43754face3cc0180fa81cea9ba304240b15490f2617e8", size = 785088, upload-time = "2026-10-20T16:02:28.784Z" }, - { url = "https://files.pythonhosted.org/packages/11/6a/9727002b938c28ab4456fc43ba31a3159ebff040021ce8dbd70e904c7cc9/wcwidth-0.9.3-cp315-cp315t-win32.whl", hash = "sha256:16d09df90b3a8f799ea14c726a41d9b906c3104f95f46d158e1ebe45cf4d547b", size = 600787, upload-time = "2026-10-20T16:02:39.766Z" }, - { url = "https://files.pythonhosted.org/packages/7c/db/0e24c2ff1e82cf298dd40a29e022da31b79be2589f0b8d865488e49140e1/wcwidth-0.9.3-cp315-cp315t-win_amd64.whl", hash = "sha256:3e3e31d6c17d6da3051f7eb854d5e4bebdc52a08a7a52adc2da6f15af51304e8", size = 605298, upload-time = "2026-10-20T16:02:41.479Z" }, - { url = "https://files.pythonhosted.org/packages/84/71/b470bd1dec14cbe6cee0c2e142787a8d99ac01711d5a1b533dda90754b48/wcwidth-0.9.3-cp315-cp315t-win_arm64.whl", hash = "sha256:5d3b0b6c37f40e8d8298941ec373a426a892bb9a514328abcc9226cdc60ae6eb", size = 606346, upload-time = "2026-10-20T16:02:32.662Z" }, - { url = "https://files.pythonhosted.org/packages/bf/12/e10aad98050389ef674c9f69409e38ae086c2104912644e1f9143b394301/wcwidth-0.9.3-py3-none-any.whl", hash = "sha256:e3c9069c54a2da0bf4f6c7e65a735cb1da0f47601a15cb5fef7e4b6ffca4cf60", size = 301629, upload-time = "2026-10-20T16:02:00.861Z" }, +version = "0.9.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ea/01/e5ac23733628a6bbb91913a765fcf55ee8070d8d991bc88fdaaf805052c7/wcwidth-0.9.4.tar.gz", hash = "sha256:fd8d57d3cdfe570e3265c8fab1885c24e34ef40889c0759c0c304a19e9835954", size = 970051, upload-time = "2026-10-24T18:11:44.954Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bf/b8/d251589a100250b71a7b8e83fedfcabfd8bd60e78cd1e3329372f63bcc93/wcwidth-0.9.4-cp310-abi3-macosx_10_9_x86_64.whl", hash = "sha256:b7969c9aa258d536df54c8ac8af5cad0c74a6268c9972e1fb60a5f29feffb66d", size = 612952, upload-time = "2026-10-24T18:10:55.925Z" }, + { url = "https://files.pythonhosted.org/packages/04/e9/dfdca30ca36c472de3e260406dee29fc108499ec590c63b3fe279887ee9d/wcwidth-0.9.4-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:f279f32c8e206a9092fa350e53ca0c2bd8072e45b1c9fd31bb6d476b59b591c4", size = 618904, upload-time = "2026-10-24T18:11:02.008Z" }, + { url = "https://files.pythonhosted.org/packages/5d/b6/d7416f38054a107d2fb17c2b73b68723c6c334f69c4e29545fb9e6df81eb/wcwidth-0.9.4-cp310-abi3-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:a1526cd25c6420e5153bb7d764c7509e692215ee3ad9b725db1ad665d47eae09", size = 778780, upload-time = "2026-10-24T18:11:17.299Z" }, + { url = "https://files.pythonhosted.org/packages/7d/5b/42bdf9a4b0e4f9126584af2ec73642de495f3bd8add907430f13c3bb98d2/wcwidth-0.9.4-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:093469e01d881bff3db93ff3f56c364dc87c441ea01f9f41c22de0c0bdf5c6ef", size = 789012, upload-time = "2026-10-24T18:11:07.829Z" }, + { url = "https://files.pythonhosted.org/packages/fa/e8/0485850748dfdba9443f4151c7b2442cfa4987ba6cd871038eb5d6b8eca9/wcwidth-0.9.4-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b185c8b927b23af2721be1783499d1cfa5c028b098b0858951b4ae224477f1c2", size = 785946, upload-time = "2026-10-24T18:11:18.748Z" }, + { url = "https://files.pythonhosted.org/packages/e9/11/dd3d0379c6094524df6585b76ae3d9727161ff29c003177e3661c36437c1/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:17619066f95c10f44d7ae08ee456602456bc66cc9d5e91966ec73d799acebc5f", size = 795348, upload-time = "2026-10-24T18:11:09.931Z" }, + { url = "https://files.pythonhosted.org/packages/3c/48/1b5299983d9ec084be897162b7cc6014622dfe62847224fa3272b6d79ea5/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:b52f265a694dda6b3ad9050c8bd89158ad519109ef7c5eb110b906cc49f25763", size = 793420, upload-time = "2026-10-24T18:11:20.551Z" }, + { url = "https://files.pythonhosted.org/packages/7a/be/e3097d859b075344a7be57774a58d468eafb0ca88e02aad93eb31d69f6ba/wcwidth-0.9.4-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d8905f1390d828d745fdd1904374c90386d902d3cfa9ee88e9875099f75a4e17", size = 796192, upload-time = "2026-10-24T18:11:22.552Z" }, + { url = "https://files.pythonhosted.org/packages/5e/cd/739710c8cf0de461239db5bb6ee678c9a33d30aaa22beff55cc356781818/wcwidth-0.9.4-cp310-abi3-win32.whl", hash = "sha256:4831662c396dd4c59a016ec53c0ac96738006d653a00482777d9a2e2ea323d62", size = 593229, upload-time = "2026-10-24T18:11:35.609Z" }, + { url = "https://files.pythonhosted.org/packages/d6/f1/c123f902bc2ff9e9c2ab66241b8872204df87cbb18ecdf035e120860fedc/wcwidth-0.9.4-cp310-abi3-win_amd64.whl", hash = "sha256:f28d77153303450ee13ebbe888297e75cf532c754555b6cabafc9bdda16c421c", size = 597780, upload-time = "2026-10-24T18:11:36.952Z" }, + { url = "https://files.pythonhosted.org/packages/4b/88/1cb5ddaf5510b918e01aa95fc4b68df91dead784b63e4931037c5673e85f/wcwidth-0.9.4-cp310-abi3-win_arm64.whl", hash = "sha256:2b58fc8cf2de1bf9cdb68b8beaa5be198742414a7c8cd97aa51ec039783ffa49", size = 598786, upload-time = "2026-10-24T18:11:30.886Z" }, + { url = "https://files.pythonhosted.org/packages/b0/cc/46a31c12b4cdad04f546a3c0aca5d000d77aa5069ae88b4db24525cc29c4/wcwidth-0.9.4-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:87e4101789415a6cf55ec4c53eceeb4782c2654c88692941cb588f19dca1959f", size = 613805, upload-time = "2026-10-24T18:10:58.887Z" }, + { url = "https://files.pythonhosted.org/packages/18/f6/5a8327af9a65153ea9823d6a12fc182f325264050aa25c05a5deadc189c9/wcwidth-0.9.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ab1e5190fb82476e75fbf963e9d59b4fb1c1e1f4ced82069a0c989016aa959f7", size = 619936, upload-time = "2026-10-24T18:11:04.073Z" }, + { url = "https://files.pythonhosted.org/packages/1f/d3/bb8a7f4aa9b915e56e09841b07636ba49c82ec987ad3d2022e1696c038d9/wcwidth-0.9.4-cp314-cp314t-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:8f892713ab5795d3abae181e9c02db0eb24de4084f9ee080535369d3d98d7bb5", size = 794563, upload-time = "2026-10-24T18:11:24.4Z" }, + { url = "https://files.pythonhosted.org/packages/12/0c/986acadef534688a57502d484a40e0f30bdca2d39514fe0a311f7d575f70/wcwidth-0.9.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:befbf46467100e43fd8c8cc0c031a0105f13f5418c3be95fdcf0c47214487967", size = 806565, upload-time = "2026-10-24T18:11:14.297Z" }, + { url = "https://files.pythonhosted.org/packages/9b/1d/66a94b9ac07037d7cf2c1f1288867c9932215d467893eaa5ec8d548c7f2f/wcwidth-0.9.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9c4b0dd04cca520792100f6110d10be262c94b285a281d1759c551f159214633", size = 802372, upload-time = "2026-10-24T18:11:26.275Z" }, + { url = "https://files.pythonhosted.org/packages/d1/00/1d50b8e8b45a8330b582695bf8196081a609317928a3718cf21b3d14a899/wcwidth-0.9.4-cp314-cp314t-win32.whl", hash = "sha256:14410eb73178cc492aa9bf22f7c12e3bf930e5470b7220cf6f530efbfa2e03f3", size = 598917, upload-time = "2026-10-24T18:11:38.369Z" }, + { url = "https://files.pythonhosted.org/packages/b4/fc/3e39a33fc8f5c4e07611578710275039c9d4a6655e2be7cf3459401a30cc/wcwidth-0.9.4-cp314-cp314t-win_amd64.whl", hash = "sha256:c36954849aafae1092d6f9de9548c5280c1d6841637a27ca288b2241c802c4ab", size = 603536, upload-time = "2026-10-24T18:11:39.922Z" }, + { url = "https://files.pythonhosted.org/packages/e1/8c/b1f399fd2f8449e42978192967ab6df441d7cf894b10117983c36c062b18/wcwidth-0.9.4-cp314-cp314t-win_arm64.whl", hash = "sha256:79e09e9824c88f5e275ca99e921685567a5c5c1bb6165c16e27ddd1adab33a95", size = 605127, upload-time = "2026-10-24T18:11:32.367Z" }, + { url = "https://files.pythonhosted.org/packages/04/46/839780e772e9068580619d4d691348b7a5f9c4fa5ffe501e522eefeb27cc/wcwidth-0.9.4-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:a8c9ce14c6b4a499e61de6de7e9e456de11be8bc991554e2ab2ed4feb40b9664", size = 613850, upload-time = "2026-10-24T18:11:00.725Z" }, + { url = "https://files.pythonhosted.org/packages/d2/66/b2559c7012bbd4268f5b5c0288cb793c78235d354e306871a55893aa9d1a/wcwidth-0.9.4-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:d68f09093c9bec9226a52edc47487042ed4f64c5df91d06f00419495071c0279", size = 620207, upload-time = "2026-10-24T18:11:05.975Z" }, + { url = "https://files.pythonhosted.org/packages/d1/fe/7d2c39e28924b2430b20099e36276f14e00e75c7bbe4ba5b1ed44d1d465a/wcwidth-0.9.4-cp315-cp315t-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:d76b7c715c5ca0103b28915f699f1020ae21f06f1d22cdd85a7a97f7b1536eed", size = 797056, upload-time = "2026-10-24T18:11:27.911Z" }, + { url = "https://files.pythonhosted.org/packages/2b/d7/f4f9967a411e02b89b74df2f49f44977c4badccf29738f3ae6941619e27c/wcwidth-0.9.4-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:29c0685f5f5f8815b88308fdcbe2cd12a92996a21a5b1e18352d165174ef7a6d", size = 806169, upload-time = "2026-10-24T18:11:15.724Z" }, + { url = "https://files.pythonhosted.org/packages/ac/bb/e2b40c6522f3aa1222558487dda3551d297e07e245761b4816f6caeebc29/wcwidth-0.9.4-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:e05458491759aa42b7b85f36345b3e6df082d6d2d9bf616299668fd598e0209d", size = 803462, upload-time = "2026-10-24T18:11:29.269Z" }, + { url = "https://files.pythonhosted.org/packages/a8/f2/ab69009f2dd0d3772d3e07f025fa046b33c60c195e4f2e5f000297d23547/wcwidth-0.9.4-cp315-cp315t-win32.whl", hash = "sha256:9e5090d253f5df99659cddfd3ed90dd21f6ff51989b0421331a63fb2681cbe27", size = 598931, upload-time = "2026-10-24T18:11:41.659Z" }, + { url = "https://files.pythonhosted.org/packages/63/6f/b321f10c2298e7d16cffc1a5f05f3d7e5231b45f9e68af5ee378e23bb2e5/wcwidth-0.9.4-cp315-cp315t-win_amd64.whl", hash = "sha256:12786620375dc83fabf4b2b2aa52416fef2bc6094522ea29c8a53c75b0dfe9b6", size = 603485, upload-time = "2026-10-24T18:11:43.052Z" }, + { url = "https://files.pythonhosted.org/packages/4e/cc/7eeb28059186cae72a770df79e744f232ef068192a5a588b718473e35bb4/wcwidth-0.9.4-cp315-cp315t-win_arm64.whl", hash = "sha256:2cca7b5d0b9d0ae49068d3ce806e965326a987f555b62eaa322223396e10d01b", size = 605198, upload-time = "2026-10-24T18:11:33.75Z" }, + { url = "https://files.pythonhosted.org/packages/6f/0c/309b1813b230d1dbbd6f2c2ab2bb21ef68992358977605d9ef289bbfedcc/wcwidth-0.9.4-py3-none-any.whl", hash = "sha256:901eace6d2dd25ebb917d0ce5db18e5c537e1504c905cf32f0d006c12098b05d", size = 301806, upload-time = "2026-10-24T18:10:52.651Z" }, ] [[package]] diff --git a/vortex-array/benches/binary_ops.rs b/vortex-array/benches/binary_ops.rs index e688d2cc76e..8515956aef5 100644 --- a/vortex-array/benches/binary_ops.rs +++ b/vortex-array/benches/binary_ops.rs @@ -4,7 +4,7 @@ //! Benchmarks for the binary `Operator` path, over primitive, decimal, and boolean inputs. //! //! The primitive arithmetic and comparison cases carry `#[cpu_features]`, so they are -//! measured on every walltime CPU-feature leg rather than in simulation. Each is written +//! measured on walltime CPU-feature legs rather than in simulation. Each is written //! once and compiled differently per leg: the kernel underneath is a portable lane loop, and //! how wide the compiler vectorizes it is decided by the build flags, not by the source. //! @@ -237,7 +237,8 @@ fn mul_u32_nonnull(bencher: Bencher) { bench_primitive(bencher, lhs, rhs, Operator::Mul); } -#[vortex_bench_support::cpu_features] +// This case varies on unchanged code on the NEON leg. The cause is unknown. +#[vortex_bench_support::cpu_features(exclude = ["neon"])] #[divan::bench] fn mul_u64_nonnull(bencher: Bencher) { let lhs = primitive_u64_small_nonnull(1, I64_LEN).into_array(); diff --git a/vortex-array/benches/chunk_array_builder.rs b/vortex-array/benches/chunk_array_builder.rs index f259e09cac8..92cb559022f 100644 --- a/vortex-array/benches/chunk_array_builder.rs +++ b/vortex-array/benches/chunk_array_builder.rs @@ -63,7 +63,8 @@ fn chunked_bool_canonical_into(bencher: Bencher, (len, chunk_count): (usize, usi }) } -#[divan::bench(args = BENCH_ARGS)] +// The largest nullable case varies on unchanged code in simulation. The cause is unknown. +#[divan::bench(args = if cfg!(codspeed) { &[(10, 100), (100, 50)] } else { BENCH_ARGS })] fn chunked_opt_bool_canonical_into(bencher: Bencher, (len, chunk_count): (usize, usize)) { let chunk = make_opt_bool_chunks(len, chunk_count); diff --git a/vortex-array/benches/row_fn_utf8_input.rs b/vortex-array/benches/row_fn_utf8_input.rs index 792758b7719..cd559d3fb60 100644 --- a/vortex-array/benches/row_fn_utf8_input.rs +++ b/vortex-array/benches/row_fn_utf8_input.rs @@ -6,6 +6,8 @@ reason = "benchmark fixtures reduce values below 26 before narrowing" )] +use std::fmt::Display; +use std::fmt::Formatter; use std::sync::LazyLock; use divan::Bencher; @@ -63,6 +65,37 @@ enum Layout { const LAYOUTS: &[Layout] = &[Layout::VarBin, Layout::VarBinView]; +#[derive(Clone, Copy)] +struct Case { + len: usize, + layout: Layout, +} + +impl Display for Case { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + // Preserve the report names from the former const-length and layout parameters. + let layout = match self.layout { + Layout::VarBin => "VarBin", + Layout::VarBinView => "VarBinView", + }; + + write!(f, "{}, {layout}", self.len) + } +} + +fn cases() -> Vec { + VALUE_LENS + .iter() + .flat_map(|&len| LAYOUTS.iter().map(move |&layout| Case { len, layout })) + .filter(|case| { + // VarBin varies on unchanged code, except for short values on the NEON leg. + env!("VORTEX_BENCH_VARIANT") == "local" + || matches!(case.layout, Layout::VarBinView) + || (env!("VORTEX_BENCH_VARIANT") == "neon" && case.len == 8) + }) + .collect() +} + #[derive(Clone)] struct StartsWith; @@ -105,9 +138,9 @@ fn make_input(layout: Layout, len: usize) -> ArrayRef { } #[vortex_bench_support::cpu_features] -#[divan::bench(args = LAYOUTS, consts = VALUE_LENS)] -fn starts_with(bencher: Bencher, &layout: &Layout) { - let args = VecExecutionArgs::new(vec![make_input(layout, LEN)], ROWS); +#[divan::bench(args = cases())] +fn starts_with(bencher: Bencher, case: Case) { + let args = VecExecutionArgs::new(vec![make_input(case.layout, case.len)], ROWS); bencher .counter(ItemsCount::new(ROWS)) diff --git a/vortex-array/benches/take_chunked.rs b/vortex-array/benches/take_chunked.rs index 7882ddfb557..6932d8d1136 100644 --- a/vortex-array/benches/take_chunked.rs +++ b/vortex-array/benches/take_chunked.rs @@ -147,7 +147,7 @@ impl Display for Case { } } -// Chunk and index counts are sized to keep CodSpeed simulation under 1ms per case. +// Chunk and index counts cover routing costs while keeping each iteration below 1 ms. fn cases() -> Vec { let mut cases = Vec::new(); @@ -347,7 +347,10 @@ fn take_indices(case: Case) -> ArrayRef { } } -#[divan::bench(args = cases())] +// Materialization can grow mimalloc's page map through system calls. Measure its full cost. +// The x86 variants still vary between processes with larger samples. Keep those runs local. +#[vortex_bench_support::cpu_features(exclude = ["avx2", "avx512"])] +#[divan::bench(args = cases(), sample_size = 16)] fn take(bencher: Bencher, case: Case) { let values = chunked_values(case); let indices = take_indices(case); diff --git a/vortex-array/src/aggregate_fn/fns/max/mod.rs b/vortex-array/src/aggregate_fn/fns/max/mod.rs index e570ea97071..863e40fedad 100644 --- a/vortex-array/src/aggregate_fn/fns/max/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/max/mod.rs @@ -42,28 +42,36 @@ pub struct MaxPartial { } impl MaxPartial { - fn merge(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>, max: Scalar) { + fn merge( + &mut self, + args: AggregateArgs<'_, NumericalAggregateOpts>, + max: Scalar, + ) -> VortexResult<()> { if max.is_null() { - return; + return Ok(()); } // NaN scalars are incomparable under `partial_max`; they poison the maximum when NaNs // participate, and are dropped when they are skipped. if scalar_is_nan(&max) || self.is_poisoned() { if !args.options.skip_nans { - self.poison(args); + self.poison(args)?; } - return; + return Ok(()); } self.max = Some(match self.max.take() { Some(current) => partial_max(max, current).vortex_expect("incomparable max scalars"), None => max, }); + + Ok(()) } - fn poison(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>) { - self.max = Some(nan_scalar(args.dtype)); + fn poison(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>) -> VortexResult<()> { + self.max = Some(nan_scalar(args.dtype)?); + + Ok(()) } fn is_poisoned(&self) -> bool { @@ -134,7 +142,7 @@ impl AggregateFnVTable for Max { ) -> VortexResult { let mut partial = MaxPartial { max: None }; // `merge` normalizes the parsed scalar: nulls stay empty and NaNs poison or drop. - partial.merge(args, scalar.clone()); + partial.merge(args, scalar.clone())?; Ok(partial) } @@ -145,7 +153,7 @@ impl AggregateFnVTable for Max { second: Self::Partial, ) -> VortexResult { if let Some(max) = second.max { - first.merge(args, max); + first.merge(args, max)?; } Ok(first) } @@ -182,7 +190,7 @@ impl AggregateFnVTable for Max { // `min_max` computes both extrema in one pass and caches both on `batch`, so a // `Min` over the same batch reads the cached value instead of a second scan. if let Some(result) = min_max(batch, ctx, *args.options)? { - partial.merge(args, result.max); + partial.merge(args, result.max)?; } return Ok(true); } @@ -192,13 +200,13 @@ impl AggregateFnVTable for Max { // NaN-free batch: the cached NaN-skipping maximum (if any) is valid. `to_scalar` // re-casts to the result dtype, so the cached scalar can merge as-is. if let Some(max) = batch.statistics().get(Stat::Max).as_exact() { - partial.merge(args, max); + partial.merge(args, max)?; return Ok(true); } Ok(false) } Precision::Exact(_) => { - partial.poison(args); + partial.poison(args)?; Ok(true) } _ => Ok(false), @@ -215,7 +223,7 @@ impl AggregateFnVTable for Max { // Delegate to the existing min_max implementation for now. A dedicated max aggregate // would avoid computing min when only max is needed. if let Some(result) = columnar_min_max(batch, *args.options, ctx)? { - partial.merge(args, result.max); + partial.merge(args, result.max)?; } Ok(()) } diff --git a/vortex-array/src/aggregate_fn/fns/min/mod.rs b/vortex-array/src/aggregate_fn/fns/min/mod.rs index 4392b8c3996..5dc08bf7afa 100644 --- a/vortex-array/src/aggregate_fn/fns/min/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/min/mod.rs @@ -42,28 +42,36 @@ pub struct MinPartial { } impl MinPartial { - fn merge(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>, min: Scalar) { + fn merge( + &mut self, + args: AggregateArgs<'_, NumericalAggregateOpts>, + min: Scalar, + ) -> VortexResult<()> { if min.is_null() { - return; + return Ok(()); } // NaN scalars are incomparable under `partial_min`; they poison the minimum when NaNs // participate, and are dropped when they are skipped. if scalar_is_nan(&min) || self.is_poisoned() { if !args.options.skip_nans { - self.poison(args); + self.poison(args)?; } - return; + return Ok(()); } self.min = Some(match self.min.take() { Some(current) => partial_min(min, current).vortex_expect("incomparable min scalars"), None => min, }); + + Ok(()) } - fn poison(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>) { - self.min = Some(nan_scalar(args.dtype)); + fn poison(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>) -> VortexResult<()> { + self.min = Some(nan_scalar(args.dtype)?); + + Ok(()) } fn is_poisoned(&self) -> bool { @@ -134,7 +142,7 @@ impl AggregateFnVTable for Min { ) -> VortexResult { let mut partial = MinPartial { min: None }; // `merge` normalizes the parsed scalar: nulls stay empty and NaNs poison or drop. - partial.merge(args, scalar.clone()); + partial.merge(args, scalar.clone())?; Ok(partial) } @@ -145,7 +153,7 @@ impl AggregateFnVTable for Min { second: Self::Partial, ) -> VortexResult { if let Some(min) = second.min { - first.merge(args, min); + first.merge(args, min)?; } Ok(first) } @@ -182,7 +190,7 @@ impl AggregateFnVTable for Min { // `min_max` computes both extrema in one pass and caches both on `batch`, so a // `Max` over the same batch reads the cached value instead of a second scan. if let Some(result) = min_max(batch, ctx, *args.options)? { - partial.merge(args, result.min); + partial.merge(args, result.min)?; } return Ok(true); } @@ -192,13 +200,13 @@ impl AggregateFnVTable for Min { // NaN-free batch: the cached NaN-skipping minimum (if any) is valid. `to_scalar` // re-casts to the result dtype, so the cached scalar can merge as-is. if let Some(min) = batch.statistics().get(Stat::Min).as_exact() { - partial.merge(args, min); + partial.merge(args, min)?; return Ok(true); } Ok(false) } Precision::Exact(_) => { - partial.poison(args); + partial.poison(args)?; Ok(true) } _ => Ok(false), @@ -215,7 +223,7 @@ impl AggregateFnVTable for Min { // Delegate to the existing min_max implementation for now. A dedicated min aggregate // would avoid computing max when only min is needed. if let Some(result) = columnar_min_max(batch, *args.options, ctx)? { - partial.merge(args, result.min); + partial.merge(args, result.min)?; } Ok(()) } diff --git a/vortex-array/src/aggregate_fn/fns/min_max/bool.rs b/vortex-array/src/aggregate_fn/fns/min_max/bool.rs index d2f49dffa3c..19df7d4c68e 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/bool.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/bool.rs @@ -53,6 +53,5 @@ pub(super) fn accumulate_bool( min: Scalar::bool(min, NonNullable), max: Scalar::bool(max, NonNullable), }), - ); - Ok(()) + ) } diff --git a/vortex-array/src/aggregate_fn/fns/min_max/decimal.rs b/vortex-array/src/aggregate_fn/fns/min_max/decimal.rs index 2fa1e137ffb..f7c0a633d69 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/decimal.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/decimal.rs @@ -25,8 +25,7 @@ pub(super) fn accumulate_decimal( ) -> VortexResult<()> { match_each_decimal_value_type!(array.values_type(), |T| { let local = compute_min_max_with_validity::(array, ctx)?; - partial.merge(args, local); - Ok(()) + partial.merge(args, local) }) } diff --git a/vortex-array/src/aggregate_fn/fns/min_max/extension.rs b/vortex-array/src/aggregate_fn/fns/min_max/extension.rs index 658d374604d..e43a4f222ae 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/extension.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/extension.rs @@ -11,7 +11,6 @@ use crate::aggregate_fn::AggregateArgs; use crate::aggregate_fn::NumericalAggregateOpts; use crate::arrays::ExtensionArray; use crate::arrays::extension::ExtensionArrayExt; -use crate::dtype::DType; use crate::dtype::Nullability; use crate::scalar::Scalar; @@ -21,17 +20,18 @@ pub(super) fn accumulate_extension( array: &ExtensionArray, ctx: &mut ExecutionCtx, ) -> VortexResult<()> { - let dtype = DType::Extension(array.ext_dtype().with_nullability(Nullability::NonNullable)); + let non_nullable_ext_dtype = array.ext_dtype().with_nullability(Nullability::NonNullable); + // A NaN in float storage comes back as NaN extrema, which `merge` skips or poisons with. - let local = min_max(array.storage_array(), ctx, *args.options)? - .map(|MinMaxResult { min, max }| { - // Storage extremes the extension type rejects are an error, not an invariant violation. - VortexResult::Ok(MinMaxResult { - min: Scalar::try_new(dtype.clone(), min.into_value())?, - max: Scalar::try_new(dtype, max.into_value())?, - }) - }) - .transpose()?; - partial.merge(args, local); - Ok(()) + let Some(MinMaxResult { min, max }) = min_max(array.storage_array(), ctx, *args.options)? + else { + return Ok(()); + }; + + let local = MinMaxResult { + min: Scalar::try_extension_ref(non_nullable_ext_dtype.clone(), min)?, + max: Scalar::try_extension_ref(non_nullable_ext_dtype, max)?, + }; + + partial.merge(args, Some(local)) } diff --git a/vortex-array/src/aggregate_fn/fns/min_max/fixed_size_list.rs b/vortex-array/src/aggregate_fn/fns/min_max/fixed_size_list.rs index f4e3cc6a51d..153abc97993 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/fixed_size_list.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/fixed_size_list.rs @@ -55,6 +55,5 @@ pub(super) fn accumulate_fixed_size_bytes( min: make_scalar(min), max: make_scalar(max), }), - ); - Ok(()) + ) } diff --git a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs index 707c1aa024b..aec6227ccdf 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/mod.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/mod.rs @@ -71,7 +71,7 @@ pub fn min_max( // NaN-free: identical to the NaN-skipping path below, including its stat caching. Precision::Exact(0) => {} // At least one NaN value poisons both extrema. - Precision::Exact(_) => return Ok(Some(nan_minmax_result(array.dtype()))), + Precision::Exact(_) => return Ok(Some(nan_minmax_result(array.dtype())?)), _ => { if array.is_empty() || array.valid_count(ctx)? == 0 { return Ok(None); @@ -158,12 +158,13 @@ pub(crate) fn columnar_min_max( } /// A `{min: NaN, max: NaN}` result for a poisoned NaN-including min/max over `dtype`. -fn nan_minmax_result(dtype: &DType) -> MinMaxResult { - let nan = nan_scalar(dtype); - MinMaxResult { +fn nan_minmax_result(dtype: &DType) -> VortexResult { + let nan = nan_scalar(dtype)?; + + Ok(MinMaxResult { min: nan.clone(), max: nan, - } + }) } /// Whether `dtype` can hold NaN values: floats, and extension types stored as floats. @@ -175,19 +176,22 @@ pub(crate) fn has_nan_values(dtype: &DType) -> bool { } /// A non-nullable NaN scalar of `dtype`, a float or an extension type stored as a float. -pub(crate) fn nan_scalar(dtype: &DType) -> Scalar { +/// +/// Returns an error if an extension dtype rejects NaN. +pub(crate) fn nan_scalar(dtype: &DType) -> VortexResult { if let DType::Extension(ext_dtype) = dtype { - return Scalar::extension_ref( + return Scalar::try_extension_ref( ext_dtype.with_nullability(Nullability::NonNullable), - nan_scalar(ext_dtype.storage_dtype()), + nan_scalar(ext_dtype.storage_dtype())?, ); } - match dtype.as_ptype() { + + Ok(match dtype.as_ptype() { PType::F16 => Scalar::primitive(f16::NAN, Nullability::NonNullable), PType::F32 => Scalar::primitive(f32::NAN, Nullability::NonNullable), PType::F64 => Scalar::primitive(f64::NAN, Nullability::NonNullable), _ => vortex_panic!("NaN scalar requested for non-float dtype {dtype}"), - } + }) } /// Whether a scalar holds a float NaN value, directly or as the storage of an extension scalar. @@ -250,9 +254,9 @@ impl MinMaxPartial { &mut self, args: AggregateArgs<'_, NumericalAggregateOpts>, local: Option, - ) { + ) -> VortexResult<()> { let Some(MinMaxResult { min, max }) = local else { - return; + return Ok(()); }; // NaN scalars are incomparable under `partial_min`/`partial_max`, so they are handled @@ -260,9 +264,9 @@ impl MinMaxPartial { // dropped when they are skipped. if scalar_is_nan(&min) || scalar_is_nan(&max) || self.is_poisoned() { if !args.options.skip_nans { - self.poison(args); + self.poison(args)?; } - return; + return Ok(()); } self.min = Some(match self.min.take() { @@ -274,13 +278,17 @@ impl MinMaxPartial { Some(current) => partial_max(max, current).vortex_expect("incomparable max scalars"), None => max, }); + + Ok(()) } /// Poison the partial state to `{min: NaN, max: NaN}`. - fn poison(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>) { - let nan = nan_scalar(args.dtype); + fn poison(&mut self, args: AggregateArgs<'_, NumericalAggregateOpts>) -> VortexResult<()> { + let nan = nan_scalar(args.dtype)?; self.min = Some(nan.clone()); self.max = Some(nan); + + Ok(()) } /// Whether the partial state is poisoned to NaN. @@ -376,7 +384,7 @@ impl AggregateFnVTable for MinMax { max: None, }; // `merge` normalizes the parsed extrema: nulls stay empty and NaNs poison or drop. - partial.merge(args, MinMaxResult::from_scalar(scalar)?); + partial.merge(args, MinMaxResult::from_scalar(scalar)?)?; Ok(partial) } @@ -387,7 +395,7 @@ impl AggregateFnVTable for MinMax { second: Self::Partial, ) -> VortexResult { if let (Some(min), Some(max)) = (second.min, second.max) { - first.merge(args, Some(MinMaxResult { min, max })); + first.merge(args, Some(MinMaxResult { min, max }))?; } Ok(first) } @@ -441,14 +449,14 @@ impl AggregateFnVTable for MinMax { min: min.cast(&non_nullable_dtype)?, max: max.cast(&non_nullable_dtype)?, }), - ); + )?; return Ok(true); } Ok(false) } Precision::Exact(_) => { // At least one NaN value poisons both extrema without scanning the batch. - partial.poison(args); + partial.poison(args)?; Ok(true) } _ => Ok(false), @@ -475,7 +483,7 @@ impl AggregateFnVTable for MinMax { // NaN float constants are skipped or poison the extrema, per the options. if scalar_is_nan(scalar) { if !args.options.skip_nans { - partial.poison(args); + partial.poison(args)?; } return Ok(()); } @@ -487,8 +495,7 @@ impl AggregateFnVTable for MinMax { min: cast.clone(), max: cast, }), - ); - Ok(()) + ) } Columnar::Canonical(c) => match c { Canonical::Primitive(p) => accumulate_primitive(args, partial, p, ctx), diff --git a/vortex-array/src/aggregate_fn/fns/min_max/primitive.rs b/vortex-array/src/aggregate_fn/fns/min_max/primitive.rs index 263e94ffc8e..6e2d1afcd32 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/primitive.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/primitive.rs @@ -26,8 +26,7 @@ pub(super) fn accumulate_primitive( let skip_nans = args.options.skip_nans; match_each_native_ptype!(p.ptype(), |T| { let local = compute_min_max_with_validity::(p, ctx, skip_nans)?; - partial.merge(args, local); - Ok(()) + partial.merge(args, local) }) } diff --git a/vortex-array/src/aggregate_fn/fns/min_max/varbinview.rs b/vortex-array/src/aggregate_fn/fns/min_max/varbinview.rs index ecc1e30afbb..8570377edc9 100644 --- a/vortex-array/src/aggregate_fn/fns/min_max/varbinview.rs +++ b/vortex-array/src/aggregate_fn/fns/min_max/varbinview.rs @@ -22,8 +22,7 @@ pub(super) fn accumulate_varbinview( array: &VarBinViewArray, ctx: &mut ExecutionCtx, ) -> VortexResult<()> { - partial.merge(args, compute_min_max_with_validity(array, ctx)?); - Ok(()) + partial.merge(args, compute_min_max_with_validity(array, ctx)?) } fn compute_min_max_with_validity( diff --git a/vortex-array/src/array/erased.rs b/vortex-array/src/array/erased.rs index b0590e3b284..a96c67e8a3a 100644 --- a/vortex-array/src/array/erased.rs +++ b/vortex-array/src/array/erased.rs @@ -49,6 +49,7 @@ use crate::expr::stats::Stat; use crate::expr::stats::StatsProviderExt; use crate::matcher::Matcher; use crate::optimizer::ArrayOptimizer; +use crate::optimizer::OptimizedState; use crate::scalar::Scalar; use crate::scalar::ScalarValue; use crate::stats::StatsSetRef; @@ -93,10 +94,21 @@ impl ArrayRef { } /// Returns a mutable reference to the inner if this is the sole owner. + /// + /// The caller may change the array, so it is no longer known to be optimized. #[allow(clippy::inline_always)] #[inline(always)] pub(crate) fn inner_mut(&mut self) -> Option<&mut ArrayInner> { - Arc::get_mut(&mut self.0) + let inner = Arc::get_mut(&mut self.0)?; + *inner.optimized.0.get_mut() = false; + Some(inner) + } + + /// Returns the record of whether the optimizer has already taken this array to its fixpoint. + /// + /// Only the optimizer can read or set the record. + pub(crate) fn optimized_state(&self) -> &OptimizedState { + &self.0.optimized } /// Returns the Arc::as_ptr().addr() of the underlying array. @@ -537,7 +549,7 @@ impl ArrayRef { mut self, slot_idx: usize, ) -> VortexResult<(ArrayRef, ArrayRef)> { - if let Some(inner) = Arc::get_mut(&mut self.0) { + if let Some(inner) = self.inner_mut() { let child = inner.slots[slot_idx] .take() .vortex_expect("take_slot_unchecked cannot take an absent slot"); @@ -572,7 +584,7 @@ impl ArrayRef { slot_idx: usize, replacement: ArrayRef, ) -> VortexResult { - if let Some(inner) = Arc::get_mut(&mut self.0) { + if let Some(inner) = self.inner_mut() { inner.slots[slot_idx] = Some(replacement); return Ok(self); } diff --git a/vortex-array/src/array/plugin.rs b/vortex-array/src/array/plugin.rs index 979d644228c..b60559f8af9 100644 --- a/vortex-array/src/array/plugin.rs +++ b/vortex-array/src/array/plugin.rs @@ -26,8 +26,8 @@ pub type ArrayPluginRef = Arc; /// The wire representation produced by an in-memory array's serializer. /// /// A serializer may reuse the in-memory array's buffers and children with [`Self::from_array`], -/// or return different parts when an older wire representation requires a lossless structural -/// downgrade. +/// or return the wire representation of another encoding. The node must hold the logical values +/// of the array under the dtype supplied by the containing format. #[derive(Clone, Debug)] pub struct ArraySerialization { /// The concrete array ID to write on the wire. @@ -101,32 +101,35 @@ impl<'a> ArrayDeserialization<'a> { /// Registry trait for serializing and deserializing an in-memory array representation. /// -/// A plugin has one [`id`](Self::id) for the in-memory representation and one or more -/// [`serialized_ids`](Self::serialized_ids) for wire representations. Its serializer chooses the -/// wire representation, and the serialization context validates that the chosen ID is permitted -/// before it is written. +/// A plugin writes one in-memory encoding, identified by [`id`](Self::id). It declares the wire +/// IDs that it reads and writes separately, so it can write another encoding's wire form without +/// replacing that encoding's reader. The serialization context validates that the chosen wire ID +/// is permitted before it is written. /// -/// Every serialized ID is also registered for deserialization. A current plugin may therefore -/// deserialize several historical IDs into the same in-memory representation. A reader that -/// predates a newer ID has no registration for it and reports it as unknown instead of silently -/// interpreting an unsupported representation. +/// A plugin can retain historical read IDs after it stops writing them. A reader that predates a +/// newer ID has no registration for it and reports it as unknown. pub trait ArrayPlugin: 'static + Send + Sync { - /// Returns the ID of the in-memory array representation handled by this plugin. + /// Returns the ID of the in-memory encoding that this plugin writes. fn id(&self) -> ArrayId; - /// Returns the serialized array IDs understood by this plugin, ordered oldest to newest. + /// Returns the wire IDs that [`deserialize`](Self::deserialize) accepts, oldest to newest. /// - /// The default uses the in-memory ID as the sole wire ID. Override this for an in-memory array - /// that has multiple serialized variants. IDs retained only for reading may also be included; - /// the single serializer need not select them. - fn serialized_ids(&self) -> Vec { - vec![self.id()] - } + /// [`ArraySession::register`](crate::session::ArraySession::register) makes this plugin the + /// reader of each ID. An ID can stay in this list after the plugin stops writing it, so that + /// old files stay readable. + fn read_ids(&self) -> Vec; + + /// Returns the wire IDs that [`serialize`](Self::serialize) may return. + /// + /// An ID in this list does not have to be in [`read_ids`](Self::read_ids). A plugin can write + /// its arrays in the wire form of another encoding. The plugin that owns that form reads it. + /// The node must hold the logical values of the array under the dtype of the array. + fn write_ids(&self) -> Vec; /// Serialize `array` to its wire representation. /// /// This function is called only for arrays whose in-memory encoding matches [`id`](Self::id). - /// The returned ID must be declared by [`serialized_ids`](Self::serialized_ids). Return + /// The returned ID must be declared by [`write_ids`](Self::write_ids). Return /// `Ok(None)` when the array cannot be serialized. fn serialize( &self, @@ -167,6 +170,14 @@ impl ArrayPlugin for V { VTable::id(self) } + fn read_ids(&self) -> Vec { + vec![self.id()] + } + + fn write_ids(&self) -> Vec { + vec![self.id()] + } + fn serialize( &self, array: &ArrayRef, diff --git a/vortex-array/src/array/typed.rs b/vortex-array/src/array/typed.rs index 4d86a07e5ac..516879949fd 100644 --- a/vortex-array/src/array/typed.rs +++ b/vortex-array/src/array/typed.rs @@ -28,6 +28,7 @@ use crate::array::ArrayId; use crate::array::ArrayView; use crate::array::VTable; use crate::dtype::DType; +use crate::optimizer::OptimizedState; use crate::scalar::Scalar; use crate::stats::ArrayStats; use crate::stats::StatsSet; @@ -48,6 +49,7 @@ pub(crate) struct ArrayInner { pub(crate) dtype: DType, pub(crate) slots: ArraySlots, pub(crate) stats: ArrayStats, + pub(crate) optimized: OptimizedState, pub(crate) data: D, // must be last for unsized coercion } @@ -173,6 +175,7 @@ impl ArrayInner> { dtype, slots, stats, + optimized: OptimizedState::default(), data: ArrayData { vtable, data }, }); uninit.assume_init() diff --git a/vortex-array/src/arrays/datetime/mod.rs b/vortex-array/src/arrays/datetime/mod.rs index 46c92d2cf62..0fb7bc78899 100644 --- a/vortex-array/src/arrays/datetime/mod.rs +++ b/vortex-array/src/arrays/datetime/mod.rs @@ -1,8 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors -#[cfg(test)] -mod test; +//! Typed wrappers for temporal extension arrays. +//! +//! [`TemporalData`] gives date, time, and timestamp arrays a shared storage interface. The extension +//! dtype retains each type's unit and metadata while the underlying array stores numeric values. use std::sync::Arc; @@ -213,3 +215,6 @@ impl TryFrom for TemporalData { Ok(Self { ext }) } } + +#[cfg(test)] +mod tests; diff --git a/vortex-array/src/arrays/datetime/test.rs b/vortex-array/src/arrays/datetime/tests.rs similarity index 82% rename from vortex-array/src/arrays/datetime/test.rs rename to vortex-array/src/arrays/datetime/tests.rs index 2e641e262d4..9bf8a615bfe 100644 --- a/vortex-array/src/arrays/datetime/test.rs +++ b/vortex-array/src/arrays/datetime/tests.rs @@ -6,25 +6,17 @@ use std::sync::LazyLock; use rstest::rstest; use vortex_buffer::buffer; use vortex_error::VortexExpect; -use vortex_error::VortexResult; use vortex_session::VortexSession; use crate::EqMode; use crate::IntoArray; use crate::VortexSessionExecute; -use crate::arrays::BoolArray; use crate::arrays::PrimitiveArray; use crate::arrays::datetime::TemporalData; use crate::assert_arrays_eq; -use crate::expr::gt; -use crate::expr::lit; -use crate::expr::root; use crate::extension::datetime::TemporalMetadata; use crate::extension::datetime::TimeUnit; -use crate::extension::datetime::Timestamp; -use crate::extension::datetime::TimestampOptions; use crate::hash::ArrayEq; -use crate::scalar::Scalar; use crate::validity::Validity; static SESSION: LazyLock = LazyLock::new(VortexSession::empty); @@ -216,34 +208,3 @@ fn test_validity_preservation(#[case] validity: Validity) { .array_eq(&validity, EqMode::Ptr) ); } - -#[test] -fn comparison_rejects_mismatched_timestamp_units() -> VortexResult<()> { - let ts_array = PrimitiveArray::from_iter(vec![1704067200000i64, 1704153600000, 1704240000000]) - .into_array(); - let temporal = TemporalData::new_timestamp(ts_array, TimeUnit::Milliseconds, None); - - let filter_expr = gt( - root(), - lit(Scalar::extension::( - TimestampOptions { - unit: TimeUnit::Seconds, - tz: None, - }, - Scalar::from(1704153600i64), - )), - ); - - let error = temporal - .into_array() - .apply(&filter_expr)? - .execute::(&mut SESSION.create_execution_ctx()) - .unwrap_err(); - assert!( - error - .to_string() - .contains("Cannot compare extension dtypes") - ); - - Ok(()) -} diff --git a/vortex-array/src/arrays/extension/compute/rules.rs b/vortex-array/src/arrays/extension/compute/rules.rs index fd92940ac6d..0fc6b99c982 100644 --- a/vortex-array/src/arrays/extension/compute/rules.rs +++ b/vortex-array/src/arrays/extension/compute/rules.rs @@ -36,12 +36,15 @@ impl ArrayReduceRule for ExtensionConstantRule { }; let storage_scalar = const_array.scalar().clone(); - let ext_scalar = Scalar::extension_ref(array.ext_dtype().clone(), storage_scalar); - - let constant_with_extension_scalar = - ConstantArray::new(ext_scalar, array.len()).into_array(); + let Ok(ext_scalar) = Scalar::try_extension_ref(array.ext_dtype().clone(), storage_scalar) + else { + // Invalid extension values must not prevent storage access or structural operations. + return Ok(None); + }; - Ok(Some(constant_with_extension_scalar.into_array())) + Ok(Some( + ConstantArray::new(ext_scalar, array.len()).into_array(), + )) } } @@ -246,67 +249,6 @@ mod tests { assert_eq!(constant.len(), 3); } - #[test] - fn test_scalar_fn_no_pushdown_different_ext_types() { - #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] - struct TestExt2; - impl ExtVTable for TestExt2 { - type Metadata = EmptyMetadata; - type NativeValue<'a> = &'a str; - - #[expect(clippy::disallowed_methods, reason = "test-only id")] - fn id(&self) -> ExtId { - ExtId::new("test_ext_2") - } - - fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { - Ok(vec![]) - } - - fn deserialize_metadata(&self, _data: &[u8]) -> VortexResult { - Ok(EmptyMetadata) - } - - fn validate_dtype(_extension_dtype: &ExtDType) -> VortexResult<()> { - Ok(()) - } - - fn unpack_native<'a>( - _extension_dtype: &'a ExtDType, - _storage_value: &'a ScalarValue, - ) -> VortexResult> { - Ok("") - } - } - - let ext_dtype1 = ExtDType::::try_new( - EmptyMetadata, - DType::Primitive(PType::I64, Nullability::NonNullable), - ) - .unwrap() - .erased(); - - let storage = buffer![10i64, 20, 30].into_array(); - let ext_array = ExtensionArray::new(ext_dtype1, storage).into_array(); - - // Create constant with different extension type - let const_scalar = Scalar::extension::(EmptyMetadata, Scalar::from(25i64)); - let const_array = ConstantArray::new(const_scalar, 3).into_array(); - - let scalar_fn_array = Binary::try_new(ext_array, const_array, Operator::Lt) - .unwrap() - .into_array(); - - let optimized = scalar_fn_array.optimize().unwrap(); - - // The first child should still be an ExtensionArray (no pushdown happened) - let scalar_fn = optimized.as_opt::().unwrap(); - assert!( - scalar_fn.children()[0].as_opt::().is_some(), - "Expected first child to remain ExtensionArray when ext types differ" - ); - } - #[test] fn test_scalar_fn_no_pushdown_non_constant_sibling() { let ext_dtype = test_ext_dtype(); @@ -331,27 +273,4 @@ mod tests { "Expected first child to remain ExtensionArray when sibling is not constant" ); } - - #[test] - fn test_scalar_fn_no_pushdown_non_extension_constant() { - let ext_dtype = test_ext_dtype(); - let storage = buffer![10i64, 20, 30].into_array(); - let ext_array = ExtensionArray::new(ext_dtype, storage).into_array(); - - // Create a non-extension constant (plain primitive) - let const_array = ConstantArray::new(Scalar::from(25i64), 3).into_array(); - - let scalar_fn_array = Binary::try_new(ext_array, const_array, Operator::Lt) - .unwrap() - .into_array(); - - let optimized = scalar_fn_array.optimize().unwrap(); - - // No pushdown should happen because constant is not an extension scalar - let scalar_fn = optimized.as_opt::().unwrap(); - assert!( - scalar_fn.children()[0].as_opt::().is_some(), - "Expected first child to remain ExtensionArray when constant is not extension" - ); - } } diff --git a/vortex-array/src/arrays/extension/mod.rs b/vortex-array/src/arrays/extension/mod.rs index f96049d2cf8..3dfd71797a2 100644 --- a/vortex-array/src/arrays/extension/mod.rs +++ b/vortex-array/src/arrays/extension/mod.rs @@ -1,6 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Extension arrays preserve a logical dtype around its storage array. +//! +//! Construction checks the storage dtype. Reading a logical scalar also validates its value +//! against the extension dtype. + mod array; pub use array::ExtensionArrayExt; pub use array::ExtensionArraySlotsExt; @@ -16,3 +21,6 @@ pub use vtable::Extension; pub(crate) fn initialize(session: &vortex_session::VortexSession) { vtable::initialize(session); } + +#[cfg(test)] +mod tests; diff --git a/vortex-array/src/arrays/extension/tests.rs b/vortex-array/src/arrays/extension/tests.rs new file mode 100644 index 00000000000..fc6e9ec870d --- /dev/null +++ b/vortex-array/src/arrays/extension/tests.rs @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Regression tests for extension storage validation and fallible scalar reads. + +use std::fmt::Debug; +use std::sync::LazyLock; + +use rstest::rstest; +use vortex_buffer::buffer; +use vortex_error::VortexResult; +use vortex_error::vortex_ensure; +use vortex_session::VortexSession; +use vortex_session::registry::CachedId; + +use crate::ArrayParts; +use crate::ArrayRef; +use crate::EmptyArrayData; +use crate::EmptyMetadata; +use crate::IntoArray; +use crate::VortexSessionExecute; +use crate::aggregate_fn::AggregateFn; +use crate::aggregate_fn::AggregateFnRef; +use crate::aggregate_fn::NumericalAggregateOpts; +use crate::aggregate_fn::fns::max::Max; +use crate::aggregate_fn::fns::min::Min; +use crate::aggregate_fn::fns::min_max::MinMax; +use crate::aggregate_fn::fns::min_max::min_max; +use crate::aggregate_fn::fns::min_max::nan_scalar; +use crate::arrays::ConstantArray; +use crate::arrays::Extension; +use crate::arrays::ExtensionArray; +use crate::arrays::PrimitiveArray; +use crate::arrays::extension::ExtensionSlots; +use crate::assert_arrays_eq; +use crate::dtype::DType; +use crate::dtype::Nullability; +use crate::dtype::PType; +use crate::dtype::extension::ExtDType; +use crate::dtype::extension::ExtDTypeRef; +use crate::dtype::extension::ExtId; +use crate::dtype::extension::ExtVTable; +use crate::expr::ext_storage; +use crate::expr::root; +use crate::optimizer::ArrayOptimizer; +use crate::scalar::PValue; +use crate::scalar::Scalar; +use crate::scalar::ScalarValue; + +static SESSION: LazyLock = LazyLock::new(VortexSession::empty); + +#[track_caller] +fn assert_non_zero_error(result: VortexResult, value: &str) { + let error = result.unwrap_err().to_string(); + let expected = format!("NonZero requires a finite nonzero value, got {value}"); + assert!(error.contains(&expected), "{error}"); +} + +/// A test extension that rejects zero and non-finite storage values. +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] +struct NonZero; + +impl NonZero { + fn dtype(ptype: PType, nullability: Nullability) -> VortexResult { + Ok( + ExtDType::::try_new(EmptyMetadata, DType::Primitive(ptype, nullability))? + .erased(), + ) + } + + fn array(storage: ArrayRef) -> VortexResult { + let dtype = Self::dtype(storage.dtype().as_ptype(), storage.dtype().nullability())?; + + Ok(ExtensionArray::try_new(dtype, storage)?.into_array()) + } +} + +impl ExtVTable for NonZero { + type Metadata = EmptyMetadata; + type NativeValue<'a> = &'a ScalarValue; + + fn id(&self) -> ExtId { + static ID: CachedId = CachedId::new("test.non_zero"); + *ID + } + + fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { + Ok(vec![]) + } + + fn deserialize_metadata(&self, _metadata: &[u8]) -> VortexResult { + Ok(EmptyMetadata) + } + + fn validate_dtype(ext_dtype: &ExtDType) -> VortexResult<()> { + vortex_ensure!( + matches!( + ext_dtype.storage_dtype(), + DType::Primitive(PType::I64 | PType::F64, _) + ), + "NonZero requires i64 or f64 storage, got {}", + ext_dtype.storage_dtype() + ); + + Ok(()) + } + + fn unpack_native<'a>( + _ext_dtype: &'a ExtDType, + storage_value: &'a ScalarValue, + ) -> VortexResult> { + let value = storage_value.as_primitive().cast::()?; + vortex_ensure!( + value.is_finite() && value != 0.0, + "NonZero requires a finite nonzero value, got {value}" + ); + + Ok(storage_value) + } +} + +#[rstest] +#[case::primitive(buffer![0i64, 1].into_array())] +#[case::constant(ConstantArray::new(0i64, 2).into_array())] +fn test_invalid_values_return_read_errors(#[case] storage: ArrayRef) -> VortexResult<()> { + let array = NonZero::array(storage.clone())?; + let mut ctx = SESSION.create_execution_ctx(); + + assert_non_zero_error(array.execute_scalar(0, &mut ctx), "0"); + assert_non_zero_error(array.repeated_probe().execute_scalar(0, &mut ctx), "0"); + + let optimized = array.optimize()?; + assert!(optimized.is::()); + assert_arrays_eq!(optimized.apply(&ext_storage(root()))?, storage, &mut ctx); + assert_arrays_eq!( + array.slice(0..1)?.apply(&ext_storage(root()))?, + buffer![0i64].into_array(), + &mut ctx + ); + + Ok(()) +} + +#[rstest] +#[case::valid(Scalar::primitive(1i64, Nullability::Nullable))] +#[case::null(Scalar::null(DType::Primitive(PType::I64, Nullability::Nullable)))] +fn test_valid_values_keep_the_extension_dtype(#[case] storage: Scalar) -> VortexResult<()> { + let ext_dtype = NonZero::dtype(PType::I64, Nullability::Nullable)?; + let scalar = Scalar::try_extension_ref(ext_dtype.clone(), storage.clone())?; + let array = NonZero::array(ConstantArray::new(storage, 2).into_array())?.optimize()?; + let mut ctx = SESSION.create_execution_ctx(); + + assert_eq!(scalar.dtype(), &DType::Extension(ext_dtype)); + assert_eq!(array.execute_scalar(0, &mut ctx)?, scalar); + assert_arrays_eq!(array, ConstantArray::new(scalar, 2), &mut ctx); + + Ok(()) +} + +#[rstest] +#[case::wrong_kind(ScalarValue::Bool(true))] +#[case::wrong_primitive(ScalarValue::Primitive(PValue::F64(1.0)))] +fn test_scalar_values_require_the_storage_dtype(#[case] value: ScalarValue) -> VortexResult<()> { + let dtype = DType::Extension(NonZero::dtype(PType::I64, Nullability::NonNullable)?); + + assert!(Scalar::try_new(dtype, Some(value)).is_err()); + + Ok(()) +} + +#[rstest] +#[case::wrong_dtype(Scalar::from(1.0f64))] +#[case::invalid_value(Scalar::from(0i64))] +fn test_extension_constructor_rejects_invalid_storage(#[case] storage: Scalar) -> VortexResult<()> { + let dtype = NonZero::dtype(PType::I64, Nullability::NonNullable)?; + + assert!(Scalar::try_extension_ref(dtype, storage).is_err()); + + Ok(()) +} + +#[rstest] +#[case::wrong_kind(ConstantArray::new("value", 1).into_array())] +#[case::wrong_primitive(buffer![1f64].into_array())] +#[case::wrong_nullability(PrimitiveArray::from_option_iter([Some(1i64)]).into_array())] +#[case::empty(PrimitiveArray::from_iter(std::iter::empty::()).into_array())] +fn test_array_parts_require_the_storage_dtype(#[case] storage: ArrayRef) -> VortexResult<()> { + let dtype = NonZero::dtype(PType::I64, Nullability::NonNullable)?; + let parts = ArrayParts::new( + Extension, + DType::Extension(dtype), + storage.len(), + EmptyArrayData, + ExtensionSlots { storage }.into_slots(), + ); + + assert!(ExtensionArray::try_from_parts(parts).is_err()); + + Ok(()) +} + +#[rstest] +#[case::min(AggregateFn::new(Min, NumericalAggregateOpts::default()).erased())] +#[case::max(AggregateFn::new(Max, NumericalAggregateOpts::default()).erased())] +#[case::min_max(AggregateFn::new(MinMax, NumericalAggregateOpts::default()).erased())] +fn test_aggregates_return_extension_validation_errors( + #[case] aggregate: AggregateFnRef, +) -> VortexResult<()> { + let array = NonZero::array(buffer![0i64, 1].into_array())?; + let mut ctx = SESSION.create_execution_ctx(); + let mut accumulator = aggregate.accumulator(array.dtype())?; + + assert_non_zero_error(accumulator.accumulate(&array, &mut ctx), "0"); + + Ok(()) +} + +#[test] +fn test_nan_extrema_return_extension_validation_errors() -> VortexResult<()> { + let array = NonZero::array(buffer![f64::NAN, 1.0].into_array())?; + let mut ctx = SESSION.create_execution_ctx(); + + assert_non_zero_error( + min_max(&array, &mut ctx, NumericalAggregateOpts::include_nans()), + "NaN", + ); + + Ok(()) +} + +#[rstest] +fn test_nan_scalar_returns_extension_validation_errors( + #[values(Nullability::NonNullable, Nullability::Nullable)] nullability: Nullability, +) -> VortexResult<()> { + let dtype = DType::Extension(NonZero::dtype(PType::F64, nullability)?); + + assert_non_zero_error(nan_scalar(&dtype), "NaN"); + + Ok(()) +} + +#[rstest] +#[case::extension(false)] +#[case::nested(true)] +#[should_panic(expected = "has no non-null zero value")] +fn test_rejected_extension_zero_cannot_construct_a_scalar( + #[case] nested: bool, + #[values(Nullability::NonNullable, Nullability::Nullable)] nullability: Nullability, +) { + let dtype = NonZero::dtype(PType::I64, nullability).expect("NonZero accepts i64 storage"); + let mut dtype = DType::Extension(dtype); + if nested { + dtype = DType::struct_([("value", dtype)], Nullability::NonNullable); + } + + Scalar::zero_value(&dtype); +} diff --git a/vortex-array/src/arrays/extension/vtable/mod.rs b/vortex-array/src/arrays/extension/vtable/mod.rs index 6069d945efe..e8efe3a44f8 100644 --- a/vortex-array/src/arrays/extension/vtable/mod.rs +++ b/vortex-array/src/arrays/extension/vtable/mod.rs @@ -113,12 +113,7 @@ impl VTable for Extension { .as_extension_opt() .ok_or_else(|| vortex_err!("not an extension dtype"))?; - let actual_dtype = DType::Extension(ext_dtype.clone()); - vortex_ensure_eq!( - &actual_dtype, - dtype, - "ExtensionArray dtype does not match outer dtype", - ); + vortex_ensure_eq!(storage.dtype(), ext_dtype.storage_dtype()); Ok(()) } diff --git a/vortex-array/src/arrays/extension/vtable/operations.rs b/vortex-array/src/arrays/extension/vtable/operations.rs index 14d21988dd7..dd33a118f71 100644 --- a/vortex-array/src/arrays/extension/vtable/operations.rs +++ b/vortex-array/src/arrays/extension/vtable/operations.rs @@ -26,7 +26,7 @@ impl OperationsVTable for Extension { .slot(ExtensionSlots::STORAGE)? .ok_or_else(|| vortex_err!("Extension storage slot is missing"))? .execute_scalar(index, ctx)?; - Ok(Scalar::extension_ref(ext_dtype, storage)) + Scalar::try_extension_ref(ext_dtype, storage) } fn scalar_at( diff --git a/vortex-array/src/arrays/scalar_fn/plugin.rs b/vortex-array/src/arrays/scalar_fn/plugin.rs index 4a4a7d3d5ab..43a5616bc98 100644 --- a/vortex-array/src/arrays/scalar_fn/plugin.rs +++ b/vortex-array/src/arrays/scalar_fn/plugin.rs @@ -62,6 +62,14 @@ impl ArrayPlugin for ScalarFnArrayPlugi self.0.id() } + fn read_ids(&self) -> Vec { + vec![self.id()] + } + + fn write_ids(&self) -> Vec { + vec![self.id()] + } + fn serialize( &self, array: &ArrayRef, diff --git a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs index 43df40e1d2f..d2827ff68c3 100644 --- a/vortex-array/src/arrays/scalar_fn/vtable/mod.rs +++ b/vortex-array/src/arrays/scalar_fn/vtable/mod.rs @@ -42,6 +42,7 @@ use crate::scalar_fn; use crate::scalar_fn::ArrayReduceNode; use crate::scalar_fn::ReduceNode; use crate::scalar_fn::ReduceNodeValidity; +use crate::scalar_fn::ScalarFnExecutionStep; use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::VecExecutionArgs; use crate::serde::ArrayChildren; @@ -174,10 +175,12 @@ impl VTable for ScalarFn { fn execute(array: Array, ctx: &mut ExecutionCtx) -> VortexResult { let args = VecExecutionArgs::new(array.children(), array.len()); - array - .scalar_fn() - .execute(&args, ctx) - .map(ExecutionResult::done) + match array.scalar_fn().execute_step(&args, ctx)?.into_step() { + ScalarFnExecutionStep::Done(result) => Ok(ExecutionResult::done(result)), + ScalarFnExecutionStep::ExecuteInput(idx, done) => Ok( + ExecutionResult::execute_slot_until(array.into_array(), idx, done), + ), + } } fn reduce(array: ArrayView<'_, Self>) -> VortexResult> { diff --git a/vortex-array/src/dtype/extension/erased.rs b/vortex-array/src/dtype/extension/erased.rs index b2f49974247..378551dfa38 100644 --- a/vortex-array/src/dtype/extension/erased.rs +++ b/vortex-array/src/dtype/extension/erased.rs @@ -180,11 +180,9 @@ impl Hash for ExtDTypeRef { impl fmt::Debug for ExtDTypeRef { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let metadata = self.0.metadata_debug(f); - f.debug_struct("ExtDType") .field("id", &self.id()) - .field("metadata", &metadata) + .field("metadata", &MetadataDebug(self.0.as_ref())) .field("storage_dtype", &self.storage_dtype()) .finish() } @@ -206,6 +204,14 @@ impl fmt::Display for ExtDTypeRef { // Private formatting helpers for Display and Debug impls. +struct MetadataDebug<'a>(&'a dyn DynExtDType); + +impl fmt::Debug for MetadataDebug<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.metadata_debug(f) + } +} + struct MetadataDisplay<'a>(&'a dyn DynExtDType); impl fmt::Display for MetadataDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/vortex-array/src/dtype/extension/mod.rs b/vortex-array/src/dtype/extension/mod.rs index 44a6e7a01a7..e2808e79ed8 100644 --- a/vortex-array/src/dtype/extension/mod.rs +++ b/vortex-array/src/dtype/extension/mod.rs @@ -55,3 +55,6 @@ mod sealed { /// This can be the **only** implementor for [`super::typed::DynExtDType`]. impl Sealed for ExtDType {} } + +#[cfg(test)] +mod tests; diff --git a/vortex-array/src/dtype/extension/tests.rs b/vortex-array/src/dtype/extension/tests.rs new file mode 100644 index 00000000000..5fee4a2375e --- /dev/null +++ b/vortex-array/src/dtype/extension/tests.rs @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Regression tests for extension dtype nullability changes and debug output. + +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +use rstest::rstest; +use vortex_error::VortexResult; +use vortex_error::vortex_err; +use vortex_session::registry::CachedId; + +use super::ExtDType; +use super::ExtId; +use super::ExtVTable; +use crate::dtype::DType; +use crate::dtype::Nullability::NonNullable; +use crate::dtype::Nullability::Nullable; +use crate::dtype::PType; +use crate::extension::datetime::TimeUnit; +use crate::extension::datetime::Timestamp; +use crate::scalar::ScalarValue; + +/// The number of times [`CountingValidator::validate_dtype`] ran. +static VALIDATIONS: AtomicUsize = AtomicUsize::new(0); + +/// An extension type that counts how often its dtype is validated. +#[derive(Clone, Debug, Default, Eq, Hash, PartialEq)] +struct CountingValidator; + +impl ExtVTable for CountingValidator { + type Metadata = u32; + type NativeValue<'a> = &'a ScalarValue; + + fn id(&self) -> ExtId { + static ID: CachedId = CachedId::new("test.counting_validator"); + *ID + } + + fn serialize_metadata(&self, metadata: &Self::Metadata) -> VortexResult> { + Ok(metadata.to_le_bytes().to_vec()) + } + + fn deserialize_metadata(&self, metadata: &[u8]) -> VortexResult { + let bytes = metadata + .try_into() + .map_err(|_| vortex_err!("Expected four metadata bytes, got {}", metadata.len()))?; + + Ok(u32::from_le_bytes(bytes)) + } + + fn validate_dtype(_ext_dtype: &ExtDType) -> VortexResult<()> { + VALIDATIONS.fetch_add(1, Ordering::Relaxed); + + Ok(()) + } + + fn unpack_native<'a>( + _ext_dtype: &'a ExtDType, + storage_value: &'a ScalarValue, + ) -> VortexResult> { + Ok(storage_value) + } +} + +// One test owns `VALIDATIONS`, so test threads cannot race on the counter. +#[test] +fn test_nullability_changes_do_not_validate_again() -> VortexResult<()> { + for initial in [NonNullable, Nullable] { + VALIDATIONS.store(0, Ordering::Relaxed); + let dtype = + ExtDType::::try_new(42, DType::Primitive(PType::I64, initial))?; + assert_eq!(VALIDATIONS.load(Ordering::Relaxed), 1); + + for target in [Nullable, NonNullable] { + let changed = dtype.with_nullability(target); + + assert_eq!( + changed.storage_dtype(), + &DType::Primitive(PType::I64, target) + ); + assert_eq!(changed.metadata::(), &42); + assert_eq!(changed.id(), dtype.id()); + } + + assert_eq!(VALIDATIONS.load(Ordering::Relaxed), 1); + } + + Ok(()) +} + +#[rstest] +#[case::compact(false)] +#[case::pretty(true)] +fn test_debug_preserves_metadata(#[case] pretty: bool) -> VortexResult<()> { + let dtype = + Timestamp::try_new_with_tz(TimeUnit::Milliseconds, Some("UTC".into()), Nullable)?.erased(); + let output = if pretty { + format!("{dtype:#?}") + } else { + format!("{dtype:?}") + }; + + assert!(output.starts_with("ExtDType {"), "{output}"); + assert!(output.contains("metadata: TimestampOptions {"), "{output}"); + assert!(output.contains("unit: Milliseconds"), "{output}"); + assert_eq!( + output.contains("metadata: TimestampOptions {\n"), + pretty, + "{output}" + ); + assert_eq!(output.matches("UTC").count(), 1, "{output}"); + + Ok(()) +} diff --git a/vortex-array/src/dtype/extension/typed.rs b/vortex-array/src/dtype/extension/typed.rs index e59d4207860..18387482a33 100644 --- a/vortex-array/src/dtype/extension/typed.rs +++ b/vortex-array/src/dtype/extension/typed.rs @@ -12,7 +12,6 @@ use std::hash::Hash; use std::hash::Hasher; use std::sync::Arc; -use vortex_error::VortexExpect; use vortex_error::VortexResult; use crate::dtype::DType; @@ -88,14 +87,16 @@ impl ExtDType { } /// Returns a new [`ExtDTypeRef`] with the given nullability. + /// + /// This does not validate the dtype again, because [`ExtVTable::validate_dtype`] must not + /// depend on the top-level nullability of the storage dtype. pub fn with_nullability(&self, nullability: Nullability) -> ExtDTypeRef { - let storage_dtype = self.storage_dtype.with_nullability(nullability); - ExtDType::::try_with_vtable(self.vtable.clone(), self.metadata.clone(), storage_dtype) - .vortex_expect( - "Extension DType should not fail validation with the same storage type \ - but different nullability", - ) - .erased() + Self { + vtable: self.vtable.clone(), + metadata: self.metadata.clone(), + storage_dtype: self.storage_dtype.with_nullability(nullability), + } + .erased() } /// Serializes the metadata into a byte vector. diff --git a/vortex-array/src/dtype/extension/vtable.rs b/vortex-array/src/dtype/extension/vtable.rs index ecea9d24a9a..8482d710471 100644 --- a/vortex-array/src/dtype/extension/vtable.rs +++ b/vortex-array/src/dtype/extension/vtable.rs @@ -46,6 +46,15 @@ pub trait ExtVTable: 'static + Sized + Send + Sync + Clone + Debug + Eq + Hash { /// /// This is called when constructing an [`ExtDType`] and should check both storage dtype and /// extension metadata. + /// + /// The result **must not** depend on the top-level nullability of the storage dtype. Array + /// operations control whether values can be null, so extension types must accept either + /// nullability. [`ExtDType::with_nullability`] relies on this contract to change nullability + /// without validating again. Validators can still constrain nullability inside nested storage + /// types. + /// + /// Violating this contract can produce a dtype that the validator rejects. It does not cause + /// undefined behavior. fn validate_dtype(ext_dtype: &ExtDType) -> VortexResult<()>; // Methods related to the extension scalar values. @@ -67,9 +76,9 @@ pub trait ExtVTable: 'static + Sized + Send + Sync + Clone + Debug + Eq + Hash { /// Validate and unpack a native value from the storage [`ScalarValue`]. /// - /// Note that [`ExtVTable::validate_dtype()`] is always called first to validate the storage - /// [`crate::dtype::DType`], and the [`Scalar`](crate::scalar::Scalar) implementation will - /// verify that the storage value is compatible with the storage dtype on construction. + /// The storage dtype and metadata satisfy [`Self::validate_dtype`]. + /// [`Scalar`](crate::scalar::Scalar) construction also verifies that the storage value is + /// compatible with the storage dtype. /// /// # Errors /// diff --git a/vortex-array/src/executor.rs b/vortex-array/src/executor.rs index 1b4baf2438b..b261c3175be 100644 --- a/vortex-array/src/executor.rs +++ b/vortex-array/src/executor.rs @@ -852,6 +852,18 @@ impl ExecutionResult { } } + /// Like [`execute_slot`](Self::execute_slot), but with a [`DonePredicate`] chosen at runtime. + pub(crate) fn execute_slot_until( + array: ArrayRef, + slot_idx: usize, + done: DonePredicate, + ) -> Self { + Self { + array, + step: ExecutionStep::ExecuteSlot(slot_idx, done), + } + } + /// Request that the child slot at `slot_idx` be detached, appended into the current /// activation's canonical builder, and leave the returned parent as the next /// `current_array`. diff --git a/vortex-array/src/optimizer/mod.rs b/vortex-array/src/optimizer/mod.rs index 1d9c2c87da0..5384988671f 100644 --- a/vortex-array/src/optimizer/mod.rs +++ b/vortex-array/src/optimizer/mod.rs @@ -15,6 +15,15 @@ //! point used by execution. //! - [`ArrayOptimizer::optimize_recursive`] applies the session-aware optimizer to the root and //! every descendant. +//! +//! Each array records whether [`ArrayOptimizer::optimize_recursive`] has optimized it and all of +//! its descendants. A new array starts unoptimized, and the optimizer marks the arrays that +//! [`ArrayOptimizer::optimize_recursive`] returns, so optimizing a marked array again returns it +//! without trying any rule. The mark does not record the session: an array optimized with one +//! session is not optimized again with a session that registers more kernels. + +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering; use smallvec::SmallVec; use vortex_error::VortexResult; @@ -33,6 +42,69 @@ pub mod rules; /// Increasing this value permits longer rewrite chains but delays detection of cyclic rules. const MAX_OPTIMIZER_REWRITE_PASS: usize = 100; +/// Records whether the optimizer has already optimized an array node and all of its descendants. +/// +/// A shared array never changes, so a node that the optimizer took to its fixpoint stays there. +/// Every new array starts unoptimized, and changing a uniquely owned array in place clears the +/// state. +/// +/// # What the mark promises +/// +/// The mark promises only that no reduce or parent-reduce rule applies to the node or its +/// descendants, given their encodings, dtypes, slots and data. These do not change while the +/// array is shared. A thread that sees the mark skips the optimizer for the whole subtree, so a +/// rule that could apply later is never tried. +/// +/// # When an array stays unoptimized +/// +/// An array must stay unmarked, or clear its mark, when the decision of a rule depends on +/// something that can change after the optimizer pass: +/// +/// - The array changes in place. [`ArrayRef::inner_mut`] clears the mark, because the caller holds +/// the only reference and can replace slots or data. +/// - A rule reads state that can be set on a shared array after the pass, such as statistics. +/// For example, a rule that reduces an array to a constant when [`Stat::IsConstant`] is known +/// does not run if the statistic is computed after the array was marked. A shared array cannot +/// clear its mark, because that needs the only reference. Thus such a rule must not depend on +/// the mark, or the optimizer must not mark the arrays that it can apply to. +/// - The session changes. The mark does not record the kernels it was optimized with, so an +/// array optimized with one session is not optimized again with a session that registers more +/// kernels. +/// +/// # Memory ordering +/// +/// The flag uses [`Ordering::Relaxed`]. This is correct because the mark only promises things that +/// a thread can already see through its reference to the array. If the mark comes to promise +/// state that another thread writes, such as statistics that a rule reads, store it with +/// [`Ordering::Release`] and load it with [`Ordering::Acquire`]. Then a thread that sees the mark +/// also sees that state. +/// +/// [`ArrayRef::inner_mut`]: crate::ArrayRef::inner_mut +/// [`Stat::IsConstant`]: crate::expr::stats::Stat::IsConstant +#[derive(Debug, Default)] +pub(crate) struct OptimizedState(pub(crate) AtomicBool); + +impl OptimizedState { + fn is_optimized(&self) -> bool { + self.0.load(Ordering::Relaxed) + } + + fn mark_optimized(&self) { + self.0.store(true, Ordering::Relaxed); + } +} + +/// Marks an array decoded from its serialized form as optimized. +/// +/// Decoding calls this for each node it decodes, and it decodes the children of a node before the +/// node. Thus every decoded node is marked, and the optimizer does not try reduce or +/// parent-reduce rules on any of them. Only the nodes that an encoding's deserializer builds itself +/// around its decoded children stay unmarked. Arrays are usually written as the compressor built +/// them, so this skips rules on decoded arrays without the guarantee that none applies. +pub(crate) fn mark_decoded_optimized(array: &ArrayRef) { + array.optimized_state().mark_optimized(); +} + /// Extension trait for optimizing array trees using reduce/reduce_parent rules. pub trait ArrayOptimizer { /// Optimize the root array node by running reduce and reduce_parent rules to fixpoint. @@ -59,10 +131,18 @@ pub trait ArrayOptimizer { impl ArrayOptimizer for ArrayRef { fn optimize(&self) -> VortexResult { + if self.optimized_state().is_optimized() { + return Ok(self.clone()); + } + Ok(optimize_owned(self.clone(), None)?.0) } fn optimize_ctx(&self, session: &VortexSession) -> VortexResult { + if self.optimized_state().is_optimized() { + return Ok(self.clone()); + } + Ok(optimize_owned(self.clone(), Some(session))?.0) } @@ -173,6 +253,10 @@ fn try_optimize_recursive( current_array: ArrayRef, session: &VortexSession, ) -> VortexResult<(ArrayRef, bool)> { + if current_array.optimized_state().is_optimized() { + return Ok((current_array, false)); + } + trace_op!(record_optimize_recursive_start(¤t_array)); let (mut current_array, mut any_optimizations) = optimize_owned(current_array, Some(session))?; @@ -205,5 +289,64 @@ fn try_optimize_recursive( any_optimizations = true; } + // Every child is marked now, so the mark on this node covers its whole subtree. + current_array.optimized_state().mark_optimized(); Ok((current_array, any_optimizations)) } + +#[cfg(test)] +mod tests { + use std::sync::LazyLock; + + use vortex_buffer::buffer; + use vortex_error::VortexResult; + use vortex_mask::Mask; + use vortex_session::VortexSession; + + use crate::ArrayRef; + use crate::IntoArray; + use crate::arrays::FilterArray; + use crate::arrays::Primitive; + use crate::arrays::SliceArray; + use crate::optimizer::ArrayOptimizer; + + static SESSION: LazyLock = LazyLock::new(VortexSession::empty); + + #[test] + fn optimize_recursive_marks_result_and_skips_it_after() -> VortexResult<()> { + let sliced = SliceArray::try_new(buffer![1i32, 2, 3, 4].into_array(), 1..3)?.into_array(); + assert!(!sliced.optimized_state().is_optimized()); + + let optimized = sliced.optimize_recursive(&SESSION)?; + assert!(optimized.is::()); + assert!(optimized.optimized_state().is_optimized()); + assert!(ArrayRef::ptr_eq( + &optimized.optimize_recursive(&SESSION)?, + &optimized + )); + assert!(ArrayRef::ptr_eq( + &optimized.optimize_ctx(&SESSION)?, + &optimized + )); + + // A new array built over an optimized one starts unoptimized. + let resliced = SliceArray::try_new(optimized, 0..1)?.into_array(); + assert!(!resliced.optimized_state().is_optimized()); + Ok(()) + } + + #[test] + fn optimize_recursive_marks_every_descendant() -> VortexResult<()> { + let sliced = SliceArray::try_new(buffer![1i32, 2, 3, 4].into_array(), 1..4)?.into_array(); + let filtered = + FilterArray::try_new(sliced, Mask::from_iter([true, false, true]))?.into_array(); + + let optimized = filtered.optimize_recursive(&SESSION)?; + assert!( + optimized + .depth_first_traversal() + .all(|node| node.optimized_state().is_optimized()) + ); + Ok(()) + } +} diff --git a/vortex-array/src/scalar/constructor.rs b/vortex-array/src/scalar/constructor.rs index 81f72054696..1e7d84ed40b 100644 --- a/vortex-array/src/scalar/constructor.rs +++ b/vortex-array/src/scalar/constructor.rs @@ -251,12 +251,22 @@ impl Scalar { /// /// # Panics /// - /// Panics if the storage dtype of `ext_dtype` does not match `value`'s dtype. + /// Panics if [`Self::try_extension_ref`] rejects the storage scalar. pub fn extension_ref(ext_dtype: ExtDTypeRef, storage_scalar: Scalar) -> Self { - assert_eq!(ext_dtype.storage_dtype(), storage_scalar.dtype()); + Self::try_extension_ref(ext_dtype, storage_scalar) + .vortex_expect("unable to construct an extension `Scalar`") + } + + /// Creates an extension scalar after checking its storage dtype and value. + /// + /// # Errors + /// + /// Returns an error if the storage dtype differs from the extension's storage dtype, or if + /// the extension rejects the storage value. A null storage scalar requires a nullable dtype. + pub fn try_extension_ref(ext_dtype: ExtDTypeRef, storage_scalar: Scalar) -> VortexResult { + vortex_ensure_eq!(ext_dtype.storage_dtype(), storage_scalar.dtype()); Self::try_new(DType::Extension(ext_dtype), storage_scalar.into_value()) - .vortex_expect("unable to construct an extension `Scalar`") } /// Creates a union scalar from a type ID and child scalar. diff --git a/vortex-array/src/scalar/scalar_impl.rs b/vortex-array/src/scalar/scalar_impl.rs index 8f3e58bd0e8..0db903b3599 100644 --- a/vortex-array/src/scalar/scalar_impl.rs +++ b/vortex-array/src/scalar/scalar_impl.rs @@ -7,15 +7,17 @@ use std::cmp::Ordering; use std::hash::Hash; use std::hash::Hasher; -use vortex_error::VortexError; use vortex_error::VortexResult; use vortex_error::vortex_ensure_eq; +use vortex_error::vortex_err; use vortex_error::vortex_panic; use crate::dtype::DType; use crate::dtype::NativeDType; use crate::dtype::PType; use crate::dtype::StructFields; +use crate::dtype::half::f16; +use crate::scalar::PValue; use crate::scalar::Scalar; use crate::scalar::ScalarValue; @@ -66,25 +68,39 @@ impl Scalar { /// Attempts to create a new [`Scalar`] with the given [`DType`] and potentially null /// [`ScalarValue`]. /// + /// Legacy `U64` bit representations of `F16` are converted to `F16` during construction. + /// Nested and extension values must already match their storage dtypes. + /// /// # Errors /// /// Returns an error if the given [`DType`] and [`ScalarValue`] are incompatible. #[inline] pub fn try_new(dtype: DType, value: Option) -> VortexResult { - if !Self::is_compatible(&dtype, value.as_ref()) { - return Err(Self::try_new_failed(dtype, value)); + if Self::is_compatible(&dtype, value.as_ref()) { + return Ok(Self { dtype, value }); } - Ok(Self { dtype, value }) + Self::try_new_fallback(dtype, value) } - /// The error path of [`Self::try_new`]. + /// Converts legacy `F16` values or reports why the value is incompatible. /// - /// It takes ownership of the parts so that their drop code is also out of line. + /// It owns the parts so their drop code stays out of the canonical construction path. #[cold] #[inline(never)] - fn try_new_failed(dtype: DType, value: Option) -> VortexError { - Self::incompatible_error(&dtype, value.as_ref()) + fn try_new_fallback(dtype: DType, value: Option) -> VortexResult { + let value = match (&dtype, value) { + (DType::Primitive(PType::F16, _), Some(ScalarValue::Primitive(PValue::U64(bits)))) => { + let bits = u16::try_from(bits).map_err(|_| { + vortex_err!("f16 bit representation must fit in 16 bits, got {bits}") + })?; + + Some(ScalarValue::Primitive(PValue::F16(f16::from_bits(bits)))) + } + (_, value) => return Err(Self::incompatible_error(&dtype, value.as_ref())), + }; + + Ok(Self { dtype, value }) } /// Creates a new [`Scalar`] with the given [`DType`] and potentially null [`ScalarValue`] @@ -154,19 +170,21 @@ impl Scalar { /// - `Struct`: A struct where each field has a zero value, which is determined by the field /// [`DType`] /// - `Union`: A non-null union selecting the first variant with a non-null child zero value - /// - `Extension`: The zero value of the storage [`DType`] + /// - `Extension`: The zero value of the storage [`DType`], if the extension accepts it. + /// /// # Panics /// /// Panics if the dtype has no non-null zero value, such as `Null`, or if a nested dtype needed - /// to construct the zero value has no non-null zero value. + /// to construct the zero value has no non-null zero value. An extension dtype has no zero + /// value if it rejects the zero value of its storage dtype. /// /// Unlike [`Scalar::default_value`], this never uses either an outer or inner null for a union: /// even a nullable union's zero value is non-null and contains a non-null selected child. pub fn zero_value(dtype: &DType) -> Self { let value = ScalarValue::zero_value(dtype); - // SAFETY: `zero_value` creates a valid `ScalarValue` for the `DType`. - unsafe { Self::new_unchecked(dtype.clone(), Some(value)) } + Self::try_new(dtype.clone(), Some(value)) + .unwrap_or_else(|error| vortex_panic!("{dtype} has no non-null zero value: {error}")) } // Other methods. diff --git a/vortex-array/src/scalar/tests/casting.rs b/vortex-array/src/scalar/tests/casting.rs index 4b27b1ead6d..2357594d0db 100644 --- a/vortex-array/src/scalar/tests/casting.rs +++ b/vortex-array/src/scalar/tests/casting.rs @@ -8,9 +8,9 @@ mod tests { use std::f32; use std::sync::Arc; + use rstest::rstest; use vortex_error::VortexExpect; use vortex_error::VortexResult; - use vortex_error::vortex_bail; use crate::dtype::DType; use crate::dtype::FieldDType; @@ -23,7 +23,6 @@ mod tests { use crate::dtype::extension::ExtVTable; use crate::dtype::half::f16; use crate::scalar::PValue; - use crate::scalar::PrimitiveScalar; use crate::scalar::Scalar; use crate::scalar::ScalarValue; @@ -150,7 +149,7 @@ mod tests { } #[test] - fn test_struct_field_coercion() { + fn test_struct_field_values() { let f16_value = f16::from_f32(0.42); let f32_value = f32::consts::PI; @@ -174,9 +173,7 @@ mod tests { let field_values = vec![ Some(ScalarValue::Primitive(PValue::U32(42))), - Some(ScalarValue::Primitive(PValue::U64( - f16_value.to_bits() as u64 - ))), + Some(ScalarValue::Primitive(PValue::F16(f16_value))), Some(ScalarValue::Primitive(PValue::F32(f32_value))), ]; @@ -190,7 +187,6 @@ mod tests { // Check first field (no coercion needed) assert_eq!(fields[0].as_primitive().pvalue().unwrap(), PValue::U32(42)); - // Check second field (f16 coerced from u64) assert_eq!( fields[1].as_primitive().pvalue().unwrap(), PValue::F16(f16_value) @@ -219,7 +215,7 @@ mod tests { } #[test] - fn test_list_element_coercion() { + fn test_list_element_values() { let f16_value1 = f16::from_f32(1.0); let f16_value2 = f16::from_f32(2.0); @@ -229,12 +225,8 @@ mod tests { ); let elements = vec![ - Some(ScalarValue::Primitive(PValue::U64( - f16_value1.to_bits() as u64 - ))), - Some(ScalarValue::Primitive(PValue::U64( - f16_value2.to_bits() as u64 - ))), + Some(ScalarValue::Primitive(PValue::F16(f16_value1))), + Some(ScalarValue::Primitive(PValue::F16(f16_value2))), ]; let scalar = Scalar::new(list_dtype, Some(ScalarValue::Tuple(elements))); @@ -250,69 +242,68 @@ mod tests { } } + #[rstest] + #[case::zero(0x0000)] + #[case::negative_zero(0x8000)] + #[case::one(0x3c00)] + #[case::nan(0x7e00)] + fn test_f16_construction_normalizes_legacy_bits(#[case] bits: u16) -> VortexResult<()> { + let dtype = DType::Primitive(PType::F16, Nullability::NonNullable); + let value = ScalarValue::Primitive(PValue::U64(u64::from(bits))); + let expected = ScalarValue::Primitive(PValue::F16(f16::from_bits(bits))); + let scalar = Scalar::try_new(dtype.clone(), Some(value.clone()))?; + + assert_eq!(scalar.value(), Some(&expected)); + assert!(Scalar::validate(&dtype, Some(&value)).is_err()); + + Ok(()) + } + #[test] - fn test_coercion_with_overflow_protection() { - // Legacy f16 storage accepts U64 values, but reading the bits must reject overflow. - let scalar = Scalar::new( + fn test_f16_construction_rejects_bit_overflow() { + let error = Scalar::try_new( DType::Primitive(PType::F16, Nullability::NonNullable), Some(ScalarValue::Primitive(PValue::U64(u64::MAX))), - ); + ) + .unwrap_err(); - let error = PrimitiveScalar::try_new(scalar.dtype(), scalar.value()).unwrap_err(); assert!( error .to_string() - .contains("Cannot coerce U64 value to f16: value out of range") + .contains("f16 bit representation must fit in 16 bits") ); } #[test] - fn test_extension_dtype_coercion() { - // Create an extension type with f16 storage - #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] - struct F16Ext; - impl ExtVTable for F16Ext { - type Metadata = usize; - type NativeValue<'a> = &'a str; - - #[expect(clippy::disallowed_methods, reason = "test-only id")] - fn id(&self) -> ExtId { - ExtId::new("f16_ext") - } - - fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { - vortex_bail!("not implemented") - } - - fn deserialize_metadata(&self, _data: &[u8]) -> VortexResult { - vortex_bail!("not implemented") - } - - fn validate_dtype(_ext_dtype: &ExtDType) -> VortexResult<()> { - Ok(()) - } - - fn unpack_native<'a>( - _ext_dtype: &'a ExtDType, - _storage_value: &'a ScalarValue, - ) -> VortexResult> { - Ok("") - } - } + fn test_nested_f16_requires_canonical_values() { + let dtype = DType::list( + DType::Primitive(PType::F16, Nullability::NonNullable), + Nullability::NonNullable, + ); + let value = ScalarValue::Tuple(vec![Some(ScalarValue::Primitive(PValue::U64(0x3c00)))]); + + assert!(Scalar::try_new(dtype, Some(value)).is_err()); + } + #[test] + fn test_extension_dtype_requires_canonical_storage() -> VortexResult<()> { let storage_dtype = DType::Primitive(PType::F16, Nullability::NonNullable); - let ext_dtype = ExtDType::::try_new(0, storage_dtype).unwrap(); + let ext_dtype = ExtDType::::try_new(0, storage_dtype)?; - // Test f16 value stored as u64 gets coerced through extension type let f16_value = f16::from_f32(0.42); - let u64_bits = f16_value.to_bits() as u64; - - let scalar = Scalar::new( - DType::Extension(ext_dtype.erased()), - Some(ScalarValue::Primitive(PValue::U64(u64_bits))), + let dtype = DType::Extension(ext_dtype.erased()); + assert!( + Scalar::try_new( + dtype.clone(), + Some(ScalarValue::Primitive(PValue::U64(u64::from( + f16_value.to_bits() + )))), + ) + .is_err() ); - // Verify the value was coerced to f16 + let scalar = Scalar::try_new(dtype, Some(ScalarValue::Primitive(PValue::F16(f16_value))))?; + assert_eq!( scalar .as_extension() @@ -322,42 +313,12 @@ mod tests { .unwrap(), PValue::F16(f16_value) ); + + Ok(()) } #[test] - fn test_extension_dtype_nested_struct_coercion() { - // Create an extension type with struct storage that contains f16 field - #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] - struct StructExt; - impl ExtVTable for StructExt { - type Metadata = usize; - type NativeValue<'a> = &'a str; - - #[expect(clippy::disallowed_methods, reason = "test-only id")] - fn id(&self) -> ExtId { - ExtId::new("struct_ext") - } - - fn serialize_metadata(&self, _metadata: &Self::Metadata) -> VortexResult> { - vortex_bail!("not implemented") - } - - fn deserialize_metadata(&self, _data: &[u8]) -> VortexResult { - vortex_bail!("not implemented") - } - - fn validate_dtype(_ext_dtype: &ExtDType) -> VortexResult<()> { - Ok(()) - } - - fn unpack_native<'a>( - _ext_dtype: &'a ExtDType, - _storage_value: &'a ScalarValue, - ) -> VortexResult> { - Ok("") - } - } - + fn test_extension_dtype_nested_struct_values() -> VortexResult<()> { let struct_dtype = DType::Struct( StructFields::from_iter([ ( @@ -371,38 +332,33 @@ mod tests { ]), Nullability::NonNullable, ); - let ext_dtype = ExtDType::::try_new(0, struct_dtype).unwrap(); + let ext_dtype = ExtDType::::try_new(0, struct_dtype)?; - // Create struct value with f16 stored as u64 let f16_value = f16::from_f32(1.5); let field_values = vec![ Some(ScalarValue::Primitive(PValue::U32(123))), - Some(ScalarValue::Primitive(PValue::U64( - f16_value.to_bits() as u64 - ))), + Some(ScalarValue::Primitive(PValue::F16(f16_value))), ]; - let scalar = Scalar::new( + let scalar = Scalar::try_new( DType::Extension(ext_dtype.erased()), Some(ScalarValue::Tuple(field_values)), - ); + )?; - // Verify the struct field was coerced - let list_elems = scalar + let fields = scalar .as_extension() .to_storage_scalar() .as_struct() .fields_iter() .vortex_expect("non null") .collect::>(); + assert_eq!(fields[0].as_primitive().pvalue().unwrap(), PValue::U32(123)); assert_eq!( - list_elems[0].as_primitive().pvalue().unwrap(), - PValue::U32(123) - ); - assert_eq!( - list_elems[1].as_primitive().pvalue().unwrap(), + fields[1].as_primitive().pvalue().unwrap(), PValue::F16(f16_value) ); + + Ok(()) } #[test] diff --git a/vortex-array/src/scalar/typed_view/primitive/pvalue.rs b/vortex-array/src/scalar/typed_view/primitive/pvalue.rs index bea7193e2d3..09d42b6cfe1 100644 --- a/vortex-array/src/scalar/typed_view/primitive/pvalue.rs +++ b/vortex-array/src/scalar/typed_view/primitive/pvalue.rs @@ -381,6 +381,23 @@ impl PValue { } } + /// Widens an integer value to `i128`, which holds every integer `PValue` exactly. + /// + /// Returns `None` for floating-point values. + pub fn as_i128(self) -> Option { + match self { + PValue::U8(v) => Some(v.into()), + PValue::U16(v) => Some(v.into()), + PValue::U32(v) => Some(v.into()), + PValue::U64(v) => Some(v.into()), + PValue::I8(v) => Some(v.into()), + PValue::I16(v) => Some(v.into()), + PValue::I32(v) => Some(v.into()), + PValue::I64(v) => Some(v.into()), + PValue::F16(_) | PValue::F32(_) | PValue::F64(_) => None, + } + } + as_primitive!(i8, I8); as_primitive!(i16, I16); as_primitive!(i32, I32); diff --git a/vortex-array/src/scalar/typed_view/primitive/tests.rs b/vortex-array/src/scalar/typed_view/primitive/tests.rs index 08b80f021f8..957d32af846 100644 --- a/vortex-array/src/scalar/typed_view/primitive/tests.rs +++ b/vortex-array/src/scalar/typed_view/primitive/tests.rs @@ -782,3 +782,15 @@ fn test_f16_nans_equal() { let nan3 = f16::from_f16(nan1).unwrap(); assert_eq!(nan1.to_bits(), nan3.to_bits(),); } + +#[rstest] +#[case(PValue::U8(u8::MAX), Some(255))] +#[case(PValue::U64(u64::MAX), Some(i128::from(u64::MAX)))] +#[case(PValue::I8(i8::MIN), Some(-128))] +#[case(PValue::I64(i64::MIN), Some(i128::from(i64::MIN)))] +#[case(PValue::F16(f16::ONE), None)] +#[case(PValue::F32(1.0), None)] +#[case(PValue::F64(1.0), None)] +fn test_as_i128(#[case] value: PValue, #[case] expected: Option) { + assert_eq!(value.as_i128(), expected); +} diff --git a/vortex-array/src/scalar/validate.rs b/vortex-array/src/scalar/validate.rs index 274adc4ca66..1bc07c7fba8 100644 --- a/vortex-array/src/scalar/validate.rs +++ b/vortex-array/src/scalar/validate.rs @@ -1,6 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Scalar validation keeps logical values compatible with their storage representations. +//! +//! The fast check and detailed error path accept the same values. Extension values are checked +//! against the storage dtype before the extension's own validator runs. + use vortex_error::VortexError; use vortex_error::VortexExpect; use vortex_error::VortexResult; @@ -10,8 +15,8 @@ use vortex_error::vortex_ensure_eq; use vortex_error::vortex_err; use crate::dtype::DType; -use crate::dtype::PType; -use crate::scalar::PValue; +use crate::dtype::MapDType; +use crate::dtype::UnionVariants; use crate::scalar::Scalar; use crate::scalar::ScalarValue; @@ -44,9 +49,7 @@ impl Scalar { | (DType::Utf8(_), ScalarValue::Utf8(_)) | (DType::Binary(_), ScalarValue::Binary(_)) => true, (DType::Primitive(ptype, _), ScalarValue::Primitive(pvalue)) => { - // See `validate_detailed` for the `f16` backwards compatibility case. pvalue.ptype() == *ptype - || (matches!(ptype, PType::F16) && matches!(pvalue, PValue::U64(_))) } _ => Self::is_compatible_nested(dtype, value), } @@ -97,7 +100,10 @@ impl Scalar { Self::is_compatible(inner.dtype(), inner.value()) && (!inner.is_null() || matches!(inner.dtype(), DType::Null)) } - (DType::Extension(ext_dtype), value) => ext_dtype.validate_storage_value(value).is_ok(), + (DType::Extension(ext_dtype), value) => { + Self::is_compatible(ext_dtype.storage_dtype(), Some(value)) + && ext_dtype.validate_storage_value(value).is_ok() + } _ => false, } } @@ -141,29 +147,12 @@ impl Scalar { } DType::Primitive(ptype, _) => { let ScalarValue::Primitive(pvalue) = value else { - vortex_bail!("primitive dtype {ptype} expected Primitive value, got {value}",); + vortex_bail!("primitive dtype {ptype} expected Primitive value, got {value}"); }; - // Note that this is a backwards compatibility check for poor design in the - // previous implementation. `f16` `ScalarValue`s used to be serialized as - // `pb::ScalarValue::Uint64Value(v.to_bits() as u64)`, so we need to ensure - // that we can still represent them as such. - let f16_backcompat_still_works = - matches!(ptype, &PType::F16) && matches!(pvalue, PValue::U64(_)); - vortex_ensure!( - f16_backcompat_still_works || pvalue.ptype() == *ptype, - "primitive dtype {ptype} is not compatible with value {pvalue}", - ); - } - DType::Decimal(dec_dtype, _) => { - let ScalarValue::Decimal(dvalue) = value else { - vortex_bail!("decimal dtype expected Decimal value, got {value}"); - }; - - vortex_ensure!( - dvalue.fits_in_precision(*dec_dtype), - "decimal value {dvalue} does not fit in precision of {dec_dtype}", + pvalue.ptype() == *ptype, + "primitive dtype {ptype} requires a matching value, got {pvalue}", ); } DType::Utf8(_) => { @@ -178,6 +167,16 @@ impl Scalar { "binary dtype expected Binary value, got {value}", ); } + DType::Decimal(dec_dtype, _) => { + let ScalarValue::Decimal(dvalue) = value else { + vortex_bail!("decimal dtype expected Decimal value, got {value}"); + }; + + vortex_ensure!( + dvalue.fits_in_precision(*dec_dtype), + "decimal value {dvalue} does not fit in precision of {dec_dtype}", + ); + } DType::List(elem_dtype, _) => { let ScalarValue::Tuple(elements) = value else { vortex_bail!("list dtype expected Tuple value, got {value}"); @@ -206,35 +205,7 @@ impl Scalar { )?; } } - DType::Map(map, _) => { - let ScalarValue::Tuple(entries) = value else { - vortex_bail!("map dtype expected Tuple value, got {value}"); - }; - let key_dtype = map.key_dtype(); - let value_dtype = map.value_dtype(); - - for (index, entry) in entries.iter().enumerate() { - let entry = entry.as_ref().ok_or_else(|| { - vortex_error::vortex_err!("map entry at index {index} cannot be null") - })?; - let ScalarValue::Tuple(values) = entry else { - vortex_bail!( - "map entry at index {index} expected Tuple value, got {entry}" - ); - }; - vortex_ensure_eq!( - values.len(), - 2, - "map entry at index {index} has the wrong number of values", - ); - - Self::validate_detailed(&key_dtype, values[0].as_ref()) - .map_err(|error| error.with_context(format!("map key at entry {index}")))?; - Self::validate_detailed(&value_dtype, values[1].as_ref()).map_err(|error| { - error.with_context(format!("map value at entry {index}")) - })?; - } - } + DType::Map(map, _) => Self::validate_map(map, value)?, DType::Struct(fields, _) => { let ScalarValue::Tuple(values) = value else { vortex_bail!("struct dtype expected Tuple value, got {value}"); @@ -252,31 +223,7 @@ impl Scalar { Self::validate_detailed(field, field_value.as_ref())?; } } - DType::Union(variants, _) => { - let ScalarValue::Union(union_value) = value else { - vortex_bail!("union dtype expected Union value, got {value}"); - }; - - let type_id = union_value.type_id(); - let Some(child_index) = variants.tag_to_child_index(type_id) else { - vortex_bail!( - "union value has unknown type ID {type_id}; expected one of {:?}", - variants.type_ids() - ); - }; - - let child_dtype = variants - .variant_by_index(child_index) - .vortex_expect("resolved union child index must be valid"); - - Self::validate_detailed(&child_dtype, union_value.child_value()).map_err( - |error| { - error.with_context(format!( - "union value for type ID {type_id} is invalid for dtype {child_dtype}" - )) - }, - )?; - } + DType::Union(variants, _) => Self::validate_union(variants, value)?, DType::Variant(_) => { let ScalarValue::Variant(inner) = value else { vortex_bail!("variant dtype expected Variant value, got {value}"); @@ -289,11 +236,70 @@ impl Scalar { inner.dtype(), ); } - DType::Extension(ext_dtype) => ext_dtype.validate_storage_value(value)?, + DType::Extension(ext_dtype) => { + Self::validate_detailed(ext_dtype.storage_dtype(), Some(value))?; + + ext_dtype.validate_storage_value(value)?; + } + } + + Ok(()) + } + + /// Validates map entries and adds their positions to storage validation errors. + fn validate_map(map: &MapDType, value: &ScalarValue) -> VortexResult<()> { + let ScalarValue::Tuple(entries) = value else { + vortex_bail!("map dtype expected Tuple value, got {value}"); + }; + let key_dtype = map.key_dtype(); + let value_dtype = map.value_dtype(); + + for (index, entry) in entries.iter().enumerate() { + let entry = entry + .as_ref() + .ok_or_else(|| vortex_err!("map entry at index {index} cannot be null"))?; + let ScalarValue::Tuple(values) = entry else { + vortex_bail!("map entry at index {index} expected Tuple value, got {entry}"); + }; + vortex_ensure_eq!( + values.len(), + 2, + "map entry at index {index} has the wrong number of values", + ); + + Self::validate_detailed(&key_dtype, values[0].as_ref()) + .map_err(|error| error.with_context(format!("map key at entry {index}")))?; + Self::validate_detailed(&value_dtype, values[1].as_ref()) + .map_err(|error| error.with_context(format!("map value at entry {index}")))?; } Ok(()) } + + /// Validates the selected union child and adds its type ID to storage validation errors. + fn validate_union(variants: &UnionVariants, value: &ScalarValue) -> VortexResult<()> { + let ScalarValue::Union(union_value) = value else { + vortex_bail!("union dtype expected Union value, got {value}"); + }; + + let type_id = union_value.type_id(); + let Some(child_index) = variants.tag_to_child_index(type_id) else { + vortex_bail!( + "union value has unknown type ID {type_id}; expected one of {:?}", + variants.type_ids() + ); + }; + + let child_dtype = variants + .variant_by_index(child_index) + .vortex_expect("resolved union child index must be valid"); + + Self::validate_detailed(&child_dtype, union_value.child_value()).map_err(|error| { + error.with_context(format!( + "union value for type ID {type_id} is invalid for dtype {child_dtype}" + )) + }) + } } #[cfg(test)] @@ -310,6 +316,8 @@ mod tests { use crate::dtype::PType; use crate::dtype::StructFields; use crate::dtype::UnionVariants; + use crate::extension::datetime::Date; + use crate::extension::datetime::TimeUnit; use crate::scalar::DecimalValue; use crate::scalar::PValue; use crate::scalar::Scalar; @@ -342,6 +350,7 @@ mod tests { let list_dtype = DType::List(Arc::new(i32_dtype.clone()), NonNullable); let fsl_dtype = DType::FixedSizeList(Arc::new(i32_dtype.clone()), 2, NonNullable); let decimal_dtype = DType::Decimal(DecimalDType::new(3, 0), NonNullable); + let extension_dtype = DType::Extension(Date::new(TimeUnit::Days, NonNullable).erased()); let tuple = |values: Vec>| Some(ScalarValue::Tuple(values)); let cases = [ @@ -364,7 +373,13 @@ mod tests { ( DType::Primitive(PType::F16, NonNullable), Some(ScalarValue::Primitive(PValue::U64(1))), - true, + false, + ), + (extension_dtype.clone(), i32_value(), true), + ( + extension_dtype, + Some(ScalarValue::Primitive(PValue::F64(1.0))), + false, ), ( decimal_dtype.clone(), diff --git a/vortex-array/src/scalar_fn/erased.rs b/vortex-array/src/scalar_fn/erased.rs index ae951376778..b2218b8ec3a 100644 --- a/vortex-array/src/scalar_fn/erased.rs +++ b/vortex-array/src/scalar_fn/erased.rs @@ -25,6 +25,7 @@ use crate::scalar_fn::ArrayReduceNode; use crate::scalar_fn::ExecutionArgs; use crate::scalar_fn::ExpressionReduceNode; use crate::scalar_fn::ReduceNodeValidity; +use crate::scalar_fn::ScalarFnExecutionResult; use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::ScalarFnVTable; use crate::scalar_fn::options::ScalarFnOptions; @@ -153,6 +154,17 @@ impl ScalarFnRef { self.0.execute(args, ctx) } + /// Perform a single step of execution given the input arguments. + /// + /// See [`ScalarFnVTable::execute_step`]. + pub fn execute_step( + &self, + args: &dyn ExecutionArgs, + ctx: &mut ExecutionCtx, + ) -> VortexResult { + self.0.execute_step(args, ctx) + } + /// Perform abstract reduction on this scalar function node in an expression tree. pub fn reduce_expression<'a>( &self, diff --git a/vortex-array/src/scalar_fn/fns/between/mod.rs b/vortex-array/src/scalar_fn/fns/between/mod.rs index 0d32d5e8b86..360f609a935 100644 --- a/vortex-array/src/scalar_fn/fns/between/mod.rs +++ b/vortex-array/src/scalar_fn/fns/between/mod.rs @@ -24,6 +24,7 @@ use crate::arrays::ScalarFnArray; use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::dtype::DType::Bool; +use crate::dtype::NativePType; use crate::expr::display::ExprDisplay; use crate::proto::expr as pb; use crate::scalar::Scalar; @@ -77,6 +78,14 @@ impl StrictComparison { pub const fn is_strict(&self) -> bool { matches!(self, StrictComparison::Strict) } + + /// Returns the total-order bound check that this comparison applies to two native values. + pub fn to_predicate(self) -> fn(T, T) -> bool { + match self { + StrictComparison::Strict => T::is_lt, + StrictComparison::NonStrict => T::is_le, + } + } } /// Short-circuits between for the inputs that need no encoding-specific work. diff --git a/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs b/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs index 6593af28c6e..b20fdafbef7 100644 --- a/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/compare/mod.rs @@ -4,17 +4,22 @@ //! Native comparison kernels. //! //! [`execute_compare`] dispatches on the logical [`DType`] of its operands and evaluates every -//! comparison directly over Vortex canonical arrays — bit buffers for booleans, lane kernels from +//! comparison directly over Vortex canonical arrays: bit buffers for booleans, lane kernels from //! `vortex-compute` for primitives and decimals, binary views for strings/bytes, and a row-wise //! comparator for nested types. There is no Arrow fallback. //! //! Floating point values compare with Vortex's total ordering (`NaN` is the largest value, //! `-0.0 < +0.0`, and equality is bitwise), matching [`Scalar`] comparison semantics. +//! +//! Binary scalar functions can execute through encoding-specific kernels before reaching the native +//! dispatcher. [`CompareExecuteAdaptor`] connects these execution paths to [`CompareKernel`], which +//! lets an encoding compare values without first converting them to canonical arrays. use std::cmp::Ordering; use vortex_error::VortexResult; use vortex_error::vortex_bail; +use vortex_error::vortex_ensure; use vortex_error::vortex_err; use crate::ArrayRef; @@ -42,11 +47,11 @@ use crate::validity::Validity; mod boolean; mod bytes; mod decimal; + mod nested; pub(crate) use nested::build_comparator as build_row_comparator; + mod primitive; -#[cfg(test)] -mod tests; /// Trait for encoding-specific comparison kernels that operate in encoded space. /// @@ -54,6 +59,10 @@ mod tests; /// without first decompressing. The adaptor normalizes operand order so `array` is always /// the left-hand side, swapping the operator when necessary. pub trait CompareKernel: VTable { + /// Compares `lhs` with `rhs`, or returns `None` to use the default comparison path. + /// + /// Operand dtypes must match, ignoring nullability. [`CompareExecuteAdaptor`] checks this before + /// dispatch; direct callers must satisfy the same requirement. fn compare( lhs: ArrayView<'_, Self>, rhs: &ArrayRef, @@ -68,7 +77,10 @@ pub trait CompareKernel: VTable { /// this adaptor extracts the comparison operator and other operand, normalizes operand order /// (swapping the operator if the encoded array is on the RHS), and delegates to the kernel. #[derive(Default, Debug)] -pub struct CompareExecuteAdaptor(pub V); +pub struct CompareExecuteAdaptor( + /// The encoding whose comparison kernel handles the normalized operands. + pub V, +); impl ExecuteParentKernel for CompareExecuteAdaptor where @@ -101,6 +113,8 @@ where _ => return Ok(None), }; + validate_comparison_dtypes(array.dtype(), other.dtype())?; + let len = array.len(); let nullable = array.dtype().is_nullable() || other.dtype().is_nullable(); @@ -133,6 +147,8 @@ pub(crate) fn execute_compare( op: CompareOperator, ctx: &mut ExecutionCtx, ) -> VortexResult { + validate_comparison_dtypes(lhs.dtype(), rhs.dtype())?; + let nullable = lhs.dtype().is_nullable() || rhs.dtype().is_nullable(); if lhs.len() != rhs.len() { @@ -165,7 +181,9 @@ pub(crate) fn execute_compare( compare_arrays(lhs, rhs, op, ctx) } -/// Dispatch a comparison to the native kernel for the operands' logical dtype. +/// Dispatches operands with matching logical dtypes to their native comparison kernel. +/// +/// Extension operands are unwrapped before dispatch to the storage kernel. fn compare_arrays( lhs: &ArrayRef, rhs: &ArrayRef, @@ -174,32 +192,14 @@ fn compare_arrays( ) -> VortexResult { let nullability = Nullability::from(lhs.dtype().is_nullable() || rhs.dtype().is_nullable()); - // Extension arrays compare through their storage. When both sides are extensions they must - // agree on the full extension dtype (a timestamp in milliseconds must not compare its raw - // storage against one in seconds); a lone extension side may compare against its raw storage. - if lhs.dtype().is_extension() || rhs.dtype().is_extension() { - if lhs.dtype().is_extension() - && rhs.dtype().is_extension() - && !lhs.dtype().eq_ignore_nullability(rhs.dtype()) - { - vortex_bail!( - "Cannot compare extension dtypes {} and {}", - lhs.dtype(), - rhs.dtype() - ); - } + if lhs.dtype().is_extension() { let lhs = extension_storage(lhs, ctx)?; let rhs = extension_storage(rhs, ctx)?; + return compare_arrays(&lhs, &rhs, op, ctx); } - if !lhs.dtype().eq_ignore_nullability(rhs.dtype()) { - vortex_bail!( - "Cannot compare different DTypes {} and {}", - lhs.dtype(), - rhs.dtype() - ); - } + validate_comparison_dtypes(lhs.dtype(), rhs.dtype())?; match lhs.dtype() { // Every value of the null dtype is null, so every comparison result is null. @@ -221,12 +221,11 @@ fn compare_arrays( } } -/// Replace an extension array (or extension constant) with its storage. Non-extension arrays are -/// returned unchanged. +/// Returns the storage of an extension array or constant. +/// +/// Extension constants retain their constant encoding. Other extension arrays execute to their +/// canonical representation so that the caller can access their storage. fn extension_storage(array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult { - if !array.dtype().is_extension() { - return Ok(array.clone()); - } if let Some(constant) = array.as_opt::() { return Ok(ConstantArray::new( constant.scalar().as_extension().to_storage_scalar(), @@ -234,27 +233,34 @@ fn extension_storage(array: &ArrayRef, ctx: &mut ExecutionCtx) -> VortexResult(ctx)?; + Ok(ext.storage_array().clone()) } +/// Compares scalars with matching dtypes, ignoring nullability. +/// +/// Returns null if either operand is null, and an error if the operand dtypes differ. pub fn scalar_cmp(lhs: &Scalar, rhs: &Scalar, operator: CompareOperator) -> VortexResult { + validate_comparison_dtypes(lhs.dtype(), rhs.dtype())?; + if lhs.is_null() | rhs.is_null() { return Ok(Scalar::null(DType::Bool(Nullability::Nullable))); } let nullability = lhs.dtype().nullability() | rhs.dtype().nullability(); - // We use `partial_cmp` to ensure we do not lose a type mismatch error. + // Some values, such as variants, have no scalar ordering even when their dtypes match. let ordering = lhs.partial_cmp(rhs).ok_or_else(|| { vortex_err!( - "Cannot compare scalars with incompatible types: {} and {}", + "Scalar comparison requires comparable values, got {} and {}", lhs.dtype(), rhs.dtype() ) })?; - let b = match operator { + let result = match operator { CompareOperator::Eq => ordering.is_eq(), CompareOperator::NotEq => ordering.is_ne(), CompareOperator::Gt => ordering.is_gt(), @@ -263,7 +269,17 @@ pub fn scalar_cmp(lhs: &Scalar, rhs: &Scalar, operator: CompareOperator) -> Vort CompareOperator::Lte => ordering.is_le(), }; - Ok(Scalar::bool(b, nullability)) + Ok(Scalar::bool(result, nullability)) +} + +/// Checks the shared dtype requirement before comparison fast paths or encoding kernels run. +pub(super) fn validate_comparison_dtypes(lhs: &DType, rhs: &DType) -> VortexResult<()> { + vortex_ensure!( + lhs.eq_ignore_nullability(rhs), + "Comparison requires equal dtypes ignoring nullability, got {lhs} and {rhs}" + ); + + Ok(()) } /// Returns the predicate `Ordering -> bool` for a comparison operator. @@ -288,3 +304,6 @@ pub(super) fn compare_validity( ) -> VortexResult { Ok(lhs.and(rhs)?.union_nullability(nullability)) } + +#[cfg(test)] +mod tests; diff --git a/vortex-array/src/scalar_fn/fns/binary/compare/tests.rs b/vortex-array/src/scalar_fn/fns/binary/compare/tests.rs index a555466519e..2a1764050cd 100644 --- a/vortex-array/src/scalar_fn/fns/binary/compare/tests.rs +++ b/vortex-array/src/scalar_fn/fns/binary/compare/tests.rs @@ -36,6 +36,7 @@ use crate::dtype::FieldName; use crate::dtype::FieldNames; use crate::dtype::Nullability; use crate::dtype::PType; +use crate::extension::datetime::Time; use crate::extension::datetime::TimeUnit; use crate::extension::datetime::Timestamp; use crate::extension::datetime::TimestampOptions; @@ -46,6 +47,8 @@ use crate::scalar::Scalar; use crate::scalar_fn::fns::binary::scalar_cmp; use crate::scalar_fn::fns::operators::CompareOperator; use crate::scalar_fn::fns::operators::Operator; +use crate::test_harness::ExpectedOutcome; +use crate::test_harness::assert_execution_paths; use crate::validity::Validity; static SESSION: LazyLock = LazyLock::new(VortexSession::empty); @@ -641,26 +644,124 @@ fn extension_timestamp_compare() { assert_arrays_eq!(result, BoolArray::from_iter([false, true, false]), &mut ctx); } -/// Comparing extension arrays with different extension dtypes (e.g. timestamps in different -/// units) must error rather than silently comparing raw storage values. -#[test] -fn extension_mismatched_units_errors() { +#[rstest] +#[case::storage(DType::Primitive(PType::I64, Nullability::Nullable))] +#[case::different_unit(DType::Extension( + Timestamp::new(TimeUnit::Nanoseconds, Nullability::Nullable).erased() +))] +#[case::different_extension(DType::Extension( + Time::new(TimeUnit::Microseconds, Nullability::Nullable).erased() +))] +#[case::different_time_zone(DType::Extension( + Timestamp::new_with_tz(TimeUnit::Milliseconds, Some("UTC".into()), Nullability::Nullable).erased() +))] +fn test_extension_comparison_rejects_mismatched_dtypes_at_binding( + #[case] rhs_dtype: DType, + #[values(false, true)] swapped: bool, +) -> VortexResult<()> { let mut ctx = SESSION.create_execution_ctx(); - let ms = ExtensionArray::new( + let lhs = ExtensionArray::new( Timestamp::new(TimeUnit::Milliseconds, Nullability::NonNullable).erased(), - buffer![1000i64, 2000].into_array(), + buffer![1600i64, 1400].into_array(), ) .into_array(); - let secs = ExtensionArray::new( - Timestamp::new(TimeUnit::Seconds, Nullability::NonNullable).erased(), - buffer![1i64, 3].into_array(), + let scalar = Scalar::try_new(rhs_dtype, Some(1500i64.into()))?; + let rhs = ConstantArray::new(scalar, lhs.len()).into_array(); + let inputs = if swapped { [rhs, lhs] } else { [lhs, rhs] }; + + assert_execution_paths( + &inputs, + |inputs| { + let error = inputs[0] + .binary(inputs[1].clone(), Operator::Lt) + .expect_err("mismatched comparison dtypes must be rejected while binding"); + + Err(error) + }, + ExpectedOutcome::Error, + &mut ctx, + ); + + Ok(()) +} + +#[rstest] +#[case::equal(Operator::Eq, [Some(false), Some(true), Some(false), None])] +#[case::not_equal(Operator::NotEq, [Some(true), Some(false), Some(true), None])] +#[case::less(Operator::Lt, [Some(false), Some(false), Some(true), None])] +#[case::less_equal(Operator::Lte, [Some(false), Some(true), Some(true), None])] +#[case::greater(Operator::Gt, [Some(true), Some(false), Some(false), None])] +#[case::greater_equal(Operator::Gte, [Some(true), Some(true), Some(false), None])] +fn test_extension_comparison_preserves_paths_and_nulls( + #[case] operator: Operator, + #[case] expected: [Option; 4], +) -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let dtype = Timestamp::new(TimeUnit::Milliseconds, Nullability::Nullable).erased(); + let lhs = ExtensionArray::new( + dtype, + PrimitiveArray::from_option_iter([Some(1600i64), Some(1500), Some(1400), None]) + .into_array(), ) .into_array(); + let rhs = ConstantArray::new( + Scalar::extension::( + TimestampOptions { + unit: TimeUnit::Milliseconds, + tz: None, + }, + Scalar::from(1500i64), + ), + lhs.len(), + ) + .into_array(); + + assert_execution_paths( + &[lhs, rhs], + |inputs| inputs[0].binary(inputs[1].clone(), operator), + ExpectedOutcome::Array(BoolArray::from_iter(expected).into_array()), + &mut ctx, + ); - let result = ms - .binary(secs, Operator::Eq) - .and_then(|a| a.execute::(&mut ctx)); - assert!(result.is_err()); + Ok(()) +} + +#[rstest] +#[case::empty(0)] +#[case::null(2)] +fn test_extension_comparison_checks_dtypes_before_fast_paths( + #[case] len: usize, +) -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let dtype = Timestamp::new(TimeUnit::Milliseconds, Nullability::Nullable).erased(); + let lhs = ExtensionArray::new( + dtype, + ConstantArray::new(Scalar::primitive(1000i64, Nullability::Nullable), len).into_array(), + ) + .into_array(); + let rhs = ConstantArray::new( + Scalar::null(DType::Primitive(PType::I64, Nullability::Nullable)), + len, + ) + .into_array(); + + assert!(super::execute_compare(&lhs, &rhs, CompareOperator::Eq, &mut ctx).is_err()); + + Ok(()) +} + +#[test] +fn test_null_scalar_comparison_requires_matching_dtypes() { + let dtype = Timestamp::new(TimeUnit::Milliseconds, Nullability::Nullable).erased(); + + assert!( + scalar_cmp( + &Scalar::null(DType::Extension(dtype)), + &Scalar::from(1000i64), + CompareOperator::Eq + ) + .is_err() + ); } /// Struct fields containing nulls order null-first, matching `Scalar` comparison semantics; diff --git a/vortex-array/src/scalar_fn/fns/binary/mod.rs b/vortex-array/src/scalar_fn/fns/binary/mod.rs index 7898dbdb125..ee50ac15279 100644 --- a/vortex-array/src/scalar_fn/fns/binary/mod.rs +++ b/vortex-array/src/scalar_fn/fns/binary/mod.rs @@ -1,6 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Binary scalar functions and their encoding-specific execution adaptors. +//! +//! [`Binary`] binds an [`Operator`] to two operands. Binding checks the operand types and determines +//! the result dtype. Execution can use encoding-specific kernels or the native kernels for the +//! operator's comparison, boolean, or numeric operation. + use std::fmt::Display; use std::fmt::Formatter; @@ -49,12 +55,16 @@ mod primitive_operand; use crate::scalar::NumericOperator; use crate::scalar::Scalar; +/// A binary scalar function parameterized by an [`Operator`]. #[derive(Clone)] pub struct Binary; impl Binary { /// Creates a lazy binary operation over `lhs` and `rhs`. /// + /// Comparisons require matching logical dtypes, ignoring nullability, even for empty or null + /// operands. Extension dtypes must match, including their metadata; storage dtypes are distinct. + /// /// # Errors /// /// Returns an error if the children have different lengths or incompatible dtypes. @@ -150,12 +160,8 @@ impl ScalarFnVTable for Binary { ); } - if operator.is_comparison() - && !lhs.eq_ignore_nullability(rhs) - && !lhs.is_extension() - && !rhs.is_extension() - { - vortex_bail!("Cannot compare different DTypes {} and {}", lhs, rhs); + if operator.is_comparison() { + validate_comparison_dtypes(lhs, rhs)?; } if matches!(operator, Operator::And | Operator::Or) diff --git a/vortex-array/src/scalar_fn/fns/not/mod.rs b/vortex-array/src/scalar_fn/fns/not/mod.rs index b4c0c1b3bb5..6aa02959218 100644 --- a/vortex-array/src/scalar_fn/fns/not/mod.rs +++ b/vortex-array/src/scalar_fn/fns/not/mod.rs @@ -6,9 +6,11 @@ mod kernel; pub use kernel::*; use vortex_error::VortexResult; use vortex_error::vortex_bail; +use vortex_error::vortex_panic; use vortex_session::VortexSession; use vortex_session::registry::CachedId; +use crate::AnyColumnar; use crate::ArrayRef; use crate::ExecutionCtx; use crate::IntoArray; @@ -17,13 +19,13 @@ use crate::arrays::BoolArray; use crate::arrays::ConstantArray; use crate::arrays::ScalarFnArray; use crate::arrays::bool::BoolArrayExt; -use crate::builtins::ArrayBuiltins; use crate::dtype::DType; use crate::scalar::Scalar; use crate::scalar_fn::Arity; use crate::scalar_fn::ChildName; use crate::scalar_fn::EmptyOptions; use crate::scalar_fn::ExecutionArgs; +use crate::scalar_fn::ScalarFnExecutionResult; use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::ScalarFnVTable; use crate::scalar_fn::ScalarFnVTableExt; @@ -87,28 +89,23 @@ impl ScalarFnVTable for Not { fn execute( &self, - _data: &Self::Options, - args: &dyn ExecutionArgs, - ctx: &mut ExecutionCtx, + _options: &Self::Options, + _args: &dyn ExecutionArgs, + _ctx: &mut ExecutionCtx, ) -> VortexResult { - let child = args.get(0)?; - - // For constant boolean - if let Some(scalar) = child.as_constant() { - let value = match scalar.as_bool().value() { - Some(b) => Scalar::bool(!b, child.dtype().nullability()), - None => Scalar::null(child.dtype().clone()), - }; - return Ok(ConstantArray::new(value, args.row_count()).into_array()); - } + vortex_panic!("Not implements execute_step, so execute is never called") + } - // For boolean array - if let Some(bool) = child.as_opt::() { - return Ok(BoolArray::new(!bool.to_bit_buffer(), bool.validity()?).into_array()); + fn execute_step( + &self, + _data: &Self::Options, + args: &dyn ExecutionArgs, + _ctx: &mut ExecutionCtx, + ) -> VortexResult { + match not_columnar(&args.get(0)?, args.row_count())? { + Some(result) => Ok(ScalarFnExecutionResult::done(result)), + None => Ok(ScalarFnExecutionResult::execute_input::(0)), } - - // Otherwise, execute and try again - child.execute::(ctx)?.not() } fn is_strict(&self, _options: &Self::Options) -> bool { @@ -120,6 +117,25 @@ impl ScalarFnVTable for Not { } } +/// Inverts a constant or canonical boolean `child`, returning `None` for any other encoding. +fn not_columnar(child: &ArrayRef, row_count: usize) -> VortexResult> { + if let Some(scalar) = child.as_constant() { + let value = match scalar.as_bool().value() { + Some(b) => Scalar::bool(!b, child.dtype().nullability()), + None => Scalar::null(child.dtype().clone()), + }; + return Ok(Some(ConstantArray::new(value, row_count).into_array())); + } + + if let Some(bool) = child.as_opt::() { + return Ok(Some( + BoolArray::new(!bool.to_bit_buffer(), bool.validity()?).into_array(), + )); + } + + Ok(None) +} + #[cfg(test)] mod tests { use std::sync::LazyLock; @@ -127,8 +143,10 @@ mod tests { use vortex_error::VortexResult; use vortex_session::VortexSession; + use crate::Canonical; use crate::IntoArray; use crate::VortexSessionExecute; + use crate::arrays::ChunkedArray; use crate::assert_arrays_eq; use crate::dtype::DType; use crate::dtype::Nullability; @@ -138,6 +156,7 @@ mod tests { use crate::expr::root; use crate::expr::test_harness; use crate::scalar_fn::fns::not::BoolArray; + use crate::scalar_fn::fns::not::Not; static SESSION: LazyLock = LazyLock::new(VortexSession::empty); @@ -150,6 +169,27 @@ mod tests { ); } + #[test] + fn executes_non_columnar_input_iteratively() -> VortexResult<()> { + let mut ctx = SESSION.create_execution_ctx(); + let chunks = vec![ + BoolArray::from_iter([Some(true), None]).into_array(), + BoolArray::from_iter([Some(false)]).into_array(), + ]; + let dtype = chunks[0].dtype().clone(); + let chunked = ChunkedArray::try_new(chunks, dtype)?.into_array(); + let nested = Not::try_new(Not::try_new(Not::try_new(chunked)?.into_array())?.into_array())?; + + let result = nested.into_array().execute::(&mut ctx)?; + + assert_arrays_eq!( + result.into_array(), + BoolArray::from_iter([Some(false), None, Some(true)]), + &mut ctx + ); + Ok(()) + } + #[test] fn preserves_nulls() -> VortexResult<()> { let mut ctx = SESSION.create_execution_ctx(); diff --git a/vortex-array/src/scalar_fn/fns/operators.rs b/vortex-array/src/scalar_fn/fns/operators.rs index 3fdc921e39d..094db646b00 100644 --- a/vortex-array/src/scalar_fn/fns/operators.rs +++ b/vortex-array/src/scalar_fn/fns/operators.rs @@ -7,6 +7,7 @@ use std::fmt::Formatter; use vortex_error::VortexError; +use crate::dtype::NativePType; use crate::proto::expr::binary_opts::BinaryOp; /// Equalities, inequalities, and boolean operations over possibly null values. @@ -240,6 +241,18 @@ impl CompareOperator { CompareOperator::Lte => CompareOperator::Gte, } } + + /// Returns the total-order comparison that this operator applies to two native values. + pub fn to_predicate(self) -> fn(T, T) -> bool { + match self { + CompareOperator::Eq => T::is_eq, + CompareOperator::NotEq => |lhs, rhs| !lhs.is_eq(rhs), + CompareOperator::Gt => T::is_gt, + CompareOperator::Gte => T::is_ge, + CompareOperator::Lt => T::is_lt, + CompareOperator::Lte => T::is_le, + } + } } impl Display for CompareOperator { diff --git a/vortex-array/src/scalar_fn/fns/replace_time_zone.rs b/vortex-array/src/scalar_fn/fns/replace_time_zone.rs index 89cc8081c0c..0324b9964a3 100644 --- a/vortex-array/src/scalar_fn/fns/replace_time_zone.rs +++ b/vortex-array/src/scalar_fn/fns/replace_time_zone.rs @@ -252,7 +252,7 @@ fn replace_scalar( || Scalar::null(DType::Primitive(PType::I64, Nullability::Nullable)), |v| Scalar::primitive(v, Nullability::Nullable), ); - Ok(Scalar::extension_ref(ext, storage)) + Scalar::try_extension_ref(ext, storage) } fn timestamp_options(dtype: &DType) -> VortexResult<&TimestampOptions> { diff --git a/vortex-array/src/scalar_fn/typed.rs b/vortex-array/src/scalar_fn/typed.rs index ab6db6e098e..29a36a02722 100644 --- a/vortex-array/src/scalar_fn/typed.rs +++ b/vortex-array/src/scalar_fn/typed.rs @@ -19,9 +19,12 @@ use std::hash::Hasher; use std::sync::Arc; use vortex_error::VortexResult; +use vortex_error::vortex_ensure; use crate::ArrayRef; use crate::ExecutionCtx; +use crate::IntoArray; +use crate::arrays::ScalarFnArray; use crate::dtype::DType; use crate::expr::BoundExpression; use crate::expr::display::ExprDisplay; @@ -31,6 +34,8 @@ use crate::scalar_fn::ChildName; use crate::scalar_fn::ExecutionArgs; use crate::scalar_fn::ExpressionReduceNode; use crate::scalar_fn::ReduceNodeValidity; +use crate::scalar_fn::ScalarFnExecutionResult; +use crate::scalar_fn::ScalarFnExecutionStep; use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::ScalarFnRef; use crate::scalar_fn::ScalarFnVTable; @@ -67,6 +72,32 @@ impl TypedScalarFnInstance { pub fn erased(self) -> ScalarFnRef { ScalarFnRef(Arc::new(self)) } + + fn check_result(&self, args: &dyn ExecutionArgs, result: &ArrayRef) -> VortexResult<()> { + assert_eq!( + result.len(), + args.row_count(), + "Expression execution {} returned vector of length {}, but expected {}", + self.vtable.id(), + result.len(), + args.row_count(), + ); + + if cfg!(debug_assertions) { + let args_dtypes: Vec = (0..args.num_inputs()) + .map(|i| args.get(i).map(|a| a.dtype().clone())) + .collect::>()?; + let expected_dtype = V::return_dtype(&self.vtable, &self.options, &args_dtypes)?; + vortex_error::vortex_ensure_eq!( + result.dtype(), + &expected_dtype, + "Expression execution {} returned vector of invalid dtype", + self.vtable.id(), + ); + } + + Ok(()) + } } /// An object-safe, sealed trait for bound scalar function dispatch. @@ -80,6 +111,11 @@ pub(super) trait DynScalarFn: 'static + Send + Sync + super::sealed::Sealed { // Bound methods — options accessed from self fn execute(&self, args: &dyn ExecutionArgs, ctx: &mut ExecutionCtx) -> VortexResult; + fn execute_step( + &self, + args: &dyn ExecutionArgs, + ctx: &mut ExecutionCtx, + ) -> VortexResult; fn return_dtype(&self, arg_types: &[DType]) -> VortexResult; fn bind_options(&self, arg_types: &[DType]) -> VortexResult>; fn reduce_expression<'a>( @@ -133,36 +169,46 @@ impl DynScalarFn for TypedScalarFnInstance { } fn execute(&self, args: &dyn ExecutionArgs, ctx: &mut ExecutionCtx) -> VortexResult { - let expected_row_count = args.row_count(); - #[cfg(debug_assertions)] - let expected_dtype = { - let args_dtypes: Vec = (0..args.num_inputs()) - .map(|i| args.get(i).map(|a| a.dtype().clone())) - .collect::>()?; - V::return_dtype(&self.vtable, &self.options, &args_dtypes) - }?; - - let result = V::execute(&self.vtable, &self.options, args, ctx)?; - - assert_eq!( - result.len(), - expected_row_count, - "Expression execution {} returned vector of length {}, but expected {}", - self.vtable.id(), - result.len(), - expected_row_count, - ); - - #[cfg(debug_assertions)] - { - vortex_error::vortex_ensure_eq!( - result.dtype(), - &expected_dtype, - "Expression execution {} returned vector of invalid dtype", - self.vtable.id(), - ); + match self.execute_step(args, ctx)?.into_step() { + ScalarFnExecutionStep::Done(result) => Ok(result), + // Take one executor step on the requested input and return this function lazily + // over it, leaving the rest of the work to whoever executes the result. + ScalarFnExecutionStep::ExecuteInput(idx, _) => { + let mut inputs = (0..args.num_inputs()) + .map(|i| args.get(i)) + .collect::>>()?; + inputs[idx] = inputs[idx].clone().execute::(ctx)?; + let scalar_fn = + TypedScalarFnInstance::new(self.vtable.clone(), self.options.clone()).erased(); + let array = ScalarFnArray::try_new_with_len(scalar_fn, inputs, args.row_count())?; + Ok(array.into_array()) + } } + } + fn execute_step( + &self, + args: &dyn ExecutionArgs, + ctx: &mut ExecutionCtx, + ) -> VortexResult { + let result = V::execute_step(&self.vtable, &self.options, args, ctx)?; + match result.step() { + ScalarFnExecutionStep::Done(array) => self.check_result(args, array)?, + ScalarFnExecutionStep::ExecuteInput(idx, done) => { + vortex_ensure!( + *idx < args.num_inputs(), + "Scalar function {} requested input {idx}, but has {} inputs", + self.vtable.id(), + args.num_inputs(), + ); + // Requesting an input that already matches would loop without progress. + vortex_ensure!( + !done(&args.get(*idx)?), + "Scalar function {} requested execution of input {idx}, which is already done", + self.vtable.id(), + ); + } + } Ok(result) } diff --git a/vortex-array/src/scalar_fn/vtable.rs b/vortex-array/src/scalar_fn/vtable.rs index 487404c420a..698b4dc2529 100644 --- a/vortex-array/src/scalar_fn/vtable.rs +++ b/vortex-array/src/scalar_fn/vtable.rs @@ -23,10 +23,12 @@ use crate::arrays::ConstantArray; use crate::arrays::ScalarFn; use crate::arrays::ScalarFnArray; use crate::dtype::DType; +use crate::executor::DonePredicate; use crate::expr::BoundExpression; use crate::expr::Expression; use crate::expr::bound; use crate::expr::display::ExprDisplay; +use crate::matcher::Matcher; use crate::scalar::Scalar; use crate::scalar_fn::ScalarFnId; use crate::scalar_fn::ScalarFnRef; @@ -179,6 +181,12 @@ pub trait ScalarFnVTable: 'static + Sized + Clone + Send + Sync { /// Execute the expression over the input arguments. /// + /// Superseded by [`execute_step`](Self::execute_step). Vortex only calls this method through + /// the default `execute_step`, so a function that implements `execute_step` never has + /// `execute` called and should implement it with [`vortex_panic!`]. + /// + /// [`vortex_panic!`]: vortex_error::vortex_panic + /// /// Implementations are encouraged to check their inputs for constant arrays to perform /// more optimized execution. /// @@ -195,6 +203,30 @@ pub trait ScalarFnVTable: 'static + Sized + Clone + Send + Sync { ctx: &mut ExecutionCtx, ) -> VortexResult; + /// Perform a single step of execution over the input arguments. + /// + /// This is used by the iterative executor when executing a + /// [`ScalarFnArray`]. Instead of executing an input itself, an implementation can return + /// [`ScalarFnExecutionResult::execute_input`] to ask the scheduler to execute that input until + /// it matches a [`Matcher`]. The scheduler then calls `execute_step` again with the executed + /// input in its place, so deep trees of scalar functions run without recursion. + /// + /// Only request an input that does not already match, otherwise execution cannot make + /// progress and fails. + /// + /// The default delegates to [`execute`](Self::execute), for functions that have not been + /// migrated yet. [`ScalarFnRef::execute`] is defined in terms of this method, so once a + /// function overrides it, its [`execute`](Self::execute) is never called. + fn execute_step( + &self, + options: &Self::Options, + args: &dyn ExecutionArgs, + ctx: &mut ExecutionCtx, + ) -> VortexResult { + self.execute(options, args, ctx) + .map(ScalarFnExecutionResult::done) + } + /// Implement an abstract reduction rule over a tree of scalar functions. /// /// The [`ReduceNode`] can be used to traverse children, inspect their types, and @@ -559,6 +591,53 @@ pub trait ExecutionArgs { fn row_count(&self) -> usize; } +/// The result of a single [`ScalarFnVTable::execute_step`]. +pub struct ScalarFnExecutionResult(ScalarFnExecutionStep); + +/// What the scheduler should do after a [`ScalarFnVTable::execute_step`]. +#[derive(Clone)] +pub enum ScalarFnExecutionStep { + /// Execution finished with this result. + Done(ArrayRef), + /// Execute the input at this index until the predicate matches, then call + /// [`ScalarFnVTable::execute_step`] again. + ExecuteInput(usize, DonePredicate), +} + +impl ScalarFnExecutionResult { + /// Execution finished with the given result. + pub fn done(result: impl IntoArray) -> Self { + Self(ScalarFnExecutionStep::Done(result.into_array())) + } + + /// Ask the scheduler to execute the input at `input_idx` until it matches `M`, then call + /// [`ScalarFnVTable::execute_step`] again. + pub fn execute_input(input_idx: usize) -> Self { + Self(ScalarFnExecutionStep::ExecuteInput(input_idx, M::matches)) + } + + /// Returns the requested step. + pub fn step(&self) -> &ScalarFnExecutionStep { + &self.0 + } + + /// Returns the requested step. + pub fn into_step(self) -> ScalarFnExecutionStep { + self.0 + } +} + +impl Debug for ScalarFnExecutionResult { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match &self.0 { + ScalarFnExecutionStep::Done(array) => f.debug_tuple("Done").field(array).finish(), + ScalarFnExecutionStep::ExecuteInput(idx, _) => { + f.debug_tuple("ExecuteInput").field(idx).finish() + } + } + } +} + /// A concrete [`ExecutionArgs`] backed by a `Vec`. pub struct VecExecutionArgs { inputs: Vec, diff --git a/vortex-array/src/serde.rs b/vortex-array/src/serde.rs index 3653d051b6a..fb1a430f822 100644 --- a/vortex-array/src/serde.rs +++ b/vortex-array/src/serde.rs @@ -38,6 +38,7 @@ use crate::flatbuffers::FlatBuffer; use crate::flatbuffers::WriteFlatBuffer; use crate::flatbuffers::array as fba; use crate::flatbuffers::array::Compression; +use crate::optimizer::mark_decoded_optimized; use crate::session::ArraySessionExt; use crate::stats::StatsSet; @@ -430,6 +431,7 @@ impl SerializedArray { decoded.statistics().set_all(stats); } + mark_decoded_optimized(&decoded); Ok(decoded) } @@ -818,7 +820,11 @@ mod tests { old_primitive_id() } - fn serialized_ids(&self) -> Vec { + fn read_ids(&self) -> Vec { + vec![old_primitive_id(), new_primitive_id()] + } + + fn write_ids(&self) -> Vec { vec![old_primitive_id(), new_primitive_id()] } @@ -883,8 +889,12 @@ mod tests { VersionedPrimitivePlugin.id() } - fn serialized_ids(&self) -> Vec { - VersionedPrimitivePlugin.serialized_ids() + fn read_ids(&self) -> Vec { + VersionedPrimitivePlugin.read_ids() + } + + fn write_ids(&self) -> Vec { + VersionedPrimitivePlugin.write_ids() } fn serialize( diff --git a/vortex-array/src/session/mod.rs b/vortex-array/src/session/mod.rs index fd53caf395a..9bc6a3d8c4c 100644 --- a/vortex-array/src/session/mod.rs +++ b/vortex-array/src/session/mod.rs @@ -1,6 +1,12 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Session registries for array readers and writers. +//! +//! Writers are keyed by in-memory encoding IDs, while readers are keyed by wire IDs. Keeping the +//! registries separate lets a writer reuse another encoding's wire form without replacing its +//! reader. + use std::any::Any; use std::sync::Arc; @@ -62,14 +68,14 @@ impl ArraySession { &self.registry } - /// Register an in-memory array plugin and all of its recognized serialized IDs. + /// Register an in-memory array writer and its declared wire readers. /// /// This replaces any serializer with the same in-memory ID and any deserializer registered - /// under one of [`ArrayPlugin::serialized_ids`]. + /// under one of [`ArrayPlugin::read_ids`]. pub fn register(&self, plugin: P) { let plugin = Arc::new(plugin) as ArrayPluginRef; self.serializers.insert(plugin.id(), Arc::clone(&plugin)); - for serialized_id in plugin.serialized_ids() { + for serialized_id in plugin.read_ids() { self.registry.insert(serialized_id, Arc::clone(&plugin)); } } @@ -144,9 +150,7 @@ pub trait ArraySessionExt: SessionExt { return Ok(None); }; vortex_ensure!( - plugin - .serialized_ids() - .contains(&serialization.serialized_id), + plugin.write_ids().contains(&serialization.serialized_id), "array serializer {} produced undeclared serialized ID {}", array.encoding_id(), serialization.serialized_id, @@ -158,27 +162,4 @@ pub trait ArraySessionExt: SessionExt { impl ArraySessionExt for S {} #[cfg(test)] -mod tests { - use vortex_session::VortexSession; - - use crate::ArrayVTable; - use crate::arrays::Bool; - use crate::session::ArraySession; - use crate::session::ArraySessionExt; - - #[test] - fn array_session_default_registers_encodings() { - let session = VortexSession::empty().with::(); - - assert!(session.arrays().registry().contains_key(&Bool.id())); - assert!(session.arrays().serializer(&Bool.id()).is_some()); - } - - #[test] - fn empty_array_session_registers_no_encodings() { - let session = VortexSession::empty().with_some(ArraySession::empty()); - - assert!(!session.arrays().registry().contains_key(&Bool.id())); - assert!(session.arrays().serializer(&Bool.id()).is_none()); - } -} +mod tests; diff --git a/vortex-array/src/session/tests.rs b/vortex-array/src/session/tests.rs new file mode 100644 index 00000000000..968eed699d6 --- /dev/null +++ b/vortex-array/src/session/tests.rs @@ -0,0 +1,135 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Registration and serialization contracts for independent read and write IDs. + +use std::sync::Arc; + +use rstest::rstest; +use vortex_error::VortexResult; +use vortex_error::vortex_bail; +use vortex_session::VortexSession; +use vortex_session::registry::Id; + +use crate::ArrayDeserialization; +use crate::ArrayId; +use crate::ArrayPlugin; +use crate::ArrayRef; +use crate::ArraySerialization; +use crate::ArrayVTable; +use crate::IntoArray; +use crate::arrays::Bool; +use crate::arrays::Primitive; +use crate::arrays::PrimitiveArray; +use crate::session::ArraySession; +use crate::session::ArraySessionExt; + +struct WriteOnlyPrimitivePlugin { + serialized_id: ArrayId, +} + +impl ArrayPlugin for WriteOnlyPrimitivePlugin { + fn id(&self) -> ArrayId { + ArrayVTable::id(&Primitive) + } + + fn read_ids(&self) -> Vec { + vec![Id::from("vortex.test.read_only")] + } + + fn write_ids(&self) -> Vec { + vec![self.id()] + } + + fn serialize( + &self, + array: &ArrayRef, + _session: &VortexSession, + ) -> VortexResult> { + Ok(Some(ArraySerialization::from_array( + self.serialized_id, + array, + vec![], + ))) + } + + fn deserialize( + &self, + _parts: ArrayDeserialization<'_>, + _session: &VortexSession, + ) -> VortexResult { + vortex_bail!("the registration test does not deserialize nodes") + } +} + +#[test] +fn array_session_default_registers_encodings() { + let session = VortexSession::empty().with::(); + + let id = ArrayVTable::id(&Bool); + + assert!(session.arrays().registry().contains_key(&id)); + assert!(session.arrays().serializer(&id).is_some()); +} + +#[test] +fn empty_array_session_registers_no_encodings() { + let session = VortexSession::empty().with_some(ArraySession::empty()); + + let id = ArrayVTable::id(&Bool); + + assert!(!session.arrays().registry().contains_key(&id)); + assert!(session.arrays().serializer(&id).is_none()); +} + +#[test] +fn registration_preserves_the_reader_of_a_write_only_id() { + let session = VortexSession::empty().with::(); + let primitive_id = ArrayVTable::id(&Primitive); + let reader = session.arrays().registry().get(&primitive_id).unwrap(); + let plugin = WriteOnlyPrimitivePlugin { + serialized_id: primitive_id, + }; + let read_id = plugin.read_ids()[0]; + session.arrays().register(plugin); + + let arrays = session.arrays(); + assert!(Arc::ptr_eq( + &arrays.registry().get(&primitive_id).unwrap(), + &reader + )); + assert!(Arc::ptr_eq( + &arrays.registry().get(&read_id).unwrap(), + &arrays.serializer(&primitive_id).unwrap(), + )); +} + +#[rstest] +#[case::write_only(ArrayVTable::id(&Primitive), true)] +#[case::read_only(Id::from("vortex.test.read_only"), false)] +#[case::undeclared(Id::from("vortex.test.undeclared"), false)] +fn serialization_checks_only_write_ids( + #[case] serialized_id: ArrayId, + #[case] accepted: bool, +) -> VortexResult<()> { + let session = VortexSession::empty().with_some(ArraySession::empty()); + session + .arrays() + .register(WriteOnlyPrimitivePlugin { serialized_id }); + let array = PrimitiveArray::from_iter([1i32, 2, 3]).into_array(); + + let result = session.array_serialize(&array); + if accepted { + assert_eq!(result?.unwrap().serialized_id, serialized_id); + assert!(!session.arrays().registry().contains_key(&serialized_id)); + } else { + let error = result.expect_err("only declared write IDs may be returned"); + assert!( + error + .to_string() + .contains("produced undeclared serialized ID") + ); + } + + Ok(()) +} diff --git a/vortex-datafusion/Cargo.toml b/vortex-datafusion/Cargo.toml index 5335af982d0..8cdeca98def 100644 --- a/vortex-datafusion/Cargo.toml +++ b/vortex-datafusion/Cargo.toml @@ -48,6 +48,7 @@ tempfile = { workspace = true } tokio = { workspace = true, features = ["test-util", "rt-multi-thread", "fs"] } url = { workspace = true } vortex-array = { workspace = true, features = ["_test-harness"] } +vortex-json = { workspace = true } [lints] workspace = true diff --git a/vortex-datafusion/src/convert/exprs/mod.rs b/vortex-datafusion/src/convert/exprs/mod.rs index d1c62511164..b7e1b6bd676 100644 --- a/vortex-datafusion/src/convert/exprs/mod.rs +++ b/vortex-datafusion/src/convert/exprs/mod.rs @@ -1,11 +1,19 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Converts DataFusion physical expressions for native Vortex evaluation. +//! +//! Unsupported expressions stay in DataFusion. Comparison and membership literals retain their own +//! extension metadata, or inherit missing metadata from the operand they are compared with. This +//! supplies the logical dtype that Vortex requires without adding implicit casts. + use std::sync::Arc; use arrow_schema::DataType; use arrow_schema::Field; use arrow_schema::Schema; +use arrow_schema::extension::EXTENSION_TYPE_METADATA_KEY; +use arrow_schema::extension::EXTENSION_TYPE_NAME_KEY; use datafusion_common::DataFusionError; use datafusion_common::Result as DFResult; use datafusion_common::ScalarValue; @@ -39,18 +47,15 @@ use vortex::expr::nested_case_when; use vortex::expr::not; use vortex::expr::pack; use vortex::expr::root; +use vortex::scalar::Scalar; use vortex::scalar_fn::ScalarFnVTableExt; use vortex::scalar_fn::fns::binary::Binary; use vortex::scalar_fn::fns::like::Like; use vortex::scalar_fn::fns::like::LikeOptions; -use vortex::scalar_fn::fns::literal::Literal; use vortex::scalar_fn::fns::operators::Operator; use vortex::session::VortexSession; use vortex_arrow::ArrowSessionExt; -#[cfg(test)] -mod tests; - /// Result of splitting a projection into Vortex expressions and leftover DataFusion projections. pub struct ProcessedProjection { /// Projection evaluated by the Vortex scan. @@ -309,8 +314,21 @@ impl DefaultExpressionConverter { } else if !supported_data_types(&left_type) || !supported_data_types(&right_type) { return Err(Unconverted::Unsupported); } - let left = self.convert_expr(binary_expr.left(), schema, input_dtype)?; - let right = self.convert_expr(binary_expr.right(), schema, input_dtype)?; + let left = self.convert_binary_operand( + binary_expr.left(), + binary_expr.right(), + operator, + schema, + input_dtype, + )?; + let right = self.convert_binary_operand( + binary_expr.right(), + binary_expr.left(), + operator, + schema, + input_dtype, + )?; + // DataFusion may evaluate the RHS only on rows selected by the LHS. if boolean_operator && !(is_infallible(&left) && is_infallible(&right)) { return Err(Unconverted::Unsupported); @@ -329,23 +347,8 @@ impl DefaultExpressionConverter { if let Some(literal) = expr.downcast_ref::() { let field = literal.return_field(schema)?; - let array = literal.value().to_array()?; - if array.len() != 1 { - return Err(exec_datafusion_err!( - "Literal must contain exactly one value, found {}", - array.len() - ) - .into()); - } - // Literals of unknown Arrow types stay in DataFusion; conversion failures are errors. - self.arrow_dtype(&field)?; - let scalar = self - .session - .arrow() - .from_arrow_array(array, &field) - .and_then(|array| array.execute_scalar(0, &mut self.session.create_execution_ctx())) - .map_err(|e| exec_datafusion_err!("Failed to convert literal {expr}: {e}"))?; - return Ok(lit(scalar)); + + return Ok(lit(self.import_literal(literal, &field)?)); } if let Some(cast_expr) = expr.downcast_ref::() { @@ -427,6 +430,82 @@ impl DefaultExpressionConverter { Err(Unconverted::Unsupported) } + /// Converts a binary operand, using the other operand's field to type comparison literals. + /// + /// Arithmetic and Boolean operands convert independently. They do not accept extension dtypes, + /// so the other operand cannot supply an expected extension type for their literals. + fn convert_binary_operand( + &self, + expr: &Arc, + other: &Arc, + operator: Operator, + schema: &Schema, + input_dtype: &DType, + ) -> Conversion { + if operator.is_comparison() + && let Some(literal) = expr.downcast_ref::() + { + let field = other.return_field(schema)?; + let scalar = self.import_literal_for_operand(literal, &field, schema)?; + + return Ok(lit(scalar)); + } + + self.convert_expr(expr, schema, input_dtype) + } + + /// Imports a literal, using `operand_field` only when the literal has no extension metadata. + /// + /// The literal keeps its Arrow dtype, so different storage types or timestamp units still fail + /// the comparison's dtype check. Explicit metadata, including an unknown extension, is preserved. + /// The inherited extension name and payload both come from `operand_field`, including an absent + /// payload, so the import cannot combine metadata from two different types. + fn import_literal_for_operand( + &self, + literal: &df_expr::Literal, + operand_field: &Field, + schema: &Schema, + ) -> Conversion { + let field = literal.return_field(schema)?; + if field.extension_type_name().is_some() || operand_field.extension_type_name().is_none() { + return self.import_literal(literal, &field); + } + + let mut field = field.as_ref().clone(); + for key in [EXTENSION_TYPE_NAME_KEY, EXTENSION_TYPE_METADATA_KEY] { + field.metadata_mut().remove(key); + if let Some(value) = operand_field.metadata().get(key) { + field.metadata_mut().insert(key.into(), value.clone()); + } + } + + self.import_literal(literal, &field) + } + + /// Imports one scalar through the session's Arrow plugins, preserving `field`'s metadata. + fn import_literal(&self, literal: &df_expr::Literal, field: &Field) -> Conversion { + let array = literal.value().to_array()?; + if array.len() != 1 { + return Err(exec_datafusion_err!( + "Literal must contain exactly one value, got {}", + array.len() + ) + .into()); + } + + self.arrow_dtype(field)?; + + self.session + .arrow() + .from_arrow_array(array, field) + .and_then(|array| array.execute_scalar(0, &mut self.session.create_execution_ctx())) + .map_err(|error| { + Unconverted::Failed(DataFusionError::External(Box::new( + error.with_context(format!("Failed to convert literal {literal}")), + ))) + }) + } + fn convert_in_list( &self, in_list: &df_expr::InListExpr, @@ -448,23 +527,20 @@ impl DefaultExpressionConverter { return Err(Unconverted::Unsupported); } let value_dtype = converted_dtype(&value, input_dtype)?; + let value_field = in_list.expr().return_field(schema)?; // The list of a hash join filter holds every build-side key, which repeat. Each element - // converts through Arrow, so equal elements are converted once. + // converts through Arrow, so equal values with equal metadata are converted once. let elements = in_list .list() .iter() - .unique_by(|element| { - element - .downcast_ref::() - .map(|literal| literal.value().clone()) - }) + .unique_by(|element| element.downcast_ref::().cloned()) .map(|element| { - let element = self.convert_expr(element, schema, input_dtype)?; - element - .as_opt::() - .cloned() - .ok_or(Unconverted::Unsupported) + let literal = element + .downcast_ref::() + .ok_or(Unconverted::Unsupported)?; + + self.import_literal_for_operand(literal, &value_field, schema) }) .collect::>>()?; @@ -747,3 +823,6 @@ fn array_length_input(scalar_fn: &ScalarFunctionExpr) -> DFResult anyhow::Result<()> { + let mut field = Field::new("id", DataType::FixedSizeBinary(16), true); + field.try_with_extension_type(ArrowUuid)?; + let schema = Schema::new(vec![field.clone()]); + let value = ScalarValue::FixedSizeBinary(16, Some(b"0123456789abcdef".to_vec())); + let valid = Arc::new(df_expr::Literal::new_with_metadata( + value.clone(), + Some(FieldMetadata::new_from_field(&field)), + )) as Arc; + field.metadata_mut().insert( + "ARROW:extension:name".into(), + "unregistered.extension".into(), + ); + let invalid = Arc::new(df_expr::Literal::new_with_metadata( + value, + Some(FieldMetadata::new_from_field(&field)), + )) as Arc; + let column = Arc::new(df_expr::Column::new("id", 0)) as Arc; + let predicate = if membership { + Arc::new(df_expr::InListExpr::try_new( + column, + vec![valid, invalid], + false, + &schema, + )?) as Arc + } else { + Arc::new(df_expr::BinaryExpr::new(column, DFOperator::Eq, invalid)) + }; + + assert!(!converts(&predicate, &schema)?); + + Ok(()) +} + +#[test] +fn test_comparison_inherits_complete_extension_metadata() -> anyhow::Result<()> { + let mut field = Field::new("id", DataType::FixedSizeBinary(16), false); + field.try_with_extension_type(ArrowUuid)?; + let bytes = *b"0123456789abcdef"; + let values = FixedSizeBinaryArray::try_from_iter([bytes].into_iter())?; + let batch = RecordBatch::try_new( + Arc::new(Schema::new(vec![field.clone()])), + vec![Arc::new(values)], + )?; + + let mut literal_field = field; + literal_field.metadata_mut().remove(EXTENSION_TYPE_NAME_KEY); + literal_field.metadata_mut().insert( + EXTENSION_TYPE_METADATA_KEY.into(), + "unrelated payload".into(), + ); + let literal = df_expr::Literal::new_with_metadata( + ScalarValue::FixedSizeBinary(16, Some(bytes.to_vec())), + Some(FieldMetadata::new_from_field(&literal_field)), + ); + let predicate = Arc::new(df_expr::BinaryExpr::new( + Arc::new(df_expr::Column::new("id", 0)), + DFOperator::Eq, + Arc::new(literal), + )); + + assert_native_matches(predicate, batch) +} + +#[test] +fn test_comparison_literal_keeps_timestamp_units() -> DFResult<()> { + let schema = Schema::new(vec![Field::new( + "ts", + DataType::Timestamp(ArrowTimeUnit::Millisecond, None), + true, + )]); + let predicate = Arc::new(df_expr::BinaryExpr::new( + Arc::new(df_expr::Column::new("ts", 0)), + DFOperator::Eq, + Arc::new(df_expr::Literal::new(ScalarValue::TimestampNanosecond( + Some(1_000_000), + None, + ))), + )) as Arc; + + assert!(!converts(&predicate, &schema)?); + + Ok(()) +} + #[test] fn test_expr_from_df_binary() -> DFResult<()> { let left = Arc::new(df_expr::Column::new("left", 0)) as Arc; diff --git a/vortex-datafusion/src/convert/scalars.rs b/vortex-datafusion/src/convert/scalars.rs index a06b0ae1dff..b9095ba81ca 100644 --- a/vortex-datafusion/src/convert/scalars.rs +++ b/vortex-datafusion/src/convert/scalars.rs @@ -1,6 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! Converts scalar values between Vortex and DataFusion. +//! +//! A bare DataFusion scalar cannot carry extension metadata. Extensions without a dedicated +//! DataFusion scalar representation must cross a field-aware Arrow boundary instead. + use std::sync::Arc; use arrow_array::Array; @@ -136,16 +141,15 @@ impl TryToDataFusion for Scalar { vortex_bail!("Variant scalars aren't supported with DF") } DType::Extension(ext) => { - let storage_scalar = self.as_extension().to_storage_scalar(); - let Some(temporal) = ext.metadata_opt::() else { - // Unknown extension type: perform scalar conversion using the canonical - // scalar DType. - return storage_scalar.try_to_df(); + vortex_bail!( + "DataFusion ScalarValue requires a dedicated extension representation, got {}", + self.dtype() + ); }; - // Special handling: temporal extension types in Vortex correspond to Arrow's - // temporal physical types. + // Temporal extension types in Vortex have dedicated DataFusion scalar types. + let storage_scalar = self.as_extension().to_storage_scalar(); let pv = storage_scalar.as_primitive(); match temporal { TemporalMetadata::Timestamp(unit, tz) => match unit { @@ -391,6 +395,7 @@ mod tests { use datafusion_common::arrow::datatypes::i256 as arrow_i256; use rstest::rstest; use vortex::VortexSessionDefault; + use vortex::array::EmptyMetadata; use vortex::buffer::ByteBuffer; use vortex::dtype::DType; use vortex::dtype::DecimalDType; @@ -399,6 +404,7 @@ mod tests { use vortex::dtype::PType; use vortex::dtype::StructFields; use vortex::dtype::UnionVariants; + use vortex::dtype::extension::ExtDType; use vortex::dtype::i256; use vortex::error::VortexExpect; use vortex::extension::datetime::Date; @@ -406,6 +412,7 @@ mod tests { use vortex::extension::datetime::Timestamp; use vortex::scalar::DecimalValue; use vortex::scalar::Scalar; + use vortex_json::Json; use super::*; @@ -967,6 +974,45 @@ mod tests { assert!(err.to_string().contains("unsupported scalar type"), "{err}"); } + #[rstest] + #[case::value(false, false)] + #[case::null(true, false)] + #[case::nested(false, true)] + fn test_bare_extension_scalar_cannot_lose_its_dtype( + #[case] null: bool, + #[case] nested: bool, + ) -> VortexResult<()> { + let dtype = DType::Extension( + ExtDType::::try_new(EmptyMetadata, DType::Utf8(Nullability::Nullable))?.erased(), + ); + let scalar = Scalar::try_new( + dtype.clone(), + (!null).then(|| vortex::scalar::ScalarValue::from(r#"{"x":1}"#)), + )?; + let scalar = if nested { + Scalar::struct_( + DType::Struct( + StructFields::new(FieldNames::from(["json"]), vec![dtype]), + Nullability::NonNullable, + ), + vec![scalar], + ) + } else { + scalar + }; + + let error = scalar + .try_to_df() + .expect_err("extension metadata cannot fit in a ScalarValue"); + assert!( + error + .to_string() + .contains("requires a dedicated extension representation") + ); + + Ok(()) + } + /// Wraps `value` in a `ScalarValue::RunEndEncoded`, as DataFusion represents a scalar taken /// from a run-end-encoded array. fn run_end_encoded(value: ScalarValue) -> ScalarValue { diff --git a/vortex-datafusion/src/convert/stats/tests.rs b/vortex-datafusion/src/convert/stats/tests.rs index bfb165b5e21..2604c2d6f02 100644 --- a/vortex-datafusion/src/convert/stats/tests.rs +++ b/vortex-datafusion/src/convert/stats/tests.rs @@ -4,11 +4,14 @@ use datafusion_common::ScalarValue as DFScalarValue; use rstest::rstest; use vortex::VortexSessionDefault; +use vortex::array::EmptyMetadata; +use vortex::dtype::extension::ExtDType; use vortex::dtype::half::f16; use vortex::error::vortex_err; use vortex::expr::stats::Precision as VortexPrecision; use vortex::scalar::ScalarValue; use vortex::session::VortexSession; +use vortex_json::Json; use super::*; use crate::convert::scalar_from_df; @@ -218,3 +221,19 @@ fn uncompressed_size_is_not_reported_as_byte_size() -> VortexResult<()> { ); Ok(()) } + +#[test] +fn test_extension_statistics_do_not_export_storage_values() -> VortexResult<()> { + let dtype = DType::Extension( + ExtDType::::try_new(EmptyMetadata, DType::Utf8(Nullability::NonNullable))?.erased(), + ); + let value = ScalarValue::from(r#"{"x":1}"#); + let mut stats = StatsSet::of(Stat::Min, VortexPrecision::exact(value.clone())); + stats.set(Stat::Max, VortexPrecision::exact(value)); + + let converted = stats_set_to_df(&stats, &dtype)?; + assert_eq!(converted.min_value, Precision::Absent); + assert_eq!(converted.max_value, Precision::Absent); + + Ok(()) +} diff --git a/vortex-datafusion/src/v2/tests.rs b/vortex-datafusion/src/v2/tests.rs index b06b5a74337..d5c90b2c96f 100644 --- a/vortex-datafusion/src/v2/tests.rs +++ b/vortex-datafusion/src/v2/tests.rs @@ -4,9 +4,16 @@ use std::sync::Arc; use anyhow::anyhow; +use arrow_array::ArrayRef; +use arrow_array::Int32Array; use arrow_array::RecordBatch; use arrow_array::cast::AsArray; use arrow_array::types::Int32Type; +use arrow_schema::DataType; +use arrow_schema::Field; +use arrow_schema::Schema; +use arrow_schema::extension::Json as ArrowJson; +use arrow_schema::extension::Uuid as ArrowUuid; use datafusion::assert_batches_eq; use datafusion::prelude::SessionContext; use datafusion_common::ScalarValue; @@ -24,6 +31,7 @@ use datafusion_physical_expr::projection::ProjectionExpr; use datafusion_physical_expr::projection::ProjectionExprs; use datafusion_physical_plan::ExecutionPlan; use datafusion_physical_plan::expressions as df_expr; +use datafusion_physical_plan::filter::FilterExec; use datafusion_physical_plan::filter_pushdown::PushedDown; use futures::TryStreamExt; use rstest::rstest; @@ -43,7 +51,13 @@ async fn vortex_source() -> anyhow::Result { } async fn vortex_source_from_batch(batch: RecordBatch) -> anyhow::Result { - let session = VortexSession::default(); + vortex_source_from_batch_with_session(batch, &VortexSession::default()).await +} + +async fn vortex_source_from_batch_with_session( + batch: RecordBatch, + session: &VortexSession, +) -> anyhow::Result { let schema = batch.schema(); let array = session.arrow().from_arrow_record_batch(batch, &schema)?; let mut buffer = ByteBufferMut::empty(); @@ -52,10 +66,12 @@ async fn vortex_source_from_batch(batch: RecordBatch) -> anyhow::Result, +} + +impl ExtensionFilterFixture { + fn new(extension_type: ExtensionFilterType) -> anyhow::Result { + let session = VortexSession::default(); + vortex_json::initialize(&session); + + let (field, values) = match extension_type { + ExtensionFilterType::Uuid => { + let mut field = Field::new("value", DataType::FixedSizeBinary(16), true); + field.try_with_extension_type(ArrowUuid)?; + + ( + field, + vec![ + ScalarValue::FixedSizeBinary(16, Some(b"0123456789abcde1".to_vec())), // + ScalarValue::FixedSizeBinary(16, Some(b"0123456789abcde2".to_vec())), // + ScalarValue::FixedSizeBinary(16, Some(b"0123456789abcde3".to_vec())), // + ScalarValue::FixedSizeBinary(16, None), // + ], + ) + } + ExtensionFilterType::Json => { + let mut field = Field::new("value", DataType::Utf8, true); + field.try_with_extension_type(ArrowJson::default())?; + + ( + field, + vec![ + ScalarValue::Utf8(Some(r#"{"x":1}"#.into())), // + ScalarValue::Utf8(Some(r#"{"x":2}"#.into())), // + ScalarValue::Utf8(Some(r#"{"x":3}"#.into())), // + ScalarValue::Utf8(None), // + ], + ) + } + }; + + let batch = RecordBatch::try_new( + Arc::new(Schema::new(vec![ + Field::new("id", DataType::Int32, false), + field, + ])), + vec![ + Arc::new(Int32Array::from(vec![1, 2, 3, 4])) as ArrayRef, + ScalarValue::iter_to_array(values.iter().cloned())?, + ], + )?; + + Ok(Self { + session, + batch, + values, + }) + } + + fn column(&self) -> Arc { + Arc::new(df_expr::Column::new(self.batch.schema().field(1).name(), 1)) + } + + fn literal(&self, index: usize) -> Arc { + Arc::new(df_expr::Literal::new(self.values[index].clone())) + } + + fn comparison(&self, index: usize) -> Arc { + Arc::new(df_expr::BinaryExpr::new( + self.column(), + Operator::Eq, + self.literal(index), + )) + } + + fn membership(&self) -> anyhow::Result> { + Ok(Arc::new(df_expr::InListExpr::try_new( + self.column(), + vec![self.literal(1), self.literal(1)], + false, + &self.batch.schema(), + )?)) + } + + async fn source(&self) -> anyhow::Result { + vortex_source_from_batch_with_session(self.batch.clone(), &self.session).await + } +} + +/// Collects row identifiers so the tests compare the scan restriction separately from its residual. +async fn scan_ids(plan: Arc) -> anyhow::Result> { + let batches = datafusion_physical_plan::collect(plan, SessionContext::new().task_ctx()).await?; + + Ok(batches + .iter() + .flat_map(|batch| { + batch + .column(0) + .as_primitive::() + .values() + .iter() + .copied() + }) + .collect()) +} + +#[rstest] +#[case::uuid(ExtensionFilterType::Uuid)] +#[case::json(ExtensionFilterType::Json)] +#[tokio::test] +async fn test_extension_comparison_literals_are_pushed_down( + #[case] extension_type: ExtensionFilterType, + #[values(false, true)] reverse_operands: bool, +) -> anyhow::Result<()> { + let fixture = ExtensionFilterFixture::new(extension_type)?; + let (left, right) = if reverse_operands { + (fixture.literal(1), fixture.column()) + } else { + (fixture.column(), fixture.literal(1)) + }; + + let filter = Arc::new(df_expr::BinaryExpr::new(left, Operator::Eq, right)); + let pushed = fixture + .source() + .await? + .try_pushdown_filters(vec![filter], &ConfigOptions::new())?; + assert!(matches!(pushed.filters.as_slice(), [PushedDown::Yes])); + let source = pushed + .updated_node + .ok_or_else(|| anyhow!("filter was not pushed"))?; + + assert_eq!(scan_ids(Arc::new(DataSourceExec::new(source))).await?, [2]); + + Ok(()) +} + +#[rstest] +#[case::uuid(ExtensionFilterType::Uuid)] +#[case::json(ExtensionFilterType::Json)] +#[tokio::test] +async fn test_extension_membership_literals_are_pushed_down( + #[case] extension_type: ExtensionFilterType, +) -> anyhow::Result<()> { + let fixture = ExtensionFilterFixture::new(extension_type)?; + let pushed = fixture + .source() + .await? + .try_pushdown_filters(vec![fixture.membership()?], &ConfigOptions::new())?; + assert!(matches!(pushed.filters.as_slice(), [PushedDown::Yes])); + let source = pushed + .updated_node + .ok_or_else(|| anyhow!("filter was not pushed"))?; + + assert_eq!(scan_ids(Arc::new(DataSourceExec::new(source))).await?, [2]); + + Ok(()) +} + +#[rstest] +#[case::uuid(ExtensionFilterType::Uuid)] +#[case::json(ExtensionFilterType::Json)] +#[tokio::test] +async fn test_dynamic_extension_literals_refresh_and_keep_residuals( + #[case] extension_type: ExtensionFilterType, +) -> anyhow::Result<()> { + let fixture = ExtensionFilterFixture::new(extension_type)?; + let bound = Arc::new(DynamicFilterPhysicalExpr::new( + vec![fixture.column()], + df_expr::lit(true), + )); + let pushed = fixture.source().await?.try_pushdown_filters( + vec![Arc::clone(&bound) as Arc], + &ConfigOptions::new(), + )?; + assert!(matches!(pushed.filters.as_slice(), [PushedDown::No])); + let source = pushed + .updated_node + .ok_or_else(|| anyhow!("dynamic filter was not pushed"))?; + let unsupported = Arc::new(df_expr::BinaryExpr::new( + fixture.column(), + Operator::IsNotDistinctFrom, + fixture.literal(1), + )); + + for (predicate, expected_scan, expected_result) in [ + (df_expr::lit(true), vec![1, 2, 3, 4], vec![1, 2, 3, 4]), // + (fixture.comparison(0), vec![1], vec![1]), // + (fixture.comparison(2), vec![3], vec![3]), // + (fixture.comparison(3), vec![], vec![]), // + (fixture.membership()?, vec![2], vec![2]), // + ( + unsupported as Arc, + vec![1, 2, 3, 4], + vec![2], + ), // + ] { + bound.update(predicate)?; + let scan = Arc::new(DataSourceExec::new(Arc::clone(&source))) as Arc; + assert_eq!(scan_ids(Arc::clone(&scan)).await?, expected_scan); + + let residual = Arc::new(FilterExec::try_new( + Arc::clone(&bound) as Arc, + scan.reset_state()?, + )?); + assert_eq!(scan_ids(residual).await?, expected_result); + } + + Ok(()) +} diff --git a/vortex-duckdb/README.md b/vortex-duckdb/README.md index 3efda0af58a..bee3eb06c66 100644 --- a/vortex-duckdb/README.md +++ b/vortex-duckdb/README.md @@ -37,8 +37,8 @@ want to test a full setup, the release commit hash. 5. Open a PR in duckdb-vortex, check the tests and merge it. 6. Ensure the PR has been backported to the current release branch, i.e. for - duckdb 1.5.* the release branch is - [v1.5-variegata](https://github.com/vortex-data/duckdb-vortex/tree/v1.5-variegata). + duckdb 2.0.* the release branch is + [v2.0-cyanoptera](https://github.com/vortex-data/duckdb-vortex/tree/v2.0-cyanoptera). This should happen automatically. 7. Notify DuckDB maintainers in the Discord `#spiraldb` channel of the new commit and ask to update the extension version. This will likely take some diff --git a/vortex-duckdb/src/convert/expr.rs b/vortex-duckdb/src/convert/expr.rs index 4ed3cc66060..b487ab4fdc4 100644 --- a/vortex-duckdb/src/convert/expr.rs +++ b/vortex-duckdb/src/convert/expr.rs @@ -106,6 +106,18 @@ fn string_matcher_pattern(children: &[&ExpressionRef]) -> Option { } } +/// Escape each of `chars` in `pattern` with `\`, the escape character of Vortex LIKE. +fn escape_like(pattern: &str, chars: &[char]) -> String { + let mut escaped = String::with_capacity(pattern.len()); + for c in pattern.chars() { + if chars.contains(&c) { + escaped.push('\\'); + } + escaped.push(c); + } + escaped +} + /// Whether the expression's return type is a `LIST` or fixed-size `ARRAY`. fn returns_a_list(expr: &ExpressionRef) -> bool { matches!( @@ -312,17 +324,17 @@ fn try_from_bound_function( like @ ("~~" | "!~~") => { let children: Vec<_> = func.children().collect(); vortex_ensure_eq!(children.len(), 2); - let Some(string) = try_from_expression_inner(children[0], ctx)? else { + let Some(pattern) = from_bound_str(children[1]) else { return Ok(None); }; - let Some(target) = try_from_expression_inner(children[1], ctx)? else { + let Some(string) = try_from_expression_inner(children[0], ctx)? else { return Ok(None); }; let opts = LikeOptions { negated: like == "!~~", case_insensitive: false, }; - Like.new_expr(opts, [string, target]) + Like.new_expr(opts, [string, lit(escape_like(&pattern, &['\\']))]) } matchers @ ("contains" | "prefix" | "suffix") => { let children: Vec<_> = func.children().collect(); @@ -332,6 +344,7 @@ fn try_from_bound_function( let Some(value) = try_from_expression_inner(children[0], ctx)? else { return Ok(None); }; + let pattern = escape_like(&pattern, &['%', '_', '\\']); let pattern = match matchers { "contains" => format!("%{pattern}%"), "prefix" => format!("{pattern}%"), @@ -459,7 +472,8 @@ pub fn can_push_expression(value: &ExpressionRef) -> bool { ExpressionClass::BoundFunction(func) => { let children: Vec<_> = func.children().collect(); let supported = match func.scalar_function.name() { - "~~" | "!~~" | "strlen" => true, + "~~" | "!~~" => children.len() == 2 && from_bound_str(children[1]).is_some(), + "strlen" => true, "struct_extract" => children.len() == 2 && from_bound_str(children[1]).is_some(), "contains" | "prefix" | "suffix" => string_matcher_pattern(&children).is_some(), "array_length" => children.len() == 1, diff --git a/vortex-duckdb/src/e2e_test/mod.rs b/vortex-duckdb/src/e2e_test/mod.rs index 9abf6d12944..7be5711b2e5 100644 --- a/vortex-duckdb/src/e2e_test/mod.rs +++ b/vortex-duckdb/src/e2e_test/mod.rs @@ -1,6 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: Copyright the Vortex contributors +//! End-to-end tests for DuckDB scans and pushdown. +//! +//! These tests exercise the registered extension through scans, spatial pushdown, and S3 reads. + #[cfg(test)] mod s3_test; #[cfg(all(test, duckdb_release))] diff --git a/vortex-edition/src/session.rs b/vortex-edition/src/session.rs index 1b59bd85364..dd34b2ca92d 100644 --- a/vortex-edition/src/session.rs +++ b/vortex-edition/src/session.rs @@ -186,6 +186,11 @@ impl EditionSession { self.inner.read().editions.get(&id.to_string()).copied() } + /// Find a declared edition by its name, for example `core2025.10.0`. + pub fn find_by_name(&self, name: &str) -> Option { + self.inner.read().editions.get(name).copied() + } + /// The newest frozen edition of a family, if any. Drafts are never current. pub fn current(&self, family: &str) -> Option { self.editions() diff --git a/vortex-ffi/CMakeLists.txt b/vortex-ffi/CMakeLists.txt index 29b1cc2ee41..02aaeaf39fc 100644 --- a/vortex-ffi/CMakeLists.txt +++ b/vortex-ffi/CMakeLists.txt @@ -1,11 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright the Vortex contributors -# Entry point for the Rust FFI libraries. It exports Vortex::ffi_static and -# Vortex::ffi_shared for C consumers; lang/cpp layers the C++ wrapper on top. -# It supports standalone configuration and add_subdirectory() from a parent. - -# CMake 3.25 is required for block() and FetchContent SYSTEM. cmake_minimum_required(VERSION 3.25) project(VortexFFI DESCRIPTION "Vortex C FFI" LANGUAGES C CXX) @@ -13,18 +8,12 @@ project(VortexFFI DESCRIPTION "Vortex C FFI" LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# Standalone entry points own their defaults; otherwise inherit Vortex's marker. if(PROJECT_IS_TOP_LEVEL) set(_vortex_top_level ON) elseif(NOT DEFINED _vortex_top_level) set(_vortex_top_level OFF) endif() -# Vortex does not use C++ modules, so it does not require compiler-specific -# dependency scanners such as clang-scan-deps. -set(CMAKE_CXX_SCAN_FOR_MODULES OFF) - -# A standalone configure writes compile_commands.json for editor tooling. if(PROJECT_IS_TOP_LEVEL) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) endif() @@ -39,19 +28,14 @@ option(VORTEX_BUILD_EXAMPLES "Build Vortex examples" OFF) option(VORTEX_ENABLE_CUDA "Build the CUDA-enabled Vortex FFI" OFF) set(VORTEX_CARGO_PROFILE "" CACHE STRING "Override the Cargo profile selected from CMAKE_BUILD_TYPE") -# Sanitizers instrument the Rust archive, its C dependencies, and consumers of -# either FFI target; Configure.cmake enforces the toolchain constraints. set(VORTEX_SANITIZER "" CACHE STRING - "Comma-separated sanitizers for Vortex and its consumers: asan, lsan, ubsan, tsan") + "Comma-separated sanitizer list: asan, lsan, ubsan, tsan") option(VORTEX_SANITIZE_RUST_STD "Rebuild Rust's standard library with sanitizer instrumentation" OFF) -option(VORTEX_WARNINGS_AS_ERRORS - "Treat warnings in Vortex-owned sources as errors" - "${_vortex_top_level}") +option(VORTEX_WARNINGS_AS_ERRORS "Treat warnings as errors" "${_vortex_top_level}") -# Define the Cargo build and both FFI library targets. include(cmake/Configure.cmake) add_library(Vortex::ffi_static ALIAS vortex_ffi_static) diff --git a/vortex-ffi/README.md b/vortex-ffi/README.md index 3209cf02f42..b524a30e119 100644 --- a/vortex-ffi/README.md +++ b/vortex-ffi/README.md @@ -1,29 +1,28 @@ # Vortex C bindings -## Use from CMake - -Add a complete Vortex checkout. CMake builds the Rust archive for you: +Building requires CMake 3.25+ and a C11 compiler. ```cmake add_subdirectory(path/to/vortex vortex) -target_link_libraries(my_target PRIVATE Vortex::ffi) +target_link_libraries(my_target PRIVATE Vortex::ffi_static) +target_link_libraries(my_target PRIVATE Vortex::ffi_shared) ``` -The target supplies the library and headers, selecting static or shared linkage according -to `BUILD_SHARED_LIBS` (`OFF` by default). Set the option before adding Vortex. To select -linkage explicitly, use `Vortex::ffi_static` or `Vortex::ffi_shared`; both remain available -regardless of the option. You can also add `vortex-ffi` directly. See the -[CMake build guide](../lang/cpp/README.md) for requirements, options, and deployment limits. - -### Examples and tests +Note this builds Vortex Rust side for you. -Run from the repository root. Tests use Catch2 and require a C++ compiler. +Tests require a C++-20 compiler. To run tests, ```sh -cmake -S vortex-ffi -B build/ffi \ - -DVORTEX_BUILD_EXAMPLES=ON -DVORTEX_BUILD_TESTS=ON +cmake -S vortex-ffi -B build/ffi -DVORTEX_BUILD_TESTS=ON cmake --build build/ffi --parallel ctest --test-dir build/ffi --output-on-failure +``` + +To run examples, + +```sh +cmake -S vortex-ffi -B build/ffi -DVORTEX_BUILD_EXAMPLES=ON +cmake --build build/ffi --parallel ./build/ffi/examples/write_sample sample.vortex ./build/ffi/examples/dtype sample.vortex @@ -31,29 +30,12 @@ ctest --test-dir build/ffi --output-on-failure ./build/ffi/examples/scan_to_arrow sample.vortex ``` -## Runtime threading - -By default, calling threads drive the shared runtime with no Vortex workers. - -`vx_runtime_set_worker_threads(n)` configures a library-local pool of background workers that -drive the shared runtime. The pool is shared by all FFI sessions in that library instance and -persists across calls for the lifetime of the library. Passing zero signals the workers to stop -and restores caller-driven execution. Leave it at zero if your application already provides concurrency. +To regenerate `vortex.h` after making some changes, run `cargo +nightly build -p +vortex-ffi`. -## Update the C header +## Running tests with sanitizers -Regenerate `vortex-ffi/cinclude/vortex.h`: - -```sh -cargo +nightly build -p vortex-ffi -``` - -## Sanitizer tests - -### Rust and C/C++ together - -Requires nightly Rust and upstream LLVM Clang. See the -[sanitizer guide](../lang/cpp/README.md#sanitizers) for scope and alternatives. +C tests with sanitizer also require clang. To run them, ```sh rustup toolchain install nightly --component rust-src @@ -70,22 +52,20 @@ ctest --test-dir build/ffi-asan --output-on-failure For ThreadSanitizer, use `-DVORTEX_SANITIZER=tsan` and set `TSAN_OPTIONS=suppressions=/absolute/path/to/vortex/vortex-ffi/tsan_suppressions.txt`. -Pipe `build/ffi-asan/test/vortex_ffi_test` output through `rustfilt -i-` to demangle Rust symbols. - -### Rust only - -Use nightly with `rust-src` installed. This example uses the native Linux x86_64 target: +To run only Rust-side tests with sanitizers on x86_64, ```sh +# -Zsanitizer=memory and -Zsanitizer=thread are other options RUSTFLAGS="-Zsanitizer=address -Cunsafe-allow-abi-mismatch=sanitizer" \ cargo +nightly test -p vortex-ffi -Zbuild-std \ --target x86_64-unknown-linux-gnu --tests -- --no-capture ``` -Substitute your native target. Use `-Zsanitizer=memory` for MemorySanitizer or -`-Zsanitizer=thread` for ThreadSanitizer, with the suppression file above. +## Driving the runtime -- `-Zbuild-std` instruments std to avoid memory/thread sanitizer false positives. -- `-Cunsafe-allow-abi-mismatch=sanitizer` allows deliberately uninstrumented dependencies. -- `--tests` excludes doctests, which do not inherit `RUSTFLAGS`. -- Prefer `cargo test` over nextest for leak detection. Use `llvm-symbolizer` for stack traces. +Vortex is an async library which means it requires an underlying runtime, a +thread scheduler. By default, Vortex uses host threads to drive the runtime, +i.e. calling a Vortex function like `vx_data_source_scan` on multiple threads +drives the runtime on the caller threads. You can create an explicit thread pool +inside Vortex by calling `vx_runtime_set_worker_threads(n)`. After this call, +Vortex will drive the runtime on the internal thread pool and not host threads. diff --git a/vortex-ffi/test/CMakeLists.txt b/vortex-ffi/test/CMakeLists.txt index 5daf85f5244..4ddfa7b6f11 100644 --- a/vortex-ffi/test/CMakeLists.txt +++ b/vortex-ffi/test/CMakeLists.txt @@ -24,6 +24,14 @@ target_compile_options(vortex_ffi_test PRIVATE -Wall -Wextra -Wpedantic) if(VORTEX_WARNINGS_AS_ERRORS) target_compile_options(vortex_ffi_test PRIVATE -Werror) endif() + +# Catch2 test macros expand to __COUNTER__, which newer clang flags as a C2y extension under +# -Wpedantic. Check the positive flag: GCC accepts unknown -Wno-* flags without a diagnostic. +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-Wc2y-extensions VORTEX_HAS_WC2Y_EXTENSIONS) +if(VORTEX_HAS_WC2Y_EXTENSIONS) + target_compile_options(vortex_ffi_test PRIVATE -Wno-c2y-extensions) +endif() target_link_libraries(vortex_ffi_test PRIVATE Vortex::ffi Catch2::Catch2WithMain diff --git a/vortex-file/src/tests.rs b/vortex-file/src/tests.rs index 3a88d48a1dd..70b842cc487 100644 --- a/vortex-file/src/tests.rs +++ b/vortex-file/src/tests.rs @@ -179,13 +179,13 @@ async fn test_eof_values() { #[rstest] #[case::default( BtrBlocksCompressorBuilder::from_session(&SESSION), - if cfg!(feature = "zstd") { 70_052 } else { 69_988 } + if cfg!(feature = "zstd") { 70_060 } else { 69_996 } )] #[cfg_attr( feature = "zstd", case::compact( BtrBlocksCompressorBuilder::from_session(&SESSION).with_compact(), - 55_136 + 55_144 ) )] #[tokio::test] @@ -2776,68 +2776,16 @@ async fn test_file_metadata_malformed_alignment_returns_error_on_default_open() } #[tokio::test] -async fn timestamp_unit_mismatch() -> Result<(), Box> { - // Write file with MILLISECONDS timestamps - let ts_array = PrimitiveArray::from_iter(vec![1704067200000i64, 1704153600000, 1704240000000]) - .into_array(); - let temporal = TemporalArray::new_timestamp(ts_array, TimeUnit::Milliseconds, None); - - let mut buf = ByteBufferMut::empty(); - SESSION - .write_options() - .write(&mut buf, temporal.into_array().to_array_stream()) - .await?; - - // Read with SECONDS filter scalar - let filter_expr = gt( - root(), - lit(Scalar::extension::( - TimestampOptions { - unit: TimeUnit::Seconds, - tz: None, - }, - Scalar::from(1704153600i64), - )), - ); - - let file = SESSION.open_options().open_buffer(buf)?; - let filter = filter_expr.bind(file.dtype())?.optimize_recursive()?; - let mut stream = file.scan()?.with_filter(filter).into_array_stream()?; - let result = stream.try_next().await; - - assert!(result.is_err()); - - Ok(()) -} - -/// Regression test: filtering a milliseconds timestamp column with a seconds scalar should -/// always error, regardless of how the internal children of `DateTimePartsArray` are encoded. -/// -/// The compressor's built-in constant detection encodes the seconds/subseconds children -/// (`[0, 0, 0]`) as `ConstantArray`s. The scanner should still detect the time unit -/// mismatch and error, not silently return wrong results. -#[tokio::test] -async fn timestamp_unit_mismatch_errors_with_constant_children() --> Result<(), Box> { - let compressor = vortex_btrblocks::BtrBlocksCompressor::from_session(&SESSION); - - // Write file with MILLISECONDS timestamps using this compressor. - let ts_array = PrimitiveArray::from_iter(vec![1704067200000i64, 1704153600000, 1704240000000]) - .into_array(); +async fn test_timestamp_unit_mismatch_fails_binding() -> VortexResult<()> { + let ts_array = buffer![1000i64].into_array(); let temporal = TemporalArray::new_timestamp(ts_array, TimeUnit::Milliseconds, None); - let strategy = crate::strategy::WriteStrategyBuilder::from_session(&SESSION) - .with_compressor(compressor) - .build(); - let mut buf = ByteBufferMut::empty(); SESSION .write_options() - .with_strategy(strategy) .write(&mut buf, temporal.into_array().to_array_stream()) .await?; - // Read with SECONDS filter scalar — should error due to time unit mismatch. let filter_expr = gt( root(), lit(Scalar::extension::( @@ -2845,21 +2793,18 @@ async fn timestamp_unit_mismatch_errors_with_constant_children() unit: TimeUnit::Seconds, tz: None, }, - Scalar::from(1704153600i64), + Scalar::from(1i64), )), ); let file = SESSION.open_options().open_buffer(buf)?; - let filter = filter_expr.bind(file.dtype())?.optimize_recursive()?; - let stream = file.scan()?.with_filter(filter).into_array_stream()?; - let results = stream.try_collect::>().await; - + let error = filter_expr + .bind(file.dtype()) + .expect_err("timestamp filter units must match the file dtype when binding"); assert!( - results.is_err(), - "Expected error from timestamp unit mismatch (ms vs s), but got {} results. \ - This indicates the scanner silently applied the filter incorrectly when \ - DateTimePartsArray children use ConstantArray encoding.", - results?.len() + error + .to_string() + .contains("Comparison requires equal dtypes ignoring nullability") ); Ok(()) diff --git a/vortex-file/src/writer.rs b/vortex-file/src/writer.rs index 3102bc36339..659fe70b656 100644 --- a/vortex-file/src/writer.rs +++ b/vortex-file/src/writer.rs @@ -23,6 +23,8 @@ use vortex_array::ArrayContext; use vortex_array::ArrayId; use vortex_array::ArrayRef; use vortex_array::aggregate_fn::AggregateFnRef; +use vortex_array::aggregate_fn::AggregateFnVTable; +use vortex_array::aggregate_fn::fns::min::Min; use vortex_array::dtype::DType; use vortex_array::dtype::FieldPath; use vortex_array::iter::ArrayIterator; @@ -281,6 +283,7 @@ impl VortexWriteOptions { .with_buffered_bytes_tracker(self.buffered_bytes.clone()); let ctx = if enforce_editions { ctx.with_allowed_aggregates(edition_filter(&self.session, ComponentKind::Aggregate)) + .with_allowed_layouts(edition_filter(&self.session, ComponentKind::Layout)) } else { ctx }; @@ -320,11 +323,17 @@ impl VortexWriteOptions { // When unset, `accumulate_stats` resolves each leaf's own default from its dtype, the way // `default_zoned_aggregate_fns` does for zoned layouts (e.g. bounded min/max for // variable-length columns), rather than a single dtype-blind default applied uniformly. + // Editions before the aggregates (for example `core2025.10.0`) do not permit `Min`, so the + // nested statistics would have no min and max. Readers of these editions use only the + // legacy format, so these editions get the legacy statistics only. + let write_nested_statistics = + self.write_nested_statistics && ctx.allows_aggregate(&Min.id()); + let (file_stats, stream) = accumulate_stats( stream, file_statistics, &self.session, - self.write_nested_statistics, + write_nested_statistics, self.write_legacy_statistics, &ctx, )?; @@ -370,7 +379,7 @@ impl VortexWriteOptions { // Assemble the Footer object now that we have all the segments. let statistics = if omit_statistics { None - } else if self.write_nested_statistics { + } else if write_nested_statistics { Some(FileStatistics::new_with_dtype( file_stats.aggregate_stats()?.into(), file_stats.legacy_aggregate_stats()?.into(), diff --git a/vortex-jni/src/file.rs b/vortex-jni/src/file.rs index 552d36675c7..9799b7d9139 100644 --- a/vortex-jni/src/file.rs +++ b/vortex-jni/src/file.rs @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright the Vortex contributors //! Small utility JNI entry points for listing, deleting, and reading the user-defined -//! metadata of Vortex files. +//! metadata and column statistics of Vortex files. use std::sync::Arc; @@ -19,6 +19,7 @@ use jni::sys::jobject; use vortex::buffer::ByteBuffer; use vortex::error::VortexResult; use vortex::error::vortex_err; +use vortex::file::VortexFile; use vortex::file::multi::open_cached; use vortex::file::multi::parse_uri_or_path; use vortex::io::VortexReadAt; @@ -32,6 +33,9 @@ use crate::errors::try_or_throw; use crate::io::java_readable; use crate::object_store::object_store_fs; use crate::session::session_ref; +use crate::statistics::ColumnStatistics; +use crate::statistics::column_statistics_to_java; +use crate::statistics::source_column_statistics; /// Extract a Java `Map` into a Rust [`HashMap`]. pub(crate) fn extract_properties( @@ -117,27 +121,92 @@ fn metadata_to_java( Ok(raw) } -/// Open a Vortex file with metadata resolution enabled and collect its metadata segments. +/// Open a Vortex file through the session footer cache. /// -/// `cache_key` identifies the file in the session footer cache. Both entry points name the file +/// `cache_key` identifies the file in the session footer cache. All entry points name the file /// the same way the scan path does — the object-store path, or the `NativeReadable`'s name — so a -/// metadata read and a later scan of the same file share one footer read. -fn read_metadata_segments( +/// metadata or statistics read and a later scan of the same file share one footer read. +fn open_file( session: &VortexSession, source: Arc, cache_key: &str, file_size: Option, -) -> VortexResult> { - RUNTIME.block_on(async move { - let file = open_cached(session, Some(cache_key), source, file_size, &|options| { - options.include_metadata() - }) - .await?; - Ok(file - .metadata_segments() - .map(|(key, value)| (key.to_string(), value.clone())) - .collect()) - }) + include_metadata: bool, +) -> VortexResult { + RUNTIME.block_on(open_cached( + session, + Some(cache_key), + source, + file_size, + &|options| options.with_include_metadata(include_metadata), + )) +} + +/// Collect the user-defined metadata segments of an opened Vortex file. +fn metadata_segments(file: &VortexFile) -> Vec<(String, ByteBuffer)> { + file.metadata_segments() + .map(|(key, value)| (key.to_string(), value.clone())) + .collect() +} + +/// Open the Vortex file at `uri` through a native storage client. +/// +/// The cache key is the object-store path, as on the scan path. +fn open_uri_file( + env: &mut jni::Env, + session: &VortexSession, + uri: &JString, + options: &JObject, + include_metadata: bool, +) -> Result { + let uri: String = uri.try_to_string(env)?; + let url = parse_uri_or_path(&uri)?; + let properties = extract_properties(env, options)?; + + let (fs, path) = object_store_fs(&url, &properties, session.handle())?; + let source = RUNTIME.block_on(async { fs.open_read(&path).await })?; + + Ok(open_file(session, source, &path, None, include_metadata)?) +} + +/// Open a Vortex file through a caller-provided `dev.vortex.io.NativeReadable`, so no native +/// storage client is created. +/// +/// `name` is the readable's `name()`, which the interface requires to be stable and unique; it +/// keys the file in the session footer cache, as it does for the scan path. +fn open_readable_file( + env: &mut jni::Env, + session: &VortexSession, + readable: &JObject, + name: &JString, + length: jlong, + include_metadata: bool, +) -> Result { + if readable.is_null() { + throw_runtime!("null readable"); + } + let name: String = name.try_to_string(env)?; + if name.is_empty() { + throw_runtime!("readable name must not be empty"); + } + let length = + u64::try_from(length).map_err(|_| vortex_err!("negative readable length: {length}"))?; + + let vm = env.get_java_vm()?; + let readable = Arc::new(env.new_global_ref(readable)?); + let source = java_readable(vm, readable, length, session.handle()); + + // `MultiFileDataSource` strips leading slashes and the scan path keys Java readables by + // that same normalized form, so normalize here too — otherwise a read through this function + // and a scan of the same readable would land on two different cache entries. + let cache_key = name.trim_start_matches('/'); + Ok(open_file( + session, + source, + cache_key, + Some(length), + include_metadata, + )?) } /// Read the user-defined metadata segments of the Vortex file at `uri`. @@ -154,15 +223,8 @@ pub extern "system" fn Java_dev_vortex_jni_NativeFiles_readMetadata( ) -> jobject { try_or_throw(&mut env, |env| { let session = unsafe { session_ref(session_ptr) }; - let uri: String = uri.try_to_string(env)?; - let url = parse_uri_or_path(&uri)?; - let properties = extract_properties(env, &options)?; - - let (fs, path) = object_store_fs(&url, &properties, session.handle())?; - let source = RUNTIME.block_on(async { fs.open_read(&path).await })?; - - let segments = read_metadata_segments(session, source, &path, None)?; - metadata_to_java(env, segments) + let file = open_uri_file(env, session, &uri, &options, true)?; + metadata_to_java(env, metadata_segments(&file)) }) } @@ -182,26 +244,56 @@ pub extern "system" fn Java_dev_vortex_jni_NativeFiles_readMetadataFromReadable( ) -> jobject { try_or_throw(&mut env, |env| { let session = unsafe { session_ref(session_ptr) }; - if readable.is_null() { - throw_runtime!("null readable"); - } - let name: String = name.try_to_string(env)?; - if name.is_empty() { - throw_runtime!("readable name must not be empty"); - } - let length = - u64::try_from(length).map_err(|_| vortex_err!("negative readable length: {length}"))?; - - let vm = env.get_java_vm()?; - let readable = Arc::new(env.new_global_ref(&readable)?); - let source = java_readable(vm, readable, length, session.handle()); - - // `MultiFileDataSource` strips leading slashes and the scan path keys Java readables by - // that same normalized form, so normalize here too — otherwise a metadata read and a - // scan of the same readable would land on two different cache entries. - let cache_key = name.trim_start_matches('/'); - let segments = read_metadata_segments(session, source, cache_key, Some(length))?; - metadata_to_java(env, segments) + let file = open_readable_file(env, session, &readable, &name, length, true)?; + metadata_to_java(env, metadata_segments(&file)) + }) +} + +/// Read the statistics of each top-level column of an opened Vortex file through its data +/// source, so stored aggregate partials come before the legacy statistics. +fn read_column_statistics(file: &VortexFile) -> VortexResult> { + let source = file.data_source()?; + RUNTIME.block_on(source_column_statistics(source.as_ref(), file.footer())) +} + +/// Read the per-column statistics of the Vortex file at `uri`. +/// +/// Returns a `dev.vortex.api.VortexColumnStatistics[]` in schema order. The statistics come +/// from the file footer, so no column data is read. +#[unsafe(no_mangle)] +pub extern "system" fn Java_dev_vortex_jni_NativeFiles_readStatistics( + mut env: EnvUnowned, + _class: JClass, + session_ptr: jlong, + uri: JString, + options: JObject, +) -> jobject { + try_or_throw(&mut env, |env| { + let session = unsafe { session_ref(session_ptr) }; + let file = open_uri_file(env, session, &uri, &options, false)?; + let statistics = read_column_statistics(&file)?; + Ok(column_statistics_to_java(env, file.footer(), statistics)?.into_raw()) + }) +} + +/// Read the per-column statistics of a Vortex file through a caller-provided +/// `dev.vortex.io.NativeReadable`, so no native storage client is created. +/// +/// See [`Java_dev_vortex_jni_NativeFiles_readStatistics`] for the return value. +#[unsafe(no_mangle)] +pub extern "system" fn Java_dev_vortex_jni_NativeFiles_readStatisticsFromReadable( + mut env: EnvUnowned, + _class: JClass, + session_ptr: jlong, + readable: JObject, + name: JString, + length: jlong, +) -> jobject { + try_or_throw(&mut env, |env| { + let session = unsafe { session_ref(session_ptr) }; + let file = open_readable_file(env, session, &readable, &name, length, false)?; + let statistics = read_column_statistics(&file)?; + Ok(column_statistics_to_java(env, file.footer(), statistics)?.into_raw()) }) } diff --git a/vortex-jni/src/io/mod.rs b/vortex-jni/src/io/mod.rs index ce49e45c09c..34ab6ab9623 100644 --- a/vortex-jni/src/io/mod.rs +++ b/vortex-jni/src/io/mod.rs @@ -66,12 +66,19 @@ pub(crate) fn with_jvm( /// exits, so attach them as daemons; `with_jvm` then reuses the attachment. #[cfg(not(windows))] fn attach_as_daemon(vm: &JavaVM) -> VortexResult<()> { + // An upcall from another thread-local destructor can run after this slot is gone. Storing the + // guard would then panic inside a destructor, so leave the attachment to the jni crate. + if DAEMON_ATTACHMENT.try_with(|_| ()).is_err() { + return Ok(()); + } + if vm .is_thread_attached() .map_err(|e| vortex_err!("cannot check the JVM attachment: {e}"))? { return Ok(()); } + let raw = vm.get_raw(); let mut env = std::ptr::null_mut(); // SAFETY: `raw` is the live JavaVM `vm` wraps, and a null `args` attaches with defaults. @@ -81,6 +88,7 @@ fn attach_as_daemon(vm: &JavaVM) -> VortexResult<()> { if result != jni::sys::JNI_OK { vortex_bail!("failed to attach a native thread to the JVM as a daemon: {result}"); } + DAEMON_ATTACHMENT.with(|attachment| *attachment.borrow_mut() = Some(DaemonAttachment(raw))); Ok(()) } diff --git a/vortex-jni/src/lib.rs b/vortex-jni/src/lib.rs index 86c1f6f1381..8066b881432 100644 --- a/vortex-jni/src/lib.rs +++ b/vortex-jni/src/lib.rs @@ -30,6 +30,7 @@ mod object_store; mod runtime; mod scan; mod session; +mod statistics; mod writer; /// Shared current-thread runtime backing every JNI call. Using a current-thread diff --git a/vortex-jni/src/session.rs b/vortex-jni/src/session.rs index 134694848ee..5bd27e89990 100644 --- a/vortex-jni/src/session.rs +++ b/vortex-jni/src/session.rs @@ -5,16 +5,19 @@ use jni::EnvUnowned; use jni::objects::JClass; +use jni::objects::JString; use jni::sys::jlong; use vortex::VortexSessionDefault; use vortex::editions::CORE_2026_08_3; use vortex::editions::EditionSessionExt; use vortex::error::VortexExpect; +use vortex::error::vortex_err; use vortex::io::runtime::BlockingRuntime; use vortex::io::session::RuntimeSessionExt; use vortex::session::VortexSession; use crate::RUNTIME; +use crate::errors::try_or_throw; use crate::writer::register_list_layout_edition; /// Constructs a fresh [`VortexSession`] bound to the JNI-shared tokio runtime and returns @@ -53,3 +56,34 @@ pub extern "system" fn Java_dev_vortex_jni_NativeSession_free( // SAFETY: pointer must have been created by `newSession` and not yet freed. drop(unsafe { Box::from_raw(pointer as *mut VortexSession) }); } + +/// Enables the edition that has the name `edition` (for example `core2025.10.0`) for writes. +/// +/// The edition replaces the enabled edition of the same family. Writers that start after this +/// call use the new selection. Throws a `RuntimeException` if the session has no edition with +/// this name. +#[unsafe(no_mangle)] +pub extern "system" fn Java_dev_vortex_jni_NativeSession_enableEdition( + mut env: EnvUnowned, + _class: JClass, + pointer: jlong, + edition: JString, +) { + try_or_throw(&mut env, |env| { + let name: String = edition.try_to_string(env)?; + + // SAFETY: pointer must have been created by `newSession` and not yet freed. + let session = unsafe { session_ref(pointer) }; + + let edition = session + .editions() + .find_by_name(&name) + .ok_or_else(|| vortex_err!("Unknown Vortex edition: {name}"))?; + + session + .enable_edition(edition.id) + .map_err(|error| vortex_err!("{error}"))?; + + Ok(()) + }) +} diff --git a/vortex-jni/src/statistics.rs b/vortex-jni/src/statistics.rs new file mode 100644 index 00000000000..8cc148093e7 --- /dev/null +++ b/vortex-jni/src/statistics.rs @@ -0,0 +1,365 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +//! Conversion of the per-column statistics stored in a Vortex file footer into +//! `dev.vortex.api.VortexColumnStatistics` objects. +//! +//! A read resolves each statistic through the file's [`DataSource`]. It uses the stored +//! aggregate partials first, and falls back to the finalized legacy statistics only for a +//! statistic that has no partial. + +use jni::Env; +use jni::objects::JObject; +use jni::objects::JObjectArray; +use jni::objects::JValue; +use jni::sys::JNI_FALSE; +use jni::sys::JNI_TRUE; +use jni::sys::jlong; +use vortex::aggregate_fn::AggregateFnRef; +use vortex::array::scalar::PValue; +use vortex::array::scalar::Scalar; +use vortex::array::scalar::ScalarValue; +use vortex::array::stats::StatsSet; +use vortex::dtype::DType; +use vortex::dtype::FieldPath; +use vortex::error::VortexResult; +use vortex::error::vortex_err; +use vortex::expr::stats::Precision; +use vortex::expr::stats::Stat; +use vortex::file::Footer; +use vortex::layout::layouts::file_stats::AggregateStats; +use vortex::scan::DataSource; + +use crate::errors::JNIError; + +pub(crate) fn checked_jlong(value: u64, name: &str) -> VortexResult { + jlong::try_from(value).map_err(|_| vortex_err!("{name} exceeds Java long range: {value}")) +} + +/// Returns an exact count as a `jlong`, or `-1` when the count is not exact. +fn exact_count_jlong(count: Precision, name: &str) -> VortexResult { + count + .as_exact() + .and_then(|count| u64::try_from(&count).ok()) + .map(|value| checked_jlong(value, name)) + .transpose() + .map(|value| value.unwrap_or(-1)) +} + +fn big_integer<'local>( + env: &mut Env<'local>, + value: impl ToString, +) -> Result, JNIError> { + let string = env.new_string(value.to_string())?; + Ok(env.new_object( + jni::jni_str!("java/math/BigInteger"), + jni::jni_sig!("(Ljava/lang/String;)V"), + &[JValue::Object(string.as_ref())], + )?) +} + +fn scalar_to_java<'local>( + env: &mut Env<'local>, + scalar: Scalar, +) -> Result, JNIError> { + if scalar.is_null() { + return Ok(JObject::null()); + } + if scalar.dtype().is_extension() { + return scalar_to_java(env, scalar.as_extension().to_storage_scalar()); + } + + let Some(value) = scalar.value() else { + return Ok(JObject::null()); + }; + match value { + ScalarValue::Bool(value) => Ok(env.new_object( + jni::jni_str!("java/lang/Boolean"), + jni::jni_sig!("(Z)V"), + &[JValue::Bool(if *value { JNI_TRUE } else { JNI_FALSE })], + )?), + ScalarValue::Primitive(value) => match value { + PValue::U8(_) | PValue::U16(_) | PValue::I8(_) | PValue::I16(_) | PValue::I32(_) => { + Ok(env.new_object( + jni::jni_str!("java/lang/Integer"), + jni::jni_sig!("(I)V"), + &[JValue::Int(value.cast::()?)], + )?) + } + PValue::U32(_) | PValue::I64(_) => Ok(env.new_object( + jni::jni_str!("java/lang/Long"), + jni::jni_sig!("(J)V"), + &[JValue::Long(value.cast::()?)], + )?), + PValue::U64(value) => big_integer(env, value), + PValue::F16(_) | PValue::F32(_) => Ok(env.new_object( + jni::jni_str!("java/lang/Float"), + jni::jni_sig!("(F)V"), + &[JValue::Float(value.cast::()?)], + )?), + PValue::F64(value) => Ok(env.new_object( + jni::jni_str!("java/lang/Double"), + jni::jni_sig!("(D)V"), + &[JValue::Double(*value)], + )?), + }, + ScalarValue::Decimal(value) => { + let DType::Decimal(decimal_dtype, _) = scalar.dtype() else { + return Err(JNIError::Vortex(vortex_err!( + "decimal statistic has non-decimal dtype {}", + scalar.dtype() + ))); + }; + let unscaled = big_integer(env, value.as_i256())?; + Ok(env.new_object( + jni::jni_str!("java/math/BigDecimal"), + jni::jni_sig!("(Ljava/math/BigInteger;I)V"), + &[ + JValue::Object(&unscaled), + JValue::Int(i32::from(decimal_dtype.scale())), + ], + )?) + } + ScalarValue::Utf8(value) => Ok(env.new_string(value.as_str())?.into()), + ScalarValue::Binary(value) => Ok(env.byte_array_from_slice(value.as_slice())?.into()), + ScalarValue::Tuple(_) | ScalarValue::Union(_) | ScalarValue::Variant(_) => { + Err(JNIError::Vortex(vortex_err!( + "cannot return nested scalar statistic with dtype {} to Java", + scalar.dtype() + ))) + } + } +} + +/// The statistics of one top-level column that are returned to Java. +pub(crate) struct ColumnStatistics { + null_count: Precision, + nan_count: Precision, + min: Precision, + max: Precision, +} + +impl ColumnStatistics { + /// Reads the statistics from the aggregates that a writer recorded in a footer. + fn from_aggregates(aggregates: Option<&AggregateStats>) -> Self { + let get = |stat: Stat| { + aggregates + .zip(stat.aggregate_fn()) + .map_or(Precision::Absent, |(aggregates, aggregate_fn)| { + aggregates.get(&aggregate_fn) + }) + }; + + Self { + null_count: get(Stat::NullCount), + nan_count: get(Stat::NaNCount), + min: get(Stat::Min), + max: get(Stat::Max), + } + } + + /// Reads the statistics of the field at `path` from `source`. + /// + /// Stored aggregate partials come first. The legacy statistics are read only when a + /// statistic has no partial, for example in a file written before partials were stored. + async fn from_source( + source: &dyn DataSource, + path: &FieldPath, + dtype: &DType, + ) -> VortexResult { + let mut legacy = None; + + Ok(Self { + null_count: resolve_statistic(source, path, dtype, Stat::NullCount, &mut legacy) + .await?, + nan_count: resolve_statistic(source, path, dtype, Stat::NaNCount, &mut legacy).await?, + min: resolve_statistic(source, path, dtype, Stat::Min, &mut legacy).await?, + max: resolve_statistic(source, path, dtype, Stat::Max, &mut legacy).await?, + }) + } +} + +/// Resolves one statistic of the field at `path`, first from its stored aggregate partial and +/// then from the legacy statistics. +/// +/// `legacy` caches the legacy statistics of the field, so they are read at most once. +async fn resolve_statistic( + source: &dyn DataSource, + path: &FieldPath, + dtype: &DType, + stat: Stat, + legacy: &mut Option, +) -> VortexResult> { + let aggregate_fn = stat + .aggregate_fn() + .ok_or_else(|| vortex_err!("statistic {stat} has no aggregate function"))?; + + let partial = source.field_statistic(path, &aggregate_fn).await?; + if !partial.is_absent() { + return partial + .map(|partial| finalize_partial(&aggregate_fn, dtype, &partial)) + .transpose(); + } + + if legacy.is_none() { + *legacy = Some(source.field_statistics(path).await?); + } + + let Some(stat_dtype) = stat.dtype(dtype) else { + return Ok(Precision::Absent); + }; + + Ok(legacy.as_ref().map_or(Precision::Absent, |legacy| { + legacy.get(stat).into_scalar(stat_dtype) + })) +} + +/// Computes the final value of `aggregate_fn` from a stored partial over a field of `dtype`. +fn finalize_partial( + aggregate_fn: &AggregateFnRef, + dtype: &DType, + partial: &Scalar, +) -> VortexResult { + let mut accumulator = aggregate_fn.accumulator(dtype)?; + accumulator.combine_partials(partial)?; + accumulator.final_scalar() +} + +/// Returns the path and dtype of each top-level column in schema order. +/// +/// A non-struct file has a single entry for its root column. +fn columns(footer: &Footer) -> Vec<(FieldPath, DType)> { + match footer.dtype().as_struct_fields_opt() { + Some(fields) => fields + .names() + .iter() + .zip(fields.fields()) + .map(|(name, dtype)| (FieldPath::from_name(name.clone()), dtype)) + .collect(), + None => vec![(FieldPath::root(), footer.dtype().clone())], + } +} + +/// Reads the statistics of each top-level column from the aggregates in `footer`. +/// +/// Use this for a footer that a writer just produced, which has no legacy statistics to fall +/// back to. +pub(crate) fn footer_column_statistics(footer: &Footer) -> Vec { + columns(footer) + .iter() + .map(|(path, _)| { + let aggregates = footer + .statistics() + .and_then(|statistics| statistics.get_by_path(path)) + .map(|(aggregates, _)| aggregates); + ColumnStatistics::from_aggregates(aggregates) + }) + .collect() +} + +/// Reads the statistics of each top-level column of the file that `footer` describes from +/// `source`, the data source of that file. +pub(crate) async fn source_column_statistics( + source: &dyn DataSource, + footer: &Footer, +) -> VortexResult> { + let mut statistics = Vec::new(); + for (path, dtype) in columns(footer) { + statistics.push(ColumnStatistics::from_source(source, &path, &dtype).await?); + } + + Ok(statistics) +} + +/// Returns the compressed size in bytes of each top-level column in schema order. +/// +/// A non-struct file has a single entry for its root column. +fn compressed_column_sizes(footer: &Footer) -> VortexResult> { + let sizes = footer.compressed_field_sizes()?; + let Some(fields) = footer.dtype().as_struct_fields_opt() else { + return Ok(vec![sizes.total()]); + }; + + Ok(fields + .names() + .iter() + .map(|name| { + sizes + .get(&FieldPath::from_name(name.clone())) + .unwrap_or_default() + }) + .collect()) +} + +/// Build a `dev.vortex.api.VortexColumnStatistics[]` with one entry per top-level column of +/// the file that `footer` describes. +/// +/// `statistics` holds one entry per top-level column in schema order. The compressed sizes come +/// from the footer, so this performs no IO. +pub(crate) fn column_statistics_to_java<'local>( + env: &mut Env<'local>, + footer: &Footer, + statistics: Vec, +) -> Result, JNIError> { + let column_sizes = compressed_column_sizes(footer)?; + if column_sizes.len() != statistics.len() { + return Err(vortex_err!( + "expected statistics for {} columns, got {}", + column_sizes.len(), + statistics.len() + ) + .into()); + } + + let row_count = checked_jlong(footer.row_count(), "row count")?; + let columns = env.new_object_array( + i32::try_from(column_sizes.len()) + .map_err(|_| vortex_err!("column count exceeds Java array range"))?, + jni::jni_str!("dev/vortex/api/VortexColumnStatistics"), + JObject::null(), + )?; + + for (column_index, (compressed_size, column_statistics)) in + column_sizes.into_iter().zip(statistics).enumerate() + { + let ColumnStatistics { + null_count, + nan_count, + min, + max, + } = column_statistics; + let null_count = exact_count_jlong(null_count, "null count")?; + let nan_count = exact_count_jlong(nan_count, "NaN count")?; + + let column = env.with_local_frame_returning_local::<_, JObject, JNIError>(16, |env| { + let lower_bound = match min.into_inner() { + Some(value) => scalar_to_java(env, value)?, + None => JObject::null(), + }; + let upper_bound = match max.into_inner() { + Some(value) => scalar_to_java(env, value)?, + None => JObject::null(), + }; + Ok(env.new_object( + jni::jni_str!("dev/vortex/api/VortexColumnStatistics"), + jni::jni_sig!("(IJJJJLjava/lang/Object;Ljava/lang/Object;)V"), + &[ + JValue::Int( + i32::try_from(column_index) + .map_err(|_| vortex_err!("column index exceeds Java int range"))?, + ), + JValue::Long(checked_jlong(compressed_size, "compressed column size")?), + JValue::Long(row_count), + JValue::Long(null_count), + JValue::Long(nan_count), + JValue::Object(&lower_bound), + JValue::Object(&upper_bound), + ], + )?) + })?; + columns.set_element(env, column_index, &column)?; + env.delete_local_ref(column); + } + + Ok(columns) +} diff --git a/vortex-jni/src/writer.rs b/vortex-jni/src/writer.rs index 75ad2260ac7..d0c243ac61f 100644 --- a/vortex-jni/src/writer.rs +++ b/vortex-jni/src/writer.rs @@ -35,21 +35,9 @@ use jni::sys::jlong; use jni::sys::jobject; use object_store::ObjectStore; use object_store::path::Path as ObjectStorePath; -use vortex::aggregate_fn::AggregateFnRef; -use vortex::aggregate_fn::AggregateFnVTableExt; -use vortex::aggregate_fn::EmptyOptions; -use vortex::aggregate_fn::NumericalAggregateOpts; -use vortex::aggregate_fn::fns::max::Max; -use vortex::aggregate_fn::fns::min::Min; -use vortex::aggregate_fn::fns::nan_count::NanCount; -use vortex::aggregate_fn::fns::null_count::NullCount; use vortex::array::ArrayRef; -use vortex::array::scalar::PValue; -use vortex::array::scalar::Scalar; -use vortex::array::scalar::ScalarValue; use vortex::array::stream::ArrayStreamAdapter; use vortex::dtype::DType; -use vortex::dtype::FieldPath; use vortex::editions::Edition; use vortex::editions::EditionDeclaration; use vortex::editions::EditionFamily; @@ -71,7 +59,6 @@ use vortex::io::runtime::BlockingRuntime; use vortex::io::runtime::Task; use vortex::io::session::RuntimeSessionExt; use vortex::layout::BufferedBytesTracker; -use vortex::layout::layouts::file_stats::AggregateStats; use vortex::session::VortexSession; use vortex::utils::aliases::hash_map::HashMap; use vortex_arrow::ArrowSessionExt; @@ -86,6 +73,9 @@ use crate::file::extract_properties; use crate::io::JavaWrite; use crate::object_store::make_object_store; use crate::session::session_ref; +use crate::statistics::checked_jlong; +use crate::statistics::column_statistics_to_java; +use crate::statistics::footer_column_statistics; /// Capacity of the in-flight write queue. Small on purpose so that back-pressure from /// the writer is felt on the Java thread producing batches. @@ -195,170 +185,12 @@ impl NativeWriter { } } -fn checked_jlong(value: u64, name: &str) -> VortexResult { - jlong::try_from(value).map_err(|_| vortex_err!("{name} exceeds Java long range: {value}")) -} - -fn exact_count_jlong( - aggregates: Option<&AggregateStats>, - aggregate_fn: &AggregateFnRef, -) -> VortexResult { - aggregates - .and_then(|aggregates| aggregates.get(aggregate_fn).as_exact()) - .and_then(|count| u64::try_from(&count).ok()) - .map(|value| checked_jlong(value, &aggregate_fn.to_string())) - .transpose() - .map(|value| value.unwrap_or(-1)) -} - -fn big_integer<'local>( - env: &mut Env<'local>, - value: impl ToString, -) -> Result, JNIError> { - let string = env.new_string(value.to_string())?; - Ok(env.new_object( - jni::jni_str!("java/math/BigInteger"), - jni::jni_sig!("(Ljava/lang/String;)V"), - &[JValue::Object(string.as_ref())], - )?) -} - -fn scalar_to_java<'local>( - env: &mut Env<'local>, - scalar: Scalar, -) -> Result, JNIError> { - if scalar.is_null() { - return Ok(JObject::null()); - } - if scalar.dtype().is_extension() { - return scalar_to_java(env, scalar.as_extension().to_storage_scalar()); - } - - let Some(value) = scalar.value() else { - return Ok(JObject::null()); - }; - match value { - ScalarValue::Bool(value) => Ok(env.new_object( - jni::jni_str!("java/lang/Boolean"), - jni::jni_sig!("(Z)V"), - &[JValue::Bool(if *value { JNI_TRUE } else { JNI_FALSE })], - )?), - ScalarValue::Primitive(value) => match value { - PValue::U8(_) | PValue::U16(_) | PValue::I8(_) | PValue::I16(_) | PValue::I32(_) => { - Ok(env.new_object( - jni::jni_str!("java/lang/Integer"), - jni::jni_sig!("(I)V"), - &[JValue::Int(value.cast::()?)], - )?) - } - PValue::U32(_) | PValue::I64(_) => Ok(env.new_object( - jni::jni_str!("java/lang/Long"), - jni::jni_sig!("(J)V"), - &[JValue::Long(value.cast::()?)], - )?), - PValue::U64(value) => big_integer(env, value), - PValue::F16(_) | PValue::F32(_) => Ok(env.new_object( - jni::jni_str!("java/lang/Float"), - jni::jni_sig!("(F)V"), - &[JValue::Float(value.cast::()?)], - )?), - PValue::F64(value) => Ok(env.new_object( - jni::jni_str!("java/lang/Double"), - jni::jni_sig!("(D)V"), - &[JValue::Double(*value)], - )?), - }, - ScalarValue::Decimal(value) => { - let DType::Decimal(decimal_dtype, _) = scalar.dtype() else { - return Err(JNIError::Vortex(vortex_err!( - "decimal statistic has non-decimal dtype {}", - scalar.dtype() - ))); - }; - let unscaled = big_integer(env, value.as_i256())?; - Ok(env.new_object( - jni::jni_str!("java/math/BigDecimal"), - jni::jni_sig!("(Ljava/math/BigInteger;I)V"), - &[ - JValue::Object(&unscaled), - JValue::Int(i32::from(decimal_dtype.scale())), - ], - )?) - } - ScalarValue::Utf8(value) => Ok(env.new_string(value.as_str())?.into()), - ScalarValue::Binary(value) => Ok(env.byte_array_from_slice(value.as_slice())?.into()), - ScalarValue::Tuple(_) | ScalarValue::Union(_) | ScalarValue::Variant(_) => { - Err(JNIError::Vortex(vortex_err!( - "cannot return nested scalar write statistic with dtype {} to Java", - scalar.dtype() - ))) - } - } -} - fn write_summary_to_java<'local>( env: &mut Env<'local>, summary: &WriteSummary, ) -> Result, JNIError> { - let column_sizes = summary.compressed_column_sizes()?; - let file_stats = summary.footer().statistics(); - let struct_fields = summary.footer().dtype().as_struct_fields_opt(); - let columns = env.new_object_array( - i32::try_from(column_sizes.len()) - .map_err(|_| vortex_err!("column count exceeds Java array range"))?, - jni::jni_str!("dev/vortex/api/VortexColumnStatistics"), - JObject::null(), - )?; - - for (column_index, compressed_size) in column_sizes.into_iter().enumerate() { - let aggregates = struct_fields - .and_then(|fields| fields.names().get(column_index)) - .zip(file_stats) - .and_then(|(name, all_stats)| { - all_stats.get_by_path(&FieldPath::from_name(name.clone())) - }) - .map(|(aggregates, _)| aggregates); - let null_count = exact_count_jlong(aggregates, &NullCount.bind(EmptyOptions))?; - let nan_count = exact_count_jlong(aggregates, &NanCount.bind(EmptyOptions))?; - let lower_bound = aggregates.and_then(|aggregates| { - aggregates - .get(&Min.bind(NumericalAggregateOpts::skip_nans())) - .into_inner() - }); - let upper_bound = aggregates.and_then(|aggregates| { - aggregates - .get(&Max.bind(NumericalAggregateOpts::skip_nans())) - .into_inner() - }); - let column = env.with_local_frame_returning_local::<_, JObject, JNIError>(16, |env| { - let lower_bound = match lower_bound { - Some(value) => scalar_to_java(env, value)?, - None => JObject::null(), - }; - let upper_bound = match upper_bound { - Some(value) => scalar_to_java(env, value)?, - None => JObject::null(), - }; - Ok(env.new_object( - jni::jni_str!("dev/vortex/api/VortexColumnStatistics"), - jni::jni_sig!("(IJJJJLjava/lang/Object;Ljava/lang/Object;)V"), - &[ - JValue::Int( - i32::try_from(column_index) - .map_err(|_| vortex_err!("column index exceeds Java int range"))?, - ), - JValue::Long(checked_jlong(compressed_size, "compressed column size")?), - JValue::Long(checked_jlong(summary.row_count(), "row count")?), - JValue::Long(null_count), - JValue::Long(nan_count), - JValue::Object(&lower_bound), - JValue::Object(&upper_bound), - ], - )?) - })?; - columns.set_element(env, column_index, &column)?; - env.delete_local_ref(column); - } + let statistics = footer_column_statistics(summary.footer()); + let columns = column_statistics_to_java(env, summary.footer(), statistics)?; Ok(env.new_object( jni::jni_str!("dev/vortex/api/VortexWriteSummary"), diff --git a/vortex-layout/src/layouts/file_stats.rs b/vortex-layout/src/layouts/file_stats.rs index 06a10742df8..ddde8c163b8 100644 --- a/vortex-layout/src/layouts/file_stats.rs +++ b/vortex-layout/src/layouts/file_stats.rs @@ -236,6 +236,20 @@ fn non_null(value: Precision) -> Precision { value.and_then(|value| (!value.is_null()).then_some(value)) } +/// Returns whether `aggregate_fn` gives a value to a slot of the legacy stats, exactly or +/// approximately, as [`AggregateStats::to_stats_set`] fills them. For example, the bounded min of +/// a string column fills the min slot. +fn fills_legacy_stat_slot(aggregate_fn: &AggregateFnRef) -> bool { + Stat::all() + .filter_map(|stat| stat.aggregate_fn()) + .any(|requested| { + !matches!( + aggregate_fn.can_satisfy(&requested), + AggregateFnSatisfaction::No + ) + }) +} + /// Accumulates write-time statistics for a single file column. struct StatsAccumulator { aggregates: Vec<(AggregateFnRef, AccumulatorRef)>, @@ -668,8 +682,17 @@ impl FileStatsAccumulator { write_legacy_stats: bool, writer_ctx: &LayoutWriterContext, ) -> VortexResult { + let accumulates = |aggregate_fn: &AggregateFnRef| { + Self::accumulates( + writer_ctx, + write_nested_stats, + write_legacy_stats, + aggregate_fn, + ) + }; + for aggregate_fn in stats.iter().flat_map(|stats| stats.iter()) { - if !writer_ctx.allows_aggregate(&aggregate_fn.id()) { + if !accumulates(aggregate_fn) { vortex_bail!("Aggregate {} not permitted by ctx", aggregate_fn.id()); } } @@ -677,7 +700,7 @@ impl FileStatsAccumulator { let root = StatsNode::build_root( dtype, stats.as_deref(), - &|aggregate_fn| writer_ctx.allows_aggregate(&aggregate_fn.id()), + &accumulates, write_nested_stats, write_legacy_stats, ); @@ -698,7 +721,14 @@ impl FileStatsAccumulator { let mut node = StatsNode::build_root( &self.dtype, self.stats.as_deref(), - &|aggregate_fn| self.writer_ctx.allows_aggregate(&aggregate_fn.id()), + &|aggregate_fn| { + Self::accumulates( + &self.writer_ctx, + self.write_nested_stats, + self.write_legacy_stats, + aggregate_fn, + ) + }, self.write_nested_stats, self.write_legacy_stats, ); @@ -706,6 +736,26 @@ impl FileStatsAccumulator { Ok(node) } + /// Returns whether the accumulators compute `aggregate_fn`. + /// + /// The nested layout records only the aggregates that `writer_ctx` permits. The legacy layout + /// stores its values in fixed stat slots and not as aggregates, so its readers do not need + /// the aggregate. Thus, when only the legacy layout is written, it also records an aggregate + /// that `writer_ctx` does not permit, if the aggregate fills a stat slot. Editions before the + /// aggregates (for example `core2025.10.0`) permit no `vortex.min`, but their readers read + /// min and max from the slots. + fn accumulates( + writer_ctx: &LayoutWriterContext, + write_nested_stats: bool, + write_legacy_stats: bool, + aggregate_fn: &AggregateFnRef, + ) -> bool { + let legacy_only = write_legacy_stats && !write_nested_stats; + + writer_ctx.allows_aggregate(&aggregate_fn.id()) + || (legacy_only && fills_legacy_stat_slot(aggregate_fn)) + } + /// Merges the stats of the chunk that follows all chunks merged so far. fn merge(&self, mut chunk_stats: StatsNode) -> VortexResult<()> { self.root.lock().merge_from(&mut chunk_stats) @@ -732,10 +782,17 @@ impl FileStatsAccumulator { /// Returns the legacy top-level-fields-only aggregates (one per top-level struct field, or a /// single entry for a non-struct root dtype), leaving out the aggregates the writer context - /// forbids. Each entry is empty if `write_legacy_stats` was `false`. + /// forbids. Without nested stats, an aggregate that fills a legacy stat slot is kept although the + /// writer context forbids it. Each entry is empty if `write_legacy_stats` was `false`. pub fn legacy_aggregate_stats(&self) -> VortexResult> { - let allowed = - |aggregate_fn: &AggregateFnRef| self.writer_ctx.allows_aggregate(&aggregate_fn.id()); + let allowed = |aggregate_fn: &AggregateFnRef| { + Self::accumulates( + &self.writer_ctx, + self.write_nested_stats, + self.write_legacy_stats, + aggregate_fn, + ) + }; let root = self.root.lock(); // Readers that predate nested stats reject a file whose legacy layout doesn't have one // entry per top-level field, so entries that aren't recorded are still written, empty. The diff --git a/vortex-layout/src/layouts/struct_/reader.rs b/vortex-layout/src/layouts/struct_/reader.rs index 248a7b249df..1b4b1b03c6b 100644 --- a/vortex-layout/src/layouts/struct_/reader.rs +++ b/vortex-layout/src/layouts/struct_/reader.rs @@ -2072,10 +2072,14 @@ mod tests { // DType mismatch: "age" is u8 but literal is i32 let filt = eq(col("age"), lit(67i32)); - let result = filt.bind(reader.dtype()); - assert!(result.is_err()); - let err = result.err().unwrap().to_string(); - assert!(err.contains("Cannot compare different DTypes"), "{err}"); + let error = filt + .bind(reader.dtype()) + .expect_err("the u8 column cannot be compared with an i32 literal"); + assert!( + error + .to_string() + .contains("Comparison requires equal dtypes ignoring nullability") + ); } /// Nine rows sorted by `(a, b)`; three zones of three; `c` copies `b` with nulls. diff --git a/vortex-layout/src/layouts/zoned/legacy_builder.rs b/vortex-layout/src/layouts/zoned/legacy_builder.rs new file mode 100644 index 00000000000..477e00406b7 --- /dev/null +++ b/vortex-layout/src/layouts/zoned/legacy_builder.rs @@ -0,0 +1,307 @@ +//! Write-time accumulation of legacy `vortex.stats` zone tables. +//! +//! Readers before `vortex.zoned` (Vortex 0.83 and earlier) only know the `vortex.stats` layout. +//! Its zone table holds one column for each [`Stat`], in [`Stat`] order. A `max` or `min` column +//! has a `max_is_truncated` or `min_is_truncated` column after it. This module writes the same +//! table that those readers wrote. + +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: Copyright the Vortex contributors + +use std::marker::PhantomData; +use std::sync::Arc; + +use itertools::Itertools; +use vortex_array::ArrayRef; +use vortex_array::ExecutionCtx; +use vortex_array::IntoArray; +use vortex_array::arrays::ConstantArray; +use vortex_array::arrays::StructArray; +use vortex_array::builders::ArrayBuilder; +use vortex_array::builders::BoolBuilder; +use vortex_array::builders::builder_with_capacity_in; +use vortex_array::dtype::DType; +use vortex_array::dtype::FieldName; +use vortex_array::dtype::Nullability; +use vortex_array::expr::stats::Stat; +use vortex_array::scalar::Scalar; +use vortex_array::scalar::ScalarTruncation; +use vortex_array::scalar::lower_bound; +use vortex_array::scalar::upper_bound; +use vortex_array::validity::Validity; +use vortex_buffer::BufferAllocatorRef; +use vortex_buffer::BufferString; +use vortex_buffer::ByteBuffer; +use vortex_error::VortexResult; +use vortex_error::vortex_ensure_eq; + +use crate::layouts::zoned::schema::MAX_IS_TRUNCATED; +use crate::layouts::zoned::schema::MIN_IS_TRUNCATED; + +/// The stats that a legacy zone table records. +/// +/// Sum is not included, because it does not help pruning. +const LEGACY_ZONE_STATS: &[Stat] = &[Stat::Max, Stat::Min, Stat::NullCount, Stat::NaNCount]; + +/// The maximum length in bytes of a string or binary min or max value in a legacy zone table. +const MAX_VARIABLE_LENGTH_STAT_BYTES: usize = 64; + +/// Accumulates the legacy stats of each zone. +pub(crate) struct LegacyStatsAccumulator { + builders: Vec>, + length: usize, +} + +impl LegacyStatsAccumulator { + pub(crate) fn new(dtype: &DType) -> Self { + if matches!(dtype, DType::Variant(_)) { + return Self { + builders: Vec::new(), + length: 0, + }; + } + + let builders = LEGACY_ZONE_STATS + .iter() + .filter_map(|&stat| { + stat.dtype(dtype) + .map(|stat_dtype| legacy_stats_builder(stat, &stat_dtype.as_nullable())) + }) + .collect::>(); + + Self { + builders, + length: 0, + } + } + + /// The stats that this accumulator records, in the order of [`Self::push_values`]. + pub(crate) fn stats(&self) -> Arc<[Stat]> { + self.builders.iter().map(|builder| builder.stat()).collect() + } + + /// Adds the stats of one zone. `values` has one entry for each stat in [`Self::stats`]. + pub(crate) fn push_values(&mut self, values: Vec>) -> VortexResult<()> { + vortex_ensure_eq!( + values.len(), + self.builders.len(), + "legacy stat value count must match legacy zone stats builder count" + ); + + for (builder, value) in self.builders.iter_mut().zip_eq(values) { + match value { + Some(value) => builder.append_scalar(value.cast(&value.dtype().as_nullable())?)?, + None => builder.append_null(), + } + } + + self.length += 1; + Ok(()) + } + + /// Returns the zone table and its stats in [`Stat`] order. Stats that are null in all zones + /// are not included. Returns `None` if no stat is left. + pub(crate) fn as_array( + &mut self, + ctx: &mut ExecutionCtx, + ) -> VortexResult)>> { + let mut names = Vec::new(); + let mut fields = Vec::new(); + let mut stats = Vec::new(); + + for builder in self + .builders + .iter_mut() + .sorted_unstable_by_key(|builder| builder.stat()) + { + let values = builder.finish(); + + // The first array is the value column of the stat. + if values.arrays[0].all_invalid(ctx)? { + continue; + } + + stats.push(builder.stat()); + names.extend(values.names); + fields.extend(values.arrays); + } + + if names.is_empty() { + return Ok(None); + } + + let array = StructArray::try_new(names.into(), fields, self.length, Validity::NonNullable)?; + Ok(Some((array, stats.into()))) + } +} + +/// Computes the stats of `stats` for one zone. +pub(crate) fn legacy_stat_values( + array: &ArrayRef, + stats: &[Stat], + ctx: &mut ExecutionCtx, +) -> VortexResult>> { + stats + .iter() + .map(|&stat| array.statistics().compute_stat(stat, ctx)) + .collect() +} + +fn legacy_stats_builder(stat: Stat, dtype: &DType) -> Box { + let allocator = BufferAllocatorRef::static_ref(); + let values = builder_with_capacity_in(dtype, 1024, allocator); + let is_truncated = BoolBuilder::with_capacity_in(Nullability::NonNullable, 1024, allocator); + + match (stat, dtype) { + (Stat::Max, DType::Utf8(_)) => Box::new(TruncatedStatsBuilder::::new( + Stat::Max, + values, + is_truncated, + )), + (Stat::Max, DType::Binary(_)) => Box::new(TruncatedStatsBuilder::::new( + Stat::Max, + values, + is_truncated, + )), + (Stat::Min, DType::Utf8(_)) => Box::new(TruncatedStatsBuilder::::new( + Stat::Min, + values, + is_truncated, + )), + (Stat::Min, DType::Binary(_)) => Box::new(TruncatedStatsBuilder::::new( + Stat::Min, + values, + is_truncated, + )), + _ => Box::new(PlainStatsBuilder { stat, values }), + } +} + +/// Columns of the zone table for one stat. +struct NamedArrays { + names: Vec, + arrays: Vec, +} + +trait LegacyStatsArrayBuilder: Send { + fn stat(&self) -> Stat; + + fn append_scalar(&mut self, value: Scalar) -> VortexResult<()>; + + fn append_null(&mut self); + + fn finish(&mut self) -> NamedArrays; +} + +/// Writes the stat value as is. A `max` or `min` column gets a truncation column that is always +/// false. +struct PlainStatsBuilder { + stat: Stat, + values: Box, +} + +impl LegacyStatsArrayBuilder for PlainStatsBuilder { + fn stat(&self) -> Stat { + self.stat + } + + fn append_scalar(&mut self, value: Scalar) -> VortexResult<()> { + self.values.append_scalar(&value) + } + + fn append_null(&mut self) { + self.values.append_null() + } + + fn finish(&mut self) -> NamedArrays { + let array = self.values.finish(); + let len = array.len(); + + let truncated_name = match self.stat { + Stat::Max => Some(MAX_IS_TRUNCATED), + Stat::Min => Some(MIN_IS_TRUNCATED), + _ => None, + }; + + match truncated_name { + Some(truncated_name) => NamedArrays { + names: vec![self.stat.name().into(), truncated_name.into()], + arrays: vec![array, ConstantArray::new(false, len).into_array()], + }, + None => NamedArrays { + names: vec![self.stat.name().into()], + arrays: vec![array], + }, + } + } +} + +/// Writes a string or binary `max` or `min` value cut to [`MAX_VARIABLE_LENGTH_STAT_BYTES`]. +/// +/// A cut `max` is an upper bound and a cut `min` is a lower bound of the zone values. If no bound +/// is possible, the value is null. +struct TruncatedStatsBuilder { + stat: Stat, + values: Box, + is_truncated: BoolBuilder, + _marker: PhantomData, +} + +impl TruncatedStatsBuilder { + fn new(stat: Stat, values: Box, is_truncated: BoolBuilder) -> Self { + Self { + stat, + values, + is_truncated, + _marker: PhantomData, + } + } +} + +impl LegacyStatsArrayBuilder for TruncatedStatsBuilder { + fn stat(&self) -> Stat { + self.stat + } + + fn append_scalar(&mut self, value: Scalar) -> VortexResult<()> { + let nullability = value.dtype().nullability(); + let value = T::from_scalar(value)?; + + let bound = if self.stat == Stat::Max { + upper_bound(value, MAX_VARIABLE_LENGTH_STAT_BYTES, nullability) + } else { + lower_bound(value, MAX_VARIABLE_LENGTH_STAT_BYTES, nullability) + }; + + match bound { + Some((bound, truncated)) => { + self.values.append_scalar(&bound)?; + self.is_truncated.append_value(truncated); + } + None => self.append_null(), + } + + Ok(()) + } + + fn append_null(&mut self) { + self.values.append_null(); + self.is_truncated.append_value(false); + } + + fn finish(&mut self) -> NamedArrays { + let truncated_name = if self.stat == Stat::Max { + MAX_IS_TRUNCATED + } else { + MIN_IS_TRUNCATED + }; + + NamedArrays { + names: vec![self.stat.name().into(), truncated_name.into()], + arrays: vec![ + self.values.finish(), + ArrayBuilder::finish(&mut self.is_truncated), + ], + } + } +} diff --git a/vortex-layout/src/layouts/zoned/mod.rs b/vortex-layout/src/layouts/zoned/mod.rs index 75de45ba668..6b84d116f9c 100644 --- a/vortex-layout/src/layouts/zoned/mod.rs +++ b/vortex-layout/src/layouts/zoned/mod.rs @@ -13,6 +13,7 @@ pub mod aggregates; mod builder; +mod legacy_builder; mod pruning; mod reader; mod schema; @@ -24,6 +25,8 @@ use std::sync::Arc; pub(crate) use builder::AggregateStatsAccumulator; pub(crate) use builder::aggregate_partials; +pub(crate) use legacy_builder::LegacyStatsAccumulator; +pub(crate) use legacy_builder::legacy_stat_values; use prost::Message; pub use schema::MAX_IS_TRUNCATED; pub use schema::MIN_IS_TRUNCATED; @@ -242,6 +245,42 @@ impl VTable for LegacyStats { } impl LegacyStatsLayout { + /// Create a legacy `vortex.stats` layout from a data child, a zone-map child, a zone length, + /// and the stats stored in the zone map. + /// + /// Write this layout only for readers that do not know `vortex.zoned`. + pub(crate) fn try_new( + data: LayoutRef, + zones: LayoutRef, + zone_len: NonZeroUsize, + stats: Arc<[Stat]>, + ) -> VortexResult { + let expected_dtype = legacy_stats_table_dtype(data.dtype(), &stats); + if zones.dtype() != &expected_dtype { + vortex_bail!( + "Invalid legacy zone map layout: zones dtype {} does not match expected dtype {}", + zones.dtype(), + expected_dtype + ); + } + + let dtype = data.dtype().clone(); + let row_count = data.row_count(); + Ok(LayoutParts::new( + LegacyStats, + dtype, + row_count, + Vec::new(), + OwnedLayoutChildren::layout_children(vec![data, zones]), + ZonedData { + zone_len: zone_len.get(), + zone_map_schema: ZoneMapSchema::LegacyStats(stats), + stats_table_dtype: expected_dtype, + }, + ) + .into_typed()) + } + fn zoned_reader( &self, name: Arc, diff --git a/vortex-layout/src/layouts/zoned/writer.rs b/vortex-layout/src/layouts/zoned/writer.rs index 2819f6a9c79..696b7a412e7 100644 --- a/vortex-layout/src/layouts/zoned/writer.rs +++ b/vortex-layout/src/layouts/zoned/writer.rs @@ -35,9 +35,15 @@ use vortex_utils::parallelism::get_available_parallelism; use crate::LayoutRef; use crate::LayoutStrategy; use crate::LayoutWriterContext; +use crate::VTable; use crate::layouts::zoned::AggregateStatsAccumulator; +use crate::layouts::zoned::LegacyStats; +use crate::layouts::zoned::LegacyStatsAccumulator; +use crate::layouts::zoned::LegacyStatsLayout; +use crate::layouts::zoned::Zoned; use crate::layouts::zoned::ZonedLayout; use crate::layouts::zoned::aggregate_partials; +use crate::layouts::zoned::legacy_stat_values; use crate::layouts::zoned::schema::default_bounded_stat_max_bytes; use crate::segments::SegmentSinkRef; use crate::sequence::SendableSequentialStream; @@ -124,6 +130,22 @@ impl LayoutStrategy for ZonedStrategy { .write_stream(ctx, segment_sink, stream, eof, session) .await; } + + // Readers before `vortex.zoned` only know the legacy `vortex.stats` layout. If the write + // does not permit either layout, the column gets no zone map. + if !ctx.allows_layout(&Zoned.id()) { + if ctx.allows_layout(&LegacyStats.id()) { + return self + .write_legacy_stream(ctx, segment_sink, stream, eof, session) + .await; + } + + return self + .child + .write_stream(ctx, segment_sink, stream, eof, session) + .await; + } + let compute_session = session.clone(); let stats_accumulator = Arc::new(Mutex::new(AggregateStatsAccumulator::new( @@ -214,6 +236,83 @@ impl LayoutStrategy for ZonedStrategy { } } +impl ZonedStrategy { + /// Writes the data child and a legacy `vortex.stats` zone map, which readers before + /// `vortex.zoned` can read. + async fn write_legacy_stream( + &self, + ctx: LayoutWriterContext, + segment_sink: SegmentSinkRef, + stream: SendableSequentialStream, + mut eof: SequencePointer, + session: &VortexSession, + ) -> VortexResult { + let stats_accumulator = Arc::new(Mutex::new(LegacyStatsAccumulator::new(stream.dtype()))); + let stats = stats_accumulator.lock().stats(); + + let compute_session = session.clone(); + let stream_dtype = stream.dtype().clone(); + let concurrency = self.options.concurrency.get(); + let stream = stream + .map(move |item| { + let stats = Arc::clone(&stats); + let session = compute_session.clone(); + session.handle().spawn_cpu(move || { + let (sequence_id, chunk) = item?; + let values = + legacy_stat_values(&chunk, &stats, &mut session.create_execution_ctx())?; + Ok::<_, VortexError>((sequence_id, chunk, values)) + }) + }) + .buffered(concurrency); + + // Add the zone stats in stream order, so that the zone table rows align with the data + // child. + let stats_accumulator2 = Arc::clone(&stats_accumulator); + let stream = SequentialStreamAdapter::new( + stream_dtype, + stream.map(move |item| { + let (sequence_id, chunk, values) = item?; + stats_accumulator2.lock().push_values(values)?; + Ok((sequence_id, chunk)) + }), + ) + .sendable(); + + // The data child must come before the zone table in the file. + let data_eof = eof.split_off(); + let data_layout = self + .child + .write_stream( + ctx.clone(), + Arc::clone(&segment_sink), + stream, + data_eof, + session, + ) + .await?; + + let mut exec_ctx = session.create_execution_ctx(); + let Some((stats_array, stats)) = stats_accumulator.lock().as_array(&mut exec_ctx)? else { + return Ok(data_layout); + }; + + let stats_stream = stats_array + .into_array() + .to_array_stream() + .sequenced(eof.split_off()); + let zones_layout = self + .stats + .write_stream(ctx, Arc::clone(&segment_sink), stats_stream, eof, session) + .await?; + + Ok( + LegacyStatsLayout::try_new(data_layout, zones_layout, self.options.block_size, stats)? + .into_layout(), + ) + } +} + fn default_zoned_aggregate_fns(dtype: &DType, session: &VortexSession) -> Arc<[AggregateFnRef]> { let (max, min) = match dtype { DType::Utf8(_) | DType::Binary(_) => ( diff --git a/vortex-layout/src/strategy.rs b/vortex-layout/src/strategy.rs index 81dd2b12eb8..3e5bcedd5ec 100644 --- a/vortex-layout/src/strategy.rs +++ b/vortex-layout/src/strategy.rs @@ -12,6 +12,7 @@ use vortex_error::VortexResult; use vortex_session::VortexSession; use vortex_utils::aliases::hash_set::HashSet; +use crate::LayoutId; use crate::LayoutRef; use crate::segments::SegmentSinkRef; use crate::sequence::SendableSequentialStream; @@ -75,6 +76,7 @@ impl Drop for BufferedBytesReservation { pub struct LayoutWriterContext { array_ctx: ArrayContext, allowed_aggregates: Option>>, + allowed_layouts: Option>>, nullable_ancestor: bool, buffered_bytes: BufferedBytesTracker, } @@ -85,6 +87,7 @@ impl LayoutWriterContext { Self { array_ctx, allowed_aggregates: None, + allowed_layouts: None, nullable_ancestor: false, buffered_bytes: BufferedBytesTracker::new(), } @@ -109,6 +112,24 @@ impl LayoutWriterContext { .is_none_or(|allowed| allowed.contains(aggregate)) } + /// Restrict the layouts this write may produce. + /// + /// Strategies that can write more than one layout use this to select a layout that the + /// readers of the file know. The footer serializer still rejects a layout that is not + /// permitted. + pub fn with_allowed_layouts(mut self, allowed: HashSet) -> Self { + self.allowed_layouts = Some(Arc::new(allowed)); + self + } + + /// Returns whether this write may produce `layout`. Unrestricted contexts permit every + /// layout. + pub fn allows_layout(&self, layout: &LayoutId) -> bool { + self.allowed_layouts + .as_ref() + .is_none_or(|allowed| allowed.contains(layout)) + } + /// Marks this write as nested under a nullable container, such as a field of a nullable /// struct. /// diff --git a/vortex-python/benchmark/test_scalar_at.py b/vortex-python/benchmark/test_scalar_at.py index 9d2f487d9da..977156c661e 100644 --- a/vortex-python/benchmark/test_scalar_at.py +++ b/vortex-python/benchmark/test_scalar_at.py @@ -1,6 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright the Vortex contributors +import os + import pyarrow as pa import pytest from pytest_benchmark.fixture import BenchmarkFixture @@ -8,13 +10,25 @@ import vortex as vx +@pytest.fixture +def scalar_vxf(request: pytest.FixtureRequest, vxf: vx.VortexFile) -> vx.VortexFile: + enabled = request.config.getoption("codspeed", default=False) or "CODSPEED_ENV" in os.environ + mode = request.config.getoption("codspeed_mode", default=None) + if mode is None and "CODSPEED_ENV" in os.environ: + mode = os.environ.get("CODSPEED_RUNNER_MODE", "simulation") + assert isinstance(request.node, pytest.Function) + if enabled and mode == "simulation" and request.node.callspec.params["vxf"] == "int": + pytest.skip("Reactor polling varies inside these scalar scans under simulation.") + return vxf + + @pytest.mark.benchmark(group="scalar_at") -def test_scan_scalar_at(benchmark: BenchmarkFixture, vxf: vx.VortexFile) -> None: +def test_scan_scalar_at(benchmark: BenchmarkFixture, scalar_vxf: vx.VortexFile) -> None: indices = vx.array([50_000]) - benchmark(lambda: pa.concat_tables(x.to_arrow_table() for x in vxf.scan(indices=indices))) + benchmark(lambda: pa.concat_tables(x.to_arrow_table() for x in scalar_vxf.scan(indices=indices))) @pytest.mark.benchmark(group="scalar_at") -def test_repeated_scan_scalar_at(benchmark: BenchmarkFixture, vxf: vx.VortexFile) -> None: - rscan = vxf.to_repeated_scan() +def test_repeated_scan_scalar_at(benchmark: BenchmarkFixture, scalar_vxf: vx.VortexFile) -> None: + rscan = scalar_vxf.to_repeated_scan() benchmark(lambda: rscan.scalar_at(50_000)) diff --git a/vortex-python/python/vortex/_lib/io.pyi b/vortex-python/python/vortex/_lib/io.pyi index b689b137244..2b09d9bf664 100644 --- a/vortex-python/python/vortex/_lib/io.pyi +++ b/vortex-python/python/vortex/_lib/io.pyi @@ -20,6 +20,7 @@ def write( path: str, *, store: ObjectStore | None = None, + edition: str | None = None, ) -> None: ... class VortexWriteOptions: @@ -27,6 +28,7 @@ class VortexWriteOptions: def default() -> VortexWriteOptions: ... @staticmethod def compact() -> VortexWriteOptions: ... + def with_edition(self, edition: str) -> VortexWriteOptions: ... @staticmethod def write( iter: IntoArrayIterator, diff --git a/vortex-python/python/vortex/file.py b/vortex-python/python/vortex/file.py index 847da66f786..97ca60f41e0 100644 --- a/vortex-python/python/vortex/file.py +++ b/vortex-python/python/vortex/file.py @@ -98,7 +98,7 @@ def open( def open_readable( - reader: ReadBytesAt | ReadAt | IO[bytes], + reader: ReadBytesAt | ReadAt | IO[bytes] | pa.NativeFile, *, footer: Footer | None = None, concurrency: int | None = None, @@ -114,19 +114,20 @@ def open_readable( Parameters ---------- - reader : :class:`vortex.io.ReadBytesAt` | :class:`vortex.io.ReadAt` | binary file object - An object implementing :class:`vortex.io.ReadBytesAt` or :class:`vortex.io.ReadAt`, or a - binary file object with ``seek`` and ``readinto`` (or ``read``), such as - ``open(path, "rb")``, :class:`io.BytesIO` or an fsspec file. Vortex does not close it; keep - it open for as long as the returned file, or anything scanned from it, is in use. + reader : :class:`vortex.io.ReadBytesAt` | :class:`vortex.io.ReadAt` | pyarrow file | binary file object + An object implementing :class:`vortex.io.ReadBytesAt` or :class:`vortex.io.ReadAt`, a + pyarrow file such as one from :meth:`pyarrow.fs.FileSystem.open_input_file`, or a binary + file object with ``seek`` and ``readinto`` (or ``read``), such as ``open(path, "rb")``, + :class:`io.BytesIO` or an fsspec file. Vortex does not close it; keep it open for as long + as the returned file, or anything scanned from it, is in use. footer : :class:`vortex.file.Footer` | None The :attr:`VortexFile.footer` of an earlier open of the same file. Opening then does no IO, which saves the footer read when a file is opened again and again. Vortex checks only that the footer fits within the size of ``reader``, so the file must not have changed since. concurrency : :class:`int` | None - The most reads to have in flight at once through a :class:`vortex.io.ReadBytesAt` or - :class:`vortex.io.ReadAt`, 192 by default. Not accepted for a file object, whose reads are - serialized because each one has to ``seek`` first. + The most reads to have in flight at once through a :class:`vortex.io.ReadBytesAt`, a + :class:`vortex.io.ReadAt` or a pyarrow file, 192 by default. Not accepted for a binary file + object, whose reads are serialized because each one has to ``seek`` first. without_segment_cache : :class:`bool` If true, disable the segment cache for this file, useful when memory is constrained. segment_cache : :class:`vortex.SegmentCache` | None @@ -152,6 +153,8 @@ def open_readable( ... vxf = vx.open_readable(f, footer=footer) """ + if isinstance(reader, pa.NativeFile): + reader = _NativeFileReader(reader) return VortexFile( _file.open_readable( reader, @@ -164,6 +167,20 @@ def open_readable( ) +@final +class _NativeFileReader: + """A :class:`vortex.io.ReadBytesAt` over a pyarrow file, whose ``read_at`` takes ``(nbytes, offset)``.""" + + def __init__(self, file: pa.NativeFile) -> None: + self._file = file + + def size(self) -> int: + return self._file.size() + + def read_at(self, offset: int, length: int) -> bytes: + return self._file.read_at(length, offset) # ty: ignore[too-many-positional-arguments] + + @final class VortexFile: def __init__(self, file: _file.VortexFile) -> None: diff --git a/vortex-python/python/vortex/io.py b/vortex-python/python/vortex/io.py index b3e1b25f46f..198c2fe7fd9 100644 --- a/vortex-python/python/vortex/io.py +++ b/vortex-python/python/vortex/io.py @@ -14,11 +14,11 @@ class ReadAt(Protocol): A positional byte source that Vortex reads from, for storage only reachable from Python. Pass one to :func:`vortex.open_readable`. Binary file objects (``open(path, "rb")``, - :class:`io.BytesIO`, fsspec and pyarrow files) are accepted too without implementing this - protocol, but their reads are serialized because each one has to ``seek`` first. Implement - :class:`ReadAt` when the underlying storage supports positional reads, such as :func:`os.pread` - or HTTP range requests, so that Vortex can issue many reads at once: up to 192 by default, set - with the ``concurrency`` argument of :func:`vortex.open_readable`. + :class:`io.BytesIO` and fsspec files) are accepted too without implementing this protocol, but + their reads are serialized because each one has to ``seek`` first; pyarrow files are read + positionally. Implement :class:`ReadAt` when the underlying storage supports positional reads, + such as :func:`os.pread` or HTTP range requests, so that Vortex can issue many reads at once: up + to 192 by default, set with the ``concurrency`` argument of :func:`vortex.open_readable`. Reads are called from Vortex worker threads, potentially many concurrently, so implementations must be safe for concurrent use. Releasing the GIL while waiting on IO lets those reads overlap. diff --git a/vortex-python/python/vortex/ray/datasource.py b/vortex-python/python/vortex/ray/datasource.py index 3c6d758eaf3..0220013837b 100644 --- a/vortex-python/python/vortex/ray/datasource.py +++ b/vortex-python/python/vortex/ray/datasource.py @@ -5,7 +5,9 @@ from collections.abc import Iterable from typing import TYPE_CHECKING, TypeVar, final +from urllib.parse import quote +from pyarrow.fs import FileSystem, FSSpecHandler, PyFileSystem from ray.data import Datasource, ReadTask from ray.data._internal.util import RetryingPyFileSystem from ray.data.block import BlockMetadata @@ -44,6 +46,17 @@ def partition(k: int, ls: list[T]) -> list[list[T]]: return out +def _url_scheme(fs: FileSystem) -> str | None: + if isinstance(fs, PyFileSystem) and isinstance(fs.handler, FSSpecHandler): + protocol = getattr(fs.handler.fs, "protocol", "") + name = protocol if isinstance(protocol, str) else str(protocol[0]) + else: + name = fs.type_name + if name in ("file", "local"): + return None + return "gs" if name == "gcs" else name + + @final class VortexDatasource(Datasource): """Read a folder of Vortex files as a row-wise-partitioned table.""" @@ -72,7 +85,11 @@ def __init__( ignore_missing_paths=False, ) ) - self._paths: list[str] = [path for path, _ in paths_and_sizes] + paths = [path for path, _ in paths_and_sizes] + scheme = _url_scheme(fs.unwrap()) + if scheme is not None: + paths = [path if "://" in path else f"{scheme}://{quote(path)}" for path in paths] + self._paths: list[str] = paths self._batch_size = batch_size @override @@ -130,7 +147,8 @@ def _read_task( schema = schemas[0] assert all(s == schema for s in schemas[1:]) - num_rows = sum(len(f) for f in files) + num_rows = None if filter is not None else sum(len(f) for f in files) + output_schema = files[0].to_arrow(columns, limit=0).schema metadata = BlockMetadata( num_rows=num_rows, @@ -152,4 +170,4 @@ def read() -> Iterable[pandas.DataFrame]: # yield rb.to_pandas() - return ReadTask(read, metadata, schema) + return ReadTask(read, metadata, output_schema) diff --git a/vortex-python/src/io.rs b/vortex-python/src/io.rs index 23288fc5930..2dbb5503973 100644 --- a/vortex-python/src/io.rs +++ b/vortex-python/src/io.rs @@ -46,6 +46,7 @@ use crate::object_store::resolve::resolve_store; use crate::opendal_store::CosStore; use crate::opendal_store::GoosefsStore; use crate::session::session; +use crate::session::write_session; pub(crate) fn init(py: Python, parent: &Bound) -> PyResult<()> { let m = PyModule::new(py, "io")?; @@ -207,6 +208,11 @@ impl<'py> FromPyObject<'_, 'py> for AnyVortexStore { /// store : vortex.store.AzureStore | vortex.store.CosStore | vortex.store.GCSStore | vortex.store.HfStore | vortex.store.HTTPStore | vortex.store.LocalStore | vortex.store.MemoryStore | vortex.store.S3Store | None /// An optional object store configuration to use for writing the output. /// +/// edition : str | None +/// An optional Vortex edition, for example ``"core2025.10.0"``. The file then contains only +/// the formats of this edition, so that older Vortex readers can read it. If None, the +/// default edition is used. +/// /// Examples /// -------- /// @@ -241,14 +247,15 @@ impl<'py> FromPyObject<'_, 'py> for AnyVortexStore { /// /// :func:`vortex.io.VortexWriteOptions` #[pyfunction] -#[pyo3(signature = (iter, path, *, store = None))] +#[pyo3(signature = (iter, path, *, store = None, edition = None))] pub fn write( py: Python, iter: PyIntoArrayIterator, path: &str, store: Option, + edition: Option<&str>, ) -> PyVortexResult<()> { - let session = session(); + let session = write_session(edition)?; py.detach(|| { current_runtime().block_on(async move { match resolve_store(path, store.map(|x| x.into_inner()))? { @@ -286,6 +293,7 @@ pub fn write( #[pyclass(name = "VortexWriteOptions", module = "io", frozen)] pub(crate) struct PyVortexWriteOptions { use_compact_encodings: bool, + edition: Option, } #[pymethods] @@ -295,6 +303,7 @@ impl PyVortexWriteOptions { pub fn default() -> Self { Self { use_compact_encodings: false, + edition: None, } } @@ -329,9 +338,40 @@ impl PyVortexWriteOptions { pub fn compact() -> Self { Self { use_compact_encodings: true, + edition: None, } } + /// Return a copy of these options that writes with the Vortex edition ``edition``. + /// + /// The file then contains only the formats of this edition, so that older Vortex readers can + /// read it. For example, ``"core2025.10.0"`` writes files that Vortex 0.73 can read. + /// + /// Parameters + /// ---------- + /// edition : str + /// The name of the edition, for example ``"core2025.10.0"``. + /// + /// Raises + /// ------ + /// ValueError + /// If Vortex does not know the edition. + /// + /// Examples + /// -------- + /// + /// >>> import vortex as vx + /// >>> a = vx.array([0, 1, 2, 3, None, 4]) + /// >>> vx.io.VortexWriteOptions.default().with_edition("core2025.10.0").write(a, "a.vortex") # doctest: +SKIP + pub fn with_edition(&self, edition: String) -> PyResult { + write_session(Some(&edition)).map_err(|error| PyValueError::new_err(error.to_string()))?; + + Ok(Self { + use_compact_encodings: self.use_compact_encodings, + edition: Some(edition), + }) + } + /// Write an array or iterator of arrays to a file. /// /// @@ -375,14 +415,14 @@ impl PyVortexWriteOptions { path: &str, store: Option, ) -> PyVortexResult<()> { - let session = session(); + let session = write_session(self.edition.as_deref())?; py.detach(|| { - let mut compressor = BtrBlocksCompressorBuilder::from_session(session); + let mut compressor = BtrBlocksCompressorBuilder::from_session(&session); if self.use_compact_encodings { compressor = compressor.with_compact(); } let strategy = - WriteStrategyBuilder::from_session(session).with_btrblocks_builder(compressor); + WriteStrategyBuilder::from_session(&session).with_btrblocks_builder(compressor); let strategy = strategy.build(); current_runtime().block_on(async move { match resolve_store(path, store.map(|x| x.into_inner()))? { diff --git a/vortex-python/src/session.rs b/vortex-python/src/session.rs index 651addb5457..1f5478bc35f 100644 --- a/vortex-python/src/session.rs +++ b/vortex-python/src/session.rs @@ -11,6 +11,9 @@ use std::sync::atomic::AtomicPtr; use std::sync::atomic::Ordering; use vortex::VortexSessionDefault; +use vortex::editions::EditionSessionExt; +use vortex::error::VortexResult; +use vortex::error::vortex_err; use vortex::io::runtime::BlockingRuntime; #[cfg(unix)] use vortex::io::runtime::Handle; @@ -85,3 +88,26 @@ pub(crate) fn reset_session_handle(handle: Handle) { session.session().with_handle(handle); } } + +/// Returns the session for a write that selects `edition`, for example `core2025.10.0`. +/// +/// Without an edition, this is the shared session. With an edition, this is a new session that +/// enables the edition, so that the selection does not change other writes. Select an older +/// edition to write files that older Vortex readers can read. +pub(crate) fn write_session(edition: Option<&str>) -> VortexResult { + let Some(edition) = edition else { + return Ok(session().clone()); + }; + + let session = VortexSession::default().with_handle(current_runtime().handle()); + let declared = session + .editions() + .find_by_name(edition) + .ok_or_else(|| vortex_err!("Unknown Vortex edition: {edition}"))?; + + session + .enable_edition(declared.id) + .map_err(|error| vortex_err!("{error}"))?; + + Ok(session) +} diff --git a/vortex-python/test/test_datasource.py b/vortex-python/test/test_datasource.py index bf29c1cb119..5adca691f27 100644 --- a/vortex-python/test/test_datasource.py +++ b/vortex-python/test/test_datasource.py @@ -1,14 +1,23 @@ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: Copyright the Vortex contributors +import re +import threading from collections.abc import Iterator +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from pathlib import Path +from typing import ClassVar +from urllib.parse import parse_qs, unquote, urlsplit import pyarrow as pa import pytest import ray +from pyarrow.fs import GcsFileSystem from ray.data import read_datasource +from typing_extensions import override import vortex as vx +import vortex.expr as ve from vortex.ray.datasource import VortexDatasource, partition from .test_file import record @@ -29,6 +38,16 @@ def ray_init() -> Iterator[None]: ray.shutdown() +def test_vortex_datasource_count_and_schema_follow_the_scan(ray_init, tmpdir_factory) -> None: + folder = tmpdir_factory.mktemp("data") + vx.io.write(vx.array([record(x) for x in range(10)]), str(folder / "01.vortex")) + + ds = read_datasource(VortexDatasource(url=str(folder), columns=["index"], filter=ve.column("index") < 3)) + + assert ds.count() == 3 + assert ds.schema().names == ["index"] + + def test_partition() -> None: assert partition(1, []) == [[]] assert partition(1, [1]) == [[1]] @@ -43,7 +62,8 @@ def test_partition() -> None: assert partition(3, list(range(11))) == [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10]] -def test_vortex_datasource(ray_init, tmpdir_factory) -> None: +@pytest.mark.parametrize("scheme", ["", "file://", "fsspec+file://"]) +def test_vortex_datasource(ray_init, tmpdir_factory, scheme: str) -> None: folder = tmpdir_factory.mktemp("data") arr1 = vx.array([record(x) for x in range(5)]) @@ -52,7 +72,7 @@ def test_vortex_datasource(ray_init, tmpdir_factory) -> None: arr2 = vx.array([record(x) for x in range(5, 10)]) vx.io.write(arr2, str(folder / "02.vortex")) - ds = read_datasource(VortexDatasource(url=str(folder))) + ds = read_datasource(VortexDatasource(url=scheme + str(folder))) # Without an explicit sort, Ray may reorder rows *even within a single record batch*. ds = ds.sort("index") @@ -61,3 +81,97 @@ def test_vortex_datasource(ray_init, tmpdir_factory) -> None: expected = pa.Table.from_pylist([record(x) for x in range(0, 10)], schema=tbl.schema) assert tbl == expected + + +class _S3Handler(BaseHTTPRequestHandler): + """Serves the files under `root` as path-style S3 objects.""" + + root: ClassVar[Path] + + def do_HEAD(self) -> None: + self._send_object(body=False) + + def do_GET(self) -> None: + url = urlsplit(self.path) + query = parse_qs(url.query) + if "list-type" not in query: + self._send_object(body=True) + return + bucket = self.root / unquote(url.path).strip("/") + prefix = query.get("prefix", [""])[0] + keys = [p.relative_to(bucket).as_posix() for p in sorted(bucket.rglob("*")) if p.is_file()] + keys = [key for key in keys if key.startswith(prefix)] + contents = "".join( + f"{key}{(bucket / key).stat().st_size}" + '2026-01-01T00:00:00Z"0"' + for key in keys + ) + body = ( + '' + f"{len(keys)}{contents}" + ).encode() + self.send_response(200) + self.send_header("Content-Length", str(len(body))) + self.end_headers() + _ = self.wfile.write(body) + + def _send_object(self, body: bool) -> None: + file = self.root / unquote(urlsplit(self.path).path).lstrip("/") + if not file.is_file(): + self.send_response(404) + self.send_header("Content-Length", "0") + self.end_headers() + return + data = file.read_bytes() + ranged = re.fullmatch(r"bytes=(\d+)-(\d+)", self.headers.get("Range") or "") + start, end = (int(ranged[1]), min(int(ranged[2]), len(data) - 1)) if ranged else (0, len(data) - 1) + self.send_response(206 if ranged else 200) + if ranged: + self.send_header("Content-Range", f"bytes {start}-{end}/{len(data)}") + self.send_header("Content-Length", str(end - start + 1)) + self.send_header("ETag", '"0"') + self.send_header("Last-Modified", "Thu, 01 Jan 2026 00:00:00 GMT") + self.end_headers() + if body: + _ = self.wfile.write(data[start : end + 1]) + + @override + def log_message(self, format: str, *args: object) -> None: + pass + + +@pytest.fixture +def s3_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[Path]: + handler = type("Handler", (_S3Handler,), {"root": tmp_path}) + server = ThreadingHTTPServer(("127.0.0.1", 0), handler) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + for key, value in { + "AWS_ACCESS_KEY_ID": "test", + "AWS_SECRET_ACCESS_KEY": "test", + "AWS_REGION": "us-east-1", + "AWS_ENDPOINT_URL": f"http://127.0.0.1:{server.server_address[1]}", + "AWS_ALLOW_HTTP": "true", + "AWS_EC2_METADATA_DISABLED": "true", + }.items(): + monkeypatch.setenv(key, value) + yield tmp_path + server.shutdown() + + +def test_vortex_datasource_reads_s3(s3_root: Path) -> None: + folder = s3_root / "ray-datasource-test" / "data" + folder.mkdir(parents=True) + vx.io.write(vx.array([record(x) for x in range(5)]), str(folder / "01.vortex")) + vx.io.write(vx.array([record(x) for x in range(5, 10)]), str(folder / "a#b%41.vortex")) + + datasource = VortexDatasource(url="s3://ray-datasource-test/data/") + + blocks = [block for task in datasource.get_read_tasks(2) for block in task()] + assert sorted(i for block in blocks for i in block["index"]) == list(range(10)) + + +def test_url_scheme_of_gcs_is_gs() -> None: + from vortex.ray.datasource import _url_scheme + + assert _url_scheme(GcsFileSystem(anonymous=True)) == "gs" diff --git a/vortex-python/test/test_editions.py b/vortex-python/test/test_editions.py new file mode 100644 index 00000000000..d433bdf5be5 --- /dev/null +++ b/vortex-python/test/test_editions.py @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: Apache-2.0 +# SPDX-FileCopyrightText: Copyright the Vortex contributors + +import pyarrow as pa +import pytest + +import vortex as vx + +# Readers before the `vortex.zoned` layout, for example Vortex 0.73, can read this edition. +OLD_READER_EDITION = "core2025.10.0" + + +def table() -> pa.Table: + n = 50_000 + return pa.table( + { + "int": pa.array(range(n), type=pa.int32()), + "bigint": pa.array([None if i % 5 == 0 else i * 1_000_003 for i in range(n)], type=pa.int64()), + "bool": pa.array([None if i % 11 == 0 else i % 2 == 0 for i in range(n)]), + "double": pa.array([None if i % 13 == 0 else i * 0.5 for i in range(n)]), + "string": pa.array([None if i % 7 == 0 else f"row-{i:06}" for i in range(n)]), + "list": pa.array([[f"item-{i}", None] for i in range(n)], type=pa.list_(pa.string())), + "nested": pa.array([{"a": i, "b": f"n{i}"} for i in range(n)]), + } + ) + + +def layout_ids(path: str) -> set[bytes]: + with open(path, "rb") as f: + data = f.read() + return {name for name in (b"vortex.stats", b"vortex.zoned") if name in data} + + +@pytest.mark.parametrize("compact", [False, True]) +def test_write_options_with_edition_writes_legacy_zone_maps(tmp_path, compact): + path = str(tmp_path / "old.vortex") + options = vx.io.VortexWriteOptions.compact() if compact else vx.io.VortexWriteOptions.default() + + options.with_edition(OLD_READER_EDITION).write(table(), path) + + assert layout_ids(path) == {b"vortex.stats"} + assert vx.open(path).scan().read_all().to_arrow_table().to_pylist() == table().to_pylist() + + +def test_write_with_edition_writes_legacy_zone_maps(tmp_path): + path = str(tmp_path / "old.vortex") + + vx.io.write(table(), path, edition=OLD_READER_EDITION) + + assert layout_ids(path) == {b"vortex.stats"} + assert vx.open(path).scan().read_all().to_arrow_table().to_pylist() == table().to_pylist() + + +def test_write_without_edition_uses_zoned_layout(tmp_path): + path = str(tmp_path / "new.vortex") + + vx.io.write(table(), path) + + assert b"vortex.zoned" in layout_ids(path) + + +def test_unknown_edition_is_rejected(): + with pytest.raises(ValueError, match="Unknown Vortex edition"): + vx.io.VortexWriteOptions.default().with_edition("core1999.01.0") diff --git a/vortex-python/test/test_readable.py b/vortex-python/test/test_readable.py index 7a9c83423bf..15b2462e170 100644 --- a/vortex-python/test/test_readable.py +++ b/vortex-python/test/test_readable.py @@ -8,12 +8,14 @@ import threading import time import weakref +from collections.abc import Callable from pathlib import Path from typing import IO, cast import numpy as np import pyarrow as pa import pytest +from pyarrow.fs import LocalFileSystem from typing_extensions import Buffer from vortex.io import ReadAt, ReadBytesAt @@ -37,7 +39,7 @@ def expected(table: pa.Table) -> pa.Table: return table.cast(pa.schema([("index", pa.int64()), ("string", pa.string_view())])) -def read_all(source: ReadBytesAt | ReadAt | IO[bytes]) -> pa.Table: +def read_all(source: ReadBytesAt | ReadAt | IO[bytes] | pa.NativeFile) -> pa.Table: return vx.open_readable(source, without_segment_cache=True).to_arrow().read_all() @@ -81,6 +83,16 @@ def test_bytes_io(path: Path, expected: pa.Table) -> None: assert read_all(io.BytesIO(path.read_bytes())).equals(expected) +@pytest.mark.parametrize( + "open_file", + [pa.OSFile, pa.memory_map, LocalFileSystem().open_input_file], + ids=["os_file", "memory_map", "filesystem"], +) +def test_pyarrow_file(path: Path, expected: pa.Table, open_file: Callable[[str], pa.NativeFile]) -> None: + with open_file(str(path)) as f: + assert read_all(f).equals(expected) + + def test_reopen_with_footer(path: Path, expected: pa.Table) -> None: reader = PReadFile(path) try: diff --git a/vortex-spatial/src/prune/distance.rs b/vortex-spatial/src/prune/distance.rs index 7417a23d042..388088240e4 100644 --- a/vortex-spatial/src/prune/distance.rs +++ b/vortex-spatial/src/prune/distance.rs @@ -285,15 +285,25 @@ mod tests { Ok(()) } - /// An extension-typed radius passes `Binary`'s typecheck (extension operands are exempt) but - /// has no numeric value - the rule declines rather than erroring, and the chunk is scanned. + /// A geometry scalar is not a numeric radius, so the comparison fails while binding. #[test] - fn extension_radius_never_prunes() -> VortexResult<()> { + fn test_extension_radius_fails_binding() -> VortexResult<()> { let session = spatial_session(); let mut ctx = session.create_execution_ctx(); let geometry = point_column(vec![0.0], vec![0.0])?.execute_scalar(0, &mut ctx)?; - assert!(falsify_distance(Operator::Lte, true, geometry)?.is_none()); + let scope = geometry.dtype().clone(); + let distance = SpatialDistance.new_expr(EmptyOptions, [root(), lit(geometry.clone())]); + let predicate = Binary.new_expr(Operator::Lte, [distance, lit(geometry)]); + let error = predicate + .bind(&scope) + .expect_err("a geometry scalar cannot be compared with a numeric distance"); + assert!( + error + .to_string() + .contains("Comparison requires equal dtypes ignoring nullability") + ); + Ok(()) } diff --git a/vortex-sqllogictest/README.md b/vortex-sqllogictest/README.md index 14dfe5041cf..6e4590143d8 100644 --- a/vortex-sqllogictest/README.md +++ b/vortex-sqllogictest/README.md @@ -1,206 +1,45 @@ # vortex-sqllogictest -This crate uses [`sqllogictest-rs`](https://github.com/risinglightdb/sqllogictest-rs) to run -`.slt`-based tests against both DataFusion and DuckDB, each preconfigured to read Vortex files. - -Every `.slt` file is turned into one independent test per engine, driven by `sqllogictest`'s -`libtest-mimic` harness. Tests run in parallel; within a single file the records execute -sequentially for one engine. Each test is named `slt::::`, for example -`slt::datafusion::integers.slt` or `slt::duckdb::duckdb/explain.slt`. +This crate tests correctness of our DuckDB and DataFusion integrations. It runs +[.slt](https://github.com/risinglightdb/sqllogictest-rs) tests with our queries +as well as 0.1 scale of TPC-H, TPC-DS, and 1 shard of partitioned ClickBench. +For last three query sets, tests also verify each query's `EXPLAIN` result. ## Running tests -Some tests use TPC-H and TPC-DS data at scale factor 0.1 and one shard of the partitioned -ClickBench dataset (about one million rows of `hits`). Generate them first, then run the suite -with `cargo nextest`: - -```shell -./vortex-sqllogictest/slt/generate_data.sh -cargo nextest run -p vortex-sqllogictest -# the built-in cargo test harness also works: +```sh +# For running our own queries cargo test -p vortex-sqllogictest --test sqllogictests -``` - -`generate_data.sh` accepts dataset names to generate only some of the fixtures, for example -`./vortex-sqllogictest/slt/generate_data.sh tpch`, `... tpcds` or `... clickbench`. Run it with -`--help` to list the datasets. It runs each dataset's own script, `slt/tpch/generate_data.sh`, -`slt/tpcds/generate_data.sh` or `slt/clickbench/generate_data.sh`, which can also be run directly. -TPC-H is generated by `vortex-bench`'s `data-gen` binary, the same generator the benchmarks use, -and TPC-DS by `tpcgen-cli` through `uvx`. - -The generated Vortex and Parquet data lives under `slt/tpch/data/`, `slt/tpcds/data/` and -`slt/clickbench/data/` (git-ignored). Both formats are required; regenerate older fixtures if they -only contain Vortex files. If either format is missing, that suite's tests are reported as -**ignored**, so the rest of the suite still runs. These `.slt` files load their tables through -paths relative to the crate root, so run the tests via `cargo nextest`/`cargo test`, which set the -working directory accordingly. - -TPC-H scripts live under `slt/tpch/datafusion/` and `slt/tpch/duckdb/`, TPC-DS scripts under -`slt/tpcds/datafusion/` and `slt/tpcds/duckdb/`, ClickBench scripts under -`slt/clickbench/datafusion/` and `slt/clickbench/duckdb/`. Each engine has its own -`create.slt.no` and `drop.slt.no`. The query results, `results/q*.slt.no` (`q1` to `q22` for -TPC-H, `q1` to `q99` for TPC-DS, `q0` to `q42` for ClickBench, matching the upstream numbering), -are shared by both engines in `slt/tpch/results/` and `slt/tpcds/results/`. ClickBench keeps one -`results/` directory for each engine. Each engine's `tpch.slt`/`tpcds.slt`/`clickbench.slt` runs -the queries against Vortex and asserts EXPLAIN output from the matching `plans/q*.slt.no`. Its -`parquet.slt` runs the same queries against the original Parquet fixtures and checks the same -expected results. - -DataFusion truncates decimal division and `avg` to the scale of the result type, while DuckDB -calculates them as `DOUBLE`. Thus the DuckDB validator accepts a value with more fractional digits -when it truncates to the expected value. Use `onlyif datafusion`/`onlyif duckdb` records when the -engines differ more than that, as TPC-DS q66 does. -DataFusion uses external tables; DuckDB uses views over files. The `FILE_FORMAT` substitution -variable selects the format in each engine's table setup. - -ClickBench plans explain the upstream queries unchanged. Where an upstream query leaves the order -of tied rows unspecified, its result record adds tie-breaking `ORDER BY` columns so both formats -and repeated runs produce the same rows. The ClickBench and TPC-DS generators also run -`slt/clickbench/duckdb/parity.slt` and `slt/tpcds/duckdb/parity.slt` right after converting their -fixtures; they read both formats through DuckDB and fail if the Parquet and Vortex data differ. -After completing ClickBench or TPC-DS DataFusion plans, replace the byte ranges in `file_groups` -with ``, as the TPC-H plans do: - -```shell -sed -i -E 's/\.vortex:[0-9]+\.\.[0-9]+/.vortex:/g' vortex-sqllogictest/slt/{clickbench,tpcds}/datafusion/plans/*.slt.no -``` -Because the harness is `libtest-mimic`-based, the standard test flags work, including -`cargo nextest`, filtering, and listing: +# For running TPC-H, TPC-DS, or ClickBench you need to generate data first +./slt/generate_data.sh +# You can generate data for a specific dataset +./slt/generate_data.sh tpcds +# Then you can run the tests +cargo test -p vortex-sqllogictest --test sqllogictests -```shell -# Run only DuckDB tests: +# You can run only DuckDB tests... cargo nextest run -p vortex-sqllogictest -E 'test(/slt::duckdb::/)' -# Run a single file on both engines (substring filter): +# ... or a single test on both DuckDB and DataFusion cargo nextest run -p vortex-sqllogictest -E 'test(strings)' -# List every generated test without running: + +# You can also list all tests cargo nextest list -p vortex-sqllogictest ``` -## Scratch directory and `${WORK_DIR}` - -Tests reference a per-test working directory through the `${WORK_DIR}` substitution variable. The -runner sets `WORK_DIR` to a constant, git-ignored scratch directory **inside this crate** — -`scratch//` — rather than an OS tempdir. The path is deterministic (named after the test, -not random), so it is easy to inspect, and each test gets its own directory so concurrent tests -never collide. The directory is recreated empty before each test and removed afterwards — whether -the test passed, failed, or panicked (cleanup errors are logged, not fatal). - -Query output is passed through a normalization step that rewrites the scratch path back to the -`${WORK_DIR}` token. This keeps expected output stable across machines and runs, and is what lets -`--complete` (below) write portable expected values instead of machine-specific paths. - -## Selecting which engine runs a test - -There are two complementary mechanisms: - -- **Per-file, by directory.** A file under a `datafusion/` directory runs **only** on DataFusion; - a file under a `duckdb/` directory runs **only** on DuckDB. Anything else runs on **both**. This - is how engine-specific features (e.g. DuckDB `EXPLAIN` plans) are kept isolated. -- **Per-record, by label.** Use `onlyif