diff --git a/.github/actions/generate-dataset/action.yml b/.github/actions/generate-dataset/action.yml index 5d89e914..0e3fdca3 100644 --- a/.github/actions/generate-dataset/action.yml +++ b/.github/actions/generate-dataset/action.yml @@ -21,9 +21,11 @@ runs: # 2️⃣ Remove any .venv that might have been created earlier # with Python 3.13, so we always recreate it with 3.12. # ───────────────────────────────────────────────────────────── - - name: Remove stale virtual-env + - name: Recreate virtual-env with the correct Python shell: bash - run: rm -rf "$GITHUB_WORKSPACE/.venv" + run: | + rm -rf "$GITHUB_WORKSPACE/.venv" + python3 -m venv "$GITHUB_WORKSPACE/.venv" # ───────────────────────────────────────────────────────────── # 3️⃣ Generate the synthetic data @@ -36,5 +38,6 @@ runs: # 4️⃣ Generate the sentence embeddings # ───────────────────────────────────────────────────────────── - name: Generate embeddings + if: runner.os != 'Windows' shell: bash run: make generate-embeddings diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index 442e3308..b1fc2f17 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -10,9 +10,9 @@ run-name: >- on: push: - branches: [ '*' ] + branches: [ main, dev ] pull_request: - branches: [ '*' ] + branches: [ main, dev ] concurrency: group: Benchmarker CI-${{ github.ref }} @@ -28,7 +28,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ ubuntu-latest, macos-latest ] + platform: [ ubuntu-latest ] defaults: run: diff --git a/.github/workflows/cpp.yaml b/.github/workflows/cpp.yaml index 0d16a6cb..87de9765 100644 --- a/.github/workflows/cpp.yaml +++ b/.github/workflows/cpp.yaml @@ -13,8 +13,9 @@ run-name: >- # ────────────────────────────────────────────────────────────────────────────── on: push: + branches: [ main, dev ] pull_request: - branches: [ "main", "dev" ] + branches: [ main, dev ] # Cancel in-flight runs on the same branch/PR so we do not waste minutes concurrency: @@ -42,38 +43,19 @@ jobs: run: make format-check # ────────────────────────────────────────────────────────────────────────────── - # 2️⃣ Main build + clang-tidy (Linux + macOS + Windows) + # 2️⃣a Clang-tidy (single fast platform — diagnostics are platform-independent) # ────────────────────────────────────────────────────────────────────────────── - build: + tidy: needs: check-format strategy: fail-fast: false matrix: - platform: - - ubuntu-24.04 - - ubuntu-22.04 - - ubuntu-24.04-arm - - ubuntu-22.04-arm - - macos-15 - - macos-14 - - macos-13 build_type: [ Debug, Release ] - cxx: [ clang++ ] shared_lib: [ false, true ] - - # 🛑 Skip the flaky public-preview runner (arm64 Debug + shared) - # GitHub’s ubuntu-24.04-arm image is still in public beta (burstable capacity), - # which can terminate long jobs with “The runner has received a shutdown signal” - # → exit-code 143. See: - # https://github.blog/changelog/2024-06-24-github-actions-ubuntu-24-04-image-now-available-for-arm64-runners/ - # See also Issue #11541: “Intermittent segmentation faults on Ubuntu 24.04 ARM” - # — ~15% of runs on ubuntu-24.04-arm see segfaults or pre-emptions mid-build exclude: - - platform: ubuntu-24.04-arm - build_type: Debug + - build_type: Debug shared_lib: true - - runs-on: ${{ matrix.platform }} + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -90,10 +72,7 @@ jobs: clang --version clang-tidy --version - # ---------------------------------------------------------------------- - # Configure (runs clang-tidy via CMake) - # ---------------------------------------------------------------------- - - name: Configure (with clang-tidy checks) + - name: Configure (with clang-tidy) shell: bash run: | cmake -S "${{ github.workspace }}" \ @@ -104,11 +83,83 @@ jobs: -DFLS_BUILD_SHARED_LIBS=${{ matrix.shared_lib }} \ -DFLS_ENABLE_INSTALL=OFF \ -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} + -DCMAKE_CXX_COMPILER=clang++ - name: Build (clang-tidy runs automatically) run: cmake --build build_${{ matrix.build_type }}_${{ matrix.shared_lib }} -j $BUILD_THREADS + # ────────────────────────────────────────────────────────────────────────────── + # 2️⃣b Compile-check (remaining platforms, Release only, no tidy) + # ────────────────────────────────────────────────────────────────────────────── + build: + needs: check-format + strategy: + fail-fast: false + matrix: + cfg: + # Clang Release — platforms not fully covered by test + - { platform: ubuntu-22.04, compiler: clang, cxx: clang++, build_type: Release, shared_lib: false } + - { platform: ubuntu-22.04, compiler: clang, cxx: clang++, build_type: Release, shared_lib: true } + - { platform: ubuntu-24.04, compiler: clang, cxx: clang++, build_type: Release, shared_lib: false } + - { platform: ubuntu-24.04, compiler: clang, cxx: clang++, build_type: Release, shared_lib: true } + - { platform: ubuntu-24.04-arm, compiler: clang, cxx: clang++, build_type: Release, shared_lib: false } + - { platform: ubuntu-24.04-arm, compiler: clang, cxx: clang++, build_type: Release, shared_lib: true } + - { platform: ubuntu-22.04-arm, compiler: clang, cxx: clang++, build_type: Debug, shared_lib: true } + - { platform: macos-15, compiler: clang, cxx: clang++, build_type: Release, shared_lib: false } + # GCC ARM Debug + - { platform: ubuntu-24.04-arm, compiler: gcc, cxx: g++, build_type: Debug, shared_lib: false } + # Clang on Windows — configs not covered by test + - { platform: windows-latest, compiler: clang, cxx: clang++, build_type: Debug, shared_lib: false } + - { platform: windows-latest, compiler: clang, cxx: clang++, build_type: Release, shared_lib: true } + # windows-11-arm + clang disabled: choco installs x64 LLVM, causing target mismatch + # - { platform: windows-11-arm, compiler: clang, cxx: clang++, build_type: Debug, shared_lib: false } + # - { platform: windows-11-arm, compiler: clang, cxx: clang++, build_type: Release, shared_lib: true } + # MSVC x64 — configs not covered by test + - { platform: windows-latest, compiler: msvc, cxx: cl, build_type: Debug, shared_lib: false } + - { platform: windows-latest, compiler: msvc, cxx: cl, build_type: Release, shared_lib: true } + runs-on: ${{ matrix.cfg.platform }} + + steps: + - uses: actions/checkout@v4 + + - name: Detect CPU count + shell: bash + run: make detect-cpu | tee -a "$GITHUB_ENV" + + - name: Install LLVM + if: matrix.cfg.compiler == 'clang' + uses: ./.github/actions/install-llvm + + - name: Set up MSVC environment + if: matrix.cfg.compiler == 'msvc' + uses: ilammy/msvc-dev-cmd@v1 + + - name: Configure + shell: bash + run: | + CMAKE_ARGS=( + -S "${{ github.workspace }}" + -B build + -DFLS_ENABLE_VERBOSE_OUTPUT=ON + -DCMAKE_BUILD_TYPE=${{ matrix.cfg.build_type }} + -DFLS_BUILD_SHARED_LIBS=${{ matrix.cfg.shared_lib }} + -DFLS_ENABLE_INSTALL=OFF + ) + if [[ "${{ matrix.cfg.compiler }}" == "msvc" ]]; then + : # Ninja is used via global CMAKE_GENERATOR; vcvars sets up MSVC + elif [[ "${{ matrix.cfg.compiler }}" == "gcc" ]]; then + CMAKE_ARGS+=(-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++) + else + CMAKE_ARGS+=(-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=${{ matrix.cfg.cxx }}) + fi + if [[ "${{ runner.os }}" == "Windows" ]]; then + CMAKE_ARGS+=(-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded) + fi + cmake "${CMAKE_ARGS[@]}" + + - name: Build + run: cmake --build build -j $BUILD_THREADS + # ────────────────────────────────────────────────────────────────────────────── # 3️⃣ IWYU build (Linux only) # ────────────────────────────────────────────────────────────────────────────── @@ -146,18 +197,8 @@ jobs: # 4️⃣ Synthetic-dataset generator (Python, cached pip) # ────────────────────────────────────────────────────────────────────────────── generate_dataset: - needs: build - strategy: - matrix: - platform: - - ubuntu-24.04 - - ubuntu-22.04 - - ubuntu-24.04-arm - - ubuntu-22.04-arm - - macos-15 - - macos-14 - - macos-13 - runs-on: ${{ matrix.platform }} + needs: tidy + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -174,13 +215,26 @@ jobs: # ────────────────────────────────────────────────────────────────────────────── example: # needs: build + name: example (${{ matrix.cfg.platform }}, ${{ matrix.cfg.compiler }}, ${{ matrix.cfg.shared_lib && 'shared' || 'static' }}) strategy: + fail-fast: false matrix: - platform: [ ubuntu-latest, macos-latest, windows-latest ] - build_type: [ Release ] - cxx: [ clang++ ] - shared_lib: [ false, true ] - runs-on: ${{ matrix.platform }} + cfg: + # GCC — static + shared + - { platform: ubuntu-latest, compiler: gcc, cxx: g++, shared_lib: false } + - { platform: ubuntu-latest, compiler: gcc, cxx: g++, shared_lib: true } + # Clang — macOS static + shared + - { platform: macos-latest, compiler: clang, cxx: clang++, shared_lib: false } + - { platform: macos-latest, compiler: clang, cxx: clang++, shared_lib: true } + # Clang — Windows static + shared + - { platform: windows-latest, compiler: clang, cxx: clang++, shared_lib: false } + - { platform: windows-latest, compiler: clang, cxx: clang++, shared_lib: true } + # MSVC — static + shared on windows-latest only + - { platform: windows-latest, compiler: msvc, cxx: cl, shared_lib: false } + - { platform: windows-latest, compiler: msvc, cxx: cl, shared_lib: true } + # MSVC ARM — static only + - { platform: windows-11-arm, compiler: msvc, cxx: cl, shared_lib: false } + runs-on: ${{ matrix.cfg.platform }} defaults: run: @@ -196,37 +250,49 @@ jobs: run: make detect-cpu | tee -a "$GITHUB_ENV" - name: Install LLVM + if: matrix.cfg.compiler == 'clang' uses: ./.github/actions/install-llvm + - name: Set up MSVC environment + if: matrix.cfg.compiler == 'msvc' + uses: ilammy/msvc-dev-cmd@v1 + - name: Configure example run: | CMAKE_ARGS=( -S "${{ github.workspace }}" - -B "build_${{ matrix.build_type }}_${{ matrix.shared_lib }}" + -B "build_${{ matrix.cfg.compiler }}_Release_${{ matrix.cfg.shared_lib }}" -DFLS_BUILD_EXAMPLES=ON -DFLS_ENABLE_VERBOSE_OUTPUT=ON - -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" - -DFLS_BUILD_SHARED_LIBS=${{ matrix.shared_lib }} + -DCMAKE_BUILD_TYPE=Release + -DFLS_BUILD_SHARED_LIBS=${{ matrix.cfg.shared_lib }} -DFLS_ENABLE_INSTALL=OFF - -DCMAKE_C_COMPILER=clang - -DCMAKE_CXX_COMPILER="${{ matrix.cxx }}" ) - # Use static MSVC runtime on Windows to avoid ASAN/UBSAN mismatch + if [[ "${{ matrix.cfg.compiler }}" == "msvc" ]]; then + : # Ninja is used via global CMAKE_GENERATOR; vcvars sets up MSVC + elif [[ "${{ matrix.cfg.compiler }}" == "gcc" ]]; then + CMAKE_ARGS+=(-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++) + else + CMAKE_ARGS+=(-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER="${{ matrix.cfg.cxx }}") + fi if [[ "${{ runner.os }}" == "Windows" ]]; then CMAKE_ARGS+=(-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded) fi cmake "${CMAKE_ARGS[@]}" - name: Build example - run: cmake --build "build_${{ matrix.build_type }}_${{ matrix.shared_lib }}" --parallel + run: | + cmake --build "build_${{ matrix.cfg.compiler }}_Release_${{ matrix.cfg.shared_lib }}" \ + --config Release --parallel - name: Run cpp_example shell: bash run: | + BUILD_DIR="build_${{ matrix.cfg.compiler }}_Release_${{ matrix.cfg.shared_lib }}" if [[ "${{ runner.os }}" == "Windows" ]]; then - ./build_${{ matrix.build_type }}_${{ matrix.shared_lib }}/examples/cpp_example.exe + ./${BUILD_DIR}/examples/cpp_example.exe else - ./build_${{ matrix.build_type }}_${{ matrix.shared_lib }}/examples/cpp_example + ./${BUILD_DIR}/examples/cpp_example fi # ────────────────────────────────────────────────────────────────────────────── @@ -234,24 +300,43 @@ jobs: # ────────────────────────────────────────────────────────────────────────────── test: # needs: build - name: test (${{ matrix.platform }}, ${{ matrix.build_type }}, ${{ matrix.shared_lib && 'shared' || 'static' }}) + name: test (${{ matrix.cfg.platform }}, ${{ matrix.cfg.compiler }}, ${{ matrix.cfg.build_type }}, ${{ matrix.cfg.shared_lib && 'shared' || 'static' }}) strategy: + fail-fast: false matrix: - platform: - - ubuntu-24.04 - - ubuntu-22.04 - - ubuntu-24.04-arm - - ubuntu-22.04-arm - - macos-15 - - macos-14 - - macos-13 - build_type: [ Release ] - shared_lib: [ false, true ] - runs-on: ${{ matrix.platform }} + cfg: + # GCC on ubuntu (Release only — Debug is too slow / times out) + - { platform: ubuntu-24.04, compiler: gcc, shared_lib: false, build_type: Release } + - { platform: ubuntu-24.04, compiler: gcc, shared_lib: true, build_type: Release } + - { platform: ubuntu-24.04-arm, compiler: gcc, shared_lib: true, build_type: Release } + # Clang on ubuntu-24.04 (Debug builds that were GCC) + - { platform: ubuntu-24.04, compiler: clang, shared_lib: true, build_type: Debug } + # ubuntu-24.04-arm clang Debug static removed — times out after 51 min + # Clang on ubuntu-22.04 + - { platform: ubuntu-22.04, compiler: clang, shared_lib: true, build_type: Debug } + # Clang on ubuntu-22.04-arm + - { platform: ubuntu-22.04-arm, compiler: clang, shared_lib: true, build_type: Release } + # Clang on macOS + - { platform: macos-26, compiler: clang, shared_lib: false, build_type: Release } + - { platform: macos-26, compiler: clang, shared_lib: true, build_type: Debug } + - { platform: macos-15, compiler: clang, shared_lib: false, build_type: Debug } + - { platform: macos-15, compiler: clang, shared_lib: true, build_type: Release } + # Clang on Windows + - { platform: windows-latest, compiler: clang, shared_lib: true, build_type: Debug } + - { platform: windows-latest, compiler: clang, shared_lib: false, build_type: Release } + # windows-11-arm + clang disabled: choco installs x64 LLVM, causing target mismatch + # - { platform: windows-11-arm, compiler: clang, shared_lib: true, build_type: Debug } + # - { platform: windows-11-arm, compiler: clang, shared_lib: false, build_type: Release } + # MSVC on Windows + - { platform: windows-latest, compiler: msvc, shared_lib: false, build_type: Release } + - { platform: windows-latest, compiler: msvc, shared_lib: true, build_type: Debug } + - { platform: windows-11-arm, compiler: msvc, shared_lib: false, build_type: Debug } + - { platform: windows-11-arm, compiler: msvc, shared_lib: true, build_type: Release } + runs-on: ${{ matrix.cfg.platform }} defaults: run: - shell: bash # Use bash on all platforms to avoid PowerShell issues on Windows + shell: bash steps: - uses: actions/checkout@v4 @@ -261,7 +346,7 @@ jobs: # Map the boolean shared_lib into a human-friendly label - name: Determine lib label run: | - if [[ "${{ matrix.shared_lib }}" == "true" ]]; then + if [[ "${{ matrix.cfg.shared_lib }}" == "true" ]]; then echo "LIB_LABEL=shared" >> $GITHUB_ENV else echo "LIB_LABEL=static" >> $GITHUB_ENV @@ -274,24 +359,32 @@ jobs: uses: ./.github/actions/generate-dataset - name: Install LLVM + if: matrix.cfg.compiler == 'clang' uses: ./.github/actions/install-llvm + - name: Set up MSVC environment + if: matrix.cfg.compiler == 'msvc' + uses: ilammy/msvc-dev-cmd@v1 + - name: Configure tests run: | - # Build directory uses our human-friendly label - BUILD_DIR="test_build_${LIB_LABEL}" + BUILD_DIR="test_build_${{ matrix.cfg.compiler }}_${LIB_LABEL}" CMAKE_ARGS=( -S "${{ github.workspace }}" -B "${BUILD_DIR}" -DFLS_BUILD_TESTING=ON -DFLS_ENABLE_VERBOSE_OUTPUT=ON - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DFLS_BUILD_SHARED_LIBS=${{ matrix.shared_lib }} + -DCMAKE_BUILD_TYPE=${{ matrix.cfg.build_type }} + -DFLS_BUILD_SHARED_LIBS=${{ matrix.cfg.shared_lib }} -DFLS_ENABLE_INSTALL=OFF - -DCMAKE_C_COMPILER=clang - -DCMAKE_CXX_COMPILER=clang++ ) - # On Windows, use static MSVC runtime to prevent ASAN/UBSAN mismatch + if [[ "${{ matrix.cfg.compiler }}" == "msvc" ]]; then + : # Ninja is used via global CMAKE_GENERATOR; vcvars sets up MSVC + elif [[ "${{ matrix.cfg.compiler }}" == "gcc" ]]; then + CMAKE_ARGS+=(-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++) + else + CMAKE_ARGS+=(-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++) + fi if [[ "${{ runner.os }}" == "Windows" ]]; then CMAKE_ARGS+=(-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded) fi @@ -299,29 +392,38 @@ jobs: - name: Build tests run: | - # Use the same labeled build directory - cmake --build "test_build_${LIB_LABEL}" -j $BUILD_THREADS + cmake --build "test_build_${{ matrix.cfg.compiler }}_${LIB_LABEL}" \ + --config ${{ matrix.cfg.build_type }} -j $BUILD_THREADS - name: Run tests - working-directory: "test_build_${{ env.LIB_LABEL }}" + working-directory: "test_build_${{ matrix.cfg.compiler }}_${{ env.LIB_LABEL }}" run: | - # Exclude Quick-Fuzz tests from the normal suite + EXCLUDE="QuickFuzz" ctest -j $BUILD_THREADS \ + --build-config ${{ matrix.cfg.build_type }} \ --stop-on-failure \ --output-on-failure \ --timeout 5000 \ - -E "QuickFuzz" + -E "$EXCLUDE" # ────────────────────────────────────────────────────────────────────────────── # 7️⃣ Install job # ────────────────────────────────────────────────────────────────────────────── install: needs: test + name: install (${{ matrix.cfg.os }}, ${{ matrix.cfg.compiler }}, ${{ matrix.cfg.shared_lib && 'shared' || 'static' }}) strategy: + fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - shared_lib: [ false, true ] - runs-on: ${{ matrix.os }} + cfg: + - { os: ubuntu-latest, compiler: gcc, shared_lib: false } + - { os: ubuntu-latest, compiler: gcc, shared_lib: true } + - { os: macos-latest, compiler: clang, shared_lib: false } + - { os: macos-latest, compiler: clang, shared_lib: true } + - { os: windows-latest, compiler: msvc, shared_lib: false } + - { os: windows-latest, compiler: msvc, shared_lib: true } + - { os: windows-11-arm, compiler: msvc, shared_lib: false } + runs-on: ${{ matrix.cfg.os }} steps: - uses: actions/checkout@v4 @@ -332,30 +434,38 @@ jobs: shell: bash run: make detect-cpu | tee -a "$GITHUB_ENV" - # Use the same LLVM toolchain as the other jobs - name: Install LLVM toolchain + if: matrix.cfg.compiler == 'clang' uses: ./.github/actions/install-llvm + - name: Set up MSVC environment + if: matrix.cfg.compiler == 'msvc' + uses: ilammy/msvc-dev-cmd@v1 + - name: Configure + build + install shell: bash run: | CMAKE_ARGS=( -S "${{ github.workspace }}" - -B build_${{ matrix.shared_lib }} - -G "${CMAKE_GENERATOR}" - -DCMAKE_C_COMPILER=clang - -DCMAKE_CXX_COMPILER=clang++ + -B build_${{ matrix.cfg.compiler }}_${{ matrix.cfg.shared_lib }} -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=build_${{ matrix.shared_lib }}/install - -DFLS_BUILD_SHARED_LIBS=${{ matrix.shared_lib }} + -DCMAKE_INSTALL_PREFIX=build_${{ matrix.cfg.compiler }}_${{ matrix.cfg.shared_lib }}/install + -DFLS_BUILD_SHARED_LIBS=${{ matrix.cfg.shared_lib }} -DFLS_ENABLE_INSTALL=ON ) - # Use static MSVC runtime on Windows to avoid ASAN/UBSAN mismatch + if [[ "${{ matrix.cfg.compiler }}" == "msvc" ]]; then + : # Ninja is used via global CMAKE_GENERATOR; vcvars sets up MSVC + elif [[ "${{ matrix.cfg.compiler }}" == "gcc" ]]; then + CMAKE_ARGS+=(-G "${CMAKE_GENERATOR}" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++) + else + CMAKE_ARGS+=(-G "${CMAKE_GENERATOR}" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++) + fi if [[ "${{ runner.os }}" == "Windows" ]]; then CMAKE_ARGS+=(-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded) fi cmake "${CMAKE_ARGS[@]}" - cmake --build build_${{ matrix.shared_lib }} --target install -j $BUILD_THREADS + cmake --build build_${{ matrix.cfg.compiler }}_${{ matrix.cfg.shared_lib }} \ + --config Release --target install -j $BUILD_THREADS - name: Verify installed header files shell: bash @@ -363,7 +473,7 @@ jobs: set -euo pipefail SOURCE_INCLUDE=src/include - INSTALL_INCLUDE=build_${{ matrix.shared_lib }}/install/include + INSTALL_INCLUDE=build_${{ matrix.cfg.compiler }}_${{ matrix.cfg.shared_lib }}/install/include # 1) fail fast if the install tree isn't there if [[ ! -d "$INSTALL_INCLUDE" ]]; then @@ -387,7 +497,7 @@ jobs: find . -type f \( -name '*.h' -o -name '*.hpp' \) -print0 ) - # 4) report & fail if anything’s missing + # 4) report & fail if anything's missing if (( ${#missing[@]} > 0 )); then echo "❌ Missing expected header(s):" for hdr in "${missing[@]}"; do @@ -401,5 +511,5 @@ jobs: - name: Upload C++ install tree uses: actions/upload-artifact@v4 with: - name: fastlanes-cpp-install-${{ matrix.os }}-shared-${{ matrix.shared_lib }} - path: build_${{ matrix.shared_lib }}/install + name: fastlanes-cpp-install-${{ matrix.cfg.os }}-shared-${{ matrix.cfg.shared_lib }} + path: build_${{ matrix.cfg.shared_lib }}/install diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 2777650f..2feca41f 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -10,6 +10,7 @@ run-name: >- on: push: + branches: [ main, dev ] pull_request: branches: [ main, dev ] diff --git a/.github/workflows/flatbuffers-ci.yml b/.github/workflows/flatbuffers-ci.yml index 775ccee1..5f0336aa 100644 --- a/.github/workflows/flatbuffers-ci.yml +++ b/.github/workflows/flatbuffers-ci.yml @@ -12,8 +12,10 @@ run-name: >- # Trigger on every push & PR, on all branches # ───────────────────────────────────────────────────────────── on: - push: # no branches filter ⇒ every branch - pull_request: # no branches filter ⇒ every target branch + push: + branches: [ main, dev ] + pull_request: + branches: [ main, dev ] concurrency: group: flatbuffers-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/fsst.yaml b/.github/workflows/fsst.yaml index f3926baa..bb8fc1f9 100644 --- a/.github/workflows/fsst.yaml +++ b/.github/workflows/fsst.yaml @@ -13,8 +13,9 @@ run-name: >- # ────────────────────────────────────────────────────────────────────────────── on: push: + branches: [ main, dev ] pull_request: - branches: [ "main", "dev" ] + branches: [ main, dev ] # Cancel in-flight runs on the same branch/PR so we do not waste minutes concurrency: diff --git a/.github/workflows/header-check.yml b/.github/workflows/header-check.yml index 55fbb4f0..3fdc3fcc 100644 --- a/.github/workflows/header-check.yml +++ b/.github/workflows/header-check.yml @@ -11,6 +11,7 @@ run-name: >- on: push: + branches: [ main, dev ] pull_request: branches: [ main, dev ] diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b7ee2f56..ba215d2f 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -13,6 +13,7 @@ run-name: >- # ──────────────────────────────────────────────────────── on: push: + branches: [ main, dev ] pull_request: branches: [ main, dev ] workflow_dispatch: diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3751d51e..095e73f3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -14,8 +14,9 @@ run-name: >- on: push: + branches: [ main, dev ] pull_request: - branches: [ "main", "dev" ] + branches: [ main, dev ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.gitignore b/.gitignore index 551b8a0f..e04f51e5 100644 --- a/.gitignore +++ b/.gitignore @@ -126,3 +126,8 @@ rust/target/ skbuild-*/ .idea/ .venv/ + +# Windows build artifacts +build_win.bat +cmake_output.txt +build_win/ diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..59eeffa1 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,121 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## What is FastLanes + +FastLanes is a C++20 columnar compression storage format — "Like Parquet, but with 40% better compression and 40× faster decoding." Zero external dependencies, SIMD-friendly without explicit SIMD instructions. Bindings exist for Python (`python/`), Rust (`rust/`), C (`src/c_api/`), and CUDA (`cuda/`). + +## Build Commands + +FastLanes uses CMake 3.22+ with Ninja. On Linux/macOS it requires Clang >= 13. On Windows it uses MSVC (set up via `vcvarsall.bat`). + +### Configure and build (Release with tests) +```bash +cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFLS_BUILD_TESTING=ON +cmake --build build --parallel +``` + +### Run all tests +```bash +cd build && ctest -j4 --output-on-failure --timeout 300 -E QuickFuzz +``` + +### Run a single test by filter +```bash +build/test/src/dataset_tests/dataset_tests.exe --gtest_filter=FastLanesReaderTester.issue_000 +``` + +### Run a single test target +```bash +cmake --build build --target unit_test && ctest -R unit_test --output-on-failure +``` + +### Key CMake options +| Option | Default | Purpose | +|--------|---------|---------| +| `FLS_BUILD_TESTING` | OFF | Build tests (fetches GoogleTest v1.15.2) | +| `FLS_BUILD_SHARED_LIBS` | OFF | Build as shared library (DLL) instead of static | +| `FLS_BUILD_BENCHMARKING` | OFF | Build benchmarks | +| `FLS_BUILD_PYTHON` | OFF | Build Python bindings | +| `FLS_BUILD_CUDA` | OFF | Build CUDA reader | +| `FLS_ENABLE_CLANG_TIDY` | OFF | Enable clang-tidy on all targets | + +### Windows-specific (MSVC) + +Invoke builds via a `.bat` that calls `vcvarsall.bat` first. Example pattern: +```bat +call "C:\Program Files\Microsoft Visual Studio\...\vcvarsall.bat" arm64 +cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DFLS_BUILD_TESTING=ON +cmake --build build --parallel +``` + +Test data can be cached across builds by setting `FASTLANES_DATA_DIR` environment variable to an existing data directory (e.g., `build_release/_deps/data-src`). + +### Format code +The project uses `.clang-format` (LLVM base, tabs, 120-column limit). Run clang-format on changed files before committing. + +## Architecture + +### Public API + +The main entry point is `fastlanes::Connection` (in `src/include/fls/connection.hpp`): +```cpp +auto conn = fastlanes::connect(); +conn->read_csv("input/"); // ingest CSV +conn->to_fls("output/"); // write FastLanes format +auto reader = conn->read_fls("data.fls"); // read back +auto table = reader->materialize(); +``` + +`TableReader` provides rowgroup-level random access. `RowgroupReader` decompresses individual rowgroups. The reader stack: `TableReader` → `RowgroupReader` → `RowgroupView` → `ColumnView` → `SegmentView`. + +### Library structure + +All source is under `src/`. Each subdirectory builds an OBJECT library that gets linked into the single `FastLanes` library target. Key components: + +- **`cor/`** — Core: architecture detection, CPU features, layout (`Buf`), compression/decompression engines +- **`expression/`** — Expression-based encoding: physical expressions, operators (RLE, FSST, ALP, dict, delta, etc.), interpreter +- **`encoder/`** — High-level encoding pipeline, materializer (decompression) +- **`wizard/`** — Schema discovery: analyzes data and selects optimal encoding per column +- **`reader/`** — File reading: segments, column views, rowgroup views, table reader +- **`table/`** — In-memory table representation: `Rowgroup`, `Table`, `Vector`, typed columns +- **`footer/`** — FlatBuffers-generated metadata descriptors (table, rowgroup, column, segment) +- **`alp/`** — ALP (Adaptive Lossless Floating-Point) compression codec +- **`primitive/`** — Low-level primitives: bitpacking, patching, FSST string compression + +### DLL / Shared library support (Windows) + +The `FLS_API` macro in `src/include/fls/api/api.hpp` controls symbol visibility: +- `FLS_STATIC` defined → `FLS_API` is empty (static build) +- `FLS_BUILD_DLL` defined → `FLS_API` is `__declspec(dllexport)` (building the DLL) +- Neither defined → `FLS_API` is `__declspec(dllimport)` (consuming the DLL) + +When `FLS_BUILD_SHARED_LIBS=ON`, `FLS_BUILD_DLL` is set directory-scoped via `add_compile_definitions` in `src/CMakeLists.txt` so all object libraries under `src/` get it. Test targets (under `test/`) don't get it, so `FLS_API` correctly resolves to `dllimport` for them. + +Any public function or class that test code (or external consumers) calls across the DLL boundary must be marked `FLS_API`. For template functions, the explicit instantiations in the .cpp must also carry `FLS_API`. + +Note: `WINDOWS_EXPORT_ALL_SYMBOLS` does NOT work for this project — the symbol count exceeds the 65535 .def file limit. + +**MSVC dllexport gotchas:** MSVC eagerly instantiates all special member functions for `__declspec(dllexport)` classes. This causes two problems: + +1. **Non-copyable members** (e.g., `vector>`): MSVC tries to generate copy ctor/assign and fails. Fix: explicitly `= delete` copy operations on the class. + +2. **Incomplete types in unique_ptr**: MSVC tries to generate the destructor inline, which needs the complete type. Fix: either include the complete type's header, or declare the destructor in the header and define it `= default` in the .cpp where the type is complete. + +### Type aliases + +Defined in `src/include/fls/common/alias.hpp`: +- `n_t` = `uint64_t` (counts), `idx_t` = `uint32_t` (indices), `bw_t` = `uint8_t` (bit width) +- `up` = `unique_ptr`, `sp` = `shared_ptr` + +### Test structure + +Tests live in `test/src/` with six suites: `dataset_tests`, `expression_tests`, `fls_reader_tests`, `primitive_tests`, `quick_fuzz_tests`, `unit_tests`. All use GoogleTest. On MSVC, a `msvc_heap_guard` object library handles SEH guard-page exceptions that would otherwise cause spurious test failures. + +## Code Style + +- `.clang-tidy` is strict: `WarningsAsErrors: '*'` — all warnings are errors +- Types: `CamelCase`. Functions: `aNy_CasE`. Members: `lower_case` (private: `m_` prefix). Constants: `UPPER_CASE`. Typedefs: `lower_case` with `_t` suffix +- Tabs for indentation, 120-column limit +- PRs target `dev` branch diff --git a/CMakeLists.txt b/CMakeLists.txt index 43acdaa3..baa4eaa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,13 +6,15 @@ cmake_minimum_required(VERSION 3.22) # Requirements : ------------------------------------------------------------------------------------------------------- -find_program(CLANG_CXX NAMES clang++ REQUIRED) -find_program(CLANG_C NAMES clang REQUIRED) - -if (CLANG_CXX AND CLANG_C) - # Set Clang as the compiler explicitly - set(CMAKE_C_COMPILER "${CLANG_C}" CACHE STRING "C Compiler" FORCE) - set(CMAKE_CXX_COMPILER "${CLANG_CXX}" CACHE STRING "C++ Compiler" FORCE) +# On non-Windows platforms, default to Clang unless the user explicitly sets a compiler +# (e.g. -DCMAKE_CXX_COMPILER=g++). On Windows, let CMake use the default (MSVC from vcvars). +if (NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + if (NOT DEFINED CMAKE_CXX_COMPILER) + find_program(CLANG_CXX NAMES clang++ REQUIRED) + find_program(CLANG_C NAMES clang REQUIRED) + set(CMAKE_C_COMPILER "${CLANG_C}" CACHE STRING "C Compiler" FORCE) + set(CMAKE_CXX_COMPILER "${CLANG_CXX}" CACHE STRING "C++ Compiler" FORCE) + endif () endif () @@ -48,10 +50,16 @@ include(GNUInstallDirs) include(enable_sanitizer) # Checks : ------------------------------------------------------------------------------------------------------- -if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - message(FATAL_ERROR "Only Clang is supported!") -endif () -if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) +if (MSVC) + message(STATUS "-- FLS: Building with MSVC ${CMAKE_CXX_COMPILER_VERSION}") +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + message(STATUS "-- FLS: Building with GCC ${CMAKE_CXX_COMPILER_VERSION}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11) + message(FATAL_ERROR "Only GCC >= 11 is supported (C++20 requirement)!") + endif () +elseif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + message(FATAL_ERROR "Only Clang, GCC, and MSVC are supported!") +elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) message(FATAL_ERROR "Only Clang >= 13 is supported!") endif () @@ -62,51 +70,82 @@ endif () # Flags : -------------------------------------------------------------------------------------------------------------- message("---------------------------------------------------------------------------------------------------------") message("-- FLS: detecting flags.") -# First, check if running on GitHub Actions -if (DEFINED ENV{GITHUB_ACTIONS} AND "$ENV{GITHUB_ACTIONS}" STREQUAL "true") - message(STATUS "Running on GitHub Actions runner.") - set(IS_GITHUB_ACTIONS ON) -endif () -# Check if the compiler supports -mavx512dq -check_cxx_compiler_flag("-mavx512dq" COMPILER_SUPPORTS_AVX512DQ) +if (MSVC) + # MSVC auto-targets the host architecture. No manual arch flags needed. + message(STATUS "-- FLS: MSVC build — no arch flags applied.") -# Detect AVX-512DQ hardware support via /proc/cpuinfo -set(HAS_HW_AVX512DQ OFF) -if (EXISTS "/proc/cpuinfo") - file(READ "/proc/cpuinfo" CPUINFO_CONTENT) - if (CPUINFO_CONTENT MATCHES "avx512dq") - set(HAS_HW_AVX512DQ ON) + # Warning level: /W3 for initial port (tighten to /W4 /WX later). + # /Zc:__cplusplus is needed so __cplusplus reports the correct standard version. + # /bigobj is needed for large translation units (e.g. materializer.cpp). + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /Zc:__cplusplus /bigobj /MP") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") +else () + # First, check if running on GitHub Actions + if (DEFINED ENV{GITHUB_ACTIONS} AND "$ENV{GITHUB_ACTIONS}" STREQUAL "true") + message(STATUS "Running on GitHub Actions runner.") + set(IS_GITHUB_ACTIONS ON) endif () -endif () -if (COMPILER_SUPPORTS_AVX512DQ AND HAS_HW_AVX512DQ AND NOT IS_GITHUB_ACTIONS) - message(STATUS "Compiler and hardware both support AVX-512DQ. Adding flag '-mavx512dq'.") - set(FLAGS "-mavx512dq") -elseif (COMPILER_SUPPORTS_AVX512DQ AND HAS_HW_AVX512DQ AND IS_GITHUB_ACTIONS) - message(WARNING "Hardware supports AVX-512DQ, but not adding on GitHub Actions runner.") -elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|i[3-6]86") - message(STATUS "Setting '-march=native' for x86 processors without AVX-512DQ.") - set(FLAGS "-march=native") -else () - message(STATUS "No instruction set flags applied.") -endif () + # Check if the compiler supports -mavx512dq + check_cxx_compiler_flag("-mavx512dq" COMPILER_SUPPORTS_AVX512DQ) -# Append the computed FLAGS to the compiler flags if defined -if (FLAGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}") -endif () + # Detect AVX-512DQ hardware support via /proc/cpuinfo + set(HAS_HW_AVX512DQ OFF) + if (EXISTS "/proc/cpuinfo") + file(READ "/proc/cpuinfo" CPUINFO_CONTENT) + if (CPUINFO_CONTENT MATCHES "avx512dq") + set(HAS_HW_AVX512DQ ON) + endif () + endif () -# Flags for warnings and errors: -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Winconsistent-missing-override -Wshadow -Wconversion -Wnon-virtual-dtor -Wunused -Wpedantic -Woverloaded-virtual -Wshorten-64-to-32") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wconversion") + if (COMPILER_SUPPORTS_AVX512DQ AND HAS_HW_AVX512DQ AND NOT IS_GITHUB_ACTIONS) + message(STATUS "Compiler and hardware both support AVX-512DQ. Adding flag '-mavx512dq'.") + set(FLAGS "-mavx512dq") + elseif (COMPILER_SUPPORTS_AVX512DQ AND HAS_HW_AVX512DQ AND IS_GITHUB_ACTIONS) + message(WARNING "Hardware supports AVX-512DQ, but not adding on GitHub Actions runner.") + elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|i[3-6]86") + message(STATUS "Setting '-march=native' for x86 processors without AVX-512DQ.") + set(FLAGS "-march=native") + else () + message(STATUS "No instruction set flags applied.") + endif () + + # Append the computed FLAGS to the compiler flags if defined + if (FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}") + endif () + + # Flags for warnings and errors (common to Clang and GCC): + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wnon-virtual-dtor -Wunused -Wpedantic -Woverloaded-virtual") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror") + + # Clang-only warning flags (GCC equivalents are covered by clang-tidy): + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow -Wconversion -Winconsistent-missing-override -Wshorten-64-to-32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow -Wconversion") + endif () + # GCC-only warning flags: + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override") + endif () + + # On Windows (Clang, not MSVC), vectorize-width pragmas may not be honoured + # because the CI runners lack AVX-512. Demote the transform-warning to a + # non-fatal warning so -Werror does not reject advisory hints. + if (WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pass-failed") + endif () +endif () if (CMAKE_BUILD_TYPE STREQUAL "Debug") message("---------------------------------------------------------------------------------------------------------") message("-- FLS: Debug mode enabled. Adding -g and -O0.") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0") + if (NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0") + endif () endif () # Options : ------------------------------------------------------------------------------------------------------------ @@ -184,10 +223,18 @@ if (FLS_BUILD_TESTING OR FLS_BUILD_CUDA OR FLS_ENABLE_FSST_TESTING_AND_BENCHMARK # On Windows, GoogleTest uses Microsoft-specific language extensions like `__try` # that trigger Clang's -Wlanguage-extension-token warning. Since we build with -Werror, # selectively disable that warning (and suppress all warnings with -w) ONLY for GoogleTest. - if (MSVC OR WIN32) + if (MSVC) + foreach (_t gtest gtest_main gmock gmock_main) + if (TARGET ${_t}) + get_target_property(_aliased ${_t} ALIASED_TARGET) + if (NOT _aliased) + target_compile_options(${_t} PRIVATE /w) + endif () + endif () + endforeach () + elseif (WIN32) foreach (_t gtest gtest_main gmock gmock_main) if (TARGET ${_t}) - # Skip alias targets (defensive; these names are real targets when fetched) get_target_property(_aliased ${_t} ALIASED_TARGET) if (NOT _aliased) target_compile_options(${_t} PRIVATE -Wno-language-extension-token -w) diff --git a/cmake/enable_sanitizer.cmake b/cmake/enable_sanitizer.cmake index ec54f44c..860eab6a 100644 --- a/cmake/enable_sanitizer.cmake +++ b/cmake/enable_sanitizer.cmake @@ -58,11 +58,13 @@ function(fls_enable_sanitizers target) -fsanitize=address -fsanitize=undefined -fsanitize=vptr - -fsanitize=function -fsanitize=null -fno-sanitize-recover=all -fno-omit-frame-pointer ) + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + list(APPEND _san_flags -fsanitize=function) + endif () string(REPLACE ";" " " _san_flags_str "${_san_flags}") message(STATUS diff --git a/examples/rust_example/Cargo.toml b/examples/rust_example/Cargo.toml index 16cd1dc6..5b8db0f6 100644 --- a/examples/rust_example/Cargo.toml +++ b/examples/rust_example/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] anyhow = "1.0" -fls-rs = "0.1.3-alpha.7" +fls-rs = { path = "../../rust" } [[bin]] name = "rust_example" diff --git a/fls_gen/cuda_unpack.py b/fls_gen/cuda_unpack.py index 061f4d1a..e767bcd7 100644 --- a/fls_gen/cuda_unpack.py +++ b/fls_gen/cuda_unpack.py @@ -179,7 +179,7 @@ def unpack_store(self, cu): def gen_before_loop_pragmas(self, cu): if self.mode is Mode.aav and self.ow > 46: - cu("#pragma clang loop vectorize(enable)") + cu("FLS_PRAGMA_VECTORIZE") def get_func_signature(self): return '__device__ void unpack_$bw$bw_$ow$ow_$crw$crw_$uf$uf(const uint$ow$_t *__restrict a_in_p, uint$ow$_t ' \ diff --git a/mk/benchmark.mk b/mk/benchmark.mk index 1c15fbda..c18c65f4 100644 --- a/mk/benchmark.mk +++ b/mk/benchmark.mk @@ -12,7 +12,7 @@ VENV_DIR := $(abspath ../.venv) PYTHON3 := $(VENV_DIR)/bin/python3 -PYTHON := $(if $(wildcard $(PYTHON3)),$(PYTHON3),$(VENV_DIR)/bin/python) +PYTHON ?= $(if $(wildcard $(PYTHON3)),$(PYTHON3),$(VENV_DIR)/bin/python) PIP := $(PYTHON) -m pip # ── Script location (relative to project root) diff --git a/mk/data.mk b/mk/data.mk index d2fdcd68..dcb6ccf2 100644 --- a/mk/data.mk +++ b/mk/data.mk @@ -10,7 +10,7 @@ PROJECT_ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..) -include $(PROJECT_ROOT)/mk/python.mk # non-fatal if missing VENV ?= $(PROJECT_ROOT)/.venv -PYTHON ?= $(VENV)/bin/python3 # python.exe on Win via python.mk +PYTHON ?= $(VENV)/bin/python3 PIP ?= $(PYTHON) -m pip DATA_DIR := $(PROJECT_ROOT)/data diff --git a/mk/example.mk b/mk/example.mk index 4b1362d3..3b1548ae 100644 --- a/mk/example.mk +++ b/mk/example.mk @@ -132,7 +132,7 @@ clean-examples: # ───────────────────────────────────────────────────────────── VENV_DIR := $(EXAMPLES_DIR)/.venv -PYTHON := $(VENV_DIR)/bin/python +PYTHON ?= $(VENV_DIR)/bin/python PIP := $(VENV_DIR)/bin/pip PDF_SCRIPT := $(PROJECT_DIR)/data/example/extract_sentences.py CSV_OUTPUT := $(PROJECT_DIR)/data/example/papers.csv diff --git a/mk/header_check.mk b/mk/header_check.mk index 225af9e6..2ad86732 100644 --- a/mk/header_check.mk +++ b/mk/header_check.mk @@ -5,7 +5,7 @@ # ──────────────────────────────────────────────────────── include mk/venv.mk -PYTHON := $(VENV_DIR)/bin/python3 +PYTHON ?= $(VENV_DIR)/bin/python3 SCRIPT := scripts/header_check.py .PHONY: check-header fix-header diff --git a/mk/quick_fuzz.mk b/mk/quick_fuzz.mk index 2b6a205d..077c1274 100644 --- a/mk/quick_fuzz.mk +++ b/mk/quick_fuzz.mk @@ -7,8 +7,6 @@ # ────────────────────────────────────────────────────────── # Bump & verify fuzz seed helper targets # ────────────────────────────────────────────────────────── -PYTHON := python3 - # point ROOT at repo root (parent of this mk/ directory) ROOT := $(shell dirname $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index cf802894..c8c86124 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -36,7 +36,7 @@ cxx = "1" anyhow = "1" [build-dependencies] -vergen = { version = "9.0.5", default-features = false, features = ["build"] } -vergen-gix = { version = "1.0.9", default-features = false, features = ["build"] } +vergen = { version = "9.1.0", default-features = false, features = ["build"] } +vergen-gix = { version = "9.1.0", default-features = false, features = ["build"] } cmake = "0.1" cxx-build = "1" diff --git a/rust/vendor/fastlanes/include/fls/expression/analyze_operator.hpp b/rust/vendor/fastlanes/include/fls/expression/analyze_operator.hpp index 87d9847c..fc8cb265 100644 --- a/rust/vendor/fastlanes/include/fls/expression/analyze_operator.hpp +++ b/rust/vendor/fastlanes/include/fls/expression/analyze_operator.hpp @@ -23,9 +23,9 @@ struct InterpreterState; * Histogram \*--------------------------------------------------------------------------------------------------------------------*/ template -class Histogram { +class AnalyzeHistogram { public: - Histogram() = default; // + AnalyzeHistogram() = default; // public: void Cal(PT* data); void Reset(); @@ -56,7 +56,7 @@ struct enc_analyze_opr { alp::exp_p_t exception_pos_arr[CFG::VEC_SZ]; PT exceptions[CFG::VEC_SZ]; bw_t bw; - Histogram histogram; + AnalyzeHistogram histogram; NullMapView null_map_view; bool is_rsum; }; diff --git a/rust/vendor/fastlanes/include/fls/table/rowgroup.hpp b/rust/vendor/fastlanes/include/fls/table/rowgroup.hpp index 3ad1b2b6..fef18be0 100644 --- a/rust/vendor/fastlanes/include/fls/table/rowgroup.hpp +++ b/rust/vendor/fastlanes/include/fls/table/rowgroup.hpp @@ -240,6 +240,8 @@ class Rowgroup { /// void Cast(); /// + void PopulateBiMap(); + /// void Init(); /// void FillMissingValues(n_t how_many_to_fill); diff --git a/rust/vendor/fastlanes/src/connection.cpp b/rust/vendor/fastlanes/src/connection.cpp index adca4e85..396df5c8 100644 --- a/rust/vendor/fastlanes/src/connection.cpp +++ b/rust/vendor/fastlanes/src/connection.cpp @@ -63,9 +63,12 @@ void prepare_rowgroup(Rowgroup& rowgroup) { // could be combined rowgroup.Init(); - rowgroup.Cast(); rowgroup.Finalize(); rowgroup.GetStatistics(); + rowgroup.Cast(); + + // Populate bimap after Cast, so it reflects the final (possibly cast) column types + rowgroup.PopulateBiMap(); } void Connection::prepare_table() const { diff --git a/rust/vendor/fastlanes/src/cor/prm/fsst12/libfsst12.cpp b/rust/vendor/fastlanes/src/cor/prm/fsst12/libfsst12.cpp index 53aace0f..e81eedd6 100644 --- a/rust/vendor/fastlanes/src/cor/prm/fsst12/libfsst12.cpp +++ b/rust/vendor/fastlanes/src/cor/prm/fsst12/libfsst12.cpp @@ -257,25 +257,25 @@ static inline ulong compressBulk( } cur += (code >> 12); res |= (code & FSST12_CODE_MASK) << 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } while (cur < end) { ulong code = symbolMap.findExpansion(Symbol12(cur, end)); u32 res = (code & FSST12_CODE_MASK); if (out + 8 > lim) { - return curLine; // u32 write would be out of bounds (out of output memory) + return curLine; // u64 write would be out of bounds (out of output memory) } cur += code >> 12; if (cur >= end) { - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 2; break; } code = symbolMap.findExpansion(Symbol12(cur, end)); res |= (code & FSST12_CODE_MASK) << 12; cur += code >> 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } lenOut[curLine] = out - strOut[curLine]; diff --git a/rust/vendor/fastlanes/src/expression/analyze_operator.cpp b/rust/vendor/fastlanes/src/expression/analyze_operator.cpp index 63c40f59..d83e4c94 100644 --- a/rust/vendor/fastlanes/src/expression/analyze_operator.cpp +++ b/rust/vendor/fastlanes/src/expression/analyze_operator.cpp @@ -35,7 +35,7 @@ class Option { }; template -void Histogram::Cal(PT* data) { +void AnalyzeHistogram::Cal(PT* data) { val_vec.clear(); rep_vec.clear(); @@ -77,17 +77,14 @@ bool is_exception(Option& option, T val) { FLS_ASSERT_CORRECT_N(option.n_exceptions) FLS_ASSERT_CORRECT_SZ(option.size()) - make_unsigned_t a = *reinterpret_cast*>(&option.base); - make_unsigned_t b = a + pow2>(option.bw); - T real_upper = *reinterpret_cast(&b); - - if (val < option.base) { - return true; - } - if (val >= real_upper) { - return true; + if (option.bw >= sizeof(make_unsigned_t) * CHAR_BIT) { + return false; } - return false; + + // Use unsigned delta to correctly handle base + 2^bw overflow/wraparound. + make_unsigned_t uval = *reinterpret_cast*>(&val); + make_unsigned_t ubase = *reinterpret_cast*>(&option.base); + return static_cast>(uval - ubase) >= pow2>(option.bw); } template @@ -125,7 +122,7 @@ n_t count_exceptions(const T lower_bound, } template -Option find_best_option(Histogram& histogram, vec_idx_t first_base_idx, vec_idx_t next_base_idx) { +Option find_best_option(AnalyzeHistogram& histogram, vec_idx_t first_base_idx, vec_idx_t next_base_idx) { /* Initialize */ Option result; @@ -149,17 +146,19 @@ Option find_best_option(Histogram& histogram, vec_idx_t first_base_idx, ve } template -void Histogram::Reset() { +void AnalyzeHistogram::Reset() { val_vec.clear(); rep_vec.clear(); } // -template class Histogram; -template class Histogram; -template class Histogram; -template class Histogram; -template class Histogram; -template class Histogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; template enc_analyze_opr::enc_analyze_opr(const PhysicalExpr& expr, diff --git a/rust/vendor/fastlanes/src/expression/frequency_operator.cpp b/rust/vendor/fastlanes/src/expression/frequency_operator.cpp index 2a43236c..44afcaf6 100644 --- a/rust/vendor/fastlanes/src/expression/frequency_operator.cpp +++ b/rust/vendor/fastlanes/src/expression/frequency_operator.cpp @@ -193,7 +193,7 @@ void dec_frequency_opr::Decode(n_t vec_idx) { auto* exc_pos_arr = reinterpret_cast(exceptions_position_segment.data); auto n_exceptions = *reinterpret_cast(n_exceptions_segment.data); - FLS_ASSERT_CORRECT_POS(n_exceptions) + FLS_ASSERT_LE(n_exceptions, CFG::VEC_SZ) for (auto val_idx {0}; val_idx < n_exceptions; ++val_idx) { auto next_pos = exc_pos_arr[val_idx]; diff --git a/rust/vendor/fastlanes/src/expression/null_operator.cpp b/rust/vendor/fastlanes/src/expression/null_operator.cpp index 48a3d5ff..2141791d 100644 --- a/rust/vendor/fastlanes/src/expression/null_operator.cpp +++ b/rust/vendor/fastlanes/src/expression/null_operator.cpp @@ -99,7 +99,7 @@ void dec_null_opr::Materialize(n_t vec_idx, TypedCol& typed_col) { auto* exc_pos_arr = reinterpret_cast(vals_position_segment.data); auto n_exceptions = *reinterpret_cast(n_vals_segment.data); - FLS_ASSERT_CORRECT_POS(n_exceptions) + FLS_ASSERT_LE(n_exceptions, CFG::VEC_SZ) for (auto val_idx {0}; val_idx < n_exceptions; ++val_idx) { auto next_pos = exc_pos_arr[val_idx]; diff --git a/rust/vendor/fastlanes/src/expression/slpatch_operator.cpp b/rust/vendor/fastlanes/src/expression/slpatch_operator.cpp index 2046b833..493e7403 100644 --- a/rust/vendor/fastlanes/src/expression/slpatch_operator.cpp +++ b/rust/vendor/fastlanes/src/expression/slpatch_operator.cpp @@ -133,7 +133,7 @@ void dec_slpatch_opr::Patch(n_t vec_idx) { auto* exc_pos_arr = reinterpret_cast(exceptions_position_segment.data); auto n_exceptions = *reinterpret_cast(n_exceptions_segment.data); - FLS_ASSERT_CORRECT_POS(n_exceptions) + FLS_ASSERT_LE(n_exceptions, CFG::VEC_SZ) for (auto val_idx {0}; val_idx < n_exceptions; ++val_idx) { auto next_pos = exc_pos_arr[val_idx]; diff --git a/rust/vendor/fastlanes/src/primitive/fsst12/fsst12.cpp b/rust/vendor/fastlanes/src/primitive/fsst12/fsst12.cpp index 38be8be5..b8578c02 100644 --- a/rust/vendor/fastlanes/src/primitive/fsst12/fsst12.cpp +++ b/rust/vendor/fastlanes/src/primitive/fsst12/fsst12.cpp @@ -57,25 +57,25 @@ compressBulk(Symbol12Map& symbolMap, ulong nlines, u32 lenIn[], u8* strIn[], ulo } cur += (code >> 12); res |= (code & FSST12_CODE_MASK) << 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } while (cur < end) { ulong code = symbolMap.findExpansion(Symbol12(cur, end)); u32 res = (code & FSST12_CODE_MASK); if (out + 8 > lim) { - return string_idx; // u32 write would be out of bounds (out of output memory) + return string_idx; // u64 write would be out of bounds (out of output memory) } cur += code >> 12; if (cur >= end) { - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 2; break; } code = symbolMap.findExpansion(Symbol12(cur, end)); res |= (code & FSST12_CODE_MASK) << 12; cur += code >> 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } } diff --git a/rust/vendor/fastlanes/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp b/rust/vendor/fastlanes/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp index 4ace15cc..f517d341 100644 --- a/rust/vendor/fastlanes/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp +++ b/rust/vendor/fastlanes/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp @@ -19,32 +19,30 @@ void unrsum(const uint8_t* a_in_p, uint8_t* a_out_p) { register_0_1 = in[(0 * 128) + (i * 1) + (128 * 1)]; out[(0 * 128) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 128) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 128) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 128) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 128) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 128) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 128) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 128) + (i * 1) + (128 * 8)]; out[(i * 1) + (0 * 128) + 896] = tmp_0; } } @@ -62,64 +60,62 @@ void unrsum(const uint16_t* a_in_p, uint16_t* a_out_p) { register_0_1 = in[(0 * 64) + (i * 1) + (128 * 1)]; out[(0 * 64) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 64) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 64) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 64) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 64) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 64) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 64) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 64) + (i * 1) + (128 * 8)]; + register_0_0 = register_0_1; out[(i * 1) + (0 * 64) + 896] = tmp_0; register_0_1 = in[64 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 0) + i] = tmp_0; register_0_1 = in[64 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 1) + i] = tmp_0; register_0_1 = in[64 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 2) + i] = tmp_0; register_0_1 = in[64 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 3) + i] = tmp_0; register_0_1 = in[64 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 4) + i] = tmp_0; register_0_1 = in[64 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 5) + i] = tmp_0; register_0_1 = in[64 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 6) + i] = tmp_0; register_0_1 = in[64 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 7) + i]; a_out_p[64 + (128 * 7) + i] = tmp_0; } } @@ -137,128 +133,126 @@ void unrsum(const uint32_t* a_in_p, uint32_t* a_out_p) { register_0_1 = in[(0 * 32) + (i * 1) + (128 * 1)]; out[(0 * 32) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 32) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 32) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 32) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 32) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 32) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 32) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 32) + (i * 1) + (128 * 8)]; + register_0_0 = register_0_1; out[(i * 1) + (0 * 32) + 896] = tmp_0; register_0_1 = in[64 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 0) + i] = tmp_0; register_0_1 = in[64 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 1) + i] = tmp_0; register_0_1 = in[64 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 2) + i] = tmp_0; register_0_1 = in[64 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 3) + i] = tmp_0; register_0_1 = in[64 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 4) + i] = tmp_0; register_0_1 = in[64 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 5) + i] = tmp_0; register_0_1 = in[64 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 6) + i] = tmp_0; register_0_1 = in[64 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 7) + i] = tmp_0; register_0_1 = in[32 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 0) + i] = tmp_0; register_0_1 = in[32 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 1) + i] = tmp_0; register_0_1 = in[32 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 2) + i] = tmp_0; register_0_1 = in[32 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 3) + i] = tmp_0; register_0_1 = in[32 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 4) + i] = tmp_0; register_0_1 = in[32 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 5) + i] = tmp_0; register_0_1 = in[32 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 6) + i] = tmp_0; register_0_1 = in[32 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 7) + i] = tmp_0; register_0_1 = in[96 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 0) + i] = tmp_0; register_0_1 = in[96 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 1) + i] = tmp_0; register_0_1 = in[96 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 2) + i] = tmp_0; register_0_1 = in[96 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 3) + i] = tmp_0; register_0_1 = in[96 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 4) + i] = tmp_0; register_0_1 = in[96 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 5) + i] = tmp_0; register_0_1 = in[96 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 6) + i] = tmp_0; register_0_1 = in[96 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 7) + i]; a_out_p[96 + (128 * 7) + i] = tmp_0; } } @@ -276,256 +270,254 @@ void unrsum(const uint64_t* a_in_p, uint64_t* a_out_p) { register_0_1 = in[(0 * 16) + (i * 1) + (128 * 1)]; out[(0 * 16) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 16) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 16) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 16) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 16) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 16) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 16) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 16) + (i * 1) + (128 * 8)]; + register_0_0 = register_0_1; out[(i * 1) + (0 * 16) + 896] = tmp_0; register_0_1 = in[64 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 0) + i] = tmp_0; register_0_1 = in[64 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 1) + i] = tmp_0; register_0_1 = in[64 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 2) + i] = tmp_0; register_0_1 = in[64 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 3) + i] = tmp_0; register_0_1 = in[64 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 4) + i] = tmp_0; register_0_1 = in[64 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 5) + i] = tmp_0; register_0_1 = in[64 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 6) + i] = tmp_0; register_0_1 = in[64 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 7) + i] = tmp_0; register_0_1 = in[32 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 0) + i] = tmp_0; register_0_1 = in[32 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 1) + i] = tmp_0; register_0_1 = in[32 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 2) + i] = tmp_0; register_0_1 = in[32 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 3) + i] = tmp_0; register_0_1 = in[32 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 4) + i] = tmp_0; register_0_1 = in[32 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 5) + i] = tmp_0; register_0_1 = in[32 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 6) + i] = tmp_0; register_0_1 = in[32 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 7) + i] = tmp_0; register_0_1 = in[96 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 0) + i] = tmp_0; register_0_1 = in[96 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 1) + i] = tmp_0; register_0_1 = in[96 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 2) + i] = tmp_0; register_0_1 = in[96 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 3) + i] = tmp_0; register_0_1 = in[96 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 4) + i] = tmp_0; register_0_1 = in[96 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 5) + i] = tmp_0; register_0_1 = in[96 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 6) + i] = tmp_0; register_0_1 = in[96 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 7) + i] = tmp_0; register_0_1 = in[16 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 0) + i] = tmp_0; register_0_1 = in[16 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 1) + i] = tmp_0; register_0_1 = in[16 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 2) + i] = tmp_0; register_0_1 = in[16 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 3) + i] = tmp_0; register_0_1 = in[16 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 4) + i] = tmp_0; register_0_1 = in[16 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 5) + i] = tmp_0; register_0_1 = in[16 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 6) + i] = tmp_0; register_0_1 = in[16 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 7) + i] = tmp_0; register_0_1 = in[80 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 0) + i] = tmp_0; register_0_1 = in[80 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 1) + i] = tmp_0; register_0_1 = in[80 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 2) + i] = tmp_0; register_0_1 = in[80 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 3) + i] = tmp_0; register_0_1 = in[80 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 4) + i] = tmp_0; register_0_1 = in[80 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 5) + i] = tmp_0; register_0_1 = in[80 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 6) + i] = tmp_0; register_0_1 = in[80 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 7) + i]; a_out_p[80 + (128 * 7) + i] = tmp_0; + register_0_0 = register_0_1; register_0_1 = in[48 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 0) + i] = tmp_0; register_0_1 = in[48 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 1) + i] = tmp_0; register_0_1 = in[48 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 2) + i] = tmp_0; register_0_1 = in[48 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 3) + i] = tmp_0; register_0_1 = in[48 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 4) + i] = tmp_0; register_0_1 = in[48 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 5) + i] = tmp_0; register_0_1 = in[48 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 6) + i] = tmp_0; register_0_1 = in[48 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 7) + i] = tmp_0; register_0_1 = in[112 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 0) + i] = tmp_0; register_0_1 = in[112 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 1) + i] = tmp_0; register_0_1 = in[112 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 2) + i] = tmp_0; register_0_1 = in[112 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 3) + i] = tmp_0; register_0_1 = in[112 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 4) + i] = tmp_0; register_0_1 = in[112 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 5) + i] = tmp_0; register_0_1 = in[112 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 6) + i] = tmp_0; register_0_1 = in[112 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 7) + i]; a_out_p[112 + (128 * 7) + i] = tmp_0; } } diff --git a/rust/vendor/fastlanes/src/table/rowgroup.cpp b/rust/vendor/fastlanes/src/table/rowgroup.cpp index afad1b67..e44187cf 100644 --- a/rust/vendor/fastlanes/src/table/rowgroup.cpp +++ b/rust/vendor/fastlanes/src/table/rowgroup.cpp @@ -160,20 +160,13 @@ struct finalize_visitor { template void operator()(up>& typed_column) const { - auto& min = typed_column->m_stats.min; - auto& max = typed_column->m_stats.max; - auto& bimap_frequency = typed_column->m_stats.bimap_frequency; + auto& min = typed_column->m_stats.min; + auto& max = typed_column->m_stats.max; - // into the dictionary for (n_t val_idx {0}; val_idx < typed_column->data.size(); val_idx++) { const auto current_val = typed_column->data[val_idx]; - if (!bimap_frequency.contains_value(current_val)) { - n_t current_idx = bimap_frequency.size(); - bimap_frequency.insert(current_idx, {current_val}); - } - - min = std::min(min, current_val); - max = std::max(max, current_val); + min = std::min(min, current_val); + max = std::max(max, current_val); } } @@ -213,6 +206,54 @@ void Rowgroup::Finalize() { } } +/*--------------------------------------------------------------------------------------------------------------------*\ + * PopulateBiMap +\*--------------------------------------------------------------------------------------------------------------------*/ +struct populate_bimap_visitor { + explicit populate_bimap_visitor() = default; + + template + void operator()(up>& typed_column) const { + auto& min = typed_column->m_stats.min; + auto& max = typed_column->m_stats.max; + auto& bimap_frequency = typed_column->m_stats.bimap_frequency; + + for (n_t val_idx {0}; val_idx < typed_column->data.size(); val_idx++) { + const auto current_val = typed_column->data[val_idx]; + if (!bimap_frequency.contains_value(current_val)) { + n_t current_idx = bimap_frequency.size(); + bimap_frequency.insert(current_idx, current_val); + } else { + n_t existing_key = bimap_frequency.get_key(current_val); + bimap_frequency.insert(existing_key, current_val); + } + + min = std::min(min, current_val); + max = std::max(max, current_val); + } + } + + void operator()(up& str_col) const { + // string bimap is handled by GetStatistics + } + + void operator()(up& struct_col) const { + for (auto& col : struct_col->internal_rowgroup) { + visit(populate_bimap_visitor {}, col); + } + } + + void operator()(auto& col) const { + FLS_UNREACHABLE(); + } +}; + +void Rowgroup::PopulateBiMap() { + for (auto& col : internal_rowgroup) { + visit(populate_bimap_visitor {}, col); + } +} + /*--------------------------------------------------------------------------------------------------------------------*\ * Cast Check \*--------------------------------------------------------------------------------------------------------------------*/ @@ -435,14 +476,13 @@ void cast_from_logical_to_physical(const Rowgroup& old_table, Rowgroup& new_tabl struct rowgroup_equality_visitor { template bool operator()(const up>& org_col, const up>& decoded_col) const { - // FLS_ASSERT_E(org_col->data.size(), org_col->null_map_arr.size()) for (idx_t idx {0}; idx < org_col->data.size(); ++idx) { - const auto& original_val = org_col->data[idx]; - const auto& decoded_val = decoded_col->data[idx]; - if (org_col->null_map_arr[idx]) { + if (idx < org_col->null_map_arr.size() && org_col->null_map_arr[idx]) { continue; } + const auto& original_val = org_col->data[idx]; + const auto& decoded_val = decoded_col->data[idx]; if (original_val != decoded_val) { return false; } @@ -471,7 +511,7 @@ struct rowgroup_equality_visitor { } for (idx_t idx {0}; idx < org_col->length_arr.size(); ++idx) { - if (org_col->null_map_arr[idx]) { + if (idx < org_col->null_map_arr.size() && org_col->null_map_arr[idx]) { continue; } const fls_string_t org_fls_string {org_col->str_p_arr[idx], org_col->length_arr[idx]}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 056ed968..ecbcd95f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,26 @@ target_include_directories(fls_headers add_library(FastLanes::headers ALIAS fls_headers) + +########################################################################### +# Propagate the shared/static build mode to all object-library targets. +# add_compile_definitions is directory-scoped, so only targets under src/ +# will pick up FLS_BUILD_DLL — test targets won't, so FLS_API correctly +# expands to __declspec(dllimport) for consumers. +########################################################################### +if (FLS_BUILD_SHARED_LIBS) + add_compile_definitions(FLS_BUILD_DLL) + # Hide all symbols by default; only FLS_API-marked symbols are exported. + # This prevents template instantiations from leaking across the DSO boundary + # and avoids symbol interposition issues (e.g. broken std::visit dispatch + # when GCC's linker merges variant vtables from the library and consumer). + if (NOT MSVC) + add_compile_options(-fvisibility=hidden -fvisibility-inlines-hidden) + endif () +else () + add_compile_definitions(FLS_STATIC) +endif () + ########################################################################### # 2. Sub-directories that build individual components ########################################################################### @@ -59,19 +79,11 @@ if (FLS_BUILD_SHARED_LIBS) connection.cpp ${FASTLANES_OBJECT_FILES} ) - target_compile_definitions(FastLanes - PRIVATE - FLS_BUILD_DLL - ) else () add_library(FastLanes STATIC connection.cpp ${FASTLANES_OBJECT_FILES} ) - target_compile_definitions(FastLanes - PUBLIC - FLS_STATIC - ) endif () target_compile_features(FastLanes PUBLIC cxx_std_20) @@ -81,6 +93,12 @@ target_link_libraries(FastLanes FastLanes::headers ) +# Let consumers know whether they are linking against a static or shared build. +# FLS_STATIC makes FLS_API expand to nothing; without it MSVC defaults to dllimport. +if (NOT FLS_BUILD_SHARED_LIBS) + target_compile_definitions(FastLanes PUBLIC FLS_STATIC) +endif () + add_library(FastLanes::core ALIAS FastLanes) # Optional IWYU integration diff --git a/src/alp/src/encoder.cpp b/src/alp/src/encoder.cpp index b349887d..8c641488 100644 --- a/src/alp/src/encoder.cpp +++ b/src/alp/src/encoder.cpp @@ -11,6 +11,7 @@ #include "alp/sampler.hpp" #include "alp/state.hpp" #include "fls/common/assert.hpp" // fix me +#include "fls/compiler.hpp" #include "fls/ffor_util.hpp" #include #include // for std::ceil @@ -97,10 +98,7 @@ void encoder::encode_simdized(const PT* data_p, } } -#if !defined(_WIN32) - // Only non-Windows platforms will see this pragma -#pragma clang loop vectorize_width(64) -#endif + FLS_PRAGMA_VECTORIZE_WIDTH(64) for (uint64_t i {0}; i < config::VECTOR_SIZE; i++) { auto const actual_value = VALUE_ARR_WITHOUT_SPECIALS[i]; @@ -280,7 +278,9 @@ void encoder::find_top_k_combinations(const PT* smp_arr, state& // We try all combinations in search for the one which minimize the compression size for (int8_t exponent_idx = Constants::MAX_EXPONENT; exponent_idx >= 0; --exponent_idx) { - for (int8_t factor_idx = exponent_idx; factor_idx >= 0; --factor_idx) { + for (int8_t factor_idx = std::min(exponent_idx, static_cast(Constants::FACT_ARR.size() - 1)); + factor_idx >= 0; + --factor_idx) { uint16_t exceptions_count = {0}; uint16_t non_exceptions_count = {0}; uint32_t estimated_bits_per_value = {0}; diff --git a/src/alp/src/falp.cpp b/src/alp/src/falp.cpp index dbdf805d..320f266e 100644 --- a/src/alp/src/falp.cpp +++ b/src/alp/src/falp.cpp @@ -5,13 +5,14 @@ // ──────────────────────────────────────────────────────── // generated! // NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#pragma GCC diagnostic ignored "-Wfloat-conversion" -#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" +#include "fls/compiler.hpp" +FLS_DIAG_PUSH +FLS_DIAG_IGNORE_SIGN_CONV +FLS_DIAG_IGNORE_FLOAT_CONV +FLS_DIAG_IGNORE_INT_FLOAT_CONV -#include "alp/falp.hpp" #include "alp/constants.hpp" +#include "alp/falp.hpp" namespace generated { namespace falp::fallback { namespace scalar { static void falp_0bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, double* __restrict a_out_p, @@ -27,7 +28,7 @@ static void falp_0bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { tmp_0 = base_0; tmp_0 *= factor; @@ -114,7 +115,7 @@ static void falp_1bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 1) - 1); @@ -581,7 +582,7 @@ static void falp_2bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 2) - 1); @@ -1049,7 +1050,7 @@ static void falp_3bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 3) - 1); @@ -1520,7 +1521,7 @@ static void falp_4bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 4) - 1); @@ -1990,7 +1991,7 @@ static void falp_5bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 5) - 1); @@ -2465,7 +2466,7 @@ static void falp_6bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 6) - 1); @@ -2941,7 +2942,7 @@ static void falp_7bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 7) - 1); @@ -3420,7 +3421,7 @@ static void falp_8bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 8) - 1); @@ -3894,7 +3895,7 @@ static void falp_9bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 9) - 1); @@ -4377,7 +4378,7 @@ static void falp_10bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 10) - 1); @@ -4861,7 +4862,7 @@ static void falp_11bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 11) - 1); @@ -5348,7 +5349,7 @@ static void falp_12bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 12) - 1); @@ -5834,7 +5835,7 @@ static void falp_13bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 13) - 1); @@ -6325,7 +6326,7 @@ static void falp_14bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 14) - 1); @@ -6817,7 +6818,7 @@ static void falp_15bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 15) - 1); @@ -7312,7 +7313,7 @@ static void falp_16bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 16) - 1); @@ -7794,7 +7795,7 @@ static void falp_17bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 17) - 1); @@ -8293,7 +8294,7 @@ static void falp_18bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 18) - 1); @@ -8793,7 +8794,7 @@ static void falp_19bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 19) - 1); @@ -9296,7 +9297,7 @@ static void falp_20bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 20) - 1); @@ -9798,7 +9799,7 @@ static void falp_21bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 21) - 1); @@ -10305,7 +10306,7 @@ static void falp_22bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 22) - 1); @@ -10813,7 +10814,7 @@ static void falp_23bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 23) - 1); @@ -11324,7 +11325,7 @@ static void falp_24bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 24) - 1); @@ -11830,7 +11831,7 @@ static void falp_25bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 25) - 1); @@ -12345,7 +12346,7 @@ static void falp_26bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 26) - 1); @@ -12861,7 +12862,7 @@ static void falp_27bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 27) - 1); @@ -13380,7 +13381,7 @@ static void falp_28bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 28) - 1); @@ -13898,7 +13899,7 @@ static void falp_29bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 29) - 1); @@ -14421,7 +14422,7 @@ static void falp_30bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 30) - 1); @@ -14945,7 +14946,7 @@ static void falp_31bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 31) - 1); @@ -15472,7 +15473,7 @@ static void falp_32bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 32) - 1); @@ -15970,7 +15971,7 @@ static void falp_33bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 33) - 1); @@ -16501,7 +16502,7 @@ static void falp_34bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 34) - 1); @@ -17033,7 +17034,7 @@ static void falp_35bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 35) - 1); @@ -17568,7 +17569,7 @@ static void falp_36bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 36) - 1); @@ -18102,7 +18103,7 @@ static void falp_37bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 37) - 1); @@ -18641,7 +18642,7 @@ static void falp_38bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 38) - 1); @@ -19181,7 +19182,7 @@ static void falp_39bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 39) - 1); @@ -19724,7 +19725,7 @@ static void falp_40bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 40) - 1); @@ -20262,7 +20263,7 @@ static void falp_41bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 41) - 1); @@ -20809,7 +20810,7 @@ static void falp_42bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 42) - 1); @@ -21357,7 +21358,7 @@ static void falp_43bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 43) - 1); @@ -21908,7 +21909,7 @@ static void falp_44bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 44) - 1); @@ -22458,7 +22459,7 @@ static void falp_45bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 45) - 1); @@ -23013,7 +23014,7 @@ static void falp_46bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 46) - 1); @@ -23569,7 +23570,7 @@ static void falp_47bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 47) - 1); @@ -24128,7 +24129,7 @@ static void falp_48bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 48) - 1); @@ -24674,7 +24675,7 @@ static void falp_49bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 49) - 1); @@ -25237,7 +25238,7 @@ static void falp_50bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 50) - 1); @@ -25801,7 +25802,7 @@ static void falp_51bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 51) - 1); @@ -26368,7 +26369,7 @@ static void falp_52bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 52) - 1); @@ -26934,7 +26935,7 @@ static void falp_53bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 53) - 1); @@ -27505,7 +27506,7 @@ static void falp_54bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 54) - 1); @@ -28077,7 +28078,7 @@ static void falp_55bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 55) - 1); @@ -28652,7 +28653,7 @@ static void falp_56bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 56) - 1); @@ -29222,7 +29223,7 @@ static void falp_57bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 57) - 1); @@ -29801,7 +29802,7 @@ static void falp_58bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 58) - 1); @@ -30381,7 +30382,7 @@ static void falp_59bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 59) - 1); @@ -30964,7 +30965,7 @@ static void falp_60bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 60) - 1); @@ -31546,7 +31547,7 @@ static void falp_61bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 61) - 1); @@ -32133,7 +32134,7 @@ static void falp_62bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 62) - 1); @@ -32721,7 +32722,7 @@ static void falp_63bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 63) - 1); @@ -33312,7 +33313,7 @@ static void falp_64bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] double frac10 = alp::Constants::FRAC_ARR[exp]; [[maybe_unused]] double tmp_dbl; [[maybe_unused]] int64_t tmp_int; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); register_0 += base_0; @@ -42756,5 +42757,5 @@ void falp(const uint32_t* __restrict a_in_p, } }}}; // namespace generated::falp::fallback::scalar -#pragma GCC diagnostic pop +FLS_DIAG_POP // NOLINTEND diff --git a/src/connection.cpp b/src/connection.cpp index fbe0d46b..71fe7ccd 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -62,14 +62,17 @@ void prepare_rowgroup(Rowgroup& rowgroup, const Config& config) { // init rowgroup.Init(); + rowgroup.Finalize(); + rowgroup.GetStatistics(); + // Only cast if schema wasn’t forced const bool shouldCast = !config.is_forced_schema && !config.is_forced_schema_pool; if (shouldCast) { rowgroup.Cast(); } - rowgroup.Finalize(); - rowgroup.GetStatistics(); + // Populate bimap after Cast, so it reflects the final (possibly cast) column types + rowgroup.PopulateBiMap(); } void Connection::prepare_table() const { @@ -146,7 +149,7 @@ Status Connection::verify_fls(const path& file_path) { } if (constexpr auto versions = Info::get_all_versions(); - std::ranges::none_of(versions, [&](uint64_t v) { return file_header.version == v; })) { + std::none_of(versions.begin(), versions.end(), [&](uint64_t v) { return file_header.version == v; })) { return Status::Error(Status::ErrorCode::ERR_6_INVALID_VERSION_BYTES); } diff --git a/src/cor/prm/fsst/CMakeLists.txt b/src/cor/prm/fsst/CMakeLists.txt index 0dcb978f..f7393831 100644 --- a/src/cor/prm/fsst/CMakeLists.txt +++ b/src/cor/prm/fsst/CMakeLists.txt @@ -16,7 +16,9 @@ set(FASTLANES_OBJECT_FILES PARENT_SCOPE) -target_compile_options(fls_fsst_prm PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_fsst_prm PRIVATE -Wno-macro-redefined) +endif () target_link_libraries(fls_fsst_prm PUBLIC diff --git a/src/cor/prm/fsst12/CMakeLists.txt b/src/cor/prm/fsst12/CMakeLists.txt index a63f009b..911e5c8d 100644 --- a/src/cor/prm/fsst12/CMakeLists.txt +++ b/src/cor/prm/fsst12/CMakeLists.txt @@ -13,7 +13,12 @@ set(FASTLANES_OBJECT_FILES ${FASTLANES_OBJECT_FILES} $ PARENT_SCOPE) -target_compile_options(fls_fsst12_prm PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_fsst12_prm PRIVATE -Wno-macro-redefined) +endif () +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + target_compile_options(fls_fsst12_prm PRIVATE -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread) +endif () target_link_libraries(fls_fsst12_prm PUBLIC diff --git a/src/cor/prm/fsst12/libfsst12.cpp b/src/cor/prm/fsst12/libfsst12.cpp index f68df4aa..9f69f242 100644 --- a/src/cor/prm/fsst12/libfsst12.cpp +++ b/src/cor/prm/fsst12/libfsst12.cpp @@ -257,25 +257,25 @@ static inline ulong compressBulk( } cur += (code >> 12); res |= (code & FSST12_CODE_MASK) << 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } while (cur < end) { ulong code = symbolMap.findExpansion(Symbol12(cur, end)); u32 res = (code & FSST12_CODE_MASK); if (out + 8 > lim) { - return curLine; // u32 write would be out of bounds (out of output memory) + return curLine; // u64 write would be out of bounds (out of output memory) } cur += code >> 12; if (cur >= end) { - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 2; break; } code = symbolMap.findExpansion(Symbol12(cur, end)); res |= (code & FSST12_CODE_MASK) << 12; cur += code >> 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } lenOut[curLine] = out - strOut[curLine]; diff --git a/src/detail/CMakeLists.txt b/src/detail/CMakeLists.txt index 5f2e274a..a3aff216 100644 --- a/src/detail/CMakeLists.txt +++ b/src/detail/CMakeLists.txt @@ -12,7 +12,9 @@ if (FLS_ENABLE_IWYU) set_property(TARGET fls_detail PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path}) endif () -target_compile_options(fls_detail PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_detail PRIVATE -Wno-macro-redefined) +endif () target_link_libraries(fls_detail PUBLIC diff --git a/src/encoder/CMakeLists.txt b/src/encoder/CMakeLists.txt index 137f7b24..3f66b17c 100644 --- a/src/encoder/CMakeLists.txt +++ b/src/encoder/CMakeLists.txt @@ -13,7 +13,9 @@ if (FLS_ENABLE_IWYU) set_property(TARGET fls_encoder PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path}) endif () -target_compile_options(fls_encoder PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_encoder PRIVATE -Wno-macro-redefined) +endif () target_link_libraries(fls_encoder PUBLIC diff --git a/src/encoder/materializer.cpp b/src/encoder/materializer.cpp index 10c5f5c4..a4172980 100644 --- a/src/encoder/materializer.cpp +++ b/src/encoder/materializer.cpp @@ -93,20 +93,20 @@ struct material_visitor { auto visitor = [this, &typed_col](auto&& arg) { (*this)(std::forward(arg), typed_col); }; - visit(visitor, expr->operators[expr->operators.size() - 1]); + visit_dec(visitor, expr->operators[expr->operators.size() - 1]); } void operator()(const sp& expr, up& typed_col) const { auto visitor = [this, &typed_col](auto&& arg) { (*this)(std::forward(arg), typed_col); }; - visit(visitor, expr->operators[0]); + visit_dec(visitor, expr->operators[0]); } void operator()(const sp& struct_expr, up& struct_col) const { for (n_t expr_idx {0}; expr_idx < struct_expr->internal_exprs.size(); ++expr_idx) { - visit(material_visitor {vec_idx}, - struct_expr->internal_exprs[expr_idx] - ->operators[struct_expr->internal_exprs[expr_idx]->operators.size() - 1], - struct_col->internal_rowgroup[expr_idx]); + visit_dec(material_visitor {vec_idx}, + struct_expr->internal_exprs[expr_idx] + ->operators[struct_expr->internal_exprs[expr_idx]->operators.size() - 1], + struct_col->internal_rowgroup[expr_idx]); } } void operator()(const sp& opr, up& str_col) const { @@ -201,7 +201,7 @@ void Materializer::Materialize(const vector>& expressions, n_t FLS_ASSERT_NOT_EMPTY_VEC(expr->operators); expr->PointTo(vec_idx); - visit(material_visitor {vec_idx}, expr->operators[expr->operators.size() - 1], col); + visit_dec(material_visitor {vec_idx}, expr->operators[expr->operators.size() - 1], col); } // rowgroup.n_tup = rowgroup.n_tup + CFG::VEC_SZ; diff --git a/src/expression/CMakeLists.txt b/src/expression/CMakeLists.txt index be234fa3..6506a0fd 100644 --- a/src/expression/CMakeLists.txt +++ b/src/expression/CMakeLists.txt @@ -2,6 +2,7 @@ add_library(fls_expression OBJECT alp_expression.cpp analyze_operator.cpp + analyze_operator_unsigned.cpp # CMakeLists.txt data_parallelize_patch_operator.cpp cross_rle_operator.cpp @@ -16,16 +17,21 @@ add_library(fls_expression fsst_dict_operator.cpp fsst_expression.cpp interpreter.cpp + interpreter_encoding.cpp + interpreter_decoding.cpp rpn.cpp null_operator.cpp physical_expression.cpp predicate_operator.cpp rle_expression.cpp - rsum_operator.cpp + enc_rsum_operator.cpp + dec_rsum_operator.cpp scan_operator.cpp selection_ds.cpp - slpatch_operator.cpp - transpose_operator.cpp + enc_slpatch_operator.cpp + dec_slpatch_operator.cpp + enc_transpose_operator.cpp + dec_transpose_operator.cpp validitymask_operator.cpp ) @@ -38,7 +44,9 @@ set(FASTLANES_OBJECT_FILES PARENT_SCOPE) -target_compile_options(fls_expression PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_expression PRIVATE -Wno-macro-redefined) +endif () target_link_libraries(fls_expression PUBLIC diff --git a/src/expression/analyze_operator.cpp b/src/expression/analyze_operator.cpp index c60a9fca..dfd2b50d 100644 --- a/src/expression/analyze_operator.cpp +++ b/src/expression/analyze_operator.cpp @@ -3,49 +3,19 @@ // ──────────────────────────────────────────────────────── // src/expression/analyze_operator.cpp // ──────────────────────────────────────────────────────── +// Signed-type instantiations + Histogram class instantiations. +// Unsigned-type instantiations are in analyze_operator_unsigned.cpp. +// ──────────────────────────────────────────────────────── #include "fls/expression/analyze_operator.hpp" -#include "alp/common.hpp" +#include "analyze_operator_impl.hpp" // NOLINT(misc-include-cleaner) — template definitions needed for explicit instantiations below #include "fls/cfg/cfg.hpp" #include "fls/common/alias.hpp" -#include "fls/common/assert.hpp" -#include "fls/common/common.hpp" -#include "fls/cor/prm/ffor_prm.hpp" #include "fls/expression/data_type.hpp" -#include "fls/expression/encoding_operator.hpp" -#include "fls/expression/physical_expression.hpp" -#include "fls/expression/rsum_operator.hpp" -#include "fls/ffor_util.hpp" -#include "fls/primitive/copy/fls_copy.hpp" -#include "fls/std/type_traits.hpp" -#include "fls/std/variant.hpp" -#include "fls/std/vector.hpp" -#include "fls/table/rowgroup.hpp" -#include -#include // for CHAR_BIT -#include // for uint16_t -#include // for std::numeric_limits -#include // for std::make_signed_t -#include // for std::monostate namespace fastlanes { -static constexpr uint64_t LOCAL_EXC_LIMIT_C = 20; // between 5 and 10 percent - -template -class Option { -public: - n_t size() { - return (1024 * bw / CHAR_BIT) + n_exceptions * sizeof(T) + n_exceptions * sizeof(vec_idx_t); - } // -public: - bw_t bw; // - T base; // - vec_idx_t n_exceptions; // - T upper; // -}; - template -void Histogram::Cal(PT* data) { +void AnalyzeHistogram::Cal(PT* data) { val_vec.clear(); rep_vec.clear(); @@ -70,272 +40,21 @@ void Histogram::Cal(PT* data) { } } -template -constexpr T pow2(uint8_t bw) { - static_assert(std::is_unsigned::value, "pow2() only supports unsigned integer types"); - - if (bw >= sizeof(T) * 8) { - return 0; // Avoid undefined behavior - } - - return static_cast(T(1) << bw); // Ensure correct type before shifting -} - -template -bool is_exception(Option& option, T val) { - FLS_ASSERT_CORRECT_BW(option.bw) - FLS_ASSERT_CORRECT_N(option.n_exceptions) - FLS_ASSERT_CORRECT_SZ(option.size()) - - make_unsigned_t a = *reinterpret_cast*>(&option.base); - make_unsigned_t b = a + pow2>(option.bw); - T real_upper = *reinterpret_cast(&b); - - if (val < option.base) { - return true; - } - if (val >= real_upper) { - return true; - } - return false; -} - -template -bool is_exception(T lower_bound, T upper_bound, T val) { - if (val <= upper_bound && val >= lower_bound) { - return false; - } - return true; -} - -template -n_t count_exceptions(const T lower_bound, - const T upper_bound, - const vector& val_vec, - const vector& rep_vec) { - - FLS_ASSERT(!val_vec.empty(), "an empty vec", " "); - FLS_ASSERT(!rep_vec.empty(), "an empty vec", " "); - - n_t result {0}; - bool is_exc {false}; - - for (n_t i = 0; i < val_vec.size(); ++i) { - is_exc = is_exception(lower_bound, upper_bound, val_vec[i]); - if (!is_exc) { - continue; - } - /* It is an exception. - * Increase the number of exception by the repetition of this value. - */ - result += rep_vec[i]; - } - - return result; -} - -template -Option find_best_option(Histogram& histogram, vec_idx_t first_base_idx, vec_idx_t next_base_idx) { - /* Initialize */ - Option result; - - auto& val_vec = histogram.val_vec; - auto& rep_vec = histogram.rep_vec; - const T lower_bound = val_vec[first_base_idx]; - const T upper_bound = val_vec[next_base_idx]; - - vec_idx_t n_non_exceptions {0}; - for (vec_idx_t val_idx {first_base_idx}; val_idx <= next_base_idx; val_idx++) { - n_non_exceptions += rep_vec[val_idx]; - } - bw_t bw = count_bits(upper_bound, lower_bound); - - result.base = lower_bound; - result.bw = bw; - result.n_exceptions = 1024 - n_non_exceptions; - result.upper = upper_bound; - - return result; -} - template -void Histogram::Reset() { +void AnalyzeHistogram::Reset() { val_vec.clear(); rep_vec.clear(); } // -template class Histogram; -template class Histogram; -template class Histogram; -template class Histogram; -template class Histogram; -template class Histogram; - -template -enc_analyze_opr::enc_analyze_opr(const PhysicalExpr& expr, - const col_pt& col, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) - : null_map_view(col) { - - is_rsum = false; - visit(overloaded { - [&](const sp>& opr) { data = opr->data; }, - [&](const sp>& opr) { - data = opr->deltas; - is_rsum = true; - }, - [&](const sp>& opr) { data = opr->index_arr; }, - [&](std::monostate&) { FLS_UNREACHABLE(); }, - [&](auto&) { FLS_UNREACHABLE(); }, - }, - expr.operators.back()); -} - -template -void enc_analyze_opr::Analyze() { - auto* null_map_arr = null_map_view.NullMap(); - - if constexpr (!USE_PATCH) { - if (is_rsum) { - auto min = std::numeric_limits::max(); - auto max = std::numeric_limits::min(); - - for (n_t i {0}; i < CFG::VEC_SZ; ++i) { - if (data[i] < min) { - min = data[i]; - } - if (data[i] > max) { - max = data[i]; - } - } - bw = count_bits(max, min); - base = min; - return; - } - auto min = std::numeric_limits::max(); - auto max = std::numeric_limits::min(); - - bool all_null = true; - - for (n_t i {0}; i < CFG::VEC_SZ; ++i) { - if (data[i] < min && !null_map_arr[i]) { - min = data[i]; - all_null = false; - } - if (data[i] > max && !null_map_arr[i]) { - max = data[i]; - all_null = false; - } - } - - for (n_t i {0}; i < CFG::VEC_SZ; ++i) { - if (null_map_arr[i]) { - data[i] = min; - } - } - - if (all_null) { - bw = 0; - base = 0; - } else { - bw = count_bits(max, min); - base = min; - } - } else { - if (is_rsum) { - /* copy data into stt_buf.*/ - Option best {64, 0, 0}; - copy(data, copy_of_data); - - histogram.Reset(); - histogram.Cal(copy_of_data); - const n_t n_option = histogram.rep_vec.size(); - - /* Compute. */ - for (vec_idx_t i {0}; i < n_option; ++i) { - for (vec_idx_t j {i}; j < n_option; ++j) { - auto next = find_best_option(histogram, i, j); - if (next.size() < best.size() && next.n_exceptions < LOCAL_EXC_LIMIT_C) { - best = next; - } - } - } - - bw = best.bw; - base = best.base; - n_exceptions = best.n_exceptions; - - /* Add exception positions . */ - uint16_t exc_c {0}; - - for (alp::exp_c_t i {0}; i < vec_n_tup(); ++i) { - if (const auto& val = data[i]; is_exception(best, val)) { - exception_pos_arr[exc_c] = i; - exceptions[exc_c] = data[i]; - exc_c++; - } - } +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; +template class AnalyzeHistogram; - n_exceptions = exc_c; - return; - } - /* copy data into stt_buf.*/ - Option best {64, 0, 0}; - copy(data, copy_of_data); - - histogram.Reset(); - histogram.Cal(copy_of_data); - const n_t n_option = histogram.rep_vec.size(); - - /* Compute. */ - for (vec_idx_t i {0}; i < n_option; ++i) { - for (vec_idx_t j {i}; j < n_option; ++j) { - auto next = find_best_option(histogram, i, j); - if (next.size() < best.size() && next.n_exceptions < LOCAL_EXC_LIMIT_C) { - best = next; - } - } - } - - bw = best.bw; - base = best.base; - n_exceptions = best.n_exceptions; - - /* Add exception positions . */ - uint16_t exc_c {0}; - - for (alp::exp_c_t i {0}; i < vec_n_tup(); ++i) { - if (const auto& val = data[i]; is_exception(best, val) && !null_map_arr[i]) { - exception_pos_arr[exc_c] = i; - exceptions[exc_c] = data[i]; - exc_c++; - } - } - - for (n_t i {0}; i < CFG::VEC_SZ; ++i) { - if (null_map_arr[i]) { - data[i] = base; - } - } - - n_exceptions = exc_c; - } -} - -template -void enc_analyze_opr::PointTo(n_t vec_idx) { - null_map_view.PointTo(vec_idx); -} - -template struct enc_analyze_opr; -template struct enc_analyze_opr; -template struct enc_analyze_opr; -template struct enc_analyze_opr; -template struct enc_analyze_opr; -template struct enc_analyze_opr; -template struct enc_analyze_opr; -template struct enc_analyze_opr; template struct enc_analyze_opr; template struct enc_analyze_opr; template struct enc_analyze_opr; @@ -344,4 +63,5 @@ template struct enc_analyze_opr; template struct enc_analyze_opr; template struct enc_analyze_opr; template struct enc_analyze_opr; + } // namespace fastlanes diff --git a/src/expression/analyze_operator_impl.hpp b/src/expression/analyze_operator_impl.hpp new file mode 100644 index 00000000..feca6eca --- /dev/null +++ b/src/expression/analyze_operator_impl.hpp @@ -0,0 +1,298 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/analyze_operator_impl.hpp +// ──────────────────────────────────────────────────────── +// Private implementation header for enc_analyze_opr template definitions. +// Included by analyze_operator.cpp and analyze_operator_unsigned.cpp +// to split instantiations across two TUs for parallel compilation. +// ──────────────────────────────────────────────────────── +#ifndef FLS_EXPRESSION_ANALYZE_OPERATOR_IMPL_HPP +#define FLS_EXPRESSION_ANALYZE_OPERATOR_IMPL_HPP + +#include "alp/common.hpp" +#include "fls/cfg/cfg.hpp" +#include "fls/common/alias.hpp" +#include "fls/common/assert.hpp" +#include "fls/common/common.hpp" +#include "fls/cor/prm/ffor_prm.hpp" +#include "fls/expression/analyze_operator.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/encoding_operator.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/rsum_operator.hpp" +#include "fls/ffor_util.hpp" +#include "fls/primitive/copy/fls_copy.hpp" +#include "fls/std/type_traits.hpp" +#include "fls/std/variant.hpp" +#include "fls/std/vector.hpp" +#include "fls/table/rowgroup.hpp" +#include +#include +#include +#include +#include +#include + +namespace fastlanes { + +static constexpr uint64_t LOCAL_EXC_LIMIT_C = 20; // between 5 and 10 percent + +template +class Option { +public: + n_t size() { + return (1024 * bw / CHAR_BIT) + n_exceptions * sizeof(T) + n_exceptions * sizeof(vec_idx_t); + } // +public: + bw_t bw; // + T base; // + vec_idx_t n_exceptions; // + T upper; // +}; + +template +constexpr T pow2(uint8_t bw) { + static_assert(std::is_unsigned::value, "pow2() only supports unsigned integer types"); + + if (bw >= sizeof(T) * 8) { + return 0; // Avoid undefined behavior + } + + return static_cast(T(1) << bw); // Ensure correct type before shifting +} + +template +bool is_exception(Option& option, T val) { + FLS_ASSERT_CORRECT_BW(option.bw) + FLS_ASSERT_CORRECT_N(option.n_exceptions) + FLS_ASSERT_CORRECT_SZ(option.size()) + + if (option.bw >= sizeof(make_unsigned_t) * CHAR_BIT) { + return false; + } + + // Use unsigned delta to correctly handle base + 2^bw overflow/wraparound. + make_unsigned_t uval = *reinterpret_cast*>(&val); + make_unsigned_t ubase = *reinterpret_cast*>(&option.base); + return static_cast>(uval - ubase) >= pow2>(option.bw); +} + +template +bool is_exception(T lower_bound, T upper_bound, T val) { + if (val <= upper_bound && val >= lower_bound) { + return false; + } + return true; +} + +template +n_t count_exceptions(const T lower_bound, + const T upper_bound, + const vector& val_vec, + const vector& rep_vec) { + + FLS_ASSERT(!val_vec.empty(), "an empty vec", " "); + FLS_ASSERT(!rep_vec.empty(), "an empty vec", " "); + + n_t result {0}; + bool is_exc {false}; + + for (n_t i = 0; i < val_vec.size(); ++i) { + is_exc = is_exception(lower_bound, upper_bound, val_vec[i]); + if (!is_exc) { + continue; + } + /* It is an exception. + * Increase the number of exception by the repetition of this value. + */ + result += rep_vec[i]; + } + + return result; +} + +template +Option find_best_option(AnalyzeHistogram& histogram, vec_idx_t first_base_idx, vec_idx_t next_base_idx) { + /* Initialize */ + Option result; + + auto& val_vec = histogram.val_vec; + auto& rep_vec = histogram.rep_vec; + const T lower_bound = val_vec[first_base_idx]; + const T upper_bound = val_vec[next_base_idx]; + + vec_idx_t n_non_exceptions {0}; + for (vec_idx_t val_idx {first_base_idx}; val_idx <= next_base_idx; val_idx++) { + n_non_exceptions += rep_vec[val_idx]; + } + bw_t bw = count_bits(upper_bound, lower_bound); + + result.base = lower_bound; + result.bw = bw; + result.n_exceptions = 1024 - n_non_exceptions; + result.upper = upper_bound; + + return result; +} + +template +enc_analyze_opr::enc_analyze_opr(const PhysicalExpr& expr, + const col_pt& col, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) + : null_map_view(col) { + + is_rsum = false; + visit_enc(overloaded { + [&](const sp>& opr) { data = opr->data; }, + [&](const sp>& opr) { + data = opr->deltas; + is_rsum = true; + }, + [&](const sp>& opr) { data = opr->index_arr; }, + [&](std::monostate&) { FLS_UNREACHABLE(); }, + [&](auto&) { FLS_UNREACHABLE(); }, + }, + expr.operators.back()); +} + +template +void enc_analyze_opr::Analyze() { + auto* null_map_arr = null_map_view.NullMap(); + + if constexpr (!USE_PATCH) { + if (is_rsum) { + auto min = std::numeric_limits::max(); + auto max = std::numeric_limits::min(); + + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { + if (data[i] < min) { + min = data[i]; + } + if (data[i] > max) { + max = data[i]; + } + } + bw = count_bits(max, min); + base = min; + return; + } + auto min = std::numeric_limits::max(); + auto max = std::numeric_limits::min(); + + bool all_null = true; + + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { + if (data[i] < min && !null_map_arr[i]) { + min = data[i]; + all_null = false; + } + if (data[i] > max && !null_map_arr[i]) { + max = data[i]; + all_null = false; + } + } + + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { + if (null_map_arr[i]) { + data[i] = min; + } + } + + if (all_null) { + bw = 0; + base = 0; + } else { + bw = count_bits(max, min); + base = min; + } + } else { + if (is_rsum) { + /* copy data into stt_buf.*/ + Option best {64, 0, 0}; + copy(data, copy_of_data); + + histogram.Reset(); + histogram.Cal(copy_of_data); + const n_t n_option = histogram.rep_vec.size(); + + /* Compute. */ + for (vec_idx_t i {0}; i < n_option; ++i) { + for (vec_idx_t j {i}; j < n_option; ++j) { + auto next = find_best_option(histogram, i, j); + if (next.size() < best.size() && next.n_exceptions < LOCAL_EXC_LIMIT_C) { + best = next; + } + } + } + + bw = best.bw; + base = best.base; + n_exceptions = best.n_exceptions; + + /* Add exception positions . */ + uint16_t exc_c {0}; + + for (alp::exp_c_t i {0}; i < vec_n_tup(); ++i) { + if (const auto& val = data[i]; is_exception(best, val)) { + exception_pos_arr[exc_c] = i; + exceptions[exc_c] = data[i]; + exc_c++; + } + } + + n_exceptions = exc_c; + return; + } + /* copy data into stt_buf.*/ + Option best {64, 0, 0}; + copy(data, copy_of_data); + + histogram.Reset(); + histogram.Cal(copy_of_data); + const n_t n_option = histogram.rep_vec.size(); + + /* Compute. */ + for (vec_idx_t i {0}; i < n_option; ++i) { + for (vec_idx_t j {i}; j < n_option; ++j) { + auto next = find_best_option(histogram, i, j); + if (next.size() < best.size() && next.n_exceptions < LOCAL_EXC_LIMIT_C) { + best = next; + } + } + } + + bw = best.bw; + base = best.base; + n_exceptions = best.n_exceptions; + + /* Add exception positions . */ + uint16_t exc_c {0}; + + for (alp::exp_c_t i {0}; i < vec_n_tup(); ++i) { + if (const auto& val = data[i]; is_exception(best, val) && !null_map_arr[i]) { + exception_pos_arr[exc_c] = i; + exceptions[exc_c] = data[i]; + exc_c++; + } + } + + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { + if (null_map_arr[i]) { + data[i] = base; + } + } + + n_exceptions = exc_c; + } +} + +template +void enc_analyze_opr::PointTo(n_t vec_idx) { + null_map_view.PointTo(vec_idx); +} + +} // namespace fastlanes + +#endif // FLS_EXPRESSION_ANALYZE_OPERATOR_IMPL_HPP diff --git a/src/expression/analyze_operator_unsigned.cpp b/src/expression/analyze_operator_unsigned.cpp new file mode 100644 index 00000000..36947e6a --- /dev/null +++ b/src/expression/analyze_operator_unsigned.cpp @@ -0,0 +1,25 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/analyze_operator_unsigned.cpp +// ──────────────────────────────────────────────────────── +// Unsigned-type explicit instantiations of enc_analyze_opr. +// The template definitions live in analyze_operator.cpp. +// This file exists solely to parallelize compilation. +// ──────────────────────────────────────────────────────── +#include "analyze_operator_impl.hpp" // NOLINT(misc-include-cleaner) — template definitions needed for explicit instantiations below +#include "fls/expression/analyze_operator.hpp" +#include "fls/expression/data_type.hpp" + +namespace fastlanes { + +template struct enc_analyze_opr; +template struct enc_analyze_opr; +template struct enc_analyze_opr; +template struct enc_analyze_opr; +template struct enc_analyze_opr; +template struct enc_analyze_opr; +template struct enc_analyze_opr; +template struct enc_analyze_opr; + +} // namespace fastlanes diff --git a/src/expression/cross_rle_operator.cpp b/src/expression/cross_rle_operator.cpp index 638f3adb..fb1a87b0 100644 --- a/src/expression/cross_rle_operator.cpp +++ b/src/expression/cross_rle_operator.cpp @@ -16,6 +16,7 @@ #include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" #include // for std::min +#include // for size_t #include // for uint8_t #include @@ -282,7 +283,9 @@ void decode_rle_range(const len_t* rle_lengths, for (n_t i = 0; i < to_copy; ++i) { if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), rle_value_bytes + prev_offset, rle_value_bytes + cur_offset); out_lengths[decoded_pos++] = length; diff --git a/src/expression/data_parallelize_patch_operator.cpp b/src/expression/data_parallelize_patch_operator.cpp index b53e8b72..133b82b2 100644 --- a/src/expression/data_parallelize_patch_operator.cpp +++ b/src/expression/data_parallelize_patch_operator.cpp @@ -25,12 +25,12 @@ enc_data_parallel_patch_opr::enc_data_parallel_patch_opr(const PhysicalExpr& const col_pt& column, ColumnDescriptorT& column_descriptor, InterpreterState& state) { - visit(overloaded { - [&](const sp>& opr) { opr->data_parallelize = true; }, - [&](std::monostate&) { FLS_UNREACHABLE(); }, - [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, - }, - expr.operators[state.cur_operator++]); + visit_enc(overloaded { + [&](const sp>& opr) { opr->data_parallelize = true; }, + [&](std::monostate&) { FLS_UNREACHABLE(); }, + [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, + }, + expr.operators[state.cur_operator++]); } template struct enc_data_parallel_patch_opr; diff --git a/src/expression/rsum_operator.cpp b/src/expression/dec_rsum_operator.cpp similarity index 57% rename from src/expression/rsum_operator.cpp rename to src/expression/dec_rsum_operator.cpp index 504562be..52e22cbf 100644 --- a/src/expression/rsum_operator.cpp +++ b/src/expression/dec_rsum_operator.cpp @@ -1,74 +1,23 @@ // ──────────────────────────────────────────────────────── // | FastLanes | // ──────────────────────────────────────────────────────── -// src/expression/rsum_operator.cpp +// src/expression/dec_rsum_operator.cpp // ──────────────────────────────────────────────────────── -#include "fls/expression/rsum_operator.hpp" -#include "fls/cfg/cfg.hpp" #include "fls/common/alias.hpp" #include "fls/common/common.hpp" #include "fls/expression/data_type.hpp" -#include "fls/expression/encoding_operator.hpp" +#include "fls/expression/decoding_operator.hpp" #include "fls/expression/interpreter.hpp" #include "fls/expression/physical_expression.hpp" +#include "fls/expression/rsum_operator.hpp" #include "fls/expression/slpatch_operator.hpp" -#include "fls/expression/transpose_operator.hpp" #include "fls/reader/column_view.hpp" #include "fls/reader/segment.hpp" #include "fls/std/type_traits.hpp" -#include "fls/std/variant.hpp" -#include "fls/std/vector.hpp" -#include "fls/table/rowgroup.hpp" #include "fls_gen/rsum/rsum.hpp" -#include "fls_gen/unrsum/unrsum.hpp" -#include #include namespace fastlanes { -/*--------------------------------------------------------------------------------------------------------------------*\ - * enc rsum opr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -enc_rsum_opr::enc_rsum_opr(const PhysicalExpr& expr, - const col_pt& col, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - visit(overloaded { - [&](const sp>& opr) { data = opr->data; }, - [&](const sp>& opr) { data = opr->transposed_data; }, - [&](std::monostate&) { FLS_UNREACHABLE(); }, - [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, - }, - expr.operators[state.cur_operator++]); - - auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; - operand_tokens.emplace_back(state.cur_operand++); - - bases_segment = make_unique(); -} - -template -void enc_rsum_opr::Rsum() { - ::generated::unrsum::fallback::scalar::unrsum(data, deltas); - - bases_segment->Flush(data, CFG::UNIFIED_TRANSPOSED::BASES_SIZE); -}; - -template -void enc_rsum_opr::MoveSegments(vector>& segments) { - segments.push_back(std::move(bases_segment)); -} - -template struct enc_rsum_opr; -template struct enc_rsum_opr; -template struct enc_rsum_opr; -template struct enc_rsum_opr; -template struct enc_rsum_opr; -template struct enc_rsum_opr; -template struct enc_rsum_opr; -template struct enc_rsum_opr; - /*--------------------------------------------------------------------------------------------------------------------*\ * dec_rsum_opr \*--------------------------------------------------------------------------------------------------------------------*/ @@ -87,7 +36,7 @@ struct RsumExprVisitor { idxs = reinterpret_cast(opr->data); } void operator()(const sp& expr) { - visit(RsumExprVisitor {idxs}, expr->operators[0]); + visit_dec(RsumExprVisitor {idxs}, expr->operators[0]); } void operator()(std::monostate& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); @@ -102,7 +51,7 @@ dec_rsum_opr::dec_rsum_opr(PhysicalExpr& physical_expr, const ColumnView& co : bases_segment_view(column_view.GetSegment(state.cur_operand)) , deltas(nullptr) { - visit(RsumExprVisitor {deltas}, physical_expr.operators.back()); + visit_dec(RsumExprVisitor {deltas}, physical_expr.operators.back()); state.cur_operand = state.cur_operand - 1; state.cur_operator++; } diff --git a/src/expression/slpatch_operator.cpp b/src/expression/dec_slpatch_operator.cpp similarity index 60% rename from src/expression/slpatch_operator.cpp rename to src/expression/dec_slpatch_operator.cpp index b78301e8..ce9b7406 100644 --- a/src/expression/slpatch_operator.cpp +++ b/src/expression/dec_slpatch_operator.cpp @@ -1,17 +1,14 @@ // ──────────────────────────────────────────────────────── // | FastLanes | // ──────────────────────────────────────────────────────── -// src/expression/slpatch_operator.cpp +// src/expression/dec_slpatch_operator.cpp // ──────────────────────────────────────────────────────── -#include "fls/expression/slpatch_operator.hpp" #include "fls/cfg/cfg.hpp" #include "fls/common/alias.hpp" #include "fls/common/assert.hpp" #include "fls/common/common.hpp" -#include "fls/expression/analyze_operator.hpp" #include "fls/expression/data_type.hpp" #include "fls/expression/decoding_operator.hpp" -#include "fls/expression/encoding_operator.hpp" #include "fls/expression/interpreter.hpp" #include "fls/expression/physical_expression.hpp" #include "fls/expression/slpatch_operator.hpp" @@ -19,72 +16,11 @@ #include "fls/reader/column_view.hpp" #include "fls/reader/segment.hpp" #include "fls/std/type_traits.hpp" -#include "fls/std/variant.hpp" -#include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" #include -#include #include namespace fastlanes { -/*--------------------------------------------------------------------------------------------------------------------*\ -* enc slpatch opr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -enc_slpatch_opr::enc_slpatch_opr(const PhysicalExpr& expr, - const col_pt& col, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - visit(overloaded { - [&](const sp>& opr) { - n_exceptions_p = &opr->n_exceptions; - exceptions = opr->exceptions; - exception_pos_arr = opr->exception_pos_arr; - }, - [&](std::monostate&) { FLS_UNREACHABLE(); }, - [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, - }, - expr.operators.back()); - - n_exceptions_segment = make_unique(); - exceptions_position_segment = make_unique(); - exceptions_segment = make_unique(); - - auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; - - operand_tokens.emplace_back(state.cur_operand++); - operand_tokens.emplace_back(state.cur_operand++); - operand_tokens.emplace_back(state.cur_operand++); -} - -template -void enc_slpatch_opr::Store() { - FLS_ASSERT_NOT_NULL_POINTER(n_exceptions_p) - FLS_ASSERT_NOT_NULL_POINTER(exception_pos_arr) - FLS_ASSERT_NOT_NULL_POINTER(exceptions) - - const auto n_exceptions = *n_exceptions_p; - - n_exceptions_segment->Flush(n_exceptions_p, sizeof(vec_idx_t)); - exceptions_position_segment->Flush(exception_pos_arr, sizeof(vec_idx_t) * n_exceptions); - exceptions_segment->Flush(exceptions, sizeof(PT) * n_exceptions); -} -template -void enc_slpatch_opr::MoveSegments(vector>& segments) { - segments.push_back(std::move(exceptions_segment)); - segments.push_back(std::move(exceptions_position_segment)); - segments.push_back(std::move(n_exceptions_segment)); -} - -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; -template struct enc_slpatch_opr; /*--------------------------------------------------------------------------------------------------------------------*\ * dec slpatch opr \*--------------------------------------------------------------------------------------------------------------------*/ @@ -127,7 +63,7 @@ dec_slpatch_opr::dec_slpatch_opr(PhysicalExpr& physical_expr, ->operand_tokens())[static_cast(state.cur_operand - 0)]))) { state.cur_operand -= 3; - visit(SLPatchExprVisitor {*this}, physical_expr.operators.back()); + visit_dec(SLPatchExprVisitor {*this}, physical_expr.operators.back()); } template @@ -145,9 +81,9 @@ void dec_slpatch_opr::Patch(n_t vec_idx) { auto* exc_pos_arr = reinterpret_cast(exceptions_position_segment.data); auto n_exceptions = *reinterpret_cast(n_exceptions_segment.data); - FLS_ASSERT_CORRECT_POS(n_exceptions) + FLS_ASSERT_LE(n_exceptions, CFG::VEC_SZ) - for (auto val_idx {0}; val_idx < n_exceptions; ++val_idx) { + for (n_t val_idx {0}; val_idx < n_exceptions; ++val_idx) { auto next_pos = exc_pos_arr[val_idx]; data[next_pos] = exc_arr[val_idx]; } @@ -168,4 +104,5 @@ template struct dec_slpatch_opr; template struct dec_slpatch_opr; template struct dec_slpatch_opr; template struct dec_slpatch_opr; + } // namespace fastlanes diff --git a/src/expression/dec_transpose_operator.cpp b/src/expression/dec_transpose_operator.cpp new file mode 100644 index 00000000..2fe05d58 --- /dev/null +++ b/src/expression/dec_transpose_operator.cpp @@ -0,0 +1,67 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/dec_transpose_operator.cpp +// ──────────────────────────────────────────────────────── +#include "fls/cfg/cfg.hpp" +#include "fls/common/alias.hpp" +#include "fls/common/assert.hpp" +#include "fls/common/common.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/rsum_operator.hpp" +#include "fls/expression/transpose_operator.hpp" +#include "fls/table/rowgroup.hpp" +#include "fls_gen/untranspose/untranspose.hpp" +#include + +namespace fastlanes { +/*--------------------------------------------------------------------------------------------------------------------*\ + * dec_transpose_opr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +struct TransposeExprVisitor { + explicit TransposeExprVisitor(dec_transpose_opr& opr) + : trapose_opr(opr) { + } + + void operator()(const sp>& opr) { + trapose_opr.transposed_data = opr->idxs; + FLS_ASSERT_NOT_NULL_POINTER(trapose_opr.transposed_data) + } + void operator()(std::monostate& arg) { + FLS_UNREACHABLE_WITH_TYPE(arg); + } + void operator()(const auto& arg) { + FLS_UNREACHABLE_WITH_TYPE(arg); + } + + dec_transpose_opr& trapose_opr; +}; + +template +dec_transpose_opr::dec_transpose_opr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) + : transposed_data(nullptr) { + + visit_dec(TransposeExprVisitor {*this}, physical_expr.operators.back()); +} + +template +void dec_transpose_opr::Materialize(n_t vec_idx, TypedCol& typed_col) { + typed_col.data.resize(typed_col.data.size() + CFG::VEC_SZ); + PT* untrasposed_data_p = typed_col.data.data() + (CFG::VEC_SZ * vec_idx); + generated::untranspose::fallback::scalar::untranspose_i(transposed_data, untrasposed_data_p); +} + +template struct dec_transpose_opr; +template struct dec_transpose_opr; +template struct dec_transpose_opr; +template struct dec_transpose_opr; +template struct dec_transpose_opr; +template struct dec_transpose_opr; +template struct dec_transpose_opr; +template struct dec_transpose_opr; + +} // namespace fastlanes diff --git a/src/expression/dict_expression.cpp b/src/expression/dict_expression.cpp index da30d1c0..d32539a1 100644 --- a/src/expression/dict_expression.cpp +++ b/src/expression/dict_expression.cpp @@ -17,6 +17,8 @@ #include "fls/reader/segment.hpp" #include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" +#include // for std::max +#include // for size_t #include #include // for std::move #include // for std::monostate @@ -37,7 +39,7 @@ struct DictExprVisitor { index_arr = opr->Data(); } void operator()(const sp& expr) { - visit(DictExprVisitor {index_arr}, expr->operators[0]); + visit_dec(DictExprVisitor {index_arr}, expr->operators[0]); } void operator()(std::monostate&) { FLS_UNREACHABLE(); @@ -146,7 +148,7 @@ dec_dict_opr::dec_dict_opr(const PhysicalExpr& physical_expr, ->operand_tokens())[static_cast(state.cur_operand - 0)]))) , index_arr(nullptr) { state.cur_operand -= 1; - visit(DictExprVisitor {index_arr}, physical_expr.operators[0]); + visit_dec(DictExprVisitor {index_arr}, physical_expr.operators[0]); } template @@ -185,7 +187,7 @@ dec_dict_opr::dec_dict_opr(const PhysicalExpr& physical_ , index_arr(nullptr) { state.cur_operand = state.cur_operand - 1; - visit(DictExprVisitor {index_arr}, physical_expr.operators[0]); + visit_dec(DictExprVisitor {index_arr}, physical_expr.operators[0]); } template @@ -227,7 +229,9 @@ void dec_dict_opr::Decode(vector& byte_arr_vec, length_pointer[idx] = length; if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), Bytes() + offset, Bytes() + offset_next); } diff --git a/src/expression/enc_rsum_operator.cpp b/src/expression/enc_rsum_operator.cpp new file mode 100644 index 00000000..99a27ff6 --- /dev/null +++ b/src/expression/enc_rsum_operator.cpp @@ -0,0 +1,68 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/enc_rsum_operator.cpp +// ──────────────────────────────────────────────────────── +#include "fls/cfg/cfg.hpp" +#include "fls/common/alias.hpp" +#include "fls/common/common.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/encoding_operator.hpp" +#include "fls/expression/interpreter.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/rsum_operator.hpp" +#include "fls/expression/transpose_operator.hpp" +#include "fls/reader/segment.hpp" +#include "fls/std/variant.hpp" +#include "fls/std/vector.hpp" +#include "fls/table/rowgroup.hpp" +#include "fls_gen/unrsum/unrsum.hpp" +#include +#include + +namespace fastlanes { +/*--------------------------------------------------------------------------------------------------------------------*\ + * enc rsum opr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +enc_rsum_opr::enc_rsum_opr(const PhysicalExpr& expr, + const col_pt& col, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + visit_enc(overloaded { + [&](const sp>& opr) { data = opr->data; }, + [&](const sp>& opr) { data = opr->transposed_data; }, + [&](std::monostate&) { FLS_UNREACHABLE(); }, + [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, + }, + expr.operators[state.cur_operator++]); + + auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; + operand_tokens.emplace_back(state.cur_operand++); + + bases_segment = make_unique(); +} + +template +void enc_rsum_opr::Rsum() { + ::generated::unrsum::fallback::scalar::unrsum(data, deltas); + + bases_segment->Flush(data, CFG::UNIFIED_TRANSPOSED::BASES_SIZE); +}; + +template +void enc_rsum_opr::MoveSegments(vector>& segments) { + segments.push_back(std::move(bases_segment)); +} + +template struct enc_rsum_opr; +template struct enc_rsum_opr; +template struct enc_rsum_opr; +template struct enc_rsum_opr; +template struct enc_rsum_opr; +template struct enc_rsum_opr; +template struct enc_rsum_opr; +template struct enc_rsum_opr; + +} // namespace fastlanes diff --git a/src/expression/enc_slpatch_operator.cpp b/src/expression/enc_slpatch_operator.cpp new file mode 100644 index 00000000..f507f8f6 --- /dev/null +++ b/src/expression/enc_slpatch_operator.cpp @@ -0,0 +1,81 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/enc_slpatch_operator.cpp +// ──────────────────────────────────────────────────────── +#include "fls/common/alias.hpp" +#include "fls/common/assert.hpp" +#include "fls/common/common.hpp" +#include "fls/expression/analyze_operator.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/interpreter.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/slpatch_operator.hpp" +#include "fls/reader/segment.hpp" +#include "fls/std/variant.hpp" +#include "fls/std/vector.hpp" +#include "fls/table/rowgroup.hpp" +#include +#include + +namespace fastlanes { +/*--------------------------------------------------------------------------------------------------------------------*\ +* enc slpatch opr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +enc_slpatch_opr::enc_slpatch_opr(const PhysicalExpr& expr, + const col_pt& col, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + visit_enc(overloaded { + [&](const sp>& opr) { + n_exceptions_p = &opr->n_exceptions; + exceptions = opr->exceptions; + exception_pos_arr = opr->exception_pos_arr; + }, + [&](std::monostate&) { FLS_UNREACHABLE(); }, + [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, + }, + expr.operators.back()); + + n_exceptions_segment = make_unique(); + exceptions_position_segment = make_unique(); + exceptions_segment = make_unique(); + + auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; + + operand_tokens.emplace_back(state.cur_operand++); + operand_tokens.emplace_back(state.cur_operand++); + operand_tokens.emplace_back(state.cur_operand++); +} + +template +void enc_slpatch_opr::Store() { + FLS_ASSERT_NOT_NULL_POINTER(n_exceptions_p) + FLS_ASSERT_NOT_NULL_POINTER(exception_pos_arr) + FLS_ASSERT_NOT_NULL_POINTER(exceptions) + + const auto n_exceptions = *n_exceptions_p; + + n_exceptions_segment->Flush(n_exceptions_p, sizeof(vec_idx_t)); + exceptions_position_segment->Flush(exception_pos_arr, sizeof(vec_idx_t) * n_exceptions); + exceptions_segment->Flush(exceptions, sizeof(PT) * n_exceptions); +} +template +void enc_slpatch_opr::MoveSegments(vector>& segments) { + segments.push_back(std::move(exceptions_segment)); + segments.push_back(std::move(exceptions_position_segment)); + segments.push_back(std::move(n_exceptions_segment)); +} + +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; +template struct enc_slpatch_opr; + +} // namespace fastlanes diff --git a/src/expression/enc_transpose_operator.cpp b/src/expression/enc_transpose_operator.cpp new file mode 100644 index 00000000..a6698f40 --- /dev/null +++ b/src/expression/enc_transpose_operator.cpp @@ -0,0 +1,81 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/enc_transpose_operator.cpp +// ──────────────────────────────────────────────────────── +#include "fls/common/alias.hpp" +#include "fls/common/common.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/encoding_operator.hpp" +#include "fls/expression/fsst12_expression.hpp" +#include "fls/expression/fsst_expression.hpp" +#include "fls/expression/interpreter.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/rle_expression.hpp" +#include "fls/expression/rsum_operator.hpp" +#include "fls/expression/transpose_operator.hpp" +#include "fls/reader/segment.hpp" +#include "fls/std/variant.hpp" +#include "fls/table/rowgroup.hpp" +#include "fls_gen/transpose/transpose.hpp" +#include + +namespace fastlanes { +/*--------------------------------------------------------------------------------------------------------------------*\ + * enc transpose opr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +enc_transpose_opr::enc_transpose_opr(const PhysicalExpr& expr, + const col_pt& col, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + visit_enc(overloaded { + [&](const sp>& opr) { + data = opr->data; + opr->segment->MakeTemporary(); + }, + [&](const sp>& opr) { data = opr->data; }, + [&](const sp& opr) { + if constexpr (std::is_same_v) { + data = opr->fsst_encoded_offset_arr + 1; + opr->fsst_offset_segment->MakeTemporary(); + column_descriptor.encoding_rpn->operand_tokens.pop_back(); + state.cur_operand -= 1; + } else { + FLS_UNREACHABLE(); + } + }, + [&](const sp& opr) { + if constexpr (std::is_same_v) { + data = opr->fsst12_encoded_offset_arr + 1; + opr->fsst12_offset_segment->MakeTemporary(); + column_descriptor.encoding_rpn->operand_tokens.pop_back(); + state.cur_operand -= 1; + } else { + FLS_UNREACHABLE(); + } + }, + [&](const sp>& opr) { data = opr->index_arr; }, + [&](const sp>& opr) { data = opr->rle_idxs; }, + [&](std::monostate&) { FLS_UNREACHABLE(); }, + [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, + }, + expr.operators[state.cur_operator++]); +} + +template +void enc_transpose_opr::Transpose() { + ::generated::transpose::fallback::scalar::transpose_i(data, transposed_data); +} + +template struct enc_transpose_opr; +template struct enc_transpose_opr; +template struct enc_transpose_opr; +template struct enc_transpose_opr; +template struct enc_transpose_opr; +template struct enc_transpose_opr; +template struct enc_transpose_opr; +template struct enc_transpose_opr; + +} // namespace fastlanes diff --git a/src/expression/encoding_operator.cpp b/src/expression/encoding_operator.cpp index d4abf470..d5dd6d7f 100644 --- a/src/expression/encoding_operator.cpp +++ b/src/expression/encoding_operator.cpp @@ -86,7 +86,7 @@ void enc_dict_map_opr::Map() { throw std::runtime_error("typed_column_view.Data() returned null"); } - for (auto idx = 0; idx < CFG::VEC_SZ; ++idx) { + for (n_t idx = 0; idx < CFG::VEC_SZ; ++idx) { const auto value = value_p[idx]; // wrap get_key in try/catch if your bimap might throw index_arr[idx] = static_cast(bimap_frequency.get_key(value)); @@ -130,7 +130,7 @@ void enc_dict_map_opr::Map() { const auto* string_p_arr = column_view.String_p(); const auto* lengths_arr = column_view.Length(); - for (auto idx = 0; idx < CFG::VEC_SZ; ++idx) { + for (n_t idx = 0; idx < CFG::VEC_SZ; ++idx) { const fls_string_t fls_string = {string_p_arr[idx], lengths_arr[idx]}; index_arr[idx] = static_cast(dict.get_value(fls_string)); } @@ -190,7 +190,7 @@ void enc_fls_str_uncompressed_op::PointTo(const n_t vec_idx) { } void enc_fls_str_uncompressed_op::Copy() const { len_t ttl_size {0}; - for (auto idx = 0; idx < CFG::VEC_SZ; ++idx) { + for (n_t idx = 0; idx < CFG::VEC_SZ; ++idx) { ttl_size += fls_string_column_view.Length()[idx]; } data_segment->Flush(fls_string_column_view.Data(), ttl_size); @@ -201,23 +201,13 @@ void enc_fls_str_uncompressed_op::Copy() const { * enc struct opr \*--------------------------------------------------------------------------------------------------------------------*/ enc_struct_opr::enc_struct_opr(const col_pt& column, ColumnDescriptorT& column_descriptor) { - - auto visitor = overloaded {[&](std::monostate&) { FLS_UNREACHABLE(); }, - [&](const up& struct_col) { - for (auto& child_column_descriptor : column_descriptor.children) { - InterpreterState state; - - auto child_physical_expr = Interpreter::Encoding::Interpret( - *child_column_descriptor, struct_col->internal_rowgroup, state); - internal_exprs.emplace_back(child_physical_expr); - } - }, - // - [&](const auto&) { - FLS_UNREACHABLE() - }}; - - visit(visitor, column); + const auto& struct_col = get>(column); + for (auto& child_column_descriptor : column_descriptor.children) { + InterpreterState state; + auto child_physical_expr = + Interpreter::Encoding::Interpret(*child_column_descriptor, struct_col->internal_rowgroup, state); + internal_exprs.emplace_back(child_physical_expr); + } } /*--------------------------------------------------------------------------------------------------------------------*\ @@ -255,14 +245,14 @@ struct VisitorFunctor { void operator()(const sp>&) { // Safely step backward to [expr.size() - 2], if it exists if (expression->operators.size() >= 2) { - visit(*this, expression->operators[expression->operators.size() - 2]); + visit_enc(*this, expression->operators[expression->operators.size() - 2]); } } void operator()(const sp>>&) { // Safely step backward to [expr.size() - 2], if it exists if (expression->operators.size() >= 2) { - visit(*this, expression->operators[expression->operators.size() - 2]); + visit_enc(*this, expression->operators[expression->operators.size() - 2]); } } @@ -286,7 +276,7 @@ enc_ffor_opr::enc_ffor_opr(const PhysicalExpr& expr, VisitorFunctor functor {this, &expr}; if (!expr.operators.empty()) { - visit(functor, expr.operators.back()); + visit_enc(functor, expr.operators.back()); } auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; diff --git a/src/expression/expression_executor.cpp b/src/expression/expression_executor.cpp index 5bbc657e..e9c06de8 100644 --- a/src/expression/expression_executor.cpp +++ b/src/expression/expression_executor.cpp @@ -24,7 +24,6 @@ #include "fls/expression/slpatch_operator.hpp" #include "fls/expression/transpose_operator.hpp" #include "fls/expression/validitymask_operator.hpp" -#include "fls/std/variant.hpp" #include // for std::monostate namespace fastlanes { @@ -79,11 +78,12 @@ struct operator_visitor { // decoding template - void operator()(sp>& op) {}; + void operator()(sp>& op) { + } template void operator()(sp>& op) { op->Unffor(vec_idx); - }; + } template void operator()(sp>& op) { } @@ -245,7 +245,7 @@ struct operator_visitor { void ExprExecutor::execute(PhysicalExpr& expr, n_t vec_idx) { for (auto& expr_operator : expr.operators) { - visit(operator_visitor {vec_idx}, expr_operator); + visit_physical(operator_visitor {vec_idx}, expr_operator); } } @@ -254,7 +254,7 @@ void ExprExecutor::smart_execute(PhysicalExpr& expr, n_t vec_idx) { FLS_ASSERT_LE(n_operators, expr.operators.size()); for (n_t operator_idx {0}; operator_idx < n_operators; operator_idx++) { - visit(operator_visitor {vec_idx}, expr.operators[operator_idx]); + visit_physical(operator_visitor {vec_idx}, expr.operators[operator_idx]); } } @@ -313,11 +313,12 @@ struct operator_counter_visitor { // decoding template - void operator()(sp>& op) {}; + void operator()(sp>& op) { + } template void operator()(sp>& op) { physical_expr.n_active_operators++; - }; + } template void operator()(sp>& op) { } @@ -476,7 +477,7 @@ struct operator_counter_visitor { void ExprExecutor::CountOperator(PhysicalExpr& expr) { for (auto& expr_operator : expr.operators) { - visit(operator_counter_visitor {expr}, expr_operator); + visit_physical(operator_counter_visitor {expr}, expr_operator); } } diff --git a/src/expression/frequency_operator.cpp b/src/expression/frequency_operator.cpp index 8fe99218..f9089744 100644 --- a/src/expression/frequency_operator.cpp +++ b/src/expression/frequency_operator.cpp @@ -18,6 +18,8 @@ #include "fls/reader/segment.hpp" #include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" +#include // for std::max +#include // for size_t #include #include @@ -209,9 +211,9 @@ void dec_frequency_opr::Decode(n_t vec_idx) { auto* exc_pos_arr = reinterpret_cast(exceptions_position_segment.data); auto n_exceptions = *reinterpret_cast(n_exceptions_segment.data); - FLS_ASSERT_CORRECT_POS(n_exceptions) + FLS_ASSERT_LE(n_exceptions, CFG::VEC_SZ) - for (auto val_idx {0}; val_idx < n_exceptions; ++val_idx) { + for (n_t val_idx {0}; val_idx < n_exceptions; ++val_idx) { auto next_pos = exc_pos_arr[val_idx]; auto val = exc_arr[val_idx]; data[next_pos] = val; @@ -295,7 +297,9 @@ void dec_frequency_str_opr::Materialize(n_t vec_idx, FLSStrColumn& typed_col) { vec_idx_t exception_position {0}; for (n_t idx {0}; idx < CFG::VEC_SZ; ++idx) { if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } exception_position = exception_positions[exception_idx]; diff --git a/src/expression/fsst12_dict_operator.cpp b/src/expression/fsst12_dict_operator.cpp index 615bb2d7..9b136e99 100644 --- a/src/expression/fsst12_dict_operator.cpp +++ b/src/expression/fsst12_dict_operator.cpp @@ -19,6 +19,8 @@ #include "fls/reader/segment.hpp" #include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" +#include // for std::max +#include // for size_t #include #include // for std::move #include // for std::monostate @@ -36,7 +38,7 @@ struct FSST12DictExprVisitor { index_arr = opr->Data(); } void operator()(const sp& expr) { - visit(FSST12DictExprVisitor {index_arr}, expr->operators[0]); + visit_dec(FSST12DictExprVisitor {index_arr}, expr->operators[0]); } void operator()(std::monostate&) { FLS_UNREACHABLE(); @@ -139,7 +141,7 @@ dec_fsst12_dict_opr::dec_fsst12_dict_opr(const PhysicalExpr& physical_ // consume three operands state.cur_operand -= 3; - visit(FSST12DictExprVisitor {index_arr}, physical_expr.operators[0]); + visit_dec(FSST12DictExprVisitor {index_arr}, physical_expr.operators[0]); tmp_string.resize(CFG::String::max_bytes_per_string); fsst12_header_segment_view.PointTo(0); @@ -200,7 +202,9 @@ void dec_fsst12_dict_opr::Decode(vector& byte_arr_vec, vector length_pointer[idx] = decoded_size; if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), tmp_string.begin(), tmp_string.begin() + decoded_size); } diff --git a/src/expression/fsst12_expression.cpp b/src/expression/fsst12_expression.cpp index 6cb9b1a2..e6b12100 100644 --- a/src/expression/fsst12_expression.cpp +++ b/src/expression/fsst12_expression.cpp @@ -17,9 +17,10 @@ #include "fls/primitive/fsst12/fsst12.hpp" #include "fls/reader/column_view.hpp" #include "fls/reader/segment.hpp" -#include "fls/std/variant.hpp" #include "fls/table/rowgroup.hpp" #include "fls_gen/untranspose/untranspose.hpp" +#include // for std::max +#include // for size_t #include #include #include // for std::monostate @@ -113,7 +114,7 @@ dec_fsst12_opr::dec_fsst12_opr(PhysicalExpr& physical_expr, const ColumnView& co , fsst12_bytes_segment_view(column_view.GetSegment(1)) , offset_arr(nullptr) { - visit(FSST12ExprVisitor {*this}, physical_expr.operators.back()); + visit_dec(FSST12ExprVisitor {*this}, physical_expr.operators.back()); FLS_ASSERT_NOT_NULL_POINTER(offset_arr) fsst12_header_segment_view.PointTo(0); @@ -137,7 +138,7 @@ void dec_fsst12_opr::Decode(vector& byte_arr_vec, vector& length FLS_ASSERT_NOT_NULL_POINTER(length_pointer) - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { generated::untranspose::fallback::scalar::untranspose_i(offset_arr, untrasposed_offset); len_t encoded_size {0}; @@ -159,7 +160,9 @@ void dec_fsst12_opr::Decode(vector& byte_arr_vec, vector& length in_byte_arr += encoded_size; length_pointer[i] = decoded_size; if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), tmp_string.begin(), tmp_string.begin() + decoded_size); } diff --git a/src/expression/fsst_dict_operator.cpp b/src/expression/fsst_dict_operator.cpp index 595392cd..c01d48c1 100644 --- a/src/expression/fsst_dict_operator.cpp +++ b/src/expression/fsst_dict_operator.cpp @@ -19,6 +19,8 @@ #include "fls/reader/segment.hpp" #include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" +#include // for std::max +#include // for size_t #include #include // for std::move #include // for std::monostate @@ -36,7 +38,7 @@ struct FSSTDictExprVisitor { index_arr = opr->Data(); } void operator()(const sp& expr) { - visit(FSSTDictExprVisitor {index_arr}, expr->operators[0]); + visit_dec(FSSTDictExprVisitor {index_arr}, expr->operators[0]); } void operator()(std::monostate&) { FLS_UNREACHABLE(); @@ -136,7 +138,7 @@ dec_fsst_dict_opr::dec_fsst_dict_opr(const PhysicalExpr& physical_expr static_cast((*column_view.column_descriptor.encoding_rpn() ->operand_tokens())[static_cast(state.cur_operand - 0)]))) , index_arr(nullptr) { - visit(FSSTDictExprVisitor {index_arr}, physical_expr.operators[0]); + visit_dec(FSSTDictExprVisitor {index_arr}, physical_expr.operators[0]); tmp_string.resize(CFG::String::max_bytes_per_string); fsst_header_segment_view.PointTo(0); @@ -200,7 +202,9 @@ void dec_fsst_dict_opr::Decode(vector& byte_arr_vec, vector(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), tmp_string.begin(), tmp_string.begin() + decoded_size); } diff --git a/src/expression/fsst_expression.cpp b/src/expression/fsst_expression.cpp index 04ff9952..13dc1459 100644 --- a/src/expression/fsst_expression.cpp +++ b/src/expression/fsst_expression.cpp @@ -17,9 +17,10 @@ #include "fls/primitive/fsst/fsst.hpp" #include "fls/reader/column_view.hpp" #include "fls/reader/segment.hpp" -#include "fls/std/variant.hpp" #include "fls/table/rowgroup.hpp" #include "fls_gen/untranspose/untranspose.hpp" +#include // for std::max +#include // for size_t #include #include // for std::move #include // for std::monostate @@ -113,7 +114,7 @@ dec_fsst_opr::dec_fsst_opr(PhysicalExpr& physical_expr, const ColumnView& column , fsst_bytes_segment_view(column_view.GetSegment(1)) , offset_arr(nullptr) { - visit(FSSTExprVisitor {*this}, physical_expr.operators.back()); + visit_dec(FSSTExprVisitor {*this}, physical_expr.operators.back()); FLS_ASSERT_NOT_NULL_POINTER(offset_arr) fsst_header_segment_view.PointTo(0); @@ -137,7 +138,7 @@ void dec_fsst_opr::Decode(vector& byte_arr_vec, vector& length_v FLS_ASSERT_NOT_NULL_POINTER(length_pointer) - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { generated::untranspose::fallback::scalar::untranspose_i(offset_arr, untrasposed_offset); len_t encoded_size {0}; @@ -159,7 +160,9 @@ void dec_fsst_opr::Decode(vector& byte_arr_vec, vector& length_v in_byte_arr += encoded_size; length_pointer[i] = decoded_size; if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), tmp_string.begin(), tmp_string.begin() + decoded_size); } diff --git a/src/expression/interpreter.cpp b/src/expression/interpreter.cpp index 0e2f20a8..1878ecad 100644 --- a/src/expression/interpreter.cpp +++ b/src/expression/interpreter.cpp @@ -4,453 +4,8 @@ // src/expression/interpreter.cpp // ──────────────────────────────────────────────────────── #include "fls/expression/interpreter.hpp" -#include "flatbuffers/vector.h" // flatbuffers::Vector -#include "fls/common/alias.hpp" -#include "fls/common/assert.hpp" -#include "fls/common/common.hpp" -#include "fls/common/exception.hpp" -#include "fls/common/string.hpp" -#include "fls/expression/alp_expression.hpp" -#include "fls/expression/analyze_operator.hpp" -#include "fls/expression/cross_rle_operator.hpp" -#include "fls/expression/data_parallelize_patch_operator.hpp" -#include "fls/expression/data_type.hpp" -#include "fls/expression/decoding_operator.hpp" -#include "fls/expression/dict_expression.hpp" -#include "fls/expression/encoding_operator.hpp" -#include "fls/expression/frequency_operator.hpp" -#include "fls/expression/fsst12_dict_operator.hpp" -#include "fls/expression/fsst12_expression.hpp" -#include "fls/expression/fsst_dict_operator.hpp" -#include "fls/expression/fsst_expression.hpp" -#include "fls/expression/null_operator.hpp" -#include "fls/expression/physical_expression.hpp" -#include "fls/expression/rle_expression.hpp" -#include "fls/expression/rpn.hpp" -#include "fls/expression/rsum_operator.hpp" -#include "fls/expression/scan_operator.hpp" -#include "fls/expression/slpatch_operator.hpp" -#include "fls/expression/transpose_operator.hpp" -#include "fls/expression/validitymask_operator.hpp" -#include "fls/reader/column_view.hpp" -#include "fls/std/type_traits.hpp" -#include "fls/table/rowgroup.hpp" -#include // size_t -#include // uint32_t, uint64_t namespace fastlanes { -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_uncompressed_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_uncompressed_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; - operand_tokens.emplace_back(0); - - const auto& column = rowgroup[column_descriptor.idx]; - physical_expr.operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_validitymask_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_enc_validitymask_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; - operand_tokens.emplace_back(0); - - const auto& column = rowgroup[column_descriptor.idx]; - physical_expr.operators.emplace_back( - make_shared(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_struct_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_enc_struct_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - const auto& col = rowgroup[column_descriptor.idx]; - - physical_expr.operators.emplace_back(make_shared(col, column_descriptor)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_fls_str_uncompressed_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_fls_str_uncompressed_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; - operand_tokens.emplace_back(0); - operand_tokens.emplace_back(1); - - const auto& column = rowgroup[column_descriptor.idx]; - physical_expr.operators.emplace_back(make_shared(column)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_fsst_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_fsst_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - physical_expr.operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_fsst_delta_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_fsst_delta_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_fsst_delta_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_fsst_delta_slpatch_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_ffor_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_ffor_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_ffor_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_ffor_slpatch_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_null_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_null_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_null_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_frequency_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * enc_frequency_str_opr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_enc_frequency_str_opr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_cross_rle_opr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_cross_rle_opr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - const auto& column = rowgroup[column_descriptor.idx]; - auto& operators = physical_expr.operators; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_dict_ffor_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_dict_ffor_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_dict_ffor_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_fsst_dict_ffor_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_fsst_dict_ffor_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_fsst_dict_ffor_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_fsst_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_fsst_dict_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_fsst_dict_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_enc_dict_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_dict_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_alp_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_alp_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_galp_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_galp_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_rle_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_rle_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_rle_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_rle_slpatch_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_delta_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_delta_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); - operators.emplace_back( - make_shared>>(physical_expr, column, column_descriptor, state)); -} -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_alp_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_enc_alp_rd_expr(PhysicalExpr& physical_expr, - const rowgroup_pt& rowgroup, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - auto& operators = physical_expr.operators; - const auto& column = rowgroup[column_descriptor.idx]; - - operators.emplace_back(make_shared>(physical_expr, column, column_descriptor, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * Interpreter::Encoding -\*--------------------------------------------------------------------------------------------------------------------*/ InterpreterState::InterpreterState() : cur_operator(0) @@ -458,1600 +13,4 @@ InterpreterState::InterpreterState() , n_segments(0) { } -sp Interpreter::Encoding::Interpret(ColumnDescriptorT& column_descriptor, - const rowgroup_pt& physical_rowgroup, - InterpreterState& state) { - // return - auto physical_expr = make_shared(); - - for (auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; - const auto& operator_token : operator_tokens) { - using enum OperatorToken; - switch (operator_token) { - case EXP_UNCOMPRESSED_I64: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_I32: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_I16: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_U08: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_I64: { - make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_I32: { - make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_I16: { - make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_I08: { - make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_U08: { - make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_DBL: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_FLT: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_I08: { - make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_UNCOMPRESSED_STR: { - make_fls_str_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CONSTANT_DBL: - case EXP_CONSTANT_I64: - case EXP_CONSTANT_I32: - case EXP_CONSTANT_I16: - case EXP_CONSTANT_I08: - case EXP_CONSTANT_STR: - case EXP_CONSTANT_U08: - case EXP_CONSTANT_FLT: - case EXP_CONSTANT_BOOL: - case EXP_EQUAL: { - break; - } - case EXP_STRUCT: { - make_enc_struct_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_FFOR_U32: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_FFOR_U16: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_FFOR_U32: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_FFOR_U16: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I16_FFOR_U16: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_FFOR_U32: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I16_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I08_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_FFOR_U16: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_FLT_FFOR_U16: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_FLT_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_U08: - case EXP_DICT_I64_U16: - case EXP_DICT_I64_U32: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_U08: - case EXP_DICT_I32_U16: - case EXP_DICT_I32_U32: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I16_U08: - case EXP_DICT_I16_U16: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I08_U08: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_U08_U08: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_FLT_U08: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_U08: - case EXP_DICT_DBL_U16: - case EXP_DICT_DBL_U32: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_U08: - case EXP_DICT_STR_U16: - case EXP_DICT_STR_U32: { - make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_ALP_DBL: { - make_enc_alp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_ALP_FLT: { - make_enc_alp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_GALP_FLT: { - make_enc_galp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_GALP_DBL: { - make_enc_galp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_ALP_RD_DBL: { - make_enc_alp_rd_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_ALP_RD_FLT: { - make_enc_alp_rd_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST: { - make_fsst_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12: { - make_fsst_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_FFOR_U32: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_FFOR_U16: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_FFOR_U08: { - make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_U32: { - make_enc_fsst_dict_ffor_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_U16: { - make_enc_fsst_dict_ffor_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_U08: { - make_enc_fsst_dict_ffor_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - - case EXP_RLE_DBL_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_FLT_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I64_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I32_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I16_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I08_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_U08_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_STR_U16: { - make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DELTA: { - make_fsst_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DELTA: { - make_fsst_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DELTA_I64: { - make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DELTA_I32: { - make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DELTA_I16: { - make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DELTA_I08: { - make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DELTA_U08: { - make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_SLPATCH_I64: { - make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_SLPATCH_I32: { - make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_SLPATCH_I16: { - make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_SLPATCH_I08: { - make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FFOR_SLPATCH_U08: { - make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_FFOR_SLPATCH_U16: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_FFOR_SLPATCH_U32: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_FFOR_SLPATCH_U32: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_FFOR_SLPATCH_U16: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I32_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_FFOR_SLPATCH_U16: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_FFOR_SLPATCH_U32: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_FFOR_SLPATCH_U16: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_STR_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I16_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I08_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I16_FFOR_SLPATCH_U16: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_I64_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_FLT_FFOR_SLPATCH_U08: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_FLT_FFOR_SLPATCH_U16: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_DICT_DBL_FFOR_SLPATCH_U32: { - make_enc_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_SLPATCH_U32: { - make_enc_fsst_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_SLPATCH_U16: { - make_enc_fsst_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_SLPATCH_U08: { - make_enc_fsst_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U32: { - make_enc_fsst_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U16: { - make_enc_fsst_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U08: { - make_enc_fsst_dict_ffor_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_NULL_DBL: { - make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_NULL_FLT: { - make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_NULL_I16: { - make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_NULL_I32: { - make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I64_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I32_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I16_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_I08_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_U08_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_STR_SLPATCH_U16: { - make_enc_rle_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_DBL_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_RLE_FLT_SLPATCH_U16: { - make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DICT_STR_U32: - case EXP_FSST_DICT_STR_U16: - case EXP_FSST_DICT_STR_U08: { - make_enc_fsst_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST_DELTA_SLPATCH: { - make_enc_fsst_delta_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DELTA_SLPATCH: { - make_enc_fsst_delta_slpatch_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case WIZARD_DICTIONARY_ENCODE: { - FLS_UNREACHABLE() - } - case EXP_FSST12_DICT_STR_U32: - case EXP_FSST12_DICT_STR_U16: - case EXP_FSST12_DICT_STR_U08: { - make_enc_fsst_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_U32: { - make_enc_fsst_dict_ffor_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_U16: { - make_enc_fsst_dict_ffor_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_U08: { - make_enc_fsst_dict_ffor_expr( - *physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_DBL: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_FLT: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_I08: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_U08: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_I16: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_I32: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_I64: { - make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_FREQUENCY_STR: { - make_enc_frequency_str_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_I08: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_U08: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_I16: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_I32: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_I64: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_DBL: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_FLT: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_CROSS_RLE_STR: { - make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case EXP_VALIDITY_MASK: { - make_enc_validitymask_expr(*physical_expr, physical_rowgroup, column_descriptor, state); - break; - } - case INVALID: - default: - throw_not_supported_exception(operator_token); - FLS_UNREACHABLE(); - } - } - - return physical_expr; -} // namespace fastlanes - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_uncompressed_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_uncompressed_expr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - const InterpreterState& /*state*/) { - const auto* rpn = column_view.column_descriptor.encoding_rpn(); - FLS_ASSERT_NOT_NULL_POINTER(rpn); - - const auto* operands = rpn->operand_tokens(); - FLS_ASSERT_NOT_NULL_POINTER(operands); - - FLS_ASSERT_E(operands->size(), 1); - - const uint64_t last = operands->Get(operands->size() - 1); - - physical_expr.operators.emplace_back(std::make_shared>(column_view, last)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_validitymask_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_dec_validitymask_expr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - const InterpreterState& /*state*/) { - const auto* rpn = column_view.column_descriptor.encoding_rpn(); - FLS_ASSERT_NOT_NULL_POINTER(rpn); - - const auto* operands = rpn->operand_tokens(); - FLS_ASSERT_NOT_NULL_POINTER(operands); - - FLS_ASSERT_E(operands->size(), 1); - - const uint64_t last = operands->Get(operands->size() - 1); - physical_expr.operators.emplace_back(std::make_shared(column_view, last)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fls_str_uncompressed_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_dec_fls_str_uncompressed_expr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - const auto* rpn = column_view.column_descriptor.encoding_rpn(); - FLS_ASSERT_NOT_NULL_POINTER(rpn); - - physical_expr.operators.emplace_back(std::make_shared(column_view, *rpn)); - - state.cur_operator += 1; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fsst_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_fsst_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); - state.cur_operator = state.cur_operator + 2; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fsst_delta_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_fsst_delta_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); - state.cur_operator = state.cur_operator + 3; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fsst_delta_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_fsst_delta_slpatch_expr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); - state.cur_operator = state.cur_operator + 3; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_ffor_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_ffor_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>>(column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_ffor_sl_patch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_ffor_slpatch_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_alp_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_alp_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - physical_expr.operators.emplace_back(make_shared>(column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_galp_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_galp_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_alp_rd_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_alp_rd_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - physical_expr.operators.emplace_back(make_shared>(column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_dict_ffor_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_dict_ffor_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back( - make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_null_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_null_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_frequency_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_frequency_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_frequency_str_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_dec_frequency_str_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_cross_rle_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_cross_rle_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_dict_ffor_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back( - make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fsst_dict_ffor_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_fsst_dict_ffor_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fsst_dict_ffor_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_fsst_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fsst_dict_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_fsst_dict_expr(RowgroupReader& reader, - PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - const auto* rpn = column_view.column_descriptor.encoding_rpn(); - const auto* operand_tokens = rpn->operand_tokens(); - - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - physical_expr.operators.emplace_back(reader.m_expressions[static_cast(operand_tokens->Get(0))]); - physical_expr.operators.emplace_back(make_shared(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_dict_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_dict_expr(RowgroupReader& reader, - PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - const auto* operand_tokens = column_view.column_descriptor.encoding_rpn()->operand_tokens(); - - physical_expr.operators.emplace_back( - reader.m_expressions[static_cast(operand_tokens->Get(static_cast(state.cur_operand++)))]); - physical_expr.operators.emplace_back( - make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_rle_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_rle_expr(RowgroupReader& reader, - PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - state.cur_operator = 0; - - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back( - make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_rle_slpatch_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_rle_slpatch_expr(RowgroupReader& reader, - PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - state.cur_operator = 0; - - physical_expr.operators.emplace_back(make_shared>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back( - make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_delta_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_delta_expr(RowgroupReader& reader, - PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) { - state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; - state.cur_operator = 0; - - physical_expr.operators.emplace_back(make_shared>>(column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); - physical_expr.operators.emplace_back(make_shared>(physical_expr, column_view, state)); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_fls_str_uncompressed_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_expr(PhysicalExpr& physical_expr, ColumnView& column_view, InterpreterState& state) { - - physical_expr.operators.emplace_back(make_shared>(column_view)); - state.cur_operator = state.cur_operator + 1; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_constant_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -void make_dec_constant_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - - physical_expr.operators.emplace_back(make_shared>(column_view)); - state.cur_operator = state.cur_operator + 1; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_constant_str_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_dec_constant_str_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { - physical_expr.operators.emplace_back(make_shared(column_view)); - state.cur_operator = state.cur_operator + 1; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_equality_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_dec_equality_expr(PhysicalExpr& physical_expr, - RowgroupReader& reader, - const flatbuffers::Vector* operand_tokens) { - FLS_ASSERT_NOT_NULL_POINTER(operand_tokens); - FLS_ASSERT_FB_NOT_EMPTY(operand_tokens); - - const auto idx = static_cast(operand_tokens->Get(0)); - physical_expr.operators.emplace_back(reader.m_expressions[idx]->operators.back()); -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_dec_struct_expr -\*--------------------------------------------------------------------------------------------------------------------*/ -void make_dec_struct_expr(const ColumnDescriptor& column_descriptor, - const ColumnView& column_view, - PhysicalExpr& physical_expr, - InterpreterState& state, - RowgroupReader& reader) { - - physical_expr.operators.emplace_back(make_shared(column_descriptor, column_view, state, reader)); - state.cur_operator = state.cur_operator + 1; -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * Interpreter -\*--------------------------------------------------------------------------------------------------------------------*/ -void Interpreter::Decoding::Interpret(const ColumnDescriptor& column_descriptor, - const ColumnView& column_view, - PhysicalExpr& physical_expr, - InterpreterState& state, - RowgroupReader& reader) { - const auto* rpn = column_descriptor.encoding_rpn(); - FLS_ASSERT_NOT_NULL_POINTER(rpn); - - const auto* operator_tokens = rpn->operator_tokens(); - const auto* operand_tokens = rpn->operand_tokens(); - - FLS_ASSERT_NOT_NULL_POINTER(operator_tokens); - - using enum OperatorToken; // if you already use this in the switch - - for (std::uint32_t i = 0; i < operator_tokens->size(); ++i) { - const auto operator_token = operator_tokens->Get(i); - - switch (operator_token) { - case EXP_UNCOMPRESSED_I64: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_I32: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_I16: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_U08: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_DBL: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_FLT: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_STR: { - make_dec_fls_str_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_UNCOMPRESSED_I08: { - make_dec_uncompressed_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST: { - make_dec_fsst_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST_DELTA: { - make_dec_fsst_delta_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST12_DELTA: { - make_dec_fsst_delta_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST12: { - make_dec_fsst_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_I64: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_I32: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_I16: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_I08: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_U08: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_BOOL: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_DBL: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_FLT: { - make_dec_constant_expr(physical_expr, column_view, state); - break; - } - case EXP_CONSTANT_STR: { - make_dec_constant_str_expr(physical_expr, column_view, state); - break; - } - case EXP_EQUAL: { - make_dec_equality_expr(physical_expr, reader, operand_tokens); - break; - } - case EXP_STRUCT: { - make_dec_struct_expr(column_descriptor, column_view, physical_expr, state, reader); - break; - } - case EXP_FFOR_I64: { - make_dec_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_I32: { - make_dec_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_I16: { - make_dec_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_I08: { - make_dec_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_U08: { - make_dec_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_FFOR_U32: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_FFOR_U16: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_FFOR_U32: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_FFOR_U16: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I16_FFOR_U16: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I16_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I08_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_FFOR_U32: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_FFOR_U16: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_FLT_FFOR_U16: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_FLT_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_U32: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_U32: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_U16: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_U16: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I16_U16: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I16_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_I08_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_U08_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_FLT_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_U32: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_U16: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_U32: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_U16: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_U08: { - make_dec_dict_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_ALP_DBL: { - make_dec_alp_expr(physical_expr, column_view, state); - break; - } - case EXP_ALP_FLT: { - make_dec_alp_expr(physical_expr, column_view, state); - break; - } - case EXP_GALP_FLT: { - make_dec_galp_expr(physical_expr, column_view, state); - break; - } - case EXP_GALP_DBL: { - make_dec_galp_expr(physical_expr, column_view, state); - break; - } - case EXP_ALP_RD_DBL: { - make_dec_alp_rd_expr(physical_expr, column_view, state); - break; - } - case EXP_ALP_RD_FLT: { - make_dec_alp_rd_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_FFOR_U32: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_FFOR_U16: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_FFOR_U08: { - make_dec_dict_ffor_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_U32: { - make_dec_fsst_dict_ffor_expr, u32_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_U16: { - make_dec_fsst_dict_ffor_expr, u16_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_U08: { - make_dec_fsst_dict_ffor_expr, u08_pt>(physical_expr, column_view, state); - break; - } - case EXP_RLE_DBL_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_FLT_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I64_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I32_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I16_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I08_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_U08_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_STR_U16: { - make_dec_rle_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DELTA_I64: { - make_dec_delta_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DELTA_I32: { - make_dec_delta_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DELTA_I16: { - make_dec_delta_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DELTA_I08: { - make_dec_delta_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_DELTA_U08: { - make_dec_delta_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_FFOR_SLPATCH_I64: { - make_dec_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_SLPATCH_I32: { - make_dec_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_SLPATCH_I16: { - make_dec_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_SLPATCH_I08: { - make_dec_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FFOR_SLPATCH_U08: { - make_dec_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_FFOR_SLPATCH_U16: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_FFOR_SLPATCH_U32: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_FFOR_SLPATCH_U16: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_STR_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I16_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I08_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I16_FFOR_SLPATCH_U16: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_FLT_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_FLT_FFOR_SLPATCH_U16: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_DBL_FFOR_SLPATCH_U32: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_FFOR_SLPATCH_U08: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I32_FFOR_SLPATCH_U16: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_DICT_I64_FFOR_SLPATCH_U16: { - make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_SLPATCH_U32: { - make_dec_fsst_dict_ffor_slpatch_expr, u32_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_SLPATCH_U16: { - make_dec_fsst_dict_ffor_slpatch_expr, u16_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_FFOR_SLPATCH_U08: { - make_dec_fsst_dict_ffor_slpatch_expr, u08_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U32: { - make_dec_fsst_dict_ffor_slpatch_expr, u32_pt>( - physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U16: { - make_dec_fsst_dict_ffor_slpatch_expr, u16_pt>( - physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U08: { - make_dec_fsst_dict_ffor_slpatch_expr, u08_pt>( - physical_expr, column_view, state); - break; - } - case EXP_NULL_DBL: { - make_dec_null_expr(physical_expr, column_view, state); - break; - } - case EXP_NULL_FLT: { - make_dec_null_expr(physical_expr, column_view, state); - break; - } - case EXP_NULL_I32: { - make_dec_null_expr(physical_expr, column_view, state); - break; - } - case EXP_NULL_I16: { - make_dec_null_expr(physical_expr, column_view, state); - break; - } - case EXP_RLE_I64_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I32_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I16_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_I08_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_U08_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_STR_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_DBL_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_RLE_FLT_SLPATCH_U16: { - make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_U32: { - make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_U16: { - make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST_DICT_STR_U08: { - make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST_DELTA_SLPATCH: { - make_dec_fsst_delta_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST12_DELTA_SLPATCH: { - make_dec_fsst_delta_slpatch_expr(physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_U32: { - make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_U16: { - make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_U08: { - make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_U32: { - make_dec_fsst_dict_ffor_expr, u32_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_U16: { - make_dec_fsst_dict_ffor_expr, u16_pt>(physical_expr, column_view, state); - break; - } - case EXP_FSST12_DICT_STR_FFOR_U08: { - make_dec_fsst_dict_ffor_expr, u08_pt>(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_DBL: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_FLT: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_I08: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_U08: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_I16: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_I32: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_I64: { - make_dec_frequency_expr(physical_expr, column_view, state); - break; - } - case EXP_FREQUENCY_STR: { - make_dec_frequency_str_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_I08: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_U08: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_I16: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_I32: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_I64: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_DBL: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_FLT: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_CROSS_RLE_STR: { - make_dec_cross_rle_expr(physical_expr, column_view, state); - break; - } - case EXP_VALIDITY_MASK: { - make_dec_validitymask_expr(physical_expr, column_view, state); - break; - } - case INVALID: - default: - FLS_UNREACHABLE(); - } - } -} - -/*--------------------------------------------------------------------------------------------------------------------*\ - * make_decoding_expression -\*--------------------------------------------------------------------------------------------------------------------*/ -sp make_decoding_expression(const ColumnDescriptor& column_descriptor, - const ColumnView& column_view, - RowgroupReader& reader, - InterpreterState& state) { - auto physical_expr = make_shared(); - Interpreter::Decoding::Interpret(column_descriptor, column_view, *physical_expr, state, reader); - - return physical_expr; -} - } // namespace fastlanes diff --git a/src/expression/interpreter_decoding.cpp b/src/expression/interpreter_decoding.cpp new file mode 100644 index 00000000..c509fca0 --- /dev/null +++ b/src/expression/interpreter_decoding.cpp @@ -0,0 +1,1079 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/interpreter_decoding.cpp +// ──────────────────────────────────────────────────────── +#include "flatbuffers/vector.h" // flatbuffers::Vector +#include "fls/common/alias.hpp" +#include "fls/common/assert.hpp" +#include "fls/common/common.hpp" +#include "fls/common/exception.hpp" +#include "fls/common/string.hpp" +#include "fls/expression/alp_expression.hpp" +#include "fls/expression/cross_rle_operator.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/decoding_operator.hpp" +#include "fls/expression/dict_expression.hpp" +#include "fls/expression/frequency_operator.hpp" +#include "fls/expression/fsst12_dict_operator.hpp" +#include "fls/expression/fsst12_expression.hpp" +#include "fls/expression/fsst_dict_operator.hpp" +#include "fls/expression/fsst_expression.hpp" +#include "fls/expression/interpreter.hpp" +#include "fls/expression/null_operator.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/rle_expression.hpp" +#include "fls/expression/rpn.hpp" +#include "fls/expression/rsum_operator.hpp" +#include "fls/expression/scan_operator.hpp" +#include "fls/expression/slpatch_operator.hpp" +#include "fls/expression/transpose_operator.hpp" +#include "fls/expression/validitymask_operator.hpp" +#include "fls/reader/column_view.hpp" +#include "fls/std/type_traits.hpp" +#include // size_t +#include // uint32_t, uint64_t +#include // std::make_shared + +namespace fastlanes { + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_uncompressed_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_uncompressed_expr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + const InterpreterState& /*state*/) { + const auto* rpn = column_view.column_descriptor.encoding_rpn(); + FLS_ASSERT_NOT_NULL_POINTER(rpn); + + const auto* operands = rpn->operand_tokens(); + FLS_ASSERT_NOT_NULL_POINTER(operands); + + FLS_ASSERT_E(operands->size(), 1); + + const uint64_t last = operands->Get(operands->size() - 1); + + physical_expr.operators.emplace_back( + dec_physical_operator {std::make_shared>(column_view, last)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_validitymask_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_dec_validitymask_expr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + const InterpreterState& /*state*/) { + const auto* rpn = column_view.column_descriptor.encoding_rpn(); + FLS_ASSERT_NOT_NULL_POINTER(rpn); + + const auto* operands = rpn->operand_tokens(); + FLS_ASSERT_NOT_NULL_POINTER(operands); + + FLS_ASSERT_E(operands->size(), 1); + + const uint64_t last = operands->Get(operands->size() - 1); + physical_expr.operators.emplace_back( + dec_physical_operator {std::make_shared(column_view, last)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fls_str_uncompressed_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_dec_fls_str_uncompressed_expr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + const auto* rpn = column_view.column_descriptor.encoding_rpn(); + FLS_ASSERT_NOT_NULL_POINTER(rpn); + + physical_expr.operators.emplace_back( + dec_physical_operator {std::make_shared(column_view, *rpn)}); + + state.cur_operator += 1; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fsst_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_fsst_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back(dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); + state.cur_operator = state.cur_operator + 2; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fsst_delta_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_fsst_delta_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); + state.cur_operator = state.cur_operator + 3; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fsst_delta_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_fsst_delta_slpatch_expr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); + state.cur_operator = state.cur_operator + 3; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_ffor_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_ffor_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>>(column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_ffor_sl_patch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_ffor_slpatch_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_alp_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_alp_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + physical_expr.operators.emplace_back(dec_physical_operator {make_shared>(column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_galp_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_galp_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + // Note: dec_alp_opr uses hardcoded segment indices (0-7), so cur_operand is unused. + // Unlike other decoders, GALP/ALP encoding does not emit operand_tokens, so + // accessing operand_tokens() here would dereference a null pointer. + physical_expr.operators.emplace_back(dec_physical_operator {make_shared>(column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_alp_rd_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_alp_rd_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + physical_expr.operators.emplace_back(dec_physical_operator {make_shared>(column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_dict_ffor_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_dict_ffor_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_null_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_null_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_frequency_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_frequency_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_frequency_str_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_dec_frequency_str_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_cross_rle_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_cross_rle_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_dict_ffor_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fsst_dict_ffor_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_fsst_dict_ffor_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fsst_dict_ffor_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_fsst_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fsst_dict_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_fsst_dict_expr(RowgroupReader& reader, + PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + const auto* rpn = column_view.column_descriptor.encoding_rpn(); + const auto* operand_tokens = rpn->operand_tokens(); + + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + physical_expr.operators.emplace_back(reader.m_expressions[static_cast(operand_tokens->Get(0))]); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_dict_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_dict_expr(RowgroupReader& reader, + PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + const auto* operand_tokens = column_view.column_descriptor.encoding_rpn()->operand_tokens(); + + physical_expr.operators.emplace_back( + reader.m_expressions[static_cast(operand_tokens->Get(static_cast(state.cur_operand++)))]); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_rle_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_rle_expr(RowgroupReader& reader, + PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + state.cur_operator = 0; + + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_rle_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_rle_slpatch_expr(RowgroupReader& reader, + PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + state.cur_operator = 0; + + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_delta_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_delta_expr(RowgroupReader& reader, + PhysicalExpr& physical_expr, + const ColumnView& column_view, + InterpreterState& state) { + state.cur_operand = column_view.column_descriptor.encoding_rpn()->operand_tokens()->size() - 1; + state.cur_operator = 0; + + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>>(column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(physical_expr, column_view, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_fls_str_uncompressed_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_expr(PhysicalExpr& physical_expr, ColumnView& column_view, InterpreterState& state) { + + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared>(column_view)}); + state.cur_operator = state.cur_operator + 1; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_constant_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_dec_constant_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + + physical_expr.operators.emplace_back(dec_physical_operator {make_shared>(column_view)}); + state.cur_operator = state.cur_operator + 1; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_constant_str_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_dec_constant_str_expr(PhysicalExpr& physical_expr, const ColumnView& column_view, InterpreterState& state) { + physical_expr.operators.emplace_back(dec_physical_operator {make_shared(column_view)}); + state.cur_operator = state.cur_operator + 1; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_equality_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_dec_equality_expr(PhysicalExpr& physical_expr, + RowgroupReader& reader, + const flatbuffers::Vector* operand_tokens) { + FLS_ASSERT_NOT_NULL_POINTER(operand_tokens); + FLS_ASSERT_FB_NOT_EMPTY(operand_tokens); + + const auto idx = static_cast(operand_tokens->Get(0)); + physical_expr.operators.emplace_back(reader.m_expressions[idx]->operators.back()); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_dec_struct_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_dec_struct_expr(const ColumnDescriptor& column_descriptor, + const ColumnView& column_view, + PhysicalExpr& physical_expr, + InterpreterState& state, + RowgroupReader& reader) { + + physical_expr.operators.emplace_back( + dec_physical_operator {make_shared(column_descriptor, column_view, state, reader)}); + state.cur_operator = state.cur_operator + 1; +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * Interpreter +\*--------------------------------------------------------------------------------------------------------------------*/ +void Interpreter::Decoding::Interpret(const ColumnDescriptor& column_descriptor, + const ColumnView& column_view, + PhysicalExpr& physical_expr, + InterpreterState& state, + RowgroupReader& reader) { + const auto* rpn = column_descriptor.encoding_rpn(); + FLS_ASSERT_NOT_NULL_POINTER(rpn); + + const auto* operator_tokens = rpn->operator_tokens(); + const auto* operand_tokens = rpn->operand_tokens(); + + FLS_ASSERT_NOT_NULL_POINTER(operator_tokens); + + using enum OperatorToken; // if you already use this in the switch + + for (std::uint32_t i = 0; i < operator_tokens->size(); ++i) { + const auto operator_token = operator_tokens->Get(i); + + switch (operator_token) { + case EXP_UNCOMPRESSED_I64: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_I32: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_I16: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_U08: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_DBL: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_FLT: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_STR: { + make_dec_fls_str_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_UNCOMPRESSED_I08: { + make_dec_uncompressed_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST: { + make_dec_fsst_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST_DELTA: { + make_dec_fsst_delta_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST12_DELTA: { + make_dec_fsst_delta_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST12: { + make_dec_fsst_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_I64: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_I32: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_I16: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_I08: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_U08: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_BOOL: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_DBL: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_FLT: { + make_dec_constant_expr(physical_expr, column_view, state); + break; + } + case EXP_CONSTANT_STR: { + make_dec_constant_str_expr(physical_expr, column_view, state); + break; + } + case EXP_EQUAL: { + make_dec_equality_expr(physical_expr, reader, operand_tokens); + break; + } + case EXP_STRUCT: { + make_dec_struct_expr(column_descriptor, column_view, physical_expr, state, reader); + break; + } + case EXP_FFOR_I64: { + make_dec_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_I32: { + make_dec_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_I16: { + make_dec_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_I08: { + make_dec_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_U08: { + make_dec_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_FFOR_U32: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_FFOR_U16: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_FFOR_U32: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_FFOR_U16: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I16_FFOR_U16: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I16_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I08_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_FFOR_U32: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_FFOR_U16: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_FLT_FFOR_U16: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_FLT_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_U32: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_U32: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_U16: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_U16: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I16_U16: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I16_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_I08_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_U08_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_FLT_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_U32: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_U16: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_U32: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_U16: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_U08: { + make_dec_dict_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_ALP_DBL: { + make_dec_alp_expr(physical_expr, column_view, state); + break; + } + case EXP_ALP_FLT: { + make_dec_alp_expr(physical_expr, column_view, state); + break; + } + case EXP_GALP_FLT: { + make_dec_galp_expr(physical_expr, column_view, state); + break; + } + case EXP_GALP_DBL: { + make_dec_galp_expr(physical_expr, column_view, state); + break; + } + case EXP_ALP_RD_DBL: { + make_dec_alp_rd_expr(physical_expr, column_view, state); + break; + } + case EXP_ALP_RD_FLT: { + make_dec_alp_rd_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_FFOR_U32: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_FFOR_U16: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_FFOR_U08: { + make_dec_dict_ffor_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_U32: { + make_dec_fsst_dict_ffor_expr, u32_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_U16: { + make_dec_fsst_dict_ffor_expr, u16_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_U08: { + make_dec_fsst_dict_ffor_expr, u08_pt>(physical_expr, column_view, state); + break; + } + case EXP_RLE_DBL_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_FLT_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I64_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I32_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I16_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I08_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_U08_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_STR_U16: { + make_dec_rle_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DELTA_I64: { + make_dec_delta_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DELTA_I32: { + make_dec_delta_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DELTA_I16: { + make_dec_delta_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DELTA_I08: { + make_dec_delta_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_DELTA_U08: { + make_dec_delta_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_FFOR_SLPATCH_I64: { + make_dec_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_SLPATCH_I32: { + make_dec_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_SLPATCH_I16: { + make_dec_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_SLPATCH_I08: { + make_dec_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FFOR_SLPATCH_U08: { + make_dec_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_FFOR_SLPATCH_U16: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_FFOR_SLPATCH_U32: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_FFOR_SLPATCH_U16: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_STR_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I16_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I08_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I16_FFOR_SLPATCH_U16: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_FLT_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_FLT_FFOR_SLPATCH_U16: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_DBL_FFOR_SLPATCH_U32: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_FFOR_SLPATCH_U08: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I32_FFOR_SLPATCH_U16: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_DICT_I64_FFOR_SLPATCH_U16: { + make_dec_dict_ffor_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_SLPATCH_U32: { + make_dec_fsst_dict_ffor_slpatch_expr, u32_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_SLPATCH_U16: { + make_dec_fsst_dict_ffor_slpatch_expr, u16_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_SLPATCH_U08: { + make_dec_fsst_dict_ffor_slpatch_expr, u08_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U32: { + make_dec_fsst_dict_ffor_slpatch_expr, u32_pt>( + physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U16: { + make_dec_fsst_dict_ffor_slpatch_expr, u16_pt>( + physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U08: { + make_dec_fsst_dict_ffor_slpatch_expr, u08_pt>( + physical_expr, column_view, state); + break; + } + case EXP_NULL_DBL: { + make_dec_null_expr(physical_expr, column_view, state); + break; + } + case EXP_NULL_FLT: { + make_dec_null_expr(physical_expr, column_view, state); + break; + } + case EXP_NULL_I32: { + make_dec_null_expr(physical_expr, column_view, state); + break; + } + case EXP_NULL_I16: { + make_dec_null_expr(physical_expr, column_view, state); + break; + } + case EXP_RLE_I64_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I32_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I16_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_I08_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_U08_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_STR_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_DBL_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_RLE_FLT_SLPATCH_U16: { + make_dec_rle_slpatch_expr(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_U32: { + make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_U16: { + make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST_DICT_STR_U08: { + make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST_DELTA_SLPATCH: { + make_dec_fsst_delta_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST12_DELTA_SLPATCH: { + make_dec_fsst_delta_slpatch_expr(physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_U32: { + make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_U16: { + make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_U08: { + make_dec_fsst_dict_expr>(reader, physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_U32: { + make_dec_fsst_dict_ffor_expr, u32_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_U16: { + make_dec_fsst_dict_ffor_expr, u16_pt>(physical_expr, column_view, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_U08: { + make_dec_fsst_dict_ffor_expr, u08_pt>(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_DBL: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_FLT: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_I08: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_U08: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_I16: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_I32: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_I64: { + make_dec_frequency_expr(physical_expr, column_view, state); + break; + } + case EXP_FREQUENCY_STR: { + make_dec_frequency_str_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_I08: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_U08: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_I16: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_I32: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_I64: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_DBL: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_FLT: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_CROSS_RLE_STR: { + make_dec_cross_rle_expr(physical_expr, column_view, state); + break; + } + case EXP_VALIDITY_MASK: { + make_dec_validitymask_expr(physical_expr, column_view, state); + break; + } + case INVALID: + default: + FLS_UNREACHABLE(); + } + } +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_decoding_expression +\*--------------------------------------------------------------------------------------------------------------------*/ +sp make_decoding_expression(const ColumnDescriptor& column_descriptor, + const ColumnView& column_view, + RowgroupReader& reader, + InterpreterState& state) { + auto physical_expr = make_shared(); + Interpreter::Decoding::Interpret(column_descriptor, column_view, *physical_expr, state, reader); + + return physical_expr; +} + +} // namespace fastlanes diff --git a/src/expression/interpreter_encoding.cpp b/src/expression/interpreter_encoding.cpp new file mode 100644 index 00000000..add1de14 --- /dev/null +++ b/src/expression/interpreter_encoding.cpp @@ -0,0 +1,1095 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/expression/interpreter_encoding.cpp +// ──────────────────────────────────────────────────────── +#include "fls/common/alias.hpp" +#include "fls/common/common.hpp" +#include "fls/common/exception.hpp" +#include "fls/common/string.hpp" +#include "fls/expression/alp_expression.hpp" +#include "fls/expression/analyze_operator.hpp" +#include "fls/expression/cross_rle_operator.hpp" +#include "fls/expression/data_parallelize_patch_operator.hpp" +#include "fls/expression/data_type.hpp" +#include "fls/expression/dict_expression.hpp" +#include "fls/expression/encoding_operator.hpp" +#include "fls/expression/frequency_operator.hpp" +#include "fls/expression/fsst12_dict_operator.hpp" +#include "fls/expression/fsst12_expression.hpp" +#include "fls/expression/fsst_dict_operator.hpp" +#include "fls/expression/fsst_expression.hpp" +#include "fls/expression/interpreter.hpp" +#include "fls/expression/null_operator.hpp" +#include "fls/expression/physical_expression.hpp" +#include "fls/expression/rle_expression.hpp" +#include "fls/expression/rpn.hpp" +#include "fls/expression/rsum_operator.hpp" +#include "fls/expression/scan_operator.hpp" +#include "fls/expression/slpatch_operator.hpp" +#include "fls/expression/transpose_operator.hpp" +#include "fls/expression/validitymask_operator.hpp" +#include "fls/std/type_traits.hpp" +#include "fls/table/rowgroup.hpp" + +namespace fastlanes { +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_uncompressed_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_uncompressed_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; + operand_tokens.emplace_back(0); + + const auto& column = rowgroup[column_descriptor.idx]; + physical_expr.operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_validitymask_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_enc_validitymask_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; + operand_tokens.emplace_back(0); + + const auto& column = rowgroup[column_descriptor.idx]; + physical_expr.operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_struct_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_enc_struct_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + const auto& col = rowgroup[column_descriptor.idx]; + + physical_expr.operators.emplace_back(enc_physical_operator {make_shared(col, column_descriptor)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_fls_str_uncompressed_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_fls_str_uncompressed_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; + operand_tokens.emplace_back(0); + operand_tokens.emplace_back(1); + + const auto& column = rowgroup[column_descriptor.idx]; + physical_expr.operators.emplace_back(enc_physical_operator {make_shared(column)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_fsst_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_fsst_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + physical_expr.operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_fsst_delta_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_fsst_delta_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_fsst_delta_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_fsst_delta_slpatch_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_ffor_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_ffor_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_ffor_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_ffor_slpatch_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_null_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_null_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_null_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_frequency_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * enc_frequency_str_opr +\*--------------------------------------------------------------------------------------------------------------------*/ +void make_enc_frequency_str_opr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_cross_rle_opr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_cross_rle_opr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + const auto& column = rowgroup[column_descriptor.idx]; + auto& operators = physical_expr.operators; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_dict_ffor_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_dict_ffor_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_dict_ffor_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_fsst_dict_ffor_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_fsst_dict_ffor_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_fsst_dict_ffor_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_fsst_dict_ffor_slpatch_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_fsst_dict_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_fsst_dict_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_enc_dict_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_dict_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_alp_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_alp_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_galp_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_galp_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_rle_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_rle_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_rle_slpatch_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_rle_slpatch_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_delta_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_delta_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); + operators.emplace_back(enc_physical_operator { + make_shared>>(physical_expr, column, column_descriptor, state)}); +} +/*--------------------------------------------------------------------------------------------------------------------*\ + * make_alp_expr +\*--------------------------------------------------------------------------------------------------------------------*/ +template +void make_enc_alp_rd_expr(PhysicalExpr& physical_expr, + const rowgroup_pt& rowgroup, + ColumnDescriptorT& column_descriptor, + InterpreterState& state) { + auto& operators = physical_expr.operators; + const auto& column = rowgroup[column_descriptor.idx]; + + operators.emplace_back( + enc_physical_operator {make_shared>(physical_expr, column, column_descriptor, state)}); +} + +/*--------------------------------------------------------------------------------------------------------------------*\ + * Interpreter::Encoding +\*--------------------------------------------------------------------------------------------------------------------*/ + +sp Interpreter::Encoding::Interpret(ColumnDescriptorT& column_descriptor, + const rowgroup_pt& physical_rowgroup, + InterpreterState& state) { + // return + auto physical_expr = make_shared(); + + auto& [operator_tokens, operand_tokens] = *column_descriptor.encoding_rpn; + for (const auto& operator_token : operator_tokens) { + using enum OperatorToken; + switch (operator_token) { + case EXP_UNCOMPRESSED_I64: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_I32: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_I16: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_U08: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_I64: { + make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_I32: { + make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_I16: { + make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_I08: { + make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_U08: { + make_enc_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_DBL: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_FLT: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_I08: { + make_enc_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_UNCOMPRESSED_STR: { + make_fls_str_uncompressed_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CONSTANT_DBL: + case EXP_CONSTANT_I64: + case EXP_CONSTANT_I32: + case EXP_CONSTANT_I16: + case EXP_CONSTANT_I08: + case EXP_CONSTANT_STR: + case EXP_CONSTANT_U08: + case EXP_CONSTANT_FLT: + case EXP_CONSTANT_BOOL: + case EXP_EQUAL: { + break; + } + case EXP_STRUCT: { + make_enc_struct_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_FFOR_U32: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_FFOR_U16: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_FFOR_U32: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_FFOR_U16: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I16_FFOR_U16: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_FFOR_U32: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I16_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I08_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_FFOR_U16: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_FLT_FFOR_U16: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_FLT_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_U08: + case EXP_DICT_I64_U16: + case EXP_DICT_I64_U32: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_U08: + case EXP_DICT_I32_U16: + case EXP_DICT_I32_U32: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I16_U08: + case EXP_DICT_I16_U16: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I08_U08: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_U08_U08: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_FLT_U08: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_U08: + case EXP_DICT_DBL_U16: + case EXP_DICT_DBL_U32: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_U08: + case EXP_DICT_STR_U16: + case EXP_DICT_STR_U32: { + make_enc_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_ALP_DBL: { + make_enc_alp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_ALP_FLT: { + make_enc_alp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_GALP_FLT: { + make_enc_galp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_GALP_DBL: { + make_enc_galp_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_ALP_RD_DBL: { + make_enc_alp_rd_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_ALP_RD_FLT: { + make_enc_alp_rd_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST: { + make_fsst_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12: { + make_fsst_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_FFOR_U32: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_FFOR_U16: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_FFOR_U08: { + make_enc_dict_ffor_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_U32: { + make_enc_fsst_dict_ffor_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_U16: { + make_enc_fsst_dict_ffor_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_U08: { + make_enc_fsst_dict_ffor_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + + case EXP_RLE_DBL_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_FLT_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I64_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I32_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I16_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I08_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_U08_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_STR_U16: { + make_enc_rle_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DELTA: { + make_fsst_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DELTA: { + make_fsst_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DELTA_I64: { + make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DELTA_I32: { + make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DELTA_I16: { + make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DELTA_I08: { + make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DELTA_U08: { + make_enc_delta_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_SLPATCH_I64: { + make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_SLPATCH_I32: { + make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_SLPATCH_I16: { + make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_SLPATCH_I08: { + make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FFOR_SLPATCH_U08: { + make_enc_ffor_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_FFOR_SLPATCH_U16: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_FFOR_SLPATCH_U32: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_FFOR_SLPATCH_U32: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_FFOR_SLPATCH_U16: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I32_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_FFOR_SLPATCH_U16: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_FFOR_SLPATCH_U32: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_FFOR_SLPATCH_U16: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_STR_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I16_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I08_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I16_FFOR_SLPATCH_U16: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_I64_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_FLT_FFOR_SLPATCH_U08: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_FLT_FFOR_SLPATCH_U16: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_DICT_DBL_FFOR_SLPATCH_U32: { + make_enc_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_SLPATCH_U32: { + make_enc_fsst_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_SLPATCH_U16: { + make_enc_fsst_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_FFOR_SLPATCH_U08: { + make_enc_fsst_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U32: { + make_enc_fsst_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U16: { + make_enc_fsst_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_SLPATCH_U08: { + make_enc_fsst_dict_ffor_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_NULL_DBL: { + make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_NULL_FLT: { + make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_NULL_I16: { + make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_NULL_I32: { + make_enc_null_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I64_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I32_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I16_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_I08_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_U08_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_STR_SLPATCH_U16: { + make_enc_rle_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_DBL_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_RLE_FLT_SLPATCH_U16: { + make_enc_rle_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DICT_STR_U32: + case EXP_FSST_DICT_STR_U16: + case EXP_FSST_DICT_STR_U08: { + make_enc_fsst_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST_DELTA_SLPATCH: { + make_enc_fsst_delta_slpatch_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DELTA_SLPATCH: { + make_enc_fsst_delta_slpatch_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case WIZARD_DICTIONARY_ENCODE: { + FLS_UNREACHABLE() + } + case EXP_FSST12_DICT_STR_U32: + case EXP_FSST12_DICT_STR_U16: + case EXP_FSST12_DICT_STR_U08: { + make_enc_fsst_dict_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_U32: { + make_enc_fsst_dict_ffor_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_U16: { + make_enc_fsst_dict_ffor_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FSST12_DICT_STR_FFOR_U08: { + make_enc_fsst_dict_ffor_expr( + *physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_DBL: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_FLT: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_I08: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_U08: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_I16: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_I32: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_I64: { + make_enc_frequency_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_FREQUENCY_STR: { + make_enc_frequency_str_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_I08: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_U08: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_I16: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_I32: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_I64: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_DBL: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_FLT: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_CROSS_RLE_STR: { + make_enc_cross_rle_opr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case EXP_VALIDITY_MASK: { + make_enc_validitymask_expr(*physical_expr, physical_rowgroup, column_descriptor, state); + break; + } + case INVALID: + default: + throw_not_supported_exception(operator_token); + FLS_UNREACHABLE(); + } + } + + return physical_expr; +} + +} // namespace fastlanes diff --git a/src/expression/null_operator.cpp b/src/expression/null_operator.cpp index 9060db53..55773c0e 100644 --- a/src/expression/null_operator.cpp +++ b/src/expression/null_operator.cpp @@ -105,9 +105,9 @@ void dec_null_opr::Materialize(n_t vec_idx, TypedCol& typed_col) { auto* exc_pos_arr = reinterpret_cast(vals_position_segment.data); auto n_exceptions = *reinterpret_cast(n_vals_segment.data); - FLS_ASSERT_CORRECT_POS(n_exceptions) + FLS_ASSERT_LE(n_exceptions, CFG::VEC_SZ) - for (auto val_idx {0}; val_idx < n_exceptions; ++val_idx) { + for (n_t val_idx {0}; val_idx < n_exceptions; ++val_idx) { auto next_pos = exc_pos_arr[val_idx]; auto val = exc_arr[val_idx]; materialized_data_p[next_pos] = val; diff --git a/src/expression/physical_expression.cpp b/src/expression/physical_expression.cpp index 7295e90e..78f63dfb 100644 --- a/src/expression/physical_expression.cpp +++ b/src/expression/physical_expression.cpp @@ -28,7 +28,6 @@ #include "fls/expression/transpose_operator.hpp" #include "fls/expression/validitymask_operator.hpp" #include "fls/reader/segment.hpp" -#include "fls/std/variant.hpp" #include "fls/std/vector.hpp" #include #include @@ -250,7 +249,7 @@ PhysicalExpr::PhysicalExpr() void PhysicalExpr::PointTo(n_t vec_idx) const { for (const auto& opr : operators) { - visit(point_to_visitor {vec_idx}, opr); + visit_physical(point_to_visitor {vec_idx}, opr); } } @@ -400,7 +399,7 @@ void PhysicalExpr::Flush(Buf& buf, ColumnDescriptorT& column_descriptor, uint8_t vector> segments; for (const auto& op : operators) { - visit(flush_segments_visitor {segments, buf, column_descriptor, helper_buffer}, op); + visit_enc(flush_segments_visitor {segments, buf, column_descriptor, helper_buffer}, op); } n_t current_offset = column_descriptor.column_offset; @@ -480,7 +479,7 @@ struct extract_segments_visitor { void operator()(const sp& opr) { for (const auto& op : opr->internal_exprs) { for (const auto& child_operator : op->operators) { - visit(extract_segments_visitor {segments}, child_operator); + visit_enc(extract_segments_visitor {segments}, child_operator); } } } @@ -553,7 +552,7 @@ n_t ScaleDownTheSize(n_t segment_size, n_t sample_size, n_t n_vecs) { n_t PhysicalExpr::Size(n_t sample_size, n_t n_vecs) const { vector> segments; for (const auto& op : operators) { - visit(extract_segments_visitor {segments}, op); + visit_enc(extract_segments_visitor {segments}, op); } n_t ttl_size {0}; @@ -686,7 +685,7 @@ struct finalize_operators_visitor { void PhysicalExpr::Finalize() const { for (const auto& op : operators) { - visit(finalize_operators_visitor {}, op); + visit_enc(finalize_operators_visitor {}, op); } } } // namespace fastlanes diff --git a/src/expression/rle_expression.cpp b/src/expression/rle_expression.cpp index a98c00a9..7e57e7d4 100644 --- a/src/expression/rle_expression.cpp +++ b/src/expression/rle_expression.cpp @@ -17,6 +17,8 @@ #include "fls/std/vector.hpp" #include "fls/table/rowgroup.hpp" #include "fls_gen/untranspose/untranspose.hpp" +#include // for std::max +#include // for size_t #include #include #include // for std::monostate @@ -132,7 +134,7 @@ struct RLEExprVisitor { idxs = opr->idxs; } void operator()(const sp& expr) { - visit(RLEExprVisitor {idxs}, expr->operators[0]); + visit_dec(RLEExprVisitor {idxs}, expr->operators[0]); } void operator()(std::monostate& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); @@ -149,7 +151,7 @@ dec_rle_map_opr::dec_rle_map_opr(PhysicalExpr& physical_ex : rle_vals_segment_view(column_view.GetSegment( static_cast((*column_view.column_descriptor.encoding_rpn() ->operand_tokens())[static_cast(state.cur_operand)]))) { - visit(RLEExprVisitor {idxs}, physical_expr.operators.back()); + visit_dec(RLEExprVisitor {idxs}, physical_expr.operators.back()); state.cur_operand -= 1; } @@ -165,7 +167,7 @@ void dec_rle_map_opr::Decode(const n_t vec_idx, vector auto* rle_vals = reinterpret_cast(rle_vals_segment_view.data); - for (auto val_idx {0}; val_idx < CFG::VEC_SZ; val_idx++) { + for (n_t val_idx {0}; val_idx < CFG::VEC_SZ; val_idx++) { temporary_tranposed_arr[val_idx] = rle_vals[idxs[val_idx]]; } @@ -184,7 +186,7 @@ dec_rle_map_opr::dec_rle_map_opr(PhysicalExpr& physical , rle_offset_segment_view(column_view.GetSegment( static_cast((*column_view.column_descriptor.encoding_rpn() ->operand_tokens())[static_cast(state.cur_operand - 0)]))) { - visit(RLEExprVisitor {idxs}, physical_expr.operators.back()); + visit_dec(RLEExprVisitor {idxs}, physical_expr.operators.back()); state.cur_operand -= 2; } @@ -213,7 +215,9 @@ void dec_rle_map_opr::Decode(n_t vec_idx, length_pointer[val_idx] = next_offset - cur_ofs; if (byte_arr_vec.capacity() - byte_arr_vec.size() < CFG::String::max_bytes_per_string) { - byte_arr_vec.reserve(byte_arr_vec.size() + 1024 * CFG::String::max_bytes_per_string); + byte_arr_vec.reserve( + std::max(byte_arr_vec.capacity() * 2, + byte_arr_vec.size() + static_cast(CFG::String::max_bytes_per_string))); } byte_arr_vec.insert(byte_arr_vec.end(), bytes + cur_ofs, bytes + next_offset); } diff --git a/src/expression/transpose_operator.cpp b/src/expression/transpose_operator.cpp deleted file mode 100644 index 2915d12e..00000000 --- a/src/expression/transpose_operator.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// ──────────────────────────────────────────────────────── -// | FastLanes | -// ──────────────────────────────────────────────────────── -// src/expression/transpose_operator.cpp -// ──────────────────────────────────────────────────────── -#include "fls/expression/transpose_operator.hpp" -#include "fls/cfg/cfg.hpp" -#include "fls/common/alias.hpp" -#include "fls/common/assert.hpp" -#include "fls/common/common.hpp" -#include "fls/expression/data_type.hpp" -#include "fls/expression/encoding_operator.hpp" -#include "fls/expression/fsst12_expression.hpp" -#include "fls/expression/fsst_expression.hpp" -#include "fls/expression/interpreter.hpp" -#include "fls/expression/physical_expression.hpp" -#include "fls/expression/rle_expression.hpp" -#include "fls/expression/rsum_operator.hpp" -#include "fls/reader/segment.hpp" -#include "fls/std/variant.hpp" -#include "fls/table/rowgroup.hpp" -#include "fls_gen/transpose/transpose.hpp" -#include "fls_gen/untranspose/untranspose.hpp" -#include - -namespace fastlanes { -/*--------------------------------------------------------------------------------------------------------------------*\ - * enc transpose opr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -enc_transpose_opr::enc_transpose_opr(const PhysicalExpr& expr, - const col_pt& col, - ColumnDescriptorT& column_descriptor, - InterpreterState& state) { - - visit(overloaded { - [&](const sp>& opr) { - data = opr->data; - opr->segment->MakeTemporary(); - }, - [&](const sp>& opr) { data = opr->data; }, - [&](const sp& opr) { - if constexpr (std::is_same_v) { - data = opr->fsst_encoded_offset_arr + 1; - opr->fsst_offset_segment->MakeTemporary(); - column_descriptor.encoding_rpn->operand_tokens.pop_back(); - state.cur_operand -= 1; - } else { - FLS_UNREACHABLE(); - } - }, - [&](const sp& opr) { - if constexpr (std::is_same_v) { - data = opr->fsst12_encoded_offset_arr + 1; - opr->fsst12_offset_segment->MakeTemporary(); - column_descriptor.encoding_rpn->operand_tokens.pop_back(); - state.cur_operand -= 1; - } else { - FLS_UNREACHABLE(); - } - }, - [&](const sp>& opr) { data = opr->index_arr; }, - [&](const sp>& opr) { data = opr->rle_idxs; }, - [&](std::monostate&) { FLS_UNREACHABLE(); }, - [&](auto& arg) { FLS_UNREACHABLE_WITH_TYPE(arg); }, - }, - expr.operators[state.cur_operator++]); -} - -template -void enc_transpose_opr::Transpose() { - ::generated::transpose::fallback::scalar::transpose_i(data, transposed_data); -} - -template struct enc_transpose_opr; -template struct enc_transpose_opr; -template struct enc_transpose_opr; -template struct enc_transpose_opr; -template struct enc_transpose_opr; -template struct enc_transpose_opr; -template struct enc_transpose_opr; -template struct enc_transpose_opr; -/*--------------------------------------------------------------------------------------------------------------------*\ - * dec_transpose_opr -\*--------------------------------------------------------------------------------------------------------------------*/ -template -struct TransposeExprVisitor { - explicit TransposeExprVisitor(dec_transpose_opr& opr) - : trapose_opr(opr) { - } - - void operator()(const sp>& opr) { - trapose_opr.transposed_data = opr->idxs; - FLS_ASSERT_NOT_NULL_POINTER(trapose_opr.transposed_data) - } - void operator()(std::monostate& arg) { - FLS_UNREACHABLE_WITH_TYPE(arg); - } - void operator()(const auto& arg) { - FLS_UNREACHABLE_WITH_TYPE(arg); - } - - dec_transpose_opr& trapose_opr; -}; - -template -dec_transpose_opr::dec_transpose_opr(PhysicalExpr& physical_expr, - const ColumnView& column_view, - InterpreterState& state) - : transposed_data(nullptr) { - - visit(TransposeExprVisitor {*this}, physical_expr.operators.back()); -} - -template -void dec_transpose_opr::Materialize(n_t vec_idx, TypedCol& typed_col) { - typed_col.data.resize(typed_col.data.size() + CFG::VEC_SZ); - PT* untrasposed_data_p = typed_col.data.data() + (CFG::VEC_SZ * vec_idx); - generated::untranspose::fallback::scalar::untranspose_i(transposed_data, untrasposed_data_p); -} - -template struct dec_transpose_opr; -template struct dec_transpose_opr; -template struct dec_transpose_opr; -template struct dec_transpose_opr; -template struct dec_transpose_opr; -template struct dec_transpose_opr; -template struct dec_transpose_opr; -template struct dec_transpose_opr; -} // namespace fastlanes diff --git a/src/include/alp/decoder.hpp b/src/include/alp/decoder.hpp index 0d0d5b1f..b0104a21 100644 --- a/src/include/alp/decoder.hpp +++ b/src/include/alp/decoder.hpp @@ -9,10 +9,11 @@ #include "alp/common.hpp" #include "alp/config.hpp" #include "alp/state.hpp" +#include "fls/compiler.hpp" #include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion" +FLS_DIAG_PUSH +FLS_DIAG_IGNORE_INT_FLOAT_CONV namespace alp { @@ -113,7 +114,8 @@ struct decoder { //! Scalar decoding a single value with ALP static inline PT decode_value(const ST encoded_value, const uint8_t factor, const uint8_t exponent) { - const PT decoded_value = encoded_value * Constants::FACT_ARR[factor] * Constants::FRAC_ARR[exponent]; + const PT decoded_value = + static_cast(encoded_value) * Constants::FACT_ARR[factor] * Constants::FRAC_ARR[exponent]; return decoded_value; } @@ -135,6 +137,6 @@ struct decoder { } // namespace alp -#pragma GCC diagnostic pop +FLS_DIAG_POP #endif // ALP_DECODER_HPP diff --git a/src/include/alp/rd.hpp b/src/include/alp/rd.hpp index e3181b56..00208045 100644 --- a/src/include/alp/rd.hpp +++ b/src/include/alp/rd.hpp @@ -10,12 +10,13 @@ #include "alp/constants.hpp" #include "alp/encoder.hpp" #include "alp/sampler.hpp" +#include "fls/compiler.hpp" #include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#pragma GCC diagnostic ignored "-Wfloat-conversion" -#pragma GCC diagnostic ignored "-Wimplicit-int-conversion" +FLS_DIAG_PUSH +FLS_DIAG_IGNORE_SIGN_CONV +FLS_DIAG_IGNORE_FLOAT_CONV +FLS_DIAG_IGNORE_INT_CONV namespace alp { @@ -188,6 +189,6 @@ struct rd_encoder { } // namespace alp -#pragma GCC diagnostic pop +FLS_DIAG_POP #endif // ALP_RD_HPP diff --git a/src/include/fls/common/decimal.hpp b/src/include/fls/common/decimal.hpp index 89a07398..da8e0ee9 100644 --- a/src/include/fls/common/decimal.hpp +++ b/src/include/fls/common/decimal.hpp @@ -6,13 +6,14 @@ #ifndef FLS_COMMON_DECIMAL_HPP #define FLS_COMMON_DECIMAL_HPP +#include "fls/api/api.hpp" #include "fls/common/common.hpp" #include "fls/footer/decimal_type_generated.h" namespace fastlanes { -int64_t make_decimal(const std::string& value, n_t scale); -up make_decimal_t(const std::string& value); +FLS_API int64_t make_decimal(const std::string& value, n_t scale); +FLS_API up make_decimal_t(const std::string& value); } // namespace fastlanes diff --git a/src/include/fls/common/double.hpp b/src/include/fls/common/double.hpp index 235122e5..5d953e6d 100644 --- a/src/include/fls/common/double.hpp +++ b/src/include/fls/common/double.hpp @@ -6,10 +6,11 @@ #ifndef FLS_COMMON_DOUBLE_HPP #define FLS_COMMON_DOUBLE_HPP +#include "fls/api/api.hpp" #include "fls/common/common.hpp" namespace fastlanes { -class Double { +class FLS_API Double { public: static bool is_safely_castable_to_int64(dbl_pt value); }; diff --git a/src/include/fls/common/status.hpp b/src/include/fls/common/status.hpp index 14e1e706..e7b65474 100644 --- a/src/include/fls/common/status.hpp +++ b/src/include/fls/common/status.hpp @@ -6,11 +6,12 @@ #ifndef FOR_NOW_ERROR_HPP #define FOR_NOW_ERROR_HPP +#include "fls/api/api.hpp" #include "fls/std/string.hpp" namespace fastlanes { -class Status { +class FLS_API Status { public: enum class ErrorCode { Ok, diff --git a/src/include/fls/compiler.hpp b/src/include/fls/compiler.hpp new file mode 100644 index 00000000..1fd9fac5 --- /dev/null +++ b/src/include/fls/compiler.hpp @@ -0,0 +1,105 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// src/include/fls/compiler.hpp +// ──────────────────────────────────────────────────────── +// Compiler-portability macros for Clang, GCC, and MSVC. +// ──────────────────────────────────────────────────────── +#ifndef FLS_COMPILER_HPP +#define FLS_COMPILER_HPP + +#include + +// ── Vectorize-loop pragmas ────────────────────────────── +// Clang's auto-vectorizer hint. MSVC has no direct equivalent; +// its auto-vectorizer runs unconditionally at /O2. +#if defined(__clang__) +#define FLS_PRAGMA_VECTORIZE _Pragma("clang loop vectorize(enable)") +#elif defined(__GNUC__) +#define FLS_PRAGMA_VECTORIZE _Pragma("GCC ivdep") +#else +#define FLS_PRAGMA_VECTORIZE +#endif + +// Clang vectorize-width hint (e.g. FLS_PRAGMA_VECTORIZE_WIDTH(64)). +#if defined(__clang__) +#define FLS_PRAGMA_VECTORIZE_WIDTH_IMPL(s) _Pragma(#s) +#define FLS_PRAGMA_VECTORIZE_WIDTH(n) FLS_PRAGMA_VECTORIZE_WIDTH_IMPL(clang loop vectorize_width(n)) +#else +#define FLS_PRAGMA_VECTORIZE_WIDTH(n) +#endif + +// ── MSVC compat for __restrict__ and __builtin_ctzl ───── +#if defined(_MSC_VER) && !defined(__clang__) +#include +#ifndef __restrict__ +#define __restrict__ +#endif +#ifndef __BYTE_ORDER__ +#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +#define __ORDER_LITTLE_ENDIAN__ 2 +#endif +static __forceinline int __builtin_ctzl(unsigned long long x) { + unsigned long ret; + _BitScanForward64(&ret, x); + return (int)ret; +} +#elif defined(_MSC_VER) && defined(__clang__) +#include +#endif + +// ── Count Leading Zeros ───────────────────────────────── +#if defined(_MSC_VER) +static inline int fls_clzll(uint64_t x) { + unsigned long idx; + _BitScanReverse64(&idx, x); + return 63 - static_cast(idx); +} +static inline int fls_clz(uint32_t x) { + unsigned long idx; + _BitScanReverse(&idx, x); + return 31 - static_cast(idx); +} +#else +static inline int fls_clzll(uint64_t x) { + return __builtin_clzll(x); +} +static inline int fls_clz(uint32_t x) { + return __builtin_clz(x); +} +#endif + +// ── Diagnostic push / pop / ignore ────────────────────── +// Check __clang__ before _MSC_VER because clang-cl defines both, +// but uses clang-style diagnostics, not MSVC warning numbers. +#if defined(__clang__) +#define FLS_DIAG_PUSH _Pragma("clang diagnostic push") +#define FLS_DIAG_POP _Pragma("clang diagnostic pop") +#define FLS_DIAG_IGNORE_SIGN_CONV _Pragma("clang diagnostic ignored \"-Wsign-conversion\"") +#define FLS_DIAG_IGNORE_FLOAT_CONV _Pragma("clang diagnostic ignored \"-Wfloat-conversion\"") +#define FLS_DIAG_IGNORE_CONVERSION _Pragma("clang diagnostic ignored \"-Wconversion\"") +#define FLS_DIAG_IGNORE_SHORTEN_64_32 _Pragma("clang diagnostic ignored \"-Wshorten-64-to-32\"") +#define FLS_DIAG_IGNORE_INT_FLOAT_CONV _Pragma("clang diagnostic ignored \"-Wimplicit-int-float-conversion\"") +#define FLS_DIAG_IGNORE_INT_CONV _Pragma("clang diagnostic ignored \"-Wimplicit-int-conversion\"") +#elif defined(_MSC_VER) +#define FLS_DIAG_PUSH __pragma(warning(push)) +#define FLS_DIAG_POP __pragma(warning(pop)) +#define FLS_DIAG_IGNORE_SIGN_CONV __pragma(warning(disable : 4245 4365)) +#define FLS_DIAG_IGNORE_FLOAT_CONV __pragma(warning(disable : 4244)) +#define FLS_DIAG_IGNORE_CONVERSION __pragma(warning(disable : 4244 4267)) +#define FLS_DIAG_IGNORE_SHORTEN_64_32 +#define FLS_DIAG_IGNORE_INT_FLOAT_CONV __pragma(warning(disable : 4244)) +#define FLS_DIAG_IGNORE_INT_CONV __pragma(warning(disable : 4244 4267)) +#elif defined(__GNUC__) +#define FLS_DIAG_PUSH _Pragma("GCC diagnostic push") +#define FLS_DIAG_POP _Pragma("GCC diagnostic pop") +#define FLS_DIAG_IGNORE_SIGN_CONV _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") +#define FLS_DIAG_IGNORE_FLOAT_CONV _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") +#define FLS_DIAG_IGNORE_CONVERSION _Pragma("GCC diagnostic ignored \"-Wconversion\"") +#define FLS_DIAG_IGNORE_SHORTEN_64_32 +#define FLS_DIAG_IGNORE_INT_FLOAT_CONV \ + _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") _Pragma("GCC diagnostic ignored \"-Wconversion\"") +#define FLS_DIAG_IGNORE_INT_CONV _Pragma("GCC diagnostic ignored \"-Wconversion\"") +#endif + +#endif // FLS_COMPILER_HPP diff --git a/src/include/fls/connection.hpp b/src/include/fls/connection.hpp index f0e37424..88ebcdcf 100644 --- a/src/include/fls/connection.hpp +++ b/src/include/fls/connection.hpp @@ -28,7 +28,7 @@ class Dir; /*--------------------------------------------------------------------------------------------------------------------*\ * Config \*--------------------------------------------------------------------------------------------------------------------*/ -class Config { +class FLS_API Config { public: Config(); @@ -62,6 +62,11 @@ class FLS_API Connection { Connection(); explicit Connection(const Config& config); + Connection(const Connection&) = delete; + Connection& operator=(const Connection&) = delete; + Connection(Connection&&) = default; + Connection& operator=(Connection&&) = default; + public: /// READ CSV Connection& read_csv(const path& dir_path); diff --git a/src/include/fls/cor/lyt/buf.hpp b/src/include/fls/cor/lyt/buf.hpp index 7c22920f..a36f9841 100644 --- a/src/include/fls/cor/lyt/buf.hpp +++ b/src/include/fls/cor/lyt/buf.hpp @@ -6,11 +6,12 @@ #ifndef FLS_COR_LYT_BUF_HPP #define FLS_COR_LYT_BUF_HPP +#include "fls/api/api.hpp" #include "fls/common/common.hpp" #include "fls/std/span.hpp" namespace fastlanes { -class Buf { +class FLS_API Buf { public: // fixed size buffer; explicit Buf(); diff --git a/src/include/fls/cor/prm/fsst/fsst.h b/src/include/fls/cor/prm/fsst/fsst.h index 7b85d603..d027091f 100644 --- a/src/include/fls/cor/prm/fsst/fsst.h +++ b/src/include/fls/cor/prm/fsst/fsst.h @@ -62,15 +62,7 @@ #define FSST_INCLUDED_H #ifdef _MSC_VER -#define __restrict__ -#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ -#define __ORDER_LITTLE_ENDIAN__ 2 -#include -static inline int __builtin_ctzl(unsigned long long x) { - unsigned long ret; - _BitScanForward64(&ret, x); - return (int)ret; -} +#include "fls/compiler.hpp" #endif #ifdef __cplusplus diff --git a/src/include/fls/cor/prm/fsst/libfsst.hpp b/src/include/fls/cor/prm/fsst/libfsst.hpp index 25cd5793..984b4817 100644 --- a/src/include/fls/cor/prm/fsst/libfsst.hpp +++ b/src/include/fls/cor/prm/fsst/libfsst.hpp @@ -7,7 +7,8 @@ #define FLS_COR_PRM_FSST_LIBFSST_HPP // NOLINTBEGIN -#pragma clang diagnostic ignored "-Wconversion" +#include "fls/compiler.hpp" +FLS_DIAG_IGNORE_CONVERSION // this software is distributed under the MIT License (http://www.opensource.org/licenses/MIT): // diff --git a/src/include/fls/cor/prm/fsst12/fsst12.h b/src/include/fls/cor/prm/fsst12/fsst12.h index d7a5e87f..5aee8179 100644 --- a/src/include/fls/cor/prm/fsst12/fsst12.h +++ b/src/include/fls/cor/prm/fsst12/fsst12.h @@ -62,6 +62,10 @@ #ifndef FSST12_INCLUDED_H #define FSST12_INCLUDED_H +#ifdef _MSC_VER +#include "fls/compiler.hpp" +#endif + #include "assert.h" using ulong = unsigned long; @@ -140,9 +144,9 @@ fsst12_decompress(fsst12_decoder_t* decoder, /* IN: use this dictionary for comp unsigned long size, /* IN: byte-length of output buffer. */ unsigned char* output /* OUT: memory buffer to put the decompressed string in. */ ) { - unsigned char* __restrict__ len = (unsigned char* __restrict__)decoder->len; - unsigned long* __restrict__ symbol = (unsigned long* __restrict__)decoder->symbol; - unsigned char* __restrict__ strOut = (unsigned char* __restrict__)output; + unsigned char* __restrict__ len = (unsigned char* __restrict__)decoder->len; + unsigned long long* __restrict__ symbol = (unsigned long long* __restrict__)decoder->symbol; + unsigned char* __restrict__ strOut = (unsigned char* __restrict__)output; unsigned long posOut = 0, posIn = 0; #define FSST12_UNALIGNED_STORE(dst, src) memcpy((unsigned long long*)(dst), &(src), sizeof(unsigned long long)) while (posIn + 3 <= lenIn) { diff --git a/src/include/fls/cor/prm/fsst12/libfsst12.hpp b/src/include/fls/cor/prm/fsst12/libfsst12.hpp index 8981dd3f..7975901f 100644 --- a/src/include/fls/cor/prm/fsst12/libfsst12.hpp +++ b/src/include/fls/cor/prm/fsst12/libfsst12.hpp @@ -7,8 +7,9 @@ #define FLS_COR_PRM_FSST12_LIBFSST12_HPP // NOLINTBEGIN -#pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#include "fls/compiler.hpp" +FLS_DIAG_IGNORE_CONVERSION +FLS_DIAG_IGNORE_SHORTEN_64_32 // this software is distributed under the MIT License (http://www.opensource.org/licenses/MIT): // diff --git a/src/include/fls/csv/csv-parser/parser.hpp b/src/include/fls/csv/csv-parser/parser.hpp index 8247973a..67b3358a 100644 --- a/src/include/fls/csv/csv-parser/parser.hpp +++ b/src/include/fls/csv/csv-parser/parser.hpp @@ -14,7 +14,8 @@ #ifndef ARIA_CSV_H #define ARIA_CSV_H -#pragma clang diagnostic ignored "-Wconversion" +#include "fls/compiler.hpp" +FLS_DIAG_IGNORE_CONVERSION #include #include diff --git a/src/include/fls/encoder/assert_eq.hpp b/src/include/fls/encoder/assert_eq.hpp index 9a0136a5..eb76514b 100644 --- a/src/include/fls/encoder/assert_eq.hpp +++ b/src/include/fls/encoder/assert_eq.hpp @@ -6,7 +6,8 @@ #ifndef FLS_ENCODER_ASSERT_EQ_HPP #define FLS_ENCODER_ASSERT_EQ_HPP -#pragma clang diagnostic ignored "-Wconversion" +#include "fls/compiler.hpp" +FLS_DIAG_IGNORE_CONVERSION #include "fls/common/string.hpp" #include "fls/cor/exp/exp.hpp" @@ -34,7 +35,7 @@ std::string save_as_future_case(const PT* values, idx_t start_idx) { ss << "\"" << val << "\", "; } } else if constexpr (std::is_same_v) { - for (auto i {0}; i < vec_sz(); ++i) { + for (n_t i {0}; i < vec_sz(); ++i) { auto val = values[start_idx + i]; ss << val << ", "; } @@ -72,7 +73,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { auto bsz_vec_up = Str::get_bsz_vec(untransposed, vec_sz()); auto normal_ofs_vec_up = Str::to_normal_offset(untransposed, vec_sz()); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { auto size = (*bsz_vec_up)[i]; auto ofs = (*normal_ofs_vec_up)[i]; @@ -100,7 +101,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { else if constexpr (std::is_same_v) { uint64_t untransposed[CFG::VEC_SZ] = {0}; untranspose_i(reinterpret_cast(vec->buf_arr[0].data()), untransposed); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { const bool equal = untransposed[i] == data_p[start_idx + i]; if (!equal) { string error_message = "the arrow array offset is: " + std::to_string(start_idx) + @@ -116,7 +117,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { else if constexpr (std::is_same_v) { dbl_pt untransposed[CFG::VEC_SZ] = {0}; untranspose_i(reinterpret_cast(vec->buf_arr[0].data()), untransposed); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { const bool equal = untransposed[i] == data_p[start_idx + i]; if (!equal) { string error_message = string("the arrow array offset is: ") + std::to_string(start_idx) + @@ -140,7 +141,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { uint64_t untransposed[1024]; vec->flatten_to(transposed); untranspose_i(transposed, untransposed); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { const bool equal = untransposed[i] == data_p[start_idx + i]; if (!equal) { string message = "the arrow array offset is: " + std::to_string(start_idx) + std::to_string(i) + @@ -156,7 +157,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { dbl_pt untransposed[1024]; vec->flatten_to(transposed); untranspose_i(transposed, untransposed); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { const bool equal = untransposed[i] == data_p[start_idx + i]; if (!equal) { string error_message = "value at position: " + std::to_string(start_idx) + std::to_string(i) + @@ -185,7 +186,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { Buf decompress_buf; uint8_t* out_p = decompress_buf.mutable_data(); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { /* IN: use this symbol table for compression. */ /* IN: byte-length of compressed string. */ /* IN: compressed string. */ @@ -230,7 +231,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { Buf decompress_buf; uint8_t* out_p = decompress_buf.mutable_data(); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { /* IN: use this symbol table for compression. */ /* IN: byte-length of compressed string. */ /* IN: compressed string. */ @@ -299,7 +300,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { idx_t untransposed[1024] = {0}; untranspose_i(idx_arr, untransposed); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { auto idx = untransposed[i]; const bool equal = dic_data[idx] == data_p[start_idx + i]; @@ -319,7 +320,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { idx_t untransposed[1024] = {0}; untranspose_i(idx_arr, untransposed); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { auto idx = untransposed[i]; const bool equal = dic_data[idx] == data_p[start_idx + i]; if (!equal) { @@ -371,7 +372,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { auto* dic_data = reinterpret_cast(vec->dict_up->data_buf.mutable_data()); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { auto idx = untransposed[i]; const bool equal = dic_data[idx] == data_p[start_idx + i]; if (!equal) { @@ -392,7 +393,7 @@ void assert_eq(Vec* vec, const PT* data_p, idx_t start_idx, ExpT exp) { auto* dic_data = reinterpret_cast(vec->dict_up->data_buf.mutable_data()); - for (auto i {0}; i < CFG::VEC_SZ; ++i) { + for (n_t i {0}; i < CFG::VEC_SZ; ++i) { auto idx = untransposed[i]; const bool equal = dic_data[idx] == data_p[start_idx + i]; if (!equal) { diff --git a/src/include/fls/encoder/encoder.hpp b/src/include/fls/encoder/encoder.hpp index d31884a9..3170a059 100644 --- a/src/include/fls/encoder/encoder.hpp +++ b/src/include/fls/encoder/encoder.hpp @@ -6,6 +6,7 @@ #ifndef FLS_ENCODER_ENCODER_HPP #define FLS_ENCODER_ENCODER_HPP +#include "fls/api/api.hpp" #include "fls/std/filesystem.hpp" namespace fastlanes { @@ -14,7 +15,7 @@ class Connection; class Buf; /*--------------------------------------------------------------------------------------------------------------------*/ -class Encoder { +class FLS_API Encoder { public: static void encode(const Connection& connection, const path& file_path); }; diff --git a/src/include/fls/expression/analyze_operator.hpp b/src/include/fls/expression/analyze_operator.hpp index f2dc3f06..622ebcb8 100644 --- a/src/include/fls/expression/analyze_operator.hpp +++ b/src/include/fls/expression/analyze_operator.hpp @@ -23,9 +23,9 @@ struct InterpreterState; * Histogram \*--------------------------------------------------------------------------------------------------------------------*/ template -class Histogram { +class AnalyzeHistogram { public: - Histogram() = default; // + AnalyzeHistogram() = default; // public: void Cal(PT* data); void Reset(); @@ -49,16 +49,16 @@ struct enc_analyze_opr { void PointTo(n_t vec_idx); public: - PT copy_of_data[CFG::VEC_SZ]; - PT* data; - PT base; - vec_idx_t n_exceptions; - alp::exp_p_t exception_pos_arr[CFG::VEC_SZ]; - PT exceptions[CFG::VEC_SZ]; - bw_t bw; - Histogram histogram; - NullMapView null_map_view; - bool is_rsum; + PT copy_of_data[CFG::VEC_SZ]; + PT* data; + PT base; + vec_idx_t n_exceptions; + alp::exp_p_t exception_pos_arr[CFG::VEC_SZ]; + PT exceptions[CFG::VEC_SZ]; + bw_t bw; + AnalyzeHistogram histogram; + NullMapView null_map_view; + bool is_rsum; }; } // namespace fastlanes diff --git a/src/include/fls/expression/data_type.hpp b/src/include/fls/expression/data_type.hpp index 276f32c6..e8b2be6e 100644 --- a/src/include/fls/expression/data_type.hpp +++ b/src/include/fls/expression/data_type.hpp @@ -6,6 +6,7 @@ #ifndef FLS_EXPRESSION_DATA_TYPE_HPP #define FLS_EXPRESSION_DATA_TYPE_HPP +#include "fls/api/api.hpp" #include "fls/footer/datatype_generated.h" #include #include @@ -15,17 +16,17 @@ namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*\ * ToSt : \*--------------------------------------------------------------------------------------------------------------------*/ -std::string ToStr(DataType type); +FLS_API std::string ToStr(DataType type); /*--------------------------------------------------------------------------------------------------------------------*\ * SizeOf : \*--------------------------------------------------------------------------------------------------------------------*/ -uint64_t SizeOf(DataType datatype); +FLS_API uint64_t SizeOf(DataType datatype); /*--------------------------------------------------------------------------------------------------------------------*\ * Overload << operator \*--------------------------------------------------------------------------------------------------------------------*/ -std::ostream& operator<<(std::ostream& os, DataType type); +FLS_API std::ostream& operator<<(std::ostream& os, DataType type); /*--------------------------------------------------------------------------------------------------------------------*\ * PT diff --git a/src/include/fls/expression/physical_expression.hpp b/src/include/fls/expression/physical_expression.hpp index 065256dc..d7cb6603 100644 --- a/src/include/fls/expression/physical_expression.hpp +++ b/src/include/fls/expression/physical_expression.hpp @@ -98,284 +98,384 @@ template struct enc_data_parallel_patch_opr; /*--------------------------------------------------------------------------------------------------------------------*/ -using physical_operator = variant>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // scan - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // predication - sp, - sp, - sp, - sp, - // decoding - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp, - sp, - // DICT - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // uncompressed - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp, - sp, - sp, // - sp, - // SCAN - sp>, - // FFOR - sp>, - sp>, - sp>, - sp>, - // UNFFOR - sp>, - sp>, - sp>, - sp>, - // DICT - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // FSST - sp, - sp, - sp, - sp, - // NULL - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // FREQUENCY - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp, - sp, - // RLE - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // FFOR - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // ANALYZE - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // TRANSPOSE - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // CROSS RLE - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // VALIDITY MASK - sp, - sp, - // RSUM - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - sp>, - // DICT FSST - sp, - sp>, - sp>, - sp>, - sp, - sp>, - sp>, - sp>, - // - // DATA Parallelize Patch - sp>, - sp> - // - >; +/*--------------------------------------------------------------------------------------------------------------------*\ + * Encoding sub-variant (~110 alternatives) +\*--------------------------------------------------------------------------------------------------------------------*/ +using enc_physical_operator = variant>, + sp>, + sp>, + sp>, + // SCAN + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // PREDICATION + sp, + sp, + sp, + sp, + // UNCOMPRESSED + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp, + sp, + sp, + // DICT + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // FFOR + sp>, + sp>, + sp>, + sp>, + // FSST + sp, + sp, + // NULL + sp>, + sp>, + sp>, + sp>, + // FREQUENCY + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp, + // RLE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // SLPATCH + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // ANALYZE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // TRANSPOSE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // CROSS RLE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // VALIDITY MASK + sp, + // RSUM + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // DICT FSST + sp, + sp, + // DATA PARALLELIZE PATCH + sp>, + sp>>; + +/*--------------------------------------------------------------------------------------------------------------------*\ + * Decoding sub-variant (~137 alternatives) +\*--------------------------------------------------------------------------------------------------------------------*/ +using dec_physical_operator = variant>, + sp>, + sp>, + sp>, + // UNCOMPRESSED + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp, + // CONSTANT + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp, + sp, + // SCAN + sp>, + // DICT + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // UNFFOR + sp>, + sp>, + sp>, + sp>, + // FSST + sp, + sp, + // NULL + sp>, + sp>, + sp>, + sp>, + // FREQUENCY + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp, + // RLE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // SLPATCH + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // TRANSPOSE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // CROSS RLE + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // VALIDITY MASK + sp, + // RSUM + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + sp>, + // DICT FSST + sp>, + sp>, + sp>, + sp>, + sp>, + sp>>; + +/*--------------------------------------------------------------------------------------------------------------------*\ + * physical_operator: outer wrapper. sp at outer level because it is + * created during encoding but accessed during decoding (recursive unwrapping). +\*--------------------------------------------------------------------------------------------------------------------*/ +using physical_operator = variant>; + +/*--------------------------------------------------------------------------------------------------------------------*\ + * Visit helpers — dispatch into the correct sub-variant, halving the dispatch table. +\*--------------------------------------------------------------------------------------------------------------------*/ +// Visit both enc and dec (for visitors that handle all operator types) +template +void visit_physical(Visitor&& vis, physical_operator& op) { + visit(overloaded { + [&](std::monostate& m) { vis(m); }, + [&](enc_physical_operator& enc) { visit(std::forward(vis), enc); }, + [&](dec_physical_operator& dec) { visit(std::forward(vis), dec); }, + [&](sp& pe) { vis(pe); }, + }, + op); +} +template +void visit_physical(Visitor&& vis, const physical_operator& op) { + visit(overloaded { + [&](const std::monostate& m) { vis(m); }, + [&](const enc_physical_operator& enc) { visit(std::forward(vis), enc); }, + [&](const dec_physical_operator& dec) { visit(std::forward(vis), dec); }, + [&](const sp& pe) { vis(pe); }, + }, + op); +} + +// Visit encoding sub-variant only (also handles sp) +template +void visit_enc(Visitor&& vis, physical_operator& op) { + visit(overloaded { + [&](enc_physical_operator& enc) { visit(std::forward(vis), enc); }, + [&](sp& pe) { vis(pe); }, + [&](auto&) { FLS_UNREACHABLE(); }, + }, + op); +} +template +void visit_enc(Visitor&& vis, const physical_operator& op) { + visit(overloaded { + [&](const enc_physical_operator& enc) { visit(std::forward(vis), enc); }, + [&](const sp& pe) { vis(pe); }, + [&](const auto&) { FLS_UNREACHABLE(); }, + }, + op); +} + +// Visit decoding sub-variant only (also handles sp) +template +void visit_dec(Visitor&& vis, physical_operator& op) { + visit(overloaded { + [&](dec_physical_operator& dec) { visit(std::forward(vis), dec); }, + [&](sp& pe) { vis(pe); }, + [&](auto&) { FLS_UNREACHABLE(); }, + }, + op); +} +template +void visit_dec(Visitor&& vis, const physical_operator& op) { + visit(overloaded { + [&](const dec_physical_operator& dec) { visit(std::forward(vis), dec); }, + [&](const sp& pe) { vis(pe); }, + [&](const auto&) { FLS_UNREACHABLE(); }, + }, + op); +} + +// Two-variant visit for materializer: unwraps physical_operator then visits with col_pt +template +void visit_dec(Visitor&& vis, const physical_operator& op, ColVariant& col) { + visit(overloaded { + [&](const dec_physical_operator& dec) { + visit([&](const auto& inner) { visit([&](auto& c) { vis(inner, c); }, col); }, dec); + }, + [&](const sp& pe) { visit([&](auto& c) { vis(pe, c); }, col); }, + [&](const auto&) { FLS_UNREACHABLE(); }, + }, + op); +} using physical_operators = vector; using physical_operands = vector; -class PhysicalExpr { +class FLS_API PhysicalExpr { public: physical_operators operators; physical_operands operands; @@ -384,6 +484,11 @@ class PhysicalExpr { ~PhysicalExpr(); PhysicalExpr(); + PhysicalExpr(const PhysicalExpr&) = delete; + PhysicalExpr& operator=(const PhysicalExpr&) = delete; + PhysicalExpr(PhysicalExpr&&) = default; + PhysicalExpr& operator=(PhysicalExpr&&) = default; + public: // void PointTo(n_t vec_idx) const; diff --git a/src/include/fls/expression/rpn.hpp b/src/include/fls/expression/rpn.hpp index 6b86376a..064b3023 100644 --- a/src/include/fls/expression/rpn.hpp +++ b/src/include/fls/expression/rpn.hpp @@ -6,6 +6,7 @@ #ifndef FLS_EXPRESSION_NEW_RPN_HPP #define FLS_EXPRESSION_NEW_RPN_HPP +#include "fls/api/api.hpp" #include "fls/footer/operator_token_generated.h" #include "fls/footer/rpn_generated.h" #include "fls/std/string.hpp" @@ -15,13 +16,13 @@ namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ struct InterpreterState; /*--------------------------------------------------------------------------------------------------------------------*/ -std::ostream& operator<<(std::ostream& os, const RPNT& rpn); +FLS_API std::ostream& operator<<(std::ostream& os, const RPNT& rpn); /*--------------------------------------------------------------------------------------------------------------------*/ /* Helper Functions */ /*--------------------------------------------------------------------------------------------------------------------*/ -string token_to_string(OperatorToken token); -bool is_1_to_1(OperatorToken token); +FLS_API string token_to_string(OperatorToken token); +FLS_API bool is_1_to_1(OperatorToken token); } // namespace fastlanes diff --git a/src/include/fls/expression/selection_ds.hpp b/src/include/fls/expression/selection_ds.hpp index e8b18460..ebe068f8 100644 --- a/src/include/fls/expression/selection_ds.hpp +++ b/src/include/fls/expression/selection_ds.hpp @@ -6,6 +6,7 @@ #ifndef FLS_EXPRESSION_SELECTION_DS_HPP #define FLS_EXPRESSION_SELECTION_DS_HPP +#include "fls/api/api.hpp" #include "fls/cfg/cfg.hpp" #include "fls/common/common.hpp" #include "fls/std/array.hpp" @@ -15,7 +16,7 @@ namespace fastlanes { class LogicalExpr; /*--------------------------------------------------------------------------------------------------------------------*/ -class SelectionDS { +class FLS_API SelectionDS { using bitmap_unit_t = uint64_t; public: diff --git a/src/include/fls/ffor_util.hpp b/src/include/fls/ffor_util.hpp index 9aba646c..61e825a7 100644 --- a/src/include/fls/ffor_util.hpp +++ b/src/include/fls/ffor_util.hpp @@ -6,6 +6,7 @@ #ifndef FLS_FFOR_UTIL_HPP #define FLS_FFOR_UTIL_HPP +#include "fls/compiler.hpp" #include #include @@ -23,13 +24,13 @@ uint8_t count_bits(PT max, PT min) { return 0; if constexpr (std::is_same_v) { - return static_cast(64 - __builtin_clzll(delta)); + return static_cast(64 - fls_clzll(delta)); } else if constexpr (std::is_same_v) { - return static_cast(32 - __builtin_clz(delta)); + return static_cast(32 - fls_clz(delta)); } else if constexpr (std::is_same_v) { - return static_cast(16 - (__builtin_clz(static_cast(delta)) - 16)); + return static_cast(16 - (fls_clz(static_cast(delta)) - 16)); } else if constexpr (std::is_same_v) { - return static_cast(8 - (__builtin_clz(static_cast(delta)) - 24)); + return static_cast(8 - (fls_clz(static_cast(delta)) - 24)); } return 0; } diff --git a/src/include/fls/footer/column_descriptor.hpp b/src/include/fls/footer/column_descriptor.hpp index 92e7b568..171e48ee 100644 --- a/src/include/fls/footer/column_descriptor.hpp +++ b/src/include/fls/footer/column_descriptor.hpp @@ -6,6 +6,7 @@ #ifndef FLS_FOOTER_COLUMN_DESCRIPTOR_HPP #define FLS_FOOTER_COLUMN_DESCRIPTOR_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" #include "fls/common/decimal.hpp" #include "fls/expression/data_type.hpp" @@ -29,7 +30,7 @@ using ColumnDescriptors = vector>; /*--------------------------------------------------------------------------------------------------------------------*\ * set index \*--------------------------------------------------------------------------------------------------------------------*/ -void set_index(vector>& column_descriptors); +FLS_API void set_index(vector>& column_descriptors); } // namespace fastlanes #endif // FLS_FOOTER_COLUMN_DESCRIPTOR_HPP diff --git a/src/include/fls/footer/rowgroup_descriptor.hpp b/src/include/fls/footer/rowgroup_descriptor.hpp index 8696a052..e27191f6 100644 --- a/src/include/fls/footer/rowgroup_descriptor.hpp +++ b/src/include/fls/footer/rowgroup_descriptor.hpp @@ -6,6 +6,7 @@ #ifndef FLS_FOOTER_ROWGROUP_DESCRIPTOR_HPP #define FLS_FOOTER_ROWGROUP_DESCRIPTOR_HPP +#include "fls/api/api.hpp" #include "fls/footer/column_descriptor.hpp" #include "fls/footer/rowgroup_descriptor_generated.h" #include "fls/std/filesystem.hpp" @@ -19,8 +20,8 @@ enum class DataType : uint8_t; using col_description_it = vector>::iterator; using const_col_description_it = vector>::const_iterator; -up make_rowgroup_descriptor(const Rowgroup& rowgroup); -up make_rowgroup_descriptor(const path& dir_path); +FLS_API up make_rowgroup_descriptor(const Rowgroup& rowgroup); +FLS_API up make_rowgroup_descriptor(const path& dir_path); } // namespace fastlanes diff --git a/src/include/fls/footer/table_descriptor.hpp b/src/include/fls/footer/table_descriptor.hpp index 59b932c4..82163391 100644 --- a/src/include/fls/footer/table_descriptor.hpp +++ b/src/include/fls/footer/table_descriptor.hpp @@ -6,6 +6,7 @@ #ifndef FLS_FOOTER_TABLE_DESCRIPTOR_HPP #define FLS_FOOTER_TABLE_DESCRIPTOR_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" // n_t, up #include "fls/footer/table_descriptor_generated.h" #include "fls/std/filesystem.hpp" // path @@ -18,7 +19,7 @@ namespace fastlanes { class Table; -class TableDescriptorHandle { +class FLS_API TableDescriptorHandle { public: TableDescriptorHandle() = default; @@ -81,7 +82,7 @@ class TableDescriptorHandle { │ By-pointer helpers (return up<...>) │ │ These heap-allocate the handle and return unique ownership (up<>). │ └──────────────────────────────────────────────────────────────────────────────*/ -up make_table_descriptor(const Table& table); +FLS_API up make_table_descriptor(const Table& table); inline up make_table_descriptor(const path& file_path, bool verify = true) { return std::make_unique(TableDescriptorHandle::FromFile(file_path, verify)); diff --git a/src/include/fls/json/fls_json.hpp b/src/include/fls/json/fls_json.hpp index faf163be..1841363f 100644 --- a/src/include/fls/json/fls_json.hpp +++ b/src/include/fls/json/fls_json.hpp @@ -6,6 +6,7 @@ #ifndef FLS_JSON_FLS_JSON_HPP #define FLS_JSON_FLS_JSON_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" #include "fls/json/nlohmann/json.hpp" #include "fls/std/filesystem.hpp" @@ -29,57 +30,57 @@ struct ExpressionResultT; /*--------------------------------------------------------------------------------------------------------------------*\ * TableDescriptorT \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const TableDescriptorT& table_descriptor); -void from_json(const nlohmann::json& j, TableDescriptorT& table_descriptor); +FLS_API void to_json(nlohmann::json& j, const TableDescriptorT& table_descriptor); +FLS_API void from_json(const nlohmann::json& j, TableDescriptorT& table_descriptor); /*--------------------------------------------------------------------------------------------------------------------*\ * RowgroupDescriptor \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const RowgroupDescriptorT& rowgroup_descriptor); -void from_json(const nlohmann::json& j, RowgroupDescriptorT& rowgroup_descriptor); +FLS_API void to_json(nlohmann::json& j, const RowgroupDescriptorT& rowgroup_descriptor); +FLS_API void from_json(const nlohmann::json& j, RowgroupDescriptorT& rowgroup_descriptor); /*--------------------------------------------------------------------------------------------------------------------*\ * ColumnDescriptor \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const ColumnDescriptorT& p); -void from_json(const nlohmann::json& j, ColumnDescriptorT& p); +FLS_API void to_json(nlohmann::json& j, const ColumnDescriptorT& p); +FLS_API void from_json(const nlohmann::json& j, ColumnDescriptorT& p); /*--------------------------------------------------------------------------------------------------------------------*\ * LogicalExpr \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const LogicalExpr& p); -void from_json(const nlohmann::json& j, LogicalExpr& p); +FLS_API void to_json(nlohmann::json& j, const LogicalExpr& p); +FLS_API void from_json(const nlohmann::json& j, LogicalExpr& p); /*--------------------------------------------------------------------------------------------------------------------*\ * NewRpn \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const RPNT& p); -void from_json(const nlohmann::json& j, RPNT& p); +FLS_API void to_json(nlohmann::json& j, const RPNT& p); +FLS_API void from_json(const nlohmann::json& j, RPNT& p); /*--------------------------------------------------------------------------------------------------------------------*\ * BinaryValue \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const BinaryValueT& p); -void from_json(const nlohmann::json& j, BinaryValueT& p); +FLS_API void to_json(nlohmann::json& j, const BinaryValueT& p); +FLS_API void from_json(const nlohmann::json& j, BinaryValueT& p); /*--------------------------------------------------------------------------------------------------------------------*\ * ExprSpace \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const ExprSpace& p); -void from_json(const nlohmann::json& j, ExprSpace& p); +FLS_API void to_json(nlohmann::json& j, const ExprSpace& p); +FLS_API void from_json(const nlohmann::json& j, ExprSpace& p); /*--------------------------------------------------------------------------------------------------------------------*\ * SegmentDescriptor \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const SegmentDescriptorT& p); -void from_json(const nlohmann::json& j, SegmentDescriptorT& p); +FLS_API void to_json(nlohmann::json& j, const SegmentDescriptorT& p); +FLS_API void from_json(const nlohmann::json& j, SegmentDescriptorT& p); /*--------------------------------------------------------------------------------------------------------------------*\ * ExpressionResult \*--------------------------------------------------------------------------------------------------------------------*/ -void to_json(nlohmann::json& j, const ExpressionResultT& p); -void from_json(const nlohmann::json& j, ExpressionResultT& p); +FLS_API void to_json(nlohmann::json& j, const ExpressionResultT& p); +FLS_API void from_json(const nlohmann::json& j, ExpressionResultT& p); /*--------------------------------------------------------------------------------------------------------------------*\ * JSON \*--------------------------------------------------------------------------------------------------------------------*/ -class JSON { +class FLS_API JSON { public: static n_t write(const Connection& connection, const path& file_path, TableDescriptorT& table_descriptor); }; diff --git a/src/include/fls/primitive/patch/patch.hpp b/src/include/fls/primitive/patch/patch.hpp index 4f720070..25acb041 100644 --- a/src/include/fls/primitive/patch/patch.hpp +++ b/src/include/fls/primitive/patch/patch.hpp @@ -6,13 +6,14 @@ #ifndef FLS_PRIMITIVE_PATCH_PATCH_HPP #define FLS_PRIMITIVE_PATCH_PATCH_HPP +#include "fls/api/api.hpp" #include "fls/common/common.hpp" namespace fastlanes { n_t calculate_bitpacked_vector_size(bw_t bw); template -class Patch { +class FLS_API Patch { public: static void data_parallelize(const PT* in_exc_arr, const uint16_t* in_pos_arr, diff --git a/src/include/fls/primitive/predicate/equal.hpp b/src/include/fls/primitive/predicate/equal.hpp index 46f72f30..d2169fdc 100644 --- a/src/include/fls/primitive/predicate/equal.hpp +++ b/src/include/fls/primitive/predicate/equal.hpp @@ -6,30 +6,40 @@ #ifndef FLS_PRIMITIVE_PREDICATE_EQUAL_HPP #define FLS_PRIMITIVE_PREDICATE_EQUAL_HPP +#include "fls/common/restrict.hpp" #include "fls/expression/data_type.hpp" namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ class SelectionDS; /*--------------------------------------------------------------------------------------------------------------------*/ + +// MSVC strips __restrict from explicit template instantiation mangling, +// so declarations must omit it. Clang-cl needs it to match definitions. +#if defined(_MSC_VER) && !defined(__clang__) +#define FLS_PREDICATE_RESTRICT +#else +#define FLS_PREDICATE_RESTRICT FLS_RESTRICT +#endif + template -void eq_vector_constant_func(const PT* __restrict array_pointer, PT value, SelectionDS& selection_ds); +void eq_vector_constant_func(const PT* FLS_PREDICATE_RESTRICT array_pointer, PT value, SelectionDS& selection_ds); template -void ge_tvec_tvec(const PT* __restrict array_pointer, const PT* value, SelectionDS& selection_ds); +void ge_tvec_tvec(const PT* FLS_PREDICATE_RESTRICT array_pointer, const PT* value, SelectionDS& selection_ds); template -void ge_tvec_cvec(const PT* __restrict array_pointer, const PT* value, SelectionDS& selection_ds); +void ge_tvec_cvec(const PT* FLS_PREDICATE_RESTRICT array_pointer, const PT* value, SelectionDS& selection_ds); template -void lessthan_func(const PT* __restrict array_pointer, PT value, SelectionDS& selection_ds); +void lessthan_func(const PT* FLS_PREDICATE_RESTRICT array_pointer, PT value, SelectionDS& selection_ds); void and_selection_ds_func(const SelectionDS& selection_ds_1, const SelectionDS& selection_ds_2, SelectionDS& selection_ds_3); template -using predicate_func_p = void (*)(const PT* __restrict left_vec, - const PT* __restrict right_vec, - SelectionDS& selection_ds); +using predicate_func_p = void (*)(const PT* FLS_PREDICATE_RESTRICT left_vec, + const PT* FLS_PREDICATE_RESTRICT right_vec, + SelectionDS& selection_ds); } // namespace fastlanes #endif // FLS_PRIMITIVE_PREDICATE_EQUAL_HPP diff --git a/src/include/fls/reader/column_view.hpp b/src/include/fls/reader/column_view.hpp index 004dcafd..eb435c9a 100644 --- a/src/include/fls/reader/column_view.hpp +++ b/src/include/fls/reader/column_view.hpp @@ -6,6 +6,7 @@ #ifndef FLS_READER_COLUMN_VIEW_HPP #define FLS_READER_COLUMN_VIEW_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" #include "fls/std/span.hpp" #include "fls/std/vector.hpp" @@ -19,7 +20,7 @@ class SegmentView; /*--------------------------------------------------------------------------------------------------------------------*\ * ColumnView \*--------------------------------------------------------------------------------------------------------------------*/ -class ColumnView { +class FLS_API ColumnView { public: explicit ColumnView(span column_span, const ColumnDescriptor& column_descriptor, diff --git a/src/include/fls/reader/csv_reader.hpp b/src/include/fls/reader/csv_reader.hpp index 72c41fc1..5e0a6d41 100644 --- a/src/include/fls/reader/csv_reader.hpp +++ b/src/include/fls/reader/csv_reader.hpp @@ -6,6 +6,7 @@ #ifndef FLS_READER_CSV_READER_HPP #define FLS_READER_CSV_READER_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" // for up, idx_t #include "fls/std/filesystem.hpp" @@ -19,7 +20,7 @@ class Connection; /*--------------------------------------------------------------------------------------------------------------------*\ * CsvReader \*--------------------------------------------------------------------------------------------------------------------*/ -class CsvReader { +class FLS_API CsvReader { public: static up Read(const path& dir_path, const Connection& connection); }; diff --git a/src/include/fls/reader/fls_rowgroup.hpp b/src/include/fls/reader/fls_rowgroup.hpp index f1322cd9..4d281ac7 100644 --- a/src/include/fls/reader/fls_rowgroup.hpp +++ b/src/include/fls/reader/fls_rowgroup.hpp @@ -6,6 +6,7 @@ #ifndef FLS_READER_FLS_ROWGROUP_HPP #define FLS_READER_FLS_ROWGROUP_HPP +#include "fls/api/api.hpp" #include "fls/std/span.hpp" #include "fls/std/vector.hpp" @@ -15,7 +16,7 @@ class RowgroupDescriptor; class ColumnView; /*--------------------------------------------------------------------------------------------------------------------*/ -class RowgroupView { +class FLS_API RowgroupView { public: explicit RowgroupView(span ptr, const RowgroupDescriptor& footer); diff --git a/src/include/fls/reader/json_reader.hpp b/src/include/fls/reader/json_reader.hpp index 4e17e340..bef29512 100644 --- a/src/include/fls/reader/json_reader.hpp +++ b/src/include/fls/reader/json_reader.hpp @@ -6,6 +6,7 @@ #ifndef FLS_READER_JSON_READER_HPP #define FLS_READER_JSON_READER_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" // for up, idx_t #include "fls/std/filesystem.hpp" @@ -19,7 +20,7 @@ class Connection; /*--------------------------------------------------------------------------------------------------------------------*\ * JsonReader \*--------------------------------------------------------------------------------------------------------------------*/ -class JsonReader { +class FLS_API JsonReader { public: static up
Read(const path& dir_path, const Connection& connection); }; diff --git a/src/include/fls/reader/reader.hpp b/src/include/fls/reader/reader.hpp index f8d0ccd2..5d372ecd 100644 --- a/src/include/fls/reader/reader.hpp +++ b/src/include/fls/reader/reader.hpp @@ -6,24 +6,31 @@ #ifndef FLS_READER_READER_HPP #define FLS_READER_READER_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" // for up, n_t #include "fls/cor/lyt/buf.hpp" // for Buf #include "fls/expression/physical_expression.hpp" // for PhysicalExpr #include "fls/reader/fls_rowgroup.hpp" -#include "fls/std/filesystem.hpp" // for path -#include "fls/std/vector.hpp" // for vector -#include "fls/table/chunk.hpp" // for Chunk +#include "fls/reader/rowgroup_view.hpp" // for RowgroupView (complete type needed for dllexport) +#include "fls/std/filesystem.hpp" // for path +#include "fls/std/vector.hpp" // for vector +#include "fls/table/chunk.hpp" // for Chunk namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ class Connection; -class RowgroupView; class Rowgroup; /*--------------------------------------------------------------------------------------------------------------------*/ -class Reader { +class FLS_API Reader { public: explicit Reader(const path& dir_path, Connection& fls); + ~Reader(); + Reader(const Reader&) = delete; + Reader& operator=(const Reader&) = delete; + Reader(Reader&&) noexcept; + Reader& operator=(Reader&&) noexcept; + public: vector>& get_chunk(n_t vec_idx); /// diff --git a/src/include/fls/reader/rowgroup_reader.hpp b/src/include/fls/reader/rowgroup_reader.hpp index aca706d0..95e5fbe7 100644 --- a/src/include/fls/reader/rowgroup_reader.hpp +++ b/src/include/fls/reader/rowgroup_reader.hpp @@ -6,24 +6,31 @@ #ifndef FLS_READER_ROWGROUP_READER_HPP #define FLS_READER_ROWGROUP_READER_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" // for up, n_t #include "fls/cor/lyt/buf.hpp" // for Buf #include "fls/expression/physical_expression.hpp" // for PhysicalExpr #include "fls/reader/rowgroup_reader.hpp" -#include "fls/std/filesystem.hpp" // for path -#include "fls/std/vector.hpp" // for vector -#include "fls/table/chunk.hpp" // for Chunk +#include "fls/reader/rowgroup_view.hpp" // for RowgroupView (complete type needed for dllexport) +#include "fls/std/filesystem.hpp" // for path +#include "fls/std/vector.hpp" // for vector +#include "fls/table/chunk.hpp" // for Chunk namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ class Connection; -class RowgroupView; class Rowgroup; /*--------------------------------------------------------------------------------------------------------------------*/ -class RowgroupReader { +class FLS_API RowgroupReader { public: explicit RowgroupReader(const path& file_path, const RowgroupDescriptor& rowgroup_descriptor, Connection& fls); + ~RowgroupReader(); + RowgroupReader(const RowgroupReader&) = delete; + RowgroupReader& operator=(const RowgroupReader&) = delete; + RowgroupReader(RowgroupReader&&) = delete; + RowgroupReader& operator=(RowgroupReader&&) = delete; + public: vector>& get_chunk(n_t vec_idx); /// diff --git a/src/include/fls/reader/rowgroup_view.hpp b/src/include/fls/reader/rowgroup_view.hpp index ea5ca5f0..69af12c2 100644 --- a/src/include/fls/reader/rowgroup_view.hpp +++ b/src/include/fls/reader/rowgroup_view.hpp @@ -6,19 +6,26 @@ #ifndef FLS_READER_ROWGROUP_VIEW_HPP #define FLS_READER_ROWGROUP_VIEW_HPP +#include "fls/api/api.hpp" +#include "fls/reader/column_view.hpp" #include "fls/std/span.hpp" #include "fls/std/vector.hpp" namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ struct RowgroupDescriptor; -class ColumnView; /*--------------------------------------------------------------------------------------------------------------------*/ -class RowgroupView { +class FLS_API RowgroupView { public: explicit RowgroupView(span ptr, const RowgroupDescriptor& footer); + ~RowgroupView(); + RowgroupView(const RowgroupView&) = delete; + RowgroupView& operator=(const RowgroupView&) = delete; + RowgroupView(RowgroupView&&) noexcept; + RowgroupView& operator=(RowgroupView&&) noexcept; + public: ColumnView& operator[](n_t col_idx); const ColumnView& operator[](n_t col_idx) const; diff --git a/src/include/fls/reader/segment.hpp b/src/include/fls/reader/segment.hpp index efd4e9e1..06f2a0b9 100644 --- a/src/include/fls/reader/segment.hpp +++ b/src/include/fls/reader/segment.hpp @@ -6,14 +6,15 @@ #ifndef FLS_READER_SEGMENT_HPP #define FLS_READER_SEGMENT_HPP +#include "fls/api/api.hpp" #include "fls/common/common.hpp" +#include "fls/cor/lyt/buf.hpp" #include "fls/std/span.hpp" #include "fls/std/variant.hpp" #include "fls/std/vector.hpp" namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ -class Buf; struct SegmentDescriptor; struct SegmentDescriptorT; @@ -40,14 +41,14 @@ class EntryPointView { using entry_point_view_t = variant, EntryPointView, EntryPointView>; -n_t get_offset(const entry_point_view_t& entry_point_view, n_t vex_idx); +FLS_API n_t get_offset(const entry_point_view_t& entry_point_view, n_t vex_idx); -n_t get_size(const entry_point_view_t& entry_point_view); +FLS_API n_t get_size(const entry_point_view_t& entry_point_view); /*--------------------------------------------------------------------------------------------------------------------*\ * SegmentView \*--------------------------------------------------------------------------------------------------------------------*/ -class SegmentView { +class FLS_API SegmentView { public: explicit SegmentView(entry_point_view_t entry_point_view, span data_span); @@ -65,15 +66,21 @@ class SegmentView { /*--------------------------------------------------------------------------------------------------------------------*\ * make_segment_view \*--------------------------------------------------------------------------------------------------------------------*/ -SegmentView make_segment_view(span column_span, const SegmentDescriptor& segment_descriptor); +FLS_API SegmentView make_segment_view(span column_span, const SegmentDescriptor& segment_descriptor); /*--------------------------------------------------------------------------------------------------------------------*\ * Segment \*--------------------------------------------------------------------------------------------------------------------*/ -class Segment { +class FLS_API Segment { public: explicit Segment(); + ~Segment(); + Segment(const Segment&) = delete; + Segment& operator=(const Segment&) = delete; + Segment(Segment&&) noexcept; + Segment& operator=(Segment&&) noexcept; + public: void Flush(const void* pointer, n_t size); // diff --git a/src/include/fls/reader/table_reader.hpp b/src/include/fls/reader/table_reader.hpp index 7ef0ae73..1d93521e 100644 --- a/src/include/fls/reader/table_reader.hpp +++ b/src/include/fls/reader/table_reader.hpp @@ -8,6 +8,7 @@ #include "fls/api/api.hpp" #include "fls/common/alias.hpp" +#include "fls/footer/table_descriptor.hpp" // for TableDescriptorHandle (complete type needed for dllexport) #include "fls/std/filesystem.hpp" #include "fls/std/string.hpp" @@ -15,13 +16,18 @@ namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ class Connection; class RowgroupReader; -class TableDescriptorHandle; class Table; /*--------------------------------------------------------------------------------------------------------------------*/ class FLS_API TableReader { public: explicit TableReader(const path& file_path, Connection& fls); + ~TableReader(); + TableReader(const TableReader&) = delete; + TableReader& operator=(const TableReader&) = delete; + TableReader(TableReader&&) = delete; + TableReader& operator=(TableReader&&) = delete; + public: up operator[](n_t rowgroup_idx) const; // diff --git a/src/include/fls/reader/table_view.hpp b/src/include/fls/reader/table_view.hpp index d15909a1..8ba86cec 100644 --- a/src/include/fls/reader/table_view.hpp +++ b/src/include/fls/reader/table_view.hpp @@ -3,23 +3,29 @@ // ──────────────────────────────────────────────────────── // src/include/fls/reader/table_view.hpp // ──────────────────────────────────────────────────────── -#ifndef FLS_READER_ROWGROUP_VIEW_HPP -#define FLS_READER_ROWGROUP_VIEW_HPP +#ifndef FLS_READER_TABLE_VIEW_HPP +#define FLS_READER_TABLE_VIEW_HPP +#include "fls/api/api.hpp" +#include "fls/reader/rowgroup_view.hpp" #include "fls/std/span.hpp" #include "fls/std/vector.hpp" namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ struct TableDescriptorT; -class ColumnView; -class RowgroupView; /*--------------------------------------------------------------------------------------------------------------------*/ -class TableView { +class FLS_API TableView { public: explicit TableView(span ptr, const TableDescriptorT& table_descriptor); + ~TableView(); + TableView(const TableView&) = delete; + TableView& operator=(const TableView&) = delete; + TableView(TableView&&) noexcept; + TableView& operator=(TableView&&) noexcept; + public: RowgroupView& operator[](n_t row_idx); const RowgroupView& operator[](n_t row_idx) const; @@ -30,4 +36,4 @@ class TableView { } // namespace fastlanes -#endif // FLS_READER_ROWGROUP_VIEW_HPP +#endif // FLS_READER_TABLE_VIEW_HPP diff --git a/src/include/fls/table/attribute.hpp b/src/include/fls/table/attribute.hpp index aed29296..362481c0 100644 --- a/src/include/fls/table/attribute.hpp +++ b/src/include/fls/table/attribute.hpp @@ -6,6 +6,7 @@ #ifndef FLS_TABLE_ATTRIBUTE_HPP #define FLS_TABLE_ATTRIBUTE_HPP +#include "fls/api/api.hpp" #include "fls/common/common.hpp" #include "fls/std/string.hpp" #include "fls/table/rowgroup.hpp" @@ -16,7 +17,7 @@ template class TypedCol; enum class DataType : uint8_t; /*--------------------------------------------------------------------------------------------------------------------*/ -class Attribute { +class FLS_API Attribute { public: Attribute() = delete; diff --git a/src/include/fls/table/chunk.hpp b/src/include/fls/table/chunk.hpp index a8e7e021..bb405b24 100644 --- a/src/include/fls/table/chunk.hpp +++ b/src/include/fls/table/chunk.hpp @@ -6,6 +6,7 @@ #ifndef FLS_TABLE_CHUNK_HPP #define FLS_TABLE_CHUNK_HPP +#include "fls/api/api.hpp" #include "fls/cfg/cfg.hpp" #include "fls/common/alias.hpp" #include "fls/expression/data_type.hpp" @@ -27,14 +28,14 @@ using ofs_span_t = span; using length_span_t = span; /*--------------------------------------------------------------------------------------------------------------------*/ -class BaseVector { +class FLS_API BaseVector { public: null_map_span_t null_map_span; bool should_be_stored {false}; }; /*--------------------------------------------------------------------------------------------------------------------*/ -class VariableSizeVector : public BaseVector { +class FLS_API VariableSizeVector : public BaseVector { public: ofs_span_t ofs_span; }; @@ -128,7 +129,14 @@ using fls_chunk = vector; /*--------------------------------------------------------------------------------------------------------------------*\ * list vector \*--------------------------------------------------------------------------------------------------------------------*/ -class ListVector : public VariableSizeVector { +class FLS_API ListVector : public VariableSizeVector { +public: + ListVector() = default; + ListVector(const ListVector&) = delete; + ListVector& operator=(const ListVector&) = delete; + ListVector(ListVector&&) = default; + ListVector& operator=(ListVector&&) = default; + public: fls_vec child; }; @@ -136,7 +144,14 @@ class ListVector : public VariableSizeVector { /*--------------------------------------------------------------------------------------------------------------------*\ * struct vector \*--------------------------------------------------------------------------------------------------------------------*/ -class StructVector : public BaseVector { +class FLS_API StructVector : public BaseVector { +public: + StructVector() = default; + StructVector(const StructVector&) = delete; + StructVector& operator=(const StructVector&) = delete; + StructVector(StructVector&&) = default; + StructVector& operator=(StructVector&&) = default; + public: fls_chunk table; }; diff --git a/src/include/fls/table/column.hpp b/src/include/fls/table/column.hpp index 3a8938ae..e01e0cc1 100644 --- a/src/include/fls/table/column.hpp +++ b/src/include/fls/table/column.hpp @@ -6,12 +6,13 @@ #ifndef FLS_TABLE_COLUMN_HPP #define FLS_TABLE_COLUMN_HPP +#include "fls/api/api.hpp" #include "fls/table/rowgroup.hpp" namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------------------------*/ -class Column { +class FLS_API Column { public: static bool is_good_for_ditionary_encoding(const col_pt& col); }; diff --git a/src/include/fls/table/rowgroup.hpp b/src/include/fls/table/rowgroup.hpp index bd0476b6..1f31e0b1 100644 --- a/src/include/fls/table/rowgroup.hpp +++ b/src/include/fls/table/rowgroup.hpp @@ -6,6 +6,7 @@ #ifndef FLS_TABLE_ROWGROUP_HPP #define FLS_TABLE_ROWGROUP_HPP +#include "fls/api/api.hpp" #include "fls/cfg/cfg.hpp" #include "fls/common/common.hpp" #include "fls/expression/data_type.hpp" @@ -29,12 +30,12 @@ using byte_arr_t = vector; using ofs_arr_t = vector; using length_arr_t = vector; -class BaseCol { +class FLS_API BaseCol { public: null_map_arr_t null_map_arr; }; -class VariableSizeCol : public BaseCol { +class FLS_API VariableSizeCol : public BaseCol { public: ofs_arr_t ofs_arr; length_arr_t length_arr; @@ -114,7 +115,7 @@ class TypedColumnView { /*--------------------------------------------------------------------------------------------------------------------*\ * NullMapView \*--------------------------------------------------------------------------------------------------------------------*/ -class NullMapView { +class FLS_API NullMapView { public: explicit NullMapView(const col_pt& column); @@ -136,7 +137,7 @@ constexpr n_t TypedColumnView::GetSizeOfOneVector() { /*--------------------------------------------------------------------------------------------------------------------*\ * FLSStringView \*--------------------------------------------------------------------------------------------------------------------*/ -class FlsStrColumnView { +class FLS_API FlsStrColumnView { public: explicit FlsStrColumnView(const col_pt& column); @@ -168,12 +169,19 @@ class FlsStrColumnView { using rowgroup_pt = vector; -class List : public VariableSizeCol { +class FLS_API List : public VariableSizeCol { +public: + List() = default; + List(const List&) = delete; + List& operator=(const List&) = delete; + List(List&&) = default; + List& operator=(List&&) = default; + public: col_pt child; }; -class FLSStrColumn : public VariableSizeCol { +class FLS_API FLSStrColumn : public VariableSizeCol { public: vector byte_arr; vector str_p_arr; @@ -185,12 +193,19 @@ class FLSStrColumn : public VariableSizeCol { vector fls_str_arr; }; -class Struct : public BaseCol { +class FLS_API Struct : public BaseCol { +public: + Struct() = default; + Struct(const Struct&) = delete; + Struct& operator=(const Struct&) = delete; + Struct(Struct&&) = default; + Struct& operator=(Struct&&) = default; + public: rowgroup_pt internal_rowgroup; }; -class RowgroupComparisonResult { +class FLS_API RowgroupComparisonResult { public: bool is_equal {true}; n_t first_failed_column_idx {0}; @@ -198,7 +213,7 @@ class RowgroupComparisonResult { string description; }; -class Rowgroup { +class FLS_API Rowgroup { public: friend class LogicalExpr; friend class column; @@ -241,6 +256,8 @@ class Rowgroup { /// void Cast(); /// + void PopulateBiMap(); + /// void Init(); /// void FillMissingValues(n_t how_many_to_fill); @@ -253,7 +270,7 @@ class Rowgroup { const n_t capacity; }; -std::ostream& operator<<(std::ostream& output, const Rowgroup& mini_arrow); +FLS_API std::ostream& operator<<(std::ostream& output, const Rowgroup& mini_arrow); } // namespace fastlanes diff --git a/src/include/fls/table/stats.hpp b/src/include/fls/table/stats.hpp index ca217eee..5ae66c36 100644 --- a/src/include/fls/table/stats.hpp +++ b/src/include/fls/table/stats.hpp @@ -6,6 +6,7 @@ #ifndef FLS_TABLE_STATS_HPP #define FLS_TABLE_STATS_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" #include "fls/common/bimap.hpp" #include "fls/common/bimap_frequency.hpp" @@ -44,7 +45,7 @@ class TypedStats { bool is_double_castable; }; -class FlsStringStats { +class FLS_API FlsStringStats { public: FlsStringStats(); diff --git a/src/include/fls/table/table.hpp b/src/include/fls/table/table.hpp index da284cdc..ba0d2f49 100644 --- a/src/include/fls/table/table.hpp +++ b/src/include/fls/table/table.hpp @@ -6,16 +6,17 @@ #ifndef FLS_TABLE_TABLE_HPP #define FLS_TABLE_TABLE_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" #include "fls/std/vector.hpp" +#include "fls/table/rowgroup.hpp" #include namespace fastlanes { /*--------------------------------------------------------------------------------------------------------------------*/ -class Rowgroup; class Connection; /*--------------------------------------------------------------------------------------------------------------------*/ -class TableComparisonResult { +class FLS_API TableComparisonResult { public: bool is_equal {true}; n_t first_failed_rowgroup_idx {0}; @@ -24,10 +25,16 @@ class TableComparisonResult { string description; }; -class Table { +class FLS_API Table { public: Table(const Connection& connection); + ~Table(); + Table(const Table&) = delete; + Table& operator=(const Table&) = delete; + Table(Table&&) = delete; + Table& operator=(Table&&) = delete; + public: n_t get_n_rowgroups() const; diff --git a/src/include/fls/table/vector.hpp b/src/include/fls/table/vector.hpp index ac228ce9..81e320bf 100644 --- a/src/include/fls/table/vector.hpp +++ b/src/include/fls/table/vector.hpp @@ -6,9 +6,10 @@ #ifndef FLS_TABLE_VECTOR_HPP #define FLS_TABLE_VECTOR_HPP #include "chunk.hpp" +#include "fls/api/api.hpp" namespace fastlanes { -class Vector { +class FLS_API Vector { public: explicit Vector(const fls_vec& vector); const fls_vec& internal_vector; diff --git a/src/include/fls/types/integer.hpp b/src/include/fls/types/integer.hpp index 7c273f24..2e6ec7bf 100644 --- a/src/include/fls/types/integer.hpp +++ b/src/include/fls/types/integer.hpp @@ -6,13 +6,14 @@ #ifndef FLS_TYPES_INTEGER_HPP #define FLS_TYPES_INTEGER_HPP +#include "fls/api/api.hpp" #include "fls/std/string.hpp" #include "fls/types/integer.hpp" namespace fastlanes { template -INTEGER_T parse_integer(const string& val_str); +FLS_API INTEGER_T parse_integer(const string& val_str); } // namespace fastlanes diff --git a/src/include/fls/types/timestamp.hpp b/src/include/fls/types/timestamp.hpp index 4680bd8c..7a072a5a 100644 --- a/src/include/fls/types/timestamp.hpp +++ b/src/include/fls/types/timestamp.hpp @@ -6,6 +6,7 @@ #ifndef FLS_TYPES_TIMESTAMP_HPP #define FLS_TYPES_TIMESTAMP_HPP +#include "fls/api/api.hpp" #include "fls/std/string.hpp" #include @@ -33,7 +34,7 @@ namespace fastlanes { * @throws std::out_of_range * If the resulting timestamp exceeds int64_t range */ -int64_t parse_timestamp(string_view ts_str); +FLS_API int64_t parse_timestamp(string_view ts_str); /** * Formats a microseconds-since-epoch timestamp back into an ISO-8601 string: @@ -48,7 +49,7 @@ int64_t parse_timestamp(string_view ts_str); * @throws std::runtime_error * If the reconstructed date falls outside a valid range */ -string timestamp_formatter(int64_t microseconds_since_epoch); +FLS_API string timestamp_formatter(int64_t microseconds_since_epoch); } // namespace fastlanes diff --git a/src/include/fls/types/validitymask.hpp b/src/include/fls/types/validitymask.hpp index 7831fe46..9576e827 100644 --- a/src/include/fls/types/validitymask.hpp +++ b/src/include/fls/types/validitymask.hpp @@ -11,10 +11,11 @@ * @brief Fixed‑size ValidityMask */ +#include "fls/api/api.hpp" #include "fls/cfg/cfg.hpp" namespace fastlanes { -class ValidityMask { +class FLS_API ValidityMask { public: // ───────────────────────────────────── configuration static constexpr n_t BIT_COUNT = CFG::VEC_SZ; ///< Total bits (compile‑time configured). diff --git a/src/include/fls/wizard/sampling_layout.hpp b/src/include/fls/wizard/sampling_layout.hpp index 5eef9032..74cd9fe1 100644 --- a/src/include/fls/wizard/sampling_layout.hpp +++ b/src/include/fls/wizard/sampling_layout.hpp @@ -6,6 +6,7 @@ #ifndef SAMPLING_LAYOUT_HPP #define SAMPLING_LAYOUT_HPP +#include "fls/api/api.hpp" #include "fls/common/alias.hpp" // for n_t #include "fls/std/array.hpp" #include "fls/std/vector.hpp" @@ -68,7 +69,7 @@ inline constexpr auto sampling_layout_64 = sampling_layout<64>(); // ----------------------------------------------------------------------------------------------------------- // Run-time mapping // ----------------------------------------------------------------------------------------------------------- -vector sampling_layout_dynamic(n_t rowgroup_size); +FLS_API vector sampling_layout_dynamic(n_t rowgroup_size); } // namespace fastlanes diff --git a/src/json/fls_json.cpp b/src/json/fls_json.cpp index 83b2cbf8..830a3d64 100644 --- a/src/json/fls_json.cpp +++ b/src/json/fls_json.cpp @@ -29,7 +29,7 @@ namespace fastlanes { DataType TypeLookUp(const string& str) { // 1) Normalize to uppercase std::string s = str; - std::ranges::transform(s, s.begin(), [](unsigned char c) { return std::toupper(c); }); + std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return std::toupper(c); }); // 2) Regex for DECIMAL(p,s) static const std::regex decimal_re(R"(DECIMAL\(\d+,\s*\d+\))"); diff --git a/src/primitive/copy/fls_copy.cpp b/src/primitive/copy/fls_copy.cpp index 455b2ffa..7e5a962f 100644 --- a/src/primitive/copy/fls_copy.cpp +++ b/src/primitive/copy/fls_copy.cpp @@ -6,6 +6,7 @@ #include "fls/primitive/copy/fls_copy.hpp" #include "fls/common/common.hpp" #include "fls/common/restrict.hpp" +#include "fls/compiler.hpp" #include "fls/expression/data_type.hpp" #include @@ -155,7 +156,7 @@ static void unpack_32bw_32ow_32crw_1uf(const uint32_t* FLS_RESTRICT a_in_p, uint static void unpack_64bw_64ow_64crw_1uf(const uint64_t* FLS_RESTRICT in, uint64_t* FLS_RESTRICT out) { [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); out[(i * 1) + (0 * 16) + (16 * 0)] = register_0; diff --git a/src/primitive/fls_memset/fls_memset.cpp b/src/primitive/fls_memset/fls_memset.cpp index 6cbcac4e..bf3db262 100644 --- a/src/primitive/fls_memset/fls_memset.cpp +++ b/src/primitive/fls_memset/fls_memset.cpp @@ -6,6 +6,7 @@ #include "fls/primitive/fls_memset/fls_memset.hpp" #include "fls/common/common.hpp" #include "fls/common/restrict.hpp" +#include "fls/compiler.hpp" #include "fls/expression/data_type.hpp" #include #include @@ -98,7 +99,7 @@ static void unffor_0bw_64ow_64crw_1uf(const uint64_t* FLS_RESTRICT base_p, uint6 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(base_p); -#pragma clang loop vectorize(enable) + FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { *(out + (i * 1) + (0 * 16) + (16 * 0)) = base_0; *(out + (i * 1) + (0 * 16) + (16 * 1)) = base_0; diff --git a/src/primitive/fsst/CMakeLists.txt b/src/primitive/fsst/CMakeLists.txt index 6c973ed0..0bef08c4 100644 --- a/src/primitive/fsst/CMakeLists.txt +++ b/src/primitive/fsst/CMakeLists.txt @@ -11,7 +11,9 @@ if (ENABLE_IWYU) set_property(TARGET fls_primitive_fsst PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path}) endif () -target_compile_options(fls_primitive_fsst PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_primitive_fsst PRIVATE -Wno-macro-redefined) +endif () target_link_libraries(fls_primitive_fsst PUBLIC diff --git a/src/primitive/fsst12/CMakeLists.txt b/src/primitive/fsst12/CMakeLists.txt index 0457f6a3..9f7be06a 100644 --- a/src/primitive/fsst12/CMakeLists.txt +++ b/src/primitive/fsst12/CMakeLists.txt @@ -12,7 +12,12 @@ if (ENABLE_IWYU) set_property(TARGET fls_primitive_fsst12 PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path}) endif () -target_compile_options(fls_primitive_fsst12 PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_primitive_fsst12 PRIVATE -Wno-macro-redefined) +endif () +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + target_compile_options(fls_primitive_fsst12 PRIVATE -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread) +endif () target_link_libraries(fls_primitive_fsst12 PUBLIC diff --git a/src/primitive/fsst12/fsst12.cpp b/src/primitive/fsst12/fsst12.cpp index 254e76f6..9618374d 100644 --- a/src/primitive/fsst12/fsst12.cpp +++ b/src/primitive/fsst12/fsst12.cpp @@ -62,25 +62,25 @@ compressBulk(Symbol12Map& symbolMap, ulong nlines, u32 lenIn[], u8* strIn[], ulo } cur += (code >> 12); res |= (code & FSST12_CODE_MASK) << 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } while (cur < end) { ulong code = symbolMap.findExpansion(Symbol12(cur, end)); u32 res = (code & FSST12_CODE_MASK); if (out + 8 > lim) { - return string_idx; // u32 write would be out of bounds (out of output memory) + return string_idx; // u64 write would be out of bounds (out of output memory) } cur += code >> 12; if (cur >= end) { - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 2; break; } code = symbolMap.findExpansion(Symbol12(cur, end)); res |= (code & FSST12_CODE_MASK) << 12; cur += code >> 12; - memcpy(out, &res, sizeof(u64)); + memcpy(out, &res, sizeof(u32)); out += 3; } } diff --git a/src/primitive/patch/CMakeLists.txt b/src/primitive/patch/CMakeLists.txt index 8c549b8e..2858b463 100644 --- a/src/primitive/patch/CMakeLists.txt +++ b/src/primitive/patch/CMakeLists.txt @@ -12,7 +12,9 @@ if (ENABLE_IWYU) set_property(TARGET fls_primitive_patch PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path}) endif () -target_compile_options(fls_primitive_patch PRIVATE -Wno-macro-redefined) +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(fls_primitive_patch PRIVATE -Wno-macro-redefined) +endif () target_link_libraries(fls_primitive_patch PUBLIC diff --git a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_rsum_src.cpp b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_rsum_src.cpp index 7188f3e5..d13f16d7 100644 --- a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_rsum_src.cpp +++ b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_rsum_src.cpp @@ -5,6 +5,7 @@ // ──────────────────────────────────────────────────────── // generated! // NOLINTBEGIN +#include "fls/compiler.hpp" #include "fls_gen/macros.hpp" #include "fls_gen/rsum/rsum.hpp" namespace generated { namespace rsum::fallback { namespace scalar { @@ -216,7 +217,7 @@ void rsum(const uint64_t* __restrict a_in_p, uint64_t* __restrict a_out_p, const [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = *(base + (0 * 16) + (i * 1)); diff --git a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unffor_src.cpp b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unffor_src.cpp index e2c34def..9b458fa3 100644 --- a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unffor_src.cpp +++ b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unffor_src.cpp @@ -5,6 +5,7 @@ // ──────────────────────────────────────────────────────── // generated! // NOLINTBEGIN +#include "fls/compiler.hpp" #include "fls_gen/macros.hpp" #include "fls_gen/unffor/unffor.hpp" namespace generated { namespace unffor::fallback { namespace scalar { @@ -5917,7 +5918,7 @@ static void unffor_0bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { *(out + (i * 1) + (0 * 16) + (16 * 0)) = base_0; *(out + (i * 1) + (0 * 16) + (16 * 1)) = base_0; @@ -5993,7 +5994,7 @@ static void unffor_1bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 1) - 1); @@ -6198,7 +6199,7 @@ static void unffor_2bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 2) - 1); @@ -6404,7 +6405,7 @@ static void unffor_3bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 3) - 1); @@ -6613,7 +6614,7 @@ static void unffor_4bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 4) - 1); @@ -6821,7 +6822,7 @@ static void unffor_5bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 5) - 1); @@ -7034,7 +7035,7 @@ static void unffor_6bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 6) - 1); @@ -7248,7 +7249,7 @@ static void unffor_7bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 7) - 1); @@ -7465,7 +7466,7 @@ static void unffor_8bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 8) - 1); @@ -7677,7 +7678,7 @@ static void unffor_9bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 9) - 1); @@ -7898,7 +7899,7 @@ static void unffor_10bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 10) - 1); @@ -8120,7 +8121,7 @@ static void unffor_11bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 11) - 1); @@ -8345,7 +8346,7 @@ static void unffor_12bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 12) - 1); @@ -8569,7 +8570,7 @@ static void unffor_13bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 13) - 1); @@ -8798,7 +8799,7 @@ static void unffor_14bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 14) - 1); @@ -9028,7 +9029,7 @@ static void unffor_15bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 15) - 1); @@ -9261,7 +9262,7 @@ static void unffor_16bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 16) - 1); @@ -9481,7 +9482,7 @@ static void unffor_17bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 17) - 1); @@ -9718,7 +9719,7 @@ static void unffor_18bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 18) - 1); @@ -9956,7 +9957,7 @@ static void unffor_19bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 19) - 1); @@ -10197,7 +10198,7 @@ static void unffor_20bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 20) - 1); @@ -10437,7 +10438,7 @@ static void unffor_21bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 21) - 1); @@ -10682,7 +10683,7 @@ static void unffor_22bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 22) - 1); @@ -10928,7 +10929,7 @@ static void unffor_23bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 23) - 1); @@ -11177,7 +11178,7 @@ static void unffor_24bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 24) - 1); @@ -11421,7 +11422,7 @@ static void unffor_25bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 25) - 1); @@ -11674,7 +11675,7 @@ static void unffor_26bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 26) - 1); @@ -11928,7 +11929,7 @@ static void unffor_27bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 27) - 1); @@ -12185,7 +12186,7 @@ static void unffor_28bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 28) - 1); @@ -12441,7 +12442,7 @@ static void unffor_29bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 29) - 1); @@ -12702,7 +12703,7 @@ static void unffor_30bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 30) - 1); @@ -12964,7 +12965,7 @@ static void unffor_31bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 31) - 1); @@ -13229,7 +13230,7 @@ static void unffor_32bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 32) - 1); @@ -13465,7 +13466,7 @@ static void unffor_33bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 33) - 1); @@ -13734,7 +13735,7 @@ static void unffor_34bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 34) - 1); @@ -14004,7 +14005,7 @@ static void unffor_35bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 35) - 1); @@ -14277,7 +14278,7 @@ static void unffor_36bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 36) - 1); @@ -14549,7 +14550,7 @@ static void unffor_37bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 37) - 1); @@ -14826,7 +14827,7 @@ static void unffor_38bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 38) - 1); @@ -15104,7 +15105,7 @@ static void unffor_39bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 39) - 1); @@ -15385,7 +15386,7 @@ static void unffor_40bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 40) - 1); @@ -15661,7 +15662,7 @@ static void unffor_41bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 41) - 1); @@ -15946,7 +15947,7 @@ static void unffor_42bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 42) - 1); @@ -16232,7 +16233,7 @@ static void unffor_43bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 43) - 1); @@ -16521,7 +16522,7 @@ static void unffor_44bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 44) - 1); @@ -16809,7 +16810,7 @@ static void unffor_45bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 45) - 1); @@ -17102,7 +17103,7 @@ static void unffor_46bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 46) - 1); @@ -17396,7 +17397,7 @@ static void unffor_47bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 47) - 1); @@ -17693,7 +17694,7 @@ static void unffor_48bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 48) - 1); @@ -17977,7 +17978,7 @@ static void unffor_49bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 49) - 1); @@ -18278,7 +18279,7 @@ static void unffor_50bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 50) - 1); @@ -18580,7 +18581,7 @@ static void unffor_51bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 51) - 1); @@ -18885,7 +18886,7 @@ static void unffor_52bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 52) - 1); @@ -19189,7 +19190,7 @@ static void unffor_53bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 53) - 1); @@ -19498,7 +19499,7 @@ static void unffor_54bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 54) - 1); @@ -19808,7 +19809,7 @@ static void unffor_55bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 55) - 1); @@ -20121,7 +20122,7 @@ static void unffor_56bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 56) - 1); @@ -20429,7 +20430,7 @@ static void unffor_57bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 57) - 1); @@ -20746,7 +20747,7 @@ static void unffor_58bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 58) - 1); @@ -21064,7 +21065,7 @@ static void unffor_59bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 59) - 1); @@ -21385,7 +21386,7 @@ static void unffor_60bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 60) - 1); @@ -21705,7 +21706,7 @@ static void unffor_61bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 61) - 1); @@ -22030,7 +22031,7 @@ static void unffor_62bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 62) - 1); @@ -22356,7 +22357,7 @@ static void unffor_63bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 63) - 1); @@ -22685,7 +22686,7 @@ static void unffor_64bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = *(a_base_p); -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); register_0 += base_0; diff --git a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unpack_src.cpp b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unpack_src.cpp index 9692c4b1..0fae4da3 100644 --- a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unpack_src.cpp +++ b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unpack_src.cpp @@ -5,6 +5,7 @@ // ──────────────────────────────────────────────────────── // generated! // NOLINTBEGIN +#include "fls/compiler.hpp" #include "fls_gen/macros.hpp" #include "fls_gen/unpack/unpack.hpp" namespace generated { namespace unpack::fallback { namespace scalar { @@ -4453,7 +4454,7 @@ static void unpack_0bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { out[(i * 1) + (0 * 16) + 0] = base_0; out[(i * 1) + (0 * 16) + 16] = base_0; @@ -4527,7 +4528,7 @@ static void unpack_1bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 1) - 1); @@ -4666,7 +4667,7 @@ static void unpack_2bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 2) - 1); @@ -4806,7 +4807,7 @@ static void unpack_3bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 3) - 1); @@ -4949,7 +4950,7 @@ static void unpack_4bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 4) - 1); @@ -5091,7 +5092,7 @@ static void unpack_5bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 5) - 1); @@ -5238,7 +5239,7 @@ static void unpack_6bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 6) - 1); @@ -5386,7 +5387,7 @@ static void unpack_7bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 7) - 1); @@ -5537,7 +5538,7 @@ static void unpack_8bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 8) - 1); @@ -5683,7 +5684,7 @@ static void unpack_9bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64_ [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 9) - 1); @@ -5838,7 +5839,7 @@ static void unpack_10bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 10) - 1); @@ -5994,7 +5995,7 @@ static void unpack_11bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 11) - 1); @@ -6153,7 +6154,7 @@ static void unpack_12bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 12) - 1); @@ -6311,7 +6312,7 @@ static void unpack_13bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 13) - 1); @@ -6474,7 +6475,7 @@ static void unpack_14bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 14) - 1); @@ -6638,7 +6639,7 @@ static void unpack_15bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 15) - 1); @@ -6805,7 +6806,7 @@ static void unpack_16bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 16) - 1); @@ -6959,7 +6960,7 @@ static void unpack_17bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 17) - 1); @@ -7130,7 +7131,7 @@ static void unpack_18bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 18) - 1); @@ -7302,7 +7303,7 @@ static void unpack_19bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 19) - 1); @@ -7477,7 +7478,7 @@ static void unpack_20bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 20) - 1); @@ -7651,7 +7652,7 @@ static void unpack_21bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 21) - 1); @@ -7830,7 +7831,7 @@ static void unpack_22bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 22) - 1); @@ -8010,7 +8011,7 @@ static void unpack_23bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 23) - 1); @@ -8193,7 +8194,7 @@ static void unpack_24bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 24) - 1); @@ -8371,7 +8372,7 @@ static void unpack_25bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 25) - 1); @@ -8558,7 +8559,7 @@ static void unpack_26bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 26) - 1); @@ -8746,7 +8747,7 @@ static void unpack_27bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 27) - 1); @@ -8937,7 +8938,7 @@ static void unpack_28bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 28) - 1); @@ -9127,7 +9128,7 @@ static void unpack_29bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 29) - 1); @@ -9322,7 +9323,7 @@ static void unpack_30bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 30) - 1); @@ -9518,7 +9519,7 @@ static void unpack_31bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 31) - 1); @@ -9717,7 +9718,7 @@ static void unpack_32bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 32) - 1); @@ -9887,7 +9888,7 @@ static void unpack_33bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 33) - 1); @@ -10090,7 +10091,7 @@ static void unpack_34bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 34) - 1); @@ -10294,7 +10295,7 @@ static void unpack_35bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 35) - 1); @@ -10501,7 +10502,7 @@ static void unpack_36bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 36) - 1); @@ -10707,7 +10708,7 @@ static void unpack_37bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 37) - 1); @@ -10918,7 +10919,7 @@ static void unpack_38bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 38) - 1); @@ -11130,7 +11131,7 @@ static void unpack_39bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 39) - 1); @@ -11345,7 +11346,7 @@ static void unpack_40bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 40) - 1); @@ -11555,7 +11556,7 @@ static void unpack_41bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 41) - 1); @@ -11774,7 +11775,7 @@ static void unpack_42bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 42) - 1); @@ -11994,7 +11995,7 @@ static void unpack_43bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 43) - 1); @@ -12217,7 +12218,7 @@ static void unpack_44bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 44) - 1); @@ -12439,7 +12440,7 @@ static void unpack_45bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 45) - 1); @@ -12666,7 +12667,7 @@ static void unpack_46bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 46) - 1); @@ -12894,7 +12895,7 @@ static void unpack_47bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 47) - 1); @@ -13125,7 +13126,7 @@ static void unpack_48bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 48) - 1); @@ -13343,7 +13344,7 @@ static void unpack_49bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 49) - 1); @@ -13578,7 +13579,7 @@ static void unpack_50bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 50) - 1); @@ -13814,7 +13815,7 @@ static void unpack_51bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 51) - 1); @@ -14053,7 +14054,7 @@ static void unpack_52bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 52) - 1); @@ -14291,7 +14292,7 @@ static void unpack_53bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 53) - 1); @@ -14534,7 +14535,7 @@ static void unpack_54bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 54) - 1); @@ -14778,7 +14779,7 @@ static void unpack_55bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 55) - 1); @@ -15025,7 +15026,7 @@ static void unpack_56bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 56) - 1); @@ -15267,7 +15268,7 @@ static void unpack_57bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 57) - 1); @@ -15518,7 +15519,7 @@ static void unpack_58bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 58) - 1); @@ -15770,7 +15771,7 @@ static void unpack_59bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 59) - 1); @@ -16025,7 +16026,7 @@ static void unpack_60bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 60) - 1); @@ -16279,7 +16280,7 @@ static void unpack_61bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 61) - 1); @@ -16538,7 +16539,7 @@ static void unpack_62bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 62) - 1); @@ -16798,7 +16799,7 @@ static void unpack_63bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); tmp_0 = (register_0) & ((1ULL << 63) - 1); @@ -17061,7 +17062,7 @@ static void unpack_64bw_64ow_64crw_1uf(const uint64_t* __restrict a_in_p, uint64 [[maybe_unused]] uint64_t register_0; [[maybe_unused]] uint64_t tmp_0; [[maybe_unused]] uint64_t base_0 = 0ULL; -#pragma clang loop vectorize(enable) +FLS_PRAGMA_VECTORIZE for (int i = 0; i < 16; ++i) { register_0 = *(in + (0 * 16) + (i * 1) + 0); out[(i * 1) + (0 * 16) + 0] = register_0; diff --git a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp index 00dca7b9..b7127320 100644 --- a/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp +++ b/src/primitives/fls_generated/fallback/scalar_aav_uf1/fallback_scalar_aav_1024_uf1_unrsum_src.cpp @@ -19,32 +19,30 @@ void unrsum(const uint8_t* a_in_p, uint8_t* a_out_p) { register_0_1 = in[(0 * 128) + (i * 1) + (128 * 1)]; out[(0 * 128) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 128) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 128) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 128) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 128) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 128) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 128) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 128) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 128) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 128) + (i * 1) + (128 * 8)]; out[(i * 1) + (0 * 128) + 896] = tmp_0; } } @@ -62,64 +60,62 @@ void unrsum(const uint16_t* a_in_p, uint16_t* a_out_p) { register_0_1 = in[(0 * 64) + (i * 1) + (128 * 1)]; out[(0 * 64) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 64) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 64) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 64) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 64) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 64) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 64) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 64) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 64) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 64) + (i * 1) + (128 * 8)]; + register_0_0 = register_0_1; out[(i * 1) + (0 * 64) + 896] = tmp_0; register_0_1 = in[64 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 0) + i] = tmp_0; register_0_1 = in[64 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 1) + i] = tmp_0; register_0_1 = in[64 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 2) + i] = tmp_0; register_0_1 = in[64 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 3) + i] = tmp_0; register_0_1 = in[64 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 4) + i] = tmp_0; register_0_1 = in[64 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 5) + i] = tmp_0; register_0_1 = in[64 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 6) + i] = tmp_0; register_0_1 = in[64 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 7) + i]; a_out_p[64 + (128 * 7) + i] = tmp_0; } } @@ -137,128 +133,126 @@ void unrsum(const uint32_t* a_in_p, uint32_t* a_out_p) { register_0_1 = in[(0 * 32) + (i * 1) + (128 * 1)]; out[(0 * 32) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 32) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 32) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 32) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 32) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 32) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 32) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 32) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 32) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 32) + (i * 1) + (128 * 8)]; + register_0_0 = register_0_1; out[(i * 1) + (0 * 32) + 896] = tmp_0; register_0_1 = in[64 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 0) + i] = tmp_0; register_0_1 = in[64 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 1) + i] = tmp_0; register_0_1 = in[64 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 2) + i] = tmp_0; register_0_1 = in[64 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 3) + i] = tmp_0; register_0_1 = in[64 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 4) + i] = tmp_0; register_0_1 = in[64 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 5) + i] = tmp_0; register_0_1 = in[64 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 6) + i] = tmp_0; register_0_1 = in[64 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 7) + i] = tmp_0; register_0_1 = in[32 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 0) + i] = tmp_0; register_0_1 = in[32 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 1) + i] = tmp_0; register_0_1 = in[32 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 2) + i] = tmp_0; register_0_1 = in[32 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 3) + i] = tmp_0; register_0_1 = in[32 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 4) + i] = tmp_0; register_0_1 = in[32 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 5) + i] = tmp_0; register_0_1 = in[32 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 6) + i] = tmp_0; register_0_1 = in[32 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 7) + i] = tmp_0; register_0_1 = in[96 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 0) + i] = tmp_0; register_0_1 = in[96 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 1) + i] = tmp_0; register_0_1 = in[96 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 2) + i] = tmp_0; register_0_1 = in[96 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 3) + i] = tmp_0; register_0_1 = in[96 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 4) + i] = tmp_0; register_0_1 = in[96 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 5) + i] = tmp_0; register_0_1 = in[96 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 6) + i] = tmp_0; register_0_1 = in[96 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 7) + i]; a_out_p[96 + (128 * 7) + i] = tmp_0; } } @@ -276,256 +270,254 @@ void unrsum(const uint64_t* a_in_p, uint64_t* a_out_p) { register_0_1 = in[(0 * 16) + (i * 1) + (128 * 1)]; out[(0 * 16) + (i * 1) + (0)] = 0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 1)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 2)]; out[(i * 1) + (0 * 16) + 128] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 2)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 3)]; out[(i * 1) + (0 * 16) + 256] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 3)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 4)]; out[(i * 1) + (0 * 16) + 384] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 4)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 5)]; out[(i * 1) + (0 * 16) + 512] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 5)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 6)]; out[(i * 1) + (0 * 16) + 640] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 6)]; + register_0_0 = register_0_1; register_0_1 = in[(0 * 16) + (i * 1) + (128 * 7)]; out[(i * 1) + (0 * 16) + 768] = tmp_0; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[(0 * 16) + (i * 1) + (128 * 7)]; - register_0_1 = in[(0 * 16) + (i * 1) + (128 * 8)]; + register_0_0 = register_0_1; out[(i * 1) + (0 * 16) + 896] = tmp_0; register_0_1 = in[64 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 0) + i] = tmp_0; register_0_1 = in[64 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 1) + i] = tmp_0; register_0_1 = in[64 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 2) + i] = tmp_0; register_0_1 = in[64 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 3) + i] = tmp_0; register_0_1 = in[64 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 4) + i] = tmp_0; register_0_1 = in[64 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 5) + i] = tmp_0; register_0_1 = in[64 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 6) + i] = tmp_0; register_0_1 = in[64 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[64 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[64 + (128 * 7) + i] = tmp_0; register_0_1 = in[32 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 0) + i] = tmp_0; register_0_1 = in[32 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 1) + i] = tmp_0; register_0_1 = in[32 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 2) + i] = tmp_0; register_0_1 = in[32 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 3) + i] = tmp_0; register_0_1 = in[32 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 4) + i] = tmp_0; register_0_1 = in[32 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 5) + i] = tmp_0; register_0_1 = in[32 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 6) + i] = tmp_0; register_0_1 = in[32 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[32 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[32 + (128 * 7) + i] = tmp_0; register_0_1 = in[96 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 0) + i] = tmp_0; register_0_1 = in[96 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 1) + i] = tmp_0; register_0_1 = in[96 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 2) + i] = tmp_0; register_0_1 = in[96 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 3) + i] = tmp_0; register_0_1 = in[96 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 4) + i] = tmp_0; register_0_1 = in[96 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 5) + i] = tmp_0; register_0_1 = in[96 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 6) + i] = tmp_0; register_0_1 = in[96 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[96 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[96 + (128 * 7) + i] = tmp_0; register_0_1 = in[16 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 0) + i] = tmp_0; register_0_1 = in[16 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 1) + i] = tmp_0; register_0_1 = in[16 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 2) + i] = tmp_0; register_0_1 = in[16 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 3) + i] = tmp_0; register_0_1 = in[16 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 4) + i] = tmp_0; register_0_1 = in[16 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 5) + i] = tmp_0; register_0_1 = in[16 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 6) + i] = tmp_0; register_0_1 = in[16 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[16 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[16 + (128 * 7) + i] = tmp_0; register_0_1 = in[80 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 0) + i] = tmp_0; register_0_1 = in[80 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 1) + i] = tmp_0; register_0_1 = in[80 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 2) + i] = tmp_0; register_0_1 = in[80 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 3) + i] = tmp_0; register_0_1 = in[80 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 4) + i] = tmp_0; register_0_1 = in[80 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 5) + i] = tmp_0; register_0_1 = in[80 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[80 + (128 * 6) + i] = tmp_0; register_0_1 = in[80 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[80 + (128 * 7) + i]; a_out_p[80 + (128 * 7) + i] = tmp_0; + register_0_0 = register_0_1; register_0_1 = in[48 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 0) + i] = tmp_0; register_0_1 = in[48 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 1) + i] = tmp_0; register_0_1 = in[48 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 2) + i] = tmp_0; register_0_1 = in[48 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 3) + i] = tmp_0; register_0_1 = in[48 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 4) + i] = tmp_0; register_0_1 = in[48 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 5) + i] = tmp_0; register_0_1 = in[48 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 6) + i] = tmp_0; register_0_1 = in[48 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[48 + (128 * 7) + i]; + register_0_0 = register_0_1; a_out_p[48 + (128 * 7) + i] = tmp_0; register_0_1 = in[112 + (128 * 0) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 0) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 0) + i] = tmp_0; register_0_1 = in[112 + (128 * 1) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 1) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 1) + i] = tmp_0; register_0_1 = in[112 + (128 * 2) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 2) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 2) + i] = tmp_0; register_0_1 = in[112 + (128 * 3) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 3) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 3) + i] = tmp_0; register_0_1 = in[112 + (128 * 4) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 4) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 4) + i] = tmp_0; register_0_1 = in[112 + (128 * 5) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 5) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 5) + i] = tmp_0; register_0_1 = in[112 + (128 * 6) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 6) + i]; + register_0_0 = register_0_1; a_out_p[112 + (128 * 6) + i] = tmp_0; register_0_1 = in[112 + (128 * 7) + i]; tmp_0 = register_0_1 - register_0_0; - register_0_0 = in[112 + (128 * 7) + i]; a_out_p[112 + (128 * 7) + i] = tmp_0; } } diff --git a/src/printer/output.cpp b/src/printer/output.cpp index 27bec653..271793d6 100644 --- a/src/printer/output.cpp +++ b/src/printer/output.cpp @@ -105,11 +105,11 @@ string TerminalOutput::repeat(unsigned int times, const string& c) { unsigned TerminalOutput::glyph_length(const string& s) const { auto byte_length = s.length(); - int u = 0; + size_t u = 0; const char* c_str = s.c_str(); unsigned glyph_length = 0; while (u < byte_length) { - u += std::mblen(&c_str[u], byte_length - static_cast(u)); + u += static_cast(std::mblen(&c_str[u], byte_length - u)); glyph_length += 1; } return glyph_length; diff --git a/src/reader/reader.cpp b/src/reader/reader.cpp index 906d2751..2a162c3f 100644 --- a/src/reader/reader.cpp +++ b/src/reader/reader.cpp @@ -25,6 +25,11 @@ #include // for basic_string namespace fastlanes { + +Reader::~Reader() = default; +Reader::Reader(Reader&&) noexcept = default; +Reader& Reader::operator=(Reader&&) noexcept = default; + Reader::Reader(const path& dir_path, Connection& fls) { // read footer { m_footer = make_rowgroup_descriptor(dir_path / FOOTER_FILE_NAME); } diff --git a/src/reader/rowgroup_reader.cpp b/src/reader/rowgroup_reader.cpp index 5caa9a94..c0b7451d 100644 --- a/src/reader/rowgroup_reader.cpp +++ b/src/reader/rowgroup_reader.cpp @@ -26,6 +26,8 @@ namespace fastlanes { +RowgroupReader::~RowgroupReader() = default; + RowgroupReader::RowgroupReader(const path& file_path, const RowgroupDescriptor& rowgroup_descriptor, Connection& connection) @@ -86,7 +88,6 @@ up RowgroupReader::materialize() { materializer.Materialize(expressions, vec_idx); } - // materializer.rowgroup.Cast(); materializer.rowgroup.Finalize(); materializer.rowgroup.GetStatistics(); diff --git a/src/reader/rowgroup_view.cpp b/src/reader/rowgroup_view.cpp index d5704fbf..655f1de0 100644 --- a/src/reader/rowgroup_view.cpp +++ b/src/reader/rowgroup_view.cpp @@ -13,6 +13,10 @@ namespace fastlanes { +RowgroupView::~RowgroupView() = default; +RowgroupView::RowgroupView(RowgroupView&&) noexcept = default; +RowgroupView& RowgroupView::operator=(RowgroupView&&) noexcept = default; + RowgroupView::RowgroupView(span ptr, const RowgroupDescriptor& footer) { for (const auto& column_descriptor : *footer.m_column_descriptors()) { diff --git a/src/reader/segment.cpp b/src/reader/segment.cpp index 005c02bf..b0e2f7e5 100644 --- a/src/reader/segment.cpp +++ b/src/reader/segment.cpp @@ -99,6 +99,10 @@ n_t SegmentView::Size() const { /*--------------------------------------------------------------------------------------------------------------------*\ * Segment \*--------------------------------------------------------------------------------------------------------------------*/ +Segment::~Segment() = default; +Segment::Segment(Segment&&) noexcept = default; +Segment& Segment::operator=(Segment&&) noexcept = default; + Segment::Segment() : persistent(true) , is_block_based(false) { diff --git a/src/reader/table_reader.cpp b/src/reader/table_reader.cpp index 8170dd0a..d9b75a37 100644 --- a/src/reader/table_reader.cpp +++ b/src/reader/table_reader.cpp @@ -32,8 +32,12 @@ up TableReader::get_rowgroup_reader(const n_t rowgroup_idx) cons up
TableReader::materialize() const { auto table_up = make_unique
(m_connection); - const TableDescriptor* td = m_table_descriptor_handle->Get(); - const auto n_rgs = td->m_rowgroup_descriptors()->size(); // uoffset_t + const TableDescriptor* td = m_table_descriptor_handle->Get(); + const auto* rg_vec = td->m_rowgroup_descriptors(); + if (!rg_vec) { + return table_up; + } + const auto n_rgs = rg_vec->size(); for (flatbuffers::uoffset_t i = 0; i < n_rgs; ++i) { auto rowgroup_up = get_rowgroup_reader(static_cast(i))->materialize(); @@ -44,8 +48,12 @@ up
TableReader::materialize() const { } void TableReader::to_csv(const path& file_path) const { - const TableDescriptor* td = m_table_descriptor_handle->Get(); - const auto n_rgs = td->m_rowgroup_descriptors()->size(); + const TableDescriptor* td = m_table_descriptor_handle->Get(); + const auto* rg_vec = td->m_rowgroup_descriptors(); + if (!rg_vec) { + return; + } + const auto n_rgs = rg_vec->size(); for (flatbuffers::uoffset_t i = 0; i < n_rgs; ++i) { auto rowgroup_up = get_rowgroup_reader(static_cast(i))->materialize(); @@ -61,6 +69,8 @@ void TableReader::to_csv(const char* file_path) const { to_csv(path(file_path)); } +TableReader::~TableReader() = default; + TableReader::TableReader(const path& file_path, Connection& connection) : m_connection(connection) , m_file_path(file_path) { diff --git a/src/reader/table_view.cpp b/src/reader/table_view.cpp index af60a515..68615382 100644 --- a/src/reader/table_view.cpp +++ b/src/reader/table_view.cpp @@ -3,8 +3,12 @@ // ──────────────────────────────────────────────────────── // src/reader/table_view.cpp // ──────────────────────────────────────────────────────── -// #include "fls/reader/table_view.hpp" +#include "fls/reader/table_view.hpp" namespace fastlanes { +TableView::~TableView() = default; +TableView::TableView(TableView&&) noexcept = default; +TableView& TableView::operator=(TableView&&) noexcept = default; + } // namespace fastlanes diff --git a/src/table/attribute.cpp b/src/table/attribute.cpp index f9cd053d..5f038c8c 100644 --- a/src/table/attribute.cpp +++ b/src/table/attribute.cpp @@ -241,7 +241,7 @@ void TypedIngest(TypedCol& typed_column, const string& val_str, const Column // ingest typed_column.null_map_arr.push_back(is_null); - PT current_val; + PT current_val {}; if (!is_null && column_descriptor.data_type == DataType::DECIMAL) { if constexpr (std::is_same_v) { // fix me current_val = make_decimal(val_str, column_descriptor.fix_me_decimal_type->scale); @@ -338,7 +338,7 @@ bool isValidUint32(const std::string& str) { } try { - u64_pt value = std::stoul(str); + u64_pt value = std::stoull(str); return value <= std::numeric_limits::max(); } catch (const std::exception&) { return false; } } @@ -362,7 +362,7 @@ bool isValidInt32(const std::string& str) { try { // Convert string to long and check the range - const int64_t value = std::stol(str); + const int64_t value = std::stoll(str); return value >= std::numeric_limits::min() && value <= std::numeric_limits::max(); } catch (const std::exception&) { return false; // Overflow or invalid conversion @@ -381,7 +381,7 @@ bool isValidUint16(const std::string& str) { try { // Convert string to uint64_t and check the range - uint64_t value = std::stoul(str); + uint64_t value = std::stoull(str); return value <= std::numeric_limits::max(); } catch (const std::exception&) { return false; // Overflow or invalid conversion diff --git a/src/table/rowgroup.cpp b/src/table/rowgroup.cpp index 9ab110de..2518e7a7 100644 --- a/src/table/rowgroup.cpp +++ b/src/table/rowgroup.cpp @@ -23,6 +23,7 @@ #include "fls/table/attribute.hpp" #include "fls/table/chunk.hpp" #include // if you use asserts, or your macros depend on it +#include // ptrdiff_t #include // int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t, uint64_t #include // std::ifstream #include // std::numeric_limits @@ -146,7 +147,7 @@ struct get_statistics_visitor { auto& length_arr = str_col->length_arr; // check constness - for (auto val_idx {0}; val_idx < str_col->length_arr.size(); ++val_idx) { + for (size_t val_idx {0}; val_idx < str_col->length_arr.size(); ++val_idx) { if (val_idx != 0) { is_constant = is_constant && Str::Equal(*str_col, *str_col, val_idx, val_idx - 1); } @@ -186,20 +187,13 @@ struct finalize_visitor { template void operator()(up>& typed_column) const { - auto& min = typed_column->m_stats.min; - auto& max = typed_column->m_stats.max; - auto& bimap_frequency = typed_column->m_stats.bimap_frequency; + auto& min = typed_column->m_stats.min; + auto& max = typed_column->m_stats.max; - // into the dictionary for (n_t val_idx {0}; val_idx < typed_column->data.size(); val_idx++) { const auto current_val = typed_column->data[val_idx]; - if (!bimap_frequency.contains_value(current_val)) { - n_t current_idx = bimap_frequency.size(); - bimap_frequency.insert(current_idx, {current_val}); - } - - min = std::min(min, current_val); - max = std::max(max, current_val); + min = std::min(min, current_val); + max = std::max(max, current_val); } } @@ -241,6 +235,54 @@ void Rowgroup::Finalize() { } } +/*--------------------------------------------------------------------------------------------------------------------*\ + * PopulateBiMap +\*--------------------------------------------------------------------------------------------------------------------*/ +struct populate_bimap_visitor { + explicit populate_bimap_visitor() = default; + + template + void operator()(up>& typed_column) const { + auto& min = typed_column->m_stats.min; + auto& max = typed_column->m_stats.max; + auto& bimap_frequency = typed_column->m_stats.bimap_frequency; + + for (n_t val_idx {0}; val_idx < typed_column->data.size(); val_idx++) { + const auto current_val = typed_column->data[val_idx]; + if (!bimap_frequency.contains_value(current_val)) { + n_t current_idx = bimap_frequency.size(); + bimap_frequency.insert(current_idx, current_val); + } else { + n_t existing_key = bimap_frequency.get_key(current_val); + bimap_frequency.insert(existing_key, current_val); + } + + min = std::min(min, current_val); + max = std::max(max, current_val); + } + } + + void operator()(up& str_col) const { + // string bimap is handled by GetStatistics + } + + void operator()(up& struct_col) const { + for (auto& col : struct_col->internal_rowgroup) { + visit(populate_bimap_visitor {}, col); + } + } + + void operator()(auto& col) const { + FLS_UNREACHABLE(); + } +}; + +void Rowgroup::PopulateBiMap() { + for (auto& col : internal_rowgroup) { + visit(populate_bimap_visitor {}, col); + } +} + /*--------------------------------------------------------------------------------------------------------------------*\ * Cast Check \*--------------------------------------------------------------------------------------------------------------------*/ @@ -258,7 +300,7 @@ struct col_cast_visitor { for (n_t val_idx {0}; val_idx < n_tup; val_idx++) { std::string str(reinterpret_cast(&str_col->byte_arr[cur_offset]), str_col->length_arr[val_idx]); - auto casted_string = std::stol(str); + auto casted_string = std::stoll(str); casted_col->data[val_idx] = static_cast(casted_string); cur_offset += str_col->length_arr[val_idx]; } @@ -336,13 +378,15 @@ col_pt cast_visit(rowgroup_pt& rowgroup, const ColumnDescriptorT& column_descrip template DataType getSmallestSignedType(PT min, PT max) { if constexpr (!std::is_same_v && !std::is_same_v) { - if (min >= std::numeric_limits::min() && max <= std::numeric_limits::max()) { + auto smin = static_cast(min); + auto smax = static_cast(max); + if (smin >= std::numeric_limits::min() && smax <= std::numeric_limits::max()) { return DataType::INT8; } - if (min >= std::numeric_limits::min() && max <= std::numeric_limits::max()) { + if (smin >= std::numeric_limits::min() && smax <= std::numeric_limits::max()) { return DataType::INT16; } - if (min >= std::numeric_limits::min() && max <= std::numeric_limits::max()) { + if (smin >= std::numeric_limits::min() && smax <= std::numeric_limits::max()) { return DataType::INT32; } return DataType::INT64; @@ -430,12 +474,16 @@ void fill_in(col_pt& col, n_t how_many_to_fill) { [&](up& string_col) { const auto last_value_length = string_col->length_arr.back(); + // Copy the last value once to avoid iterator invalidation during push_back. + // push_back can reallocate the vector, invalidating references into it. + const auto last_value_offset = string_col->byte_arr.size() - last_value_length; + vector last_value(string_col->byte_arr.begin() + static_cast(last_value_offset), + string_col->byte_arr.end()); + for (n_t val_idx {0}; val_idx < how_many_to_fill; val_idx++) { - const auto size = string_col->byte_arr.size(); - for (n_t byte_index {last_value_length}; byte_index > 0; byte_index--) { - string_col->byte_arr.push_back(string_col->byte_arr[size - byte_index]); - string_col->fsst_byte_arr.push_back(string_col->byte_arr[size - byte_index]); - } + string_col->byte_arr.insert(string_col->byte_arr.end(), last_value.begin(), last_value.end()); + string_col->fsst_byte_arr.insert( + string_col->fsst_byte_arr.end(), last_value.begin(), last_value.end()); string_col->length_arr.push_back(last_value_length); string_col->fsst_length_arr.push_back(last_value_length); } @@ -483,14 +531,13 @@ void cast_from_logical_to_physical(const Rowgroup& old_table, Rowgroup& new_tabl struct rowgroup_equality_visitor { template bool operator()(const up>& org_col, const up>& decoded_col) const { - // FLS_ASSERT_E(org_col->data.size(), org_col->null_map_arr.size()) for (idx_t idx {0}; idx < org_col->data.size(); ++idx) { - const auto& original_val = org_col->data[idx]; - const auto& decoded_val = decoded_col->data[idx]; - if (org_col->null_map_arr[idx]) { + if (idx < org_col->null_map_arr.size() && org_col->null_map_arr[idx]) { continue; } + const auto& original_val = org_col->data[idx]; + const auto& decoded_val = decoded_col->data[idx]; if (original_val != decoded_val) { return false; } @@ -519,7 +566,7 @@ struct rowgroup_equality_visitor { } for (idx_t idx {0}; idx < org_col->length_arr.size(); ++idx) { - if (org_col->null_map_arr[idx]) { + if (idx < org_col->null_map_arr.size() && org_col->null_map_arr[idx]) { continue; } const fls_string_t org_fls_string {org_col->str_p_arr[idx], org_col->length_arr[idx]}; @@ -658,13 +705,14 @@ n_t Rowgroup::ColCount() const { template TypedColumnView::TypedColumnView(const col_pt& column) : m_vec_idx(INVALID_N) { + static const uint8_t zero_null_map[65536] = {}; visit(overloaded {// [&](const up>& typed_col) { // m_data = typed_col->data.data(); m_stats_p = &typed_col->m_stats; n_vals = typed_col->data.size(); - m_bools = typed_col->null_map_arr.data(); + m_bools = typed_col->null_map_arr.empty() ? zero_null_map : typed_col->null_map_arr.data(); n_tuples = typed_col->data.size(); }, [&](const std::monostate&) { FLS_UNREACHABLE() }, @@ -721,13 +769,18 @@ template class TypedColumnView; \*--------------------------------------------------------------------------------------------------------------------*/ NullMapView::NullMapView(const col_pt& column) { - visit(overloaded { - [&](const up>& typed_col) { m_null_map = typed_col->null_map_arr.data(); }, - [&](const up& fls_str_column) { m_null_map = fls_str_column->null_map_arr.data(); }, - [&](const std::monostate&) { FLS_UNREACHABLE() }, - [&](const auto& arg) { - FLS_UNREACHABLE_WITH_TYPE(arg) - }}, + static const uint8_t zero_null_map[65536] = {}; + visit(overloaded {[&](const up>& typed_col) { + m_null_map = typed_col->null_map_arr.empty() ? zero_null_map : typed_col->null_map_arr.data(); + }, + [&](const up& fls_str_column) { + m_null_map = fls_str_column->null_map_arr.empty() ? zero_null_map + : fls_str_column->null_map_arr.data(); + }, + [&](const std::monostate&) { FLS_UNREACHABLE() }, + [&](const auto& arg) { + FLS_UNREACHABLE_WITH_TYPE(arg) + }}, column); } const uint8_t* NullMapView::NullMap() const { diff --git a/src/table/table.cpp b/src/table/table.cpp index bc1692f5..5080fab2 100644 --- a/src/table/table.cpp +++ b/src/table/table.cpp @@ -11,6 +11,8 @@ namespace fastlanes { +Table::~Table() = default; + Table::Table(const Connection& connection) : m_connection(connection) { } diff --git a/src/types/date.cpp b/src/types/date.cpp index 939859f9..37bd71e7 100644 --- a/src/types/date.cpp +++ b/src/types/date.cpp @@ -80,7 +80,7 @@ string date_formatter(const int32_t days_since_epoch) { unsigned m = static_cast(ymd.month()); unsigned d = static_cast(ymd.day()); - char buf[11]; // "YYYY-MM-DD" + '\0' + char buf[16]; // "YYYY-MM-DD" + '\0' (extra space for negative years) std::snprintf(buf, sizeof(buf), "%04d-%02u-%02u", y, m, d); return buf; } diff --git a/src/types/integer.cpp b/src/types/integer.cpp index 650b01bc..f7049c88 100644 --- a/src/types/integer.cpp +++ b/src/types/integer.cpp @@ -4,6 +4,7 @@ // src/types/integer.cpp // ──────────────────────────────────────────────────────── #include "fls/types/integer.hpp" +#include "fls/api/api.hpp" #include "fls/std/string.hpp" #include // for std::isdigit #include @@ -77,13 +78,13 @@ INTEGER_T parse_integer(const string& val_str) { } } -template uint8_t parse_integer(const string&); -template uint16_t parse_integer(const string&); -template uint32_t parse_integer(const string&); -template uint64_t parse_integer(const string&); -template int8_t parse_integer(const string&); -template int16_t parse_integer(const string&); -template int32_t parse_integer(const string&); -template int64_t parse_integer(const string&); +template FLS_API uint8_t parse_integer(const string&); +template FLS_API uint16_t parse_integer(const string&); +template FLS_API uint32_t parse_integer(const string&); +template FLS_API uint64_t parse_integer(const string&); +template FLS_API int8_t parse_integer(const string&); +template FLS_API int16_t parse_integer(const string&); +template FLS_API int32_t parse_integer(const string&); +template FLS_API int64_t parse_integer(const string&); } // namespace fastlanes diff --git a/src/utl/memory_usage.cpp b/src/utl/memory_usage.cpp index c99cf2d9..431dd38d 100644 --- a/src/utl/memory_usage.cpp +++ b/src/utl/memory_usage.cpp @@ -12,8 +12,9 @@ #elif defined(__linux__) #include #include -#else -#error "Unsupported platform" +#elif defined(_WIN32) +#include +#include #endif namespace fastlanes { @@ -39,6 +40,13 @@ uint64_t memoryUsageBytes() { long page_size = sysconf(_SC_PAGESIZE); return rss_pages * static_cast(page_size); +#elif defined(_WIN32) + PROCESS_MEMORY_COUNTERS pmc; + if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) { + return static_cast(pmc.WorkingSetSize); + } + return 0; + #endif } diff --git a/test/src/CMakeLists.txt b/test/src/CMakeLists.txt index f6a53189..94e5e946 100644 --- a/test/src/CMakeLists.txt +++ b/test/src/CMakeLists.txt @@ -1,3 +1,30 @@ +# On MSVC (and clang-cl), large heap allocations can touch guard pages whose +# transient 0xc0000005 exceptions are caught by GoogleTest's SEH wrapper, +# causing spurious test failures. This small static library installs a VEH +# handler that commits those pages before GTest intercepts the fault. +# On non-MSVC toolchains the source compiles to an empty translation unit. +add_library(msvc_heap_guard OBJECT msvc_heap_guard.cpp) + +# Helper: apply Windows linker/runtime settings to a test target. +# - Static builds (MSVC/clang-cl): /WHOLEARCHIVE so all symbols are pulled in. +# - Shared builds (any Windows compiler): copy the DLL next to the test executable. +function(fls_msvc_test_setup TARGET) + if (NOT WIN32) + return() + endif () + if (NOT FLS_BUILD_SHARED_LIBS AND MSVC) + target_link_options(${TARGET} PRIVATE /WHOLEARCHIVE:$) + elseif (FLS_BUILD_SHARED_LIBS) + add_custom_command( + TARGET ${TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + COMMAND_EXPAND_LISTS + ) + endif () +endfunction() + add_subdirectory(dataset_tests) add_subdirectory(expression_tests) add_subdirectory(fls_reader_tests) diff --git a/test/src/dataset_tests/CMakeLists.txt b/test/src/dataset_tests/CMakeLists.txt index 21069be7..a2919d78 100644 --- a/test/src/dataset_tests/CMakeLists.txt +++ b/test/src/dataset_tests/CMakeLists.txt @@ -10,7 +10,8 @@ add_executable( tpch.cpp wrong_schema.cpp) -target_link_libraries(dataset_tests PUBLIC gtest_main gmock_main FastLanes) +target_link_libraries(dataset_tests PUBLIC gtest_main gmock_main FastLanes msvc_heap_guard) +fls_msvc_test_setup(dataset_tests) gtest_discover_tests(dataset_tests DISCOVERY_TIMEOUT 60) fls_enable_sanitizers(dataset_tests) diff --git a/test/src/dataset_tests/public_bi.cpp b/test/src/dataset_tests/public_bi.cpp index 40480d46..90b5bc6f 100644 --- a/test/src/dataset_tests/public_bi.cpp +++ b/test/src/dataset_tests/public_bi.cpp @@ -16,23 +16,23 @@ TEST_F(FastLanesReaderTester, Arade) { } TEST_F(FastLanesReaderTester, Bimbo) { - const vector constant_cols = {6}; - constexpr vector equal_cols = {}; // No equal columns found - const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found + const vector constant_cols = {6}; + const vector equal_cols = {}; // No equal columns found + const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found AllTest(public_bi::Bimbo, constant_cols, equal_cols, one_to_one_mapped_col_indexes); } TEST_F(FastLanesReaderTester, CMSprovider) { - const vector constant_cols = {20}; - constexpr vector equal_cols = {}; // No equal columns found - const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found + const vector constant_cols = {20}; + const vector equal_cols = {}; // No equal columns found + const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found AllTest(public_bi::CMSprovider, constant_cols, equal_cols, one_to_one_mapped_col_indexes); } TEST_F(FastLanesReaderTester, CityMaxCapita) { - const vector constant_cols = {10, 19}; - constexpr vector equal_cols = {}; // No equal columns found - const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found + const vector constant_cols = {10, 19}; + const vector equal_cols = {}; // No equal columns found + const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found AllTest(public_bi::CityMaxCapita, constant_cols, equal_cols, one_to_one_mapped_col_indexes); } @@ -67,17 +67,17 @@ TEST_F(FastLanesReaderTester, Eixo) { } TEST_F(FastLanesReaderTester, Euro2016) { - const vector constant_cols = {0}; - constexpr vector equal_cols = {}; + const vector constant_cols = {0}; + const vector equal_cols = {}; // -- one-to-one mapped columns: [(3, 4)] const vector one_to_one_mapped_col_indexes = {4}; AllTest(public_bi::Euro2016, constant_cols, equal_cols, one_to_one_mapped_col_indexes); } TEST_F(FastLanesReaderTester, Food) { - const vector constant_cols = {0}; - constexpr vector equal_cols = {}; // No equal columns found - const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found + const vector constant_cols = {0}; + const vector equal_cols = {}; // No equal columns found + const vector one_to_one_mapped_col_indexes = {}; // No one-to-one mapped columns found AllTest(public_bi::Food, constant_cols, equal_cols, one_to_one_mapped_col_indexes); } diff --git a/test/src/expression_tests/CMakeLists.txt b/test/src/expression_tests/CMakeLists.txt index fb978304..886f644f 100644 --- a/test/src/expression_tests/CMakeLists.txt +++ b/test/src/expression_tests/CMakeLists.txt @@ -1,6 +1,7 @@ macro(fls_add_test NAME SRC) add_executable(test_${NAME} ${SRC}) - target_link_libraries(test_${NAME} PUBLIC gtest_main gmock_main FastLanes) + target_link_libraries(test_${NAME} PUBLIC gtest_main gmock_main FastLanes msvc_heap_guard) + fls_msvc_test_setup(test_${NAME}) add_test(NAME test_${NAME} COMMAND $) fls_enable_sanitizers(test_${NAME}) endmacro() diff --git a/test/src/fls_reader_tests/CMakeLists.txt b/test/src/fls_reader_tests/CMakeLists.txt index 6c296db2..e31e6db0 100644 --- a/test/src/fls_reader_tests/CMakeLists.txt +++ b/test/src/fls_reader_tests/CMakeLists.txt @@ -6,7 +6,8 @@ add_executable( rowgroup_size_test.cpp verify_fastlanes_files_test.cpp) -target_link_libraries(fls_reader_tests PUBLIC gtest_main gmock_main FastLanes) +target_link_libraries(fls_reader_tests PUBLIC gtest_main gmock_main FastLanes msvc_heap_guard) +fls_msvc_test_setup(fls_reader_tests) gtest_discover_tests(fls_reader_tests DISCOVERY_TIMEOUT 60) fls_enable_sanitizers(fls_reader_tests) diff --git a/test/src/msvc_heap_guard.cpp b/test/src/msvc_heap_guard.cpp new file mode 100644 index 00000000..39997487 --- /dev/null +++ b/test/src/msvc_heap_guard.cpp @@ -0,0 +1,70 @@ +// ──────────────────────────────────────────────────────── +// | FastLanes | +// ──────────────────────────────────────────────────────── +// test/src/msvc_heap_guard.cpp +// ──────────────────────────────────────────────────────── + +// --------------------------------------------------------------------------- +// On Windows with the static CRT (/MT), large heap allocations (common when +// processing JPEG base64 data) may touch a heap-internal guard page, causing a +// transient STATUS_ACCESS_VIOLATION (0xc0000005). Under normal circumstances +// the NT heap manager's own vectored-exception handler commits the page and +// resumes execution transparently. +// +// GoogleTest, however, wraps every TEST body in an SEH __try/__except frame. +// Because SEH frames are evaluated *after* VEH handlers have all returned +// EXCEPTION_CONTINUE_SEARCH, the heap manager never gets the chance to handle +// the fault — GoogleTest's catch-all __except(EXCEPTION_EXECUTE_HANDLER) +// intercepts it first and reports a spurious test failure. +// +// The workaround below installs a first-chance VEH handler that recognises +// the specific pattern (read-AV on a page-aligned address inside the process +// heap) and commits the faulting page itself, then resumes execution — exactly +// what the heap manager would have done if GoogleTest's SEH frame were absent. +// --------------------------------------------------------------------------- +#ifdef _MSC_VER +#include + +static LONG WINAPI heap_guard_page_handler(EXCEPTION_POINTERS* ep) { + if (ep->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION) { + return EXCEPTION_CONTINUE_SEARCH; + } + + // Only handle *read* AVs (ExceptionInformation[0] == 0). + if (ep->ExceptionRecord->ExceptionInformation[0] != 0) { + return EXCEPTION_CONTINUE_SEARCH; + } + + const auto faulting_addr = reinterpret_cast(ep->ExceptionRecord->ExceptionInformation[1]); + + // Query the page state before committing. We only want to handle + // reserved-but-uncommitted heap pages (state == MEM_RESERVE). + // Stack guard pages have state MEM_COMMIT + PAGE_GUARD; committing + // those would remove the stack guard and cause STATUS_STACK_BUFFER_OVERRUN. + MEMORY_BASIC_INFORMATION mbi; + if (VirtualQuery(faulting_addr, &mbi, sizeof(mbi)) == 0) { + return EXCEPTION_CONTINUE_SEARCH; + } + if (mbi.State != MEM_RESERVE) { + return EXCEPTION_CONTINUE_SEARCH; // not a reserved page — leave it alone + } + + // Try to commit the faulting page. If it succeeds the page was a + // reserved-but-uncommitted guard region inside the heap — resume. + void* result = VirtualAlloc(faulting_addr, 1, MEM_COMMIT, PAGE_READWRITE); + if (result != nullptr) { + return EXCEPTION_CONTINUE_EXECUTION; // page committed — retry the instruction + } + + // Not a committable page — let something else handle it. + return EXCEPTION_CONTINUE_SEARCH; +} + +struct HeapGuardInstaller { + HeapGuardInstaller() { + AddVectoredExceptionHandler(1 /* first */, heap_guard_page_handler); + } +}; + +static HeapGuardInstaller g_heap_guard; +#endif diff --git a/test/src/primitive_tests/CMakeLists.txt b/test/src/primitive_tests/CMakeLists.txt index 336535d2..8739ae06 100644 --- a/test/src/primitive_tests/CMakeLists.txt +++ b/test/src/primitive_tests/CMakeLists.txt @@ -7,7 +7,9 @@ target_link_libraries(primitive_test PRIVATE gtest_main # GoogleTest’s main first FastLanes # your library second + msvc_heap_guard ) +fls_msvc_test_setup(primitive_test) fls_enable_sanitizers(primitive_test) diff --git a/test/src/quick_fuzz_tests/CMakeLists.txt b/test/src/quick_fuzz_tests/CMakeLists.txt index a48ccdfb..6bd386be 100644 --- a/test/src/quick_fuzz_tests/CMakeLists.txt +++ b/test/src/quick_fuzz_tests/CMakeLists.txt @@ -6,7 +6,9 @@ add_executable(quick_fuzz_test target_link_libraries(quick_fuzz_test PRIVATE GTest::gtest_main - FastLanes) + FastLanes + msvc_heap_guard) +fls_msvc_test_setup(quick_fuzz_test) fls_enable_sanitizers(quick_fuzz_test) diff --git a/test/src/quick_fuzz_tests/fuzz_config.json b/test/src/quick_fuzz_tests/fuzz_config.json index 889bc524..a9c7af5b 100644 --- a/test/src/quick_fuzz_tests/fuzz_config.json +++ b/test/src/quick_fuzz_tests/fuzz_config.json @@ -1,6 +1,6 @@ { "num_cases": 10, - "base_seed": 12, + "base_seed": 13, "delimiter": "|", "min_cols": 1, "max_cols": 2, diff --git a/test/src/unit_tests/CMakeLists.txt b/test/src/unit_tests/CMakeLists.txt index efd3daa3..5ee0a5bb 100644 --- a/test/src/unit_tests/CMakeLists.txt +++ b/test/src/unit_tests/CMakeLists.txt @@ -17,7 +17,9 @@ target_link_libraries(unit_test PRIVATE gtest_main # GoogleTest’s main first FastLanes # your library second + msvc_heap_guard ) +fls_msvc_test_setup(unit_test) fls_enable_sanitizers(unit_test)