├── .github └── workflows │ ├── bot-dep.yml │ ├── format.yml │ ├── pub-snapshot.yml │ ├── scripts │ ├── bot-dep │ │ └── bump-velox.sh │ ├── common │ │ ├── setup-centos7.sh │ │ └── setup-ubuntu24.sh │ ├── format │ │ ├── Dockerfile │ │ └── format.sh │ ├── ut-cpp │ │ ├── setup-centos7.sh │ │ └── setup-ubuntu24.sh │ └── ut-java │ │ ├── setup-centos7.sh │ │ └── setup-ubuntu24.sh │ ├── ut-cpp.yml │ └── ut-java.yml ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src ├── main ├── cpp │ ├── .clang-format │ ├── .cmake-format.yaml │ ├── CMakeLists.txt │ ├── build.sh │ ├── main │ │ ├── CMakeLists.txt │ │ └── velox4j │ │ │ ├── arrow │ │ │ ├── Arrow.cc │ │ │ └── Arrow.h │ │ │ ├── config │ │ │ ├── Config.cc │ │ │ └── Config.h │ │ │ ├── connector │ │ │ ├── ExternalStream.cc │ │ │ └── ExternalStream.h │ │ │ ├── eval │ │ │ ├── Evaluation.cc │ │ │ ├── Evaluation.h │ │ │ ├── Evaluator.cc │ │ │ └── Evaluator.h │ │ │ ├── init │ │ │ ├── Config.cc │ │ │ ├── Config.h │ │ │ ├── Init.cc │ │ │ └── Init.h │ │ │ ├── iterator │ │ │ ├── BlockingQueue.cc │ │ │ ├── BlockingQueue.h │ │ │ ├── DownIterator.cc │ │ │ ├── DownIterator.h │ │ │ ├── UpIterator.cc │ │ │ └── UpIterator.h │ │ │ ├── jni │ │ │ ├── JniCommon.cc │ │ │ ├── JniCommon.h │ │ │ ├── JniError.cc │ │ │ ├── JniError.h │ │ │ ├── JniLoader.cc │ │ │ ├── JniWrapper.cc │ │ │ ├── JniWrapper.h │ │ │ ├── StaticJniWrapper.cc │ │ │ └── StaticJniWrapper.h │ │ │ ├── lifecycle │ │ │ ├── ObjectStore.cc │ │ │ ├── ObjectStore.h │ │ │ ├── ResourceMap.h │ │ │ ├── Session.cc │ │ │ └── Session.h │ │ │ ├── memory │ │ │ ├── AllocationListener.cc │ │ │ ├── AllocationListener.h │ │ │ ├── ArrowMemoryPool.cc │ │ │ ├── ArrowMemoryPool.h │ │ │ ├── JavaAllocationListener.cc │ │ │ ├── JavaAllocationListener.h │ │ │ ├── MemoryManager.cc │ │ │ └── MemoryManager.h │ │ │ ├── query │ │ │ ├── Query.cc │ │ │ ├── Query.h │ │ │ ├── QueryExecutor.cc │ │ │ └── QueryExecutor.h │ │ │ └── vector │ │ │ ├── Vectors.cc │ │ │ └── Vectors.h │ ├── test.sh │ ├── test │ │ ├── CMakeLists.txt │ │ └── velox4j │ │ │ ├── iterator │ │ │ └── BlockingQueueTest.cc │ │ │ ├── query │ │ │ ├── QuerySerdeTest.cc │ │ │ └── QueryTest.cc │ │ │ └── test │ │ │ └── Init.h │ ├── velox-ref-md5.txt │ └── velox-ref.txt └── java │ ├── com │ └── fasterxml │ │ └── jackson │ │ └── databind │ │ └── deser │ │ └── BeanDeserializerUnsafe.java │ └── org │ └── boostscale │ └── velox4j │ ├── Velox4j.java │ ├── aggregate │ ├── Aggregate.java │ └── AggregateStep.java │ ├── arrow │ └── Arrow.java │ ├── collection │ └── Streams.java │ ├── config │ ├── Config.java │ └── ConnectorConfig.java │ ├── connector │ ├── Assignment.java │ ├── ColumnHandle.java │ ├── ColumnType.java │ ├── CommitStrategy.java │ ├── CompressionKind.java │ ├── ConnectorInsertTableHandle.java │ ├── ConnectorSplit.java │ ├── ConnectorTableHandle.java │ ├── ExternalStream.java │ ├── ExternalStreamConnectorSplit.java │ ├── ExternalStreamTableHandle.java │ ├── ExternalStreams.java │ ├── FileFormat.java │ ├── FileNameGenerator.java │ ├── FileProperties.java │ ├── HiveBucketConversion.java │ ├── HiveBucketProperty.java │ ├── HiveColumnHandle.java │ ├── HiveConnectorSplit.java │ ├── HiveInsertFileNameGenerator.java │ ├── HiveInsertTableHandle.java │ ├── HiveSortingColumn.java │ ├── HiveTableHandle.java │ ├── InsertTableHandle.java │ ├── LocationHandle.java │ ├── RowIdProperties.java │ └── SubfieldFilter.java │ ├── data │ ├── BaseVector.java │ ├── BaseVectors.java │ ├── RowVector.java │ ├── RowVectors.java │ ├── SelectivityVector.java │ ├── SelectivityVectors.java │ └── VectorEncoding.java │ ├── eval │ ├── Evaluation.java │ ├── Evaluations.java │ └── Evaluator.java │ ├── exception │ ├── ExceptionDescriber.java │ └── VeloxException.java │ ├── expression │ ├── CallTypedExpr.java │ ├── CastTypedExpr.java │ ├── ConcatTypedExpr.java │ ├── ConstantTypedExpr.java │ ├── DereferenceTypedExpr.java │ ├── FieldAccessTypedExpr.java │ ├── InputTypedExpr.java │ ├── LambdaTypedExpr.java │ └── TypedExpr.java │ ├── filter │ ├── AlwaysTrue.java │ └── Filter.java │ ├── iterator │ ├── CloseableIterator.java │ ├── DownIterator.java │ ├── DownIterators.java │ ├── GenericUpIterator.java │ ├── InfiniteIterator.java │ ├── UpIterator.java │ └── UpIterators.java │ ├── jni │ ├── CalledFromNative.java │ ├── CppObject.java │ ├── JniApi.java │ ├── JniLibLoader.java │ ├── JniWorkspace.java │ ├── JniWrapper.java │ ├── LocalSession.java │ ├── StaticJniApi.java │ └── StaticJniWrapper.java │ ├── join │ └── JoinType.java │ ├── memory │ ├── AllocationListener.java │ ├── BytesAllocationListener.java │ ├── MemoryManager.java │ └── NoopAllocationListener.java │ ├── plan │ ├── AbstractJoinNode.java │ ├── AggregationNode.java │ ├── FilterNode.java │ ├── HashJoinNode.java │ ├── LimitNode.java │ ├── OrderByNode.java │ ├── PlanNode.java │ ├── ProjectNode.java │ ├── TableScanNode.java │ ├── TableWriteNode.java │ ├── ValuesNode.java │ └── WindowNode.java │ ├── query │ ├── Queries.java │ ├── Query.java │ ├── QueryExecutor.java │ ├── SerialTask.java │ └── SerialTaskStats.java │ ├── resource │ ├── PlainResourceFile.java │ ├── ResourceFile.java │ └── Resources.java │ ├── serde │ ├── NativeBean.java │ ├── PolymorphicDeserializer.java │ ├── PolymorphicSerializer.java │ ├── Serde.java │ ├── SerdeRegistry.java │ └── SerdeRegistryFactory.java │ ├── serializable │ ├── ISerializable.java │ ├── ISerializableCo.java │ ├── ISerializableRegistry.java │ └── ISerializables.java │ ├── session │ └── Session.java │ ├── sort │ └── SortOrder.java │ ├── type │ ├── ArrayType.java │ ├── BigIntType.java │ ├── BooleanType.java │ ├── DateType.java │ ├── DecimalType.java │ ├── DoubleType.java │ ├── FunctionType.java │ ├── HugeIntType.java │ ├── IntegerType.java │ ├── IntervalDayTimeType.java │ ├── IntervalYearMonthType.java │ ├── MapType.java │ ├── OpaqueType.java │ ├── RealType.java │ ├── RowType.java │ ├── SmallIntType.java │ ├── TimestampType.java │ ├── TinyIntType.java │ ├── Type.java │ ├── UnknownType.java │ ├── VarCharType.java │ └── VarbinaryType.java │ ├── variant │ ├── ArrayValue.java │ ├── BigIntValue.java │ ├── BooleanValue.java │ ├── DoubleValue.java │ ├── HugeIntValue.java │ ├── IntegerValue.java │ ├── MapValue.java │ ├── RealValue.java │ ├── RowValue.java │ ├── SmallIntValue.java │ ├── TimestampValue.java │ ├── TinyIntValue.java │ ├── VarBinaryValue.java │ ├── VarCharValue.java │ ├── Variant.java │ ├── VariantCo.java │ ├── VariantRegistry.java │ └── Variants.java │ ├── window │ ├── BoundType.java │ ├── WindowFrame.java │ ├── WindowFunction.java │ └── WindowType.java │ └── write │ ├── ColumnStatsSpec.java │ └── TableWriteTraits.java └── test ├── java └── org │ └── boostscale │ └── velox4j │ ├── arrow │ └── ArrowTest.java │ ├── data │ ├── BaseVectorTest.java │ ├── BaseVectorTests.java │ ├── RowVectorTest.java │ └── SelectivityVectorTest.java │ ├── eval │ └── EvaluationTest.java │ ├── jni │ ├── JniApiTest.java │ └── JniApiTests.java │ ├── query │ └── QueryTest.java │ ├── serde │ ├── ConfigSerdeTest.java │ ├── ConnectorSerdeTest.java │ ├── EvaluationSerdeTest.java │ ├── FilterSerdeTest.java │ ├── PlanNodeSerdeTest.java │ ├── QuerySerdeTest.java │ ├── SerdeTests.java │ ├── TypeSerdeTest.java │ ├── TypedExprSerdeTest.java │ └── VariantSerdeTest.java │ ├── test │ ├── ConfigTests.java │ ├── ResourceTests.java │ ├── SampleQueryTests.java │ ├── TestThreads.java │ ├── TypeTests.java │ ├── UpIteratorTests.java │ ├── Velox4jTests.java │ └── dataset │ │ ├── TestDataFile.java │ │ ├── TestDataset.java │ │ └── tpch │ │ ├── DownloadedTpchDataset.java │ │ ├── TpchDataset.java │ │ ├── TpchDatasets.java │ │ └── TpchTableName.java │ ├── variant │ └── VariantTest.java │ └── write │ └── TableWriteTraitsTest.java └── resources ├── eval-output ├── field-access-1.txt └── multiply-1.txt ├── query-output-type └── tpch-table-write-1.json ├── query-output ├── example-1.tsv ├── tpch-aggregate-1.tsv ├── tpch-filter-1.tsv ├── tpch-join-1.tsv ├── tpch-limit-1.tsv ├── tpch-orderby-1.tsv ├── tpch-project-1.tsv ├── tpch-table-scan-nation.tsv ├── tpch-table-scan-region.tsv └── tpch-window-1.tsv ├── query └── example-1.json ├── table-write-traits ├── output-type-1.json └── output-type-with-aggregation-node-1.json ├── vector-output ├── append-1.txt ├── append-2.txt ├── partition-by-keys-1.txt ├── partition-by-keys-2.txt ├── partition-by-keys-3.txt ├── slice-1.txt ├── slice-2.txt ├── to-string-1.txt ├── variant-to-vector-1.txt └── variant-to-vector-2.txt └── vector └── rowvector-1.b64 /.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | name: Code Format 17 | 18 | on: 19 | workflow_dispatch: 20 | pull_request: 21 | types: [ opened, reopened, synchronize ] 22 | paths: 23 | - '**/*' 24 | push: 25 | branches: 26 | - 'main' 27 | paths: 28 | - '**/*' 29 | 30 | concurrency: 31 | group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }} 32 | cancel-in-progress: true 33 | 34 | jobs: 35 | format-check: 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: actions/checkout@v4 39 | - name: Run format checker 40 | run: | 41 | bash .github/workflows/scripts/format/format.sh -check 42 | -------------------------------------------------------------------------------- /.github/workflows/scripts/bot-dep/bump-velox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o pipefail 5 | set -u 6 | 7 | BASE_DIR=$(dirname "$0") 8 | VELOX_UPSTREAM_REPO=facebookincubator/velox 9 | VELOX_UPSTREAM_BRANCH=main 10 | VELOX_CPP_ROOT="$BASE_DIR/../../../../src/main/cpp" 11 | VELOX_REF_FILE="$VELOX_CPP_ROOT/velox-ref.txt" 12 | VELOX_REF_MD5_FILE="$VELOX_CPP_ROOT/velox-ref-md5.txt" 13 | GITHUB_ENV=${GITHUB_ENV:-$BASE_DIR/github-env.txt} 14 | 15 | # Read old commit hash. 16 | if [[ -f "$VELOX_REF_FILE" ]]; then 17 | OLD_COMMIT_HASH="$(cat "$VELOX_REF_FILE")" 18 | else 19 | echo "File $VELOX_REF_FILE not found!" >&2 20 | exit 1 21 | fi 22 | 23 | LATEST_COMMIT_HASH="$(git ls-remote "https://github.com/$VELOX_UPSTREAM_REPO.git" "refs/heads/$VELOX_UPSTREAM_BRANCH" | awk '{print $1;}' | head -n 1)" 24 | 25 | echo "The latest commit for $VELOX_UPSTREAM_REPO is $LATEST_COMMIT_HASH" 26 | 27 | VELOX_UPSTREAM_SOURCE_URL="https://github.com/${VELOX_UPSTREAM_REPO}/archive/${LATEST_COMMIT_HASH}.zip" 28 | VELOX_SRC_FILENAME="$BASE_DIR/velox-src-$LATEST_COMMIT_HASH.zip" 29 | wget "$VELOX_UPSTREAM_SOURCE_URL" -O "$VELOX_SRC_FILENAME" 30 | VELOX_SRC_MD5="$(md5sum "$VELOX_SRC_FILENAME" | awk '{print $1}')" 31 | 32 | echo "The MD5 HASH for $VELOX_SRC_FILENAME is $VELOX_SRC_MD5" 33 | 34 | echo "$LATEST_COMMIT_HASH" > "$VELOX_REF_FILE" 35 | echo "$VELOX_SRC_MD5" > "$VELOX_REF_MD5_FILE" 36 | 37 | rm "$VELOX_SRC_FILENAME" 38 | 39 | # Export PR description for GitHub Actions. 40 | echo "BUMP_VELOX_DESCRIPTION=Update Velox to latest. Diff: https://github.com/$VELOX_UPSTREAM_REPO/compare/$OLD_COMMIT_HASH...$LATEST_COMMIT_HASH" >> "$GITHUB_ENV" 41 | 42 | echo "Successfully updated velox-ref.txt and velox-ref-md5.txt" 43 | -------------------------------------------------------------------------------- /.github/workflows/scripts/common/setup-ubuntu24.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o pipefail 5 | set -u 6 | 7 | # APT update. 8 | apt-get update 9 | 10 | # Install essentials. 11 | apt-get install -y sudo locales wget tar tzdata git ccache ninja-build build-essential 12 | apt-get install -y llvm-14-dev clang-14 libiberty-dev libdwarf-dev libre2-dev libz-dev 13 | apt-get install -y liblzo2-dev libzstd-dev libsnappy-dev libdouble-conversion-dev libssl-dev 14 | apt-get install -y libboost-all-dev libcurl4-openssl-dev curl zip unzip tar pkg-config 15 | apt-get install -y autoconf-archive bison flex libfl-dev libc-ares-dev libicu-dev 16 | apt-get install -y libgoogle-glog-dev libbz2-dev libgflags-dev libgmock-dev libevent-dev 17 | apt-get install -y liblz4-dev libsodium-dev libelf-dev 18 | apt-get install -y autoconf automake g++ libnuma-dev libtool numactl unzip libdaxctl-dev 19 | apt-get install -y openjdk-11-jdk 20 | apt-get install -y maven cmake 21 | apt-get install -y chrpath patchelf 22 | 23 | # Install GCC 11. 24 | apt-get install -y software-properties-common 25 | add-apt-repository ppa:ubuntu-toolchain-r/test 26 | apt-get install -y gcc-11 g++-11 27 | rm -f /usr/bin/gcc /usr/bin/g++ 28 | ln -s /usr/bin/gcc-11 /usr/bin/gcc 29 | ln -s /usr/bin/g++-11 /usr/bin/g++ 30 | cc --version 31 | c++ --version 32 | -------------------------------------------------------------------------------- /.github/workflows/scripts/format/Dockerfile: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | ARG OS_VERSION=latest 17 | FROM ubuntu:${OS_VERSION} 18 | 19 | # Set non-interactive mode for apt. 20 | ENV DEBIAN_FRONTEND=noninteractive 21 | 22 | # Install clang-format-18. 23 | RUN apt-get update && \ 24 | apt-get install -y clang-format-18 cmake-format 25 | 26 | # Set the default command. 27 | CMD ["echo", "This is the docker image of Velox4J's code formatter."] 28 | -------------------------------------------------------------------------------- /.github/workflows/scripts/ut-cpp/setup-centos7.sh: -------------------------------------------------------------------------------- 1 | ../common/setup-centos7.sh -------------------------------------------------------------------------------- /.github/workflows/scripts/ut-cpp/setup-ubuntu24.sh: -------------------------------------------------------------------------------- 1 | ../common/setup-ubuntu24.sh -------------------------------------------------------------------------------- /.github/workflows/scripts/ut-java/setup-centos7.sh: -------------------------------------------------------------------------------- 1 | ../common/setup-centos7.sh -------------------------------------------------------------------------------- /.github/workflows/scripts/ut-java/setup-ubuntu24.sh: -------------------------------------------------------------------------------- 1 | ../common/setup-ubuntu24.sh -------------------------------------------------------------------------------- /.github/workflows/ut-cpp.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | name: C++ UT 17 | 18 | on: 19 | workflow_dispatch: 20 | schedule: 21 | - cron: "0 4 * * *" 22 | 23 | concurrency: 24 | group: ${{ github.repository }}-${{ github.workflow }}-${{ github.ref }} 25 | cancel-in-progress: true 26 | 27 | jobs: 28 | 29 | ut-centos7: 30 | runs-on: ubuntu-latest 31 | env: 32 | HOST_CCACHE_DIR: "${{ github.workspace }}/.ccache" 33 | steps: 34 | - uses: actions/checkout@v4 35 | - name: Restore Ccache 36 | uses: actions/cache/restore@v4 37 | with: 38 | path: '${{ env.HOST_CCACHE_DIR }}' 39 | key: ut-cpp-ut-centos7-ccache-${{github.sha}} 40 | restore-keys: | 41 | ut-cpp-ut-centos7-ccache- 42 | - name: Run setup script / Build and run UTs 43 | run: | 44 | docker run -v ${{ github.workspace }}:/work -w /work centos:7 bash -c " 45 | export CCACHE_DIR=/work/.ccache 46 | export CCACHE_MAXSIZE=3000M 47 | bash .github/workflows/scripts/ut-cpp/setup-centos7.sh 48 | bash src/main/cpp/test.sh 49 | " 50 | - name: Save Ccache 51 | uses: actions/cache/save@v4 52 | with: 53 | path: '${{ env.HOST_CCACHE_DIR }}' 54 | key: ut-cpp-ut-centos7-ccache-${{github.sha}} 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # Virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | 26 | # Others 27 | .idea 28 | /target 29 | /src/main/cpp/cmake-build-* 30 | /src/main/cpp/build 31 | a.out 32 | /dependency-reduced-pom.xml 33 | -------------------------------------------------------------------------------- /src/main/cpp/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o pipefail 5 | set -u 6 | 7 | BASE_DIR=$(dirname "$0") 8 | NUM_THREADS=$(nproc) 9 | SOURCE_DIR=$BASE_DIR 10 | BUILD_DIR=$BASE_DIR/build 11 | INSTALL_DESTINATION=$BUILD_DIR/dist/lib 12 | VELOX4J_LIB_NAME=libvelox4j.so 13 | 14 | # Build C++ so libraries. 15 | cmake -DCMAKE_BUILD_TYPE=Release -DVELOX4J_ENABLE_CCACHE=ON -DVELOX4J_BUILD_TESTING=OFF -DVELOX4J_INSTALL_DESTINATION="$INSTALL_DESTINATION" -S "$SOURCE_DIR" -B "$BUILD_DIR" 16 | cmake --build "$BUILD_DIR" --target velox4j_shared -j "$NUM_THREADS" 17 | cmake --install "$BUILD_DIR" --component velox4j 18 | 19 | # Do a check to exclude the case that CMake installation incorrectly installed symbolic links. 20 | for file in "$INSTALL_DESTINATION"/* 21 | do 22 | if [ -L "$file" ] 23 | then 24 | echo "CMake installation just created a symbolic link $file in the installation directory, this is not expected, aborting..." 25 | exit 1 26 | fi 27 | done 28 | 29 | # Force '$ORIGIN' runpaths for all so libraries to make the build portable. 30 | # 1. Remove any already set RUNPATH sections. 31 | for file in "$INSTALL_DESTINATION"/* 32 | do 33 | echo "Removing RUNPATH on file: $file ..." 34 | patchelf --remove-rpath "$file" 35 | done 36 | 37 | # 2. Add new RUNPATH sections with '$ORIGIN'. 38 | for file in "$INSTALL_DESTINATION"/* 39 | do 40 | echo "Adding RUNPATH on file: $file ..." 41 | patchelf --set-rpath '$ORIGIN' "$file" 42 | done 43 | 44 | # 3. Print new ELF headers. 45 | for file in "$INSTALL_DESTINATION"/* 46 | do 47 | echo "Checking ELF header on file: $file ..." 48 | readelf -d "$file" 49 | done 50 | 51 | # Do final checks. 52 | # 1. Check ldd result. 53 | echo "Checking ldd result of libvelox4j.so: " 54 | ldd "$INSTALL_DESTINATION/$VELOX4J_LIB_NAME" 55 | 56 | # 2. Check ld result. 57 | echo "Checking ld result of libvelox4j.so: " 58 | ld "$INSTALL_DESTINATION/$VELOX4J_LIB_NAME" 59 | 60 | # Finished. 61 | echo "Successfully built velox4j-cpp." 62 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/arrow/Arrow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | struct ArrowArray; 20 | struct ArrowSchema; 21 | 22 | namespace velox4j { 23 | 24 | // Exports the input Velox type to Arrow C schema. 25 | void fromTypeToArrow( 26 | facebook::velox::memory::MemoryPool* pool, 27 | facebook::velox::TypePtr type, 28 | ArrowSchema* cSchema); 29 | 30 | // Imports the given Arrow C schema into a Velox type, then returns it. 31 | facebook::velox::TypePtr fromArrowToType(ArrowSchema* cSchema); 32 | 33 | // Exports the input base vector to Arrow ABI structs. 34 | void fromBaseVectorToArrow( 35 | facebook::velox::VectorPtr vector, 36 | ArrowSchema* cSchema, 37 | ArrowArray* cArray); 38 | 39 | // Imports the given Arrow ABI structs into a base vector, then returns it. 40 | facebook::velox::VectorPtr fromArrowToBaseVector( 41 | facebook::velox::memory::MemoryPool* pool, 42 | ArrowSchema* cSchema, 43 | ArrowArray* cArray); 44 | } // namespace velox4j 45 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/eval/Evaluation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include "velox4j/config/Config.h" 19 | 20 | namespace velox4j { 21 | 22 | /// A JSON-able immutable struct that represents an evaluation process. 23 | /// An evaluation is built with a Velox expression and being 24 | /// used for creating an Evaluator that evaluates the expression 25 | /// for input vectors. 26 | class Evaluation : public facebook::velox::ISerializable { 27 | public: 28 | Evaluation( 29 | const facebook::velox::core::TypedExprPtr& expr, 30 | const std::shared_ptr& queryConfig, 31 | const std::shared_ptr& connectorConfig); 32 | 33 | const facebook::velox::core::TypedExprPtr& expr() const; 34 | const std::shared_ptr& queryConfig() const; 35 | const std::shared_ptr& connectorConfig() const; 36 | 37 | folly::dynamic serialize() const override; 38 | 39 | static std::shared_ptr create( 40 | const folly::dynamic& obj, 41 | void* context); 42 | 43 | static void registerSerDe(); 44 | 45 | private: 46 | const facebook::velox::core::TypedExprPtr expr_; 47 | const std::shared_ptr queryConfig_; 48 | const std::shared_ptr connectorConfig_; 49 | }; 50 | } // namespace velox4j 51 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/eval/Evaluator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "velox4j/eval/Evaluation.h" 22 | #include "velox4j/memory/MemoryManager.h" 23 | 24 | namespace velox4j { 25 | /// Evaluator is a JNI API that accepts calls from Java to evaluate 26 | /// an expression on a set of input row vectors. 27 | class Evaluator { 28 | public: 29 | Evaluator( 30 | MemoryManager* memoryManager, 31 | const std::shared_ptr& evaluation); 32 | 33 | facebook::velox::VectorPtr eval( 34 | const facebook::velox::SelectivityVector& rows, 35 | const facebook::velox::RowVector& input); 36 | 37 | private: 38 | const std::shared_ptr& evaluation_; 39 | std::shared_ptr queryCtx_; 40 | std::unique_ptr ee_; 41 | std::unique_ptr exprSet_; 42 | }; 43 | } // namespace velox4j 44 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/init/Config.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #include "velox4j/init/Config.h" 16 | 17 | namespace velox4j { 18 | using namespace facebook::velox; 19 | 20 | /// The preset used for initializing Velox4J. 21 | /// The initialization process will involve connector, function, fs 22 | /// registrations and so on. 23 | /// Spark is the only preset we support at this moment. 24 | config::ConfigBase::Entry VELOX4J_INIT_PRESET( 25 | "velox4j.init.preset", 26 | Preset::SPARK); 27 | 28 | /// The glog verbose level. 29 | config::ConfigBase::Entry VELOX4J_INIT_LOGGING_VERBOSE_LEVEL( 30 | "velox4j.init.logging.verboseLevel", 31 | 0); 32 | } // namespace velox4j 33 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/init/Config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace velox4j { 20 | enum Preset { SPARK = 0, FLINK = 1 }; 21 | 22 | extern facebook::velox::config::ConfigBase::Entry VELOX4J_INIT_PRESET; 23 | extern facebook::velox::config::ConfigBase::Entry 24 | VELOX4J_INIT_LOGGING_VERBOSE_LEVEL; 25 | } // namespace velox4j 26 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/init/Init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include "velox4j/config/Config.h" 18 | 19 | namespace velox4j { 20 | // Initializes Velox4J with a given configuration array. 21 | // Should only be called once in the same process. 22 | // Once called, further calls will be aborted by throwing an Exception. 23 | void initialize(const std::shared_ptr& configArray); 24 | } // namespace velox4j 25 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/iterator/UpIterator.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #include "velox4j/iterator/UpIterator.h" 16 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/iterator/UpIterator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include "velox4j/query/Query.h" 19 | 20 | namespace velox4j { 21 | 22 | /// An up-iterator is the opposite of down-iterator. It transmits data 23 | /// that is output from Velox pipeline from C++ to Java. 24 | class UpIterator { 25 | public: 26 | enum class State { AVAILABLE = 0, BLOCKED = 1, FINISHED = 2 }; 27 | 28 | // CTOR. 29 | UpIterator() = default; 30 | 31 | // Delete copy/move CTORs. 32 | UpIterator(UpIterator&&) = delete; 33 | UpIterator(const UpIterator&) = delete; 34 | UpIterator& operator=(const UpIterator&) = delete; 35 | UpIterator& operator=(UpIterator&&) = delete; 36 | 37 | // DTOR. 38 | virtual ~UpIterator() = default; 39 | 40 | // Gets the next state. 41 | virtual State advance() = 0; 42 | 43 | /// Called once `advance` returns `BLOCKED` state to wait until 44 | /// the state gets refreshed, either by the next row-vector 45 | /// is ready for reading or by end of stream. 46 | virtual void wait() = 0; 47 | 48 | // Called once `advance` returns `AVAILABLE` state to get 49 | // the next row-vector from the stream. 50 | virtual facebook::velox::RowVectorPtr get() = 0; 51 | }; 52 | } // namespace velox4j 53 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/jni/JniError.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | #include "velox4j/jni/JniCommon.h" 20 | 21 | namespace velox4j { 22 | 23 | // A state structure that provides utility APIs in relation 24 | // to the Java exception types used by Velox4J. 25 | class JniErrorState { 26 | public: 27 | virtual ~JniErrorState() = default; 28 | 29 | void ensureInitialized(JNIEnv* env); 30 | 31 | void assertInitialized() const; 32 | 33 | void close(); 34 | 35 | jclass runtimeExceptionClass(); 36 | 37 | jclass illegalAccessExceptionClass(); 38 | 39 | jclass veloxExceptionClass(); 40 | 41 | private: 42 | void initialize(JNIEnv* env); 43 | 44 | jclass ioExceptionClass_{nullptr}; 45 | jclass runtimeExceptionClass_{nullptr}; 46 | jclass unsupportedOperationExceptionClass_{nullptr}; 47 | jclass illegalAccessExceptionClass_{nullptr}; 48 | jclass illegalArgumentExceptionClass_{nullptr}; 49 | jclass veloxExceptionClass_{nullptr}; 50 | JavaVM* vm_{nullptr}; 51 | bool initialized_{false}; 52 | bool closed_{false}; 53 | std::mutex mtx_; 54 | }; 55 | 56 | JniErrorState* getJniErrorState(); 57 | 58 | } // namespace velox4j 59 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/jni/JniLoader.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include "velox4j/iterator/DownIterator.h" 19 | #include "velox4j/jni/JniCommon.h" 20 | #include "velox4j/jni/JniError.h" 21 | #include "velox4j/jni/JniWrapper.h" 22 | #include "velox4j/jni/StaticJniWrapper.h" 23 | #include "velox4j/memory/JavaAllocationListener.h" 24 | 25 | // The JNI entrypoint. 26 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void*) { 27 | LOG(INFO) << "Initializing Velox4J..."; 28 | JNIEnv* env = jniHelpersInitialize(jvm); 29 | if (env == nullptr) { 30 | return JNI_ERR; 31 | } 32 | 33 | velox4j::getJniErrorState()->ensureInitialized(env); 34 | velox4j::jniClassRegistry()->add(env, new velox4j::StaticJniWrapper(env)); 35 | velox4j::jniClassRegistry()->add(env, new velox4j::JniWrapper(env)); 36 | velox4j::jniClassRegistry()->add( 37 | env, new velox4j::DownIteratorJniWrapper(env)); 38 | velox4j::jniClassRegistry()->add( 39 | env, new velox4j::JavaAllocationListenerJniWrapper(env)); 40 | 41 | LOG(INFO) << "Velox4J initialized."; 42 | return JAVA_VERSION; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/jni/JniWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace velox4j { 20 | /// A dynamic JniWrapper that includes the JNI methods that are session-aware. 21 | /// Which means, the sanity of these methods usually rely on certain objects 22 | /// that were stored in the current session. For example, an API that turns 23 | /// a Velox vector into another, then returns it to Java - this method will read 24 | /// and write objects from and to the current JNI session storage. So the 25 | /// method will be defined in the (dynamic) JniWrapper. 26 | class JniWrapper final : public spotify::jni::JavaClass { 27 | public: 28 | explicit JniWrapper(JNIEnv* env) : JavaClass(env) { 29 | JniWrapper::initialize(env); 30 | } 31 | 32 | const char* getCanonicalName() const override; 33 | 34 | void initialize(JNIEnv* env) override; 35 | 36 | void mapFields() override; 37 | }; 38 | } // namespace velox4j 39 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/jni/StaticJniWrapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace velox4j { 20 | /// A static JNI wrapper that is independent to any JNI sessions. 21 | /// All the JNI methods defined in the static JNI wrapper are globally 22 | /// available without having to create a session first. 23 | class StaticJniWrapper final : public spotify::jni::JavaClass { 24 | public: 25 | explicit StaticJniWrapper(JNIEnv* env) : JavaClass(env) { 26 | StaticJniWrapper::initialize(env); 27 | } 28 | 29 | const char* getCanonicalName() const override; 30 | 31 | void initialize(JNIEnv* env) override; 32 | 33 | void mapFields() override; 34 | }; 35 | } // namespace velox4j 36 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/lifecycle/Session.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #include "velox4j/lifecycle/Session.h" 16 | 17 | namespace velox4j {} 18 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/lifecycle/Session.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include "velox4j/lifecycle/ObjectStore.h" 19 | #include "velox4j/memory/MemoryManager.h" 20 | 21 | namespace velox4j { 22 | /// A JNI session that is bound to a JniWrapper. 23 | class Session { 24 | public: 25 | Session(MemoryManager* memoryManager) 26 | : memoryManager_(memoryManager), objectStore_(ObjectStore::create()){}; 27 | virtual ~Session() = default; 28 | 29 | MemoryManager* memoryManager() { 30 | return memoryManager_; 31 | } 32 | 33 | ObjectStore* objectStore() { 34 | return objectStore_.get(); 35 | } 36 | 37 | private: 38 | MemoryManager* memoryManager_; 39 | std::unique_ptr objectStore_; 40 | }; 41 | 42 | } // namespace velox4j 43 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/memory/AllocationListener.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #include "velox4j/memory/AllocationListener.h" 16 | 17 | namespace velox4j { 18 | 19 | class NoopAllocationListener : public AllocationListener { 20 | public: 21 | void allocationChanged(int64_t diff) override { 22 | // no-op 23 | } 24 | 25 | const int64_t currentBytes() const override { 26 | return 0; 27 | } 28 | const int64_t peakBytes() const override { 29 | return 0; 30 | } 31 | }; 32 | 33 | std::unique_ptr AllocationListener::noop() { 34 | return std::make_unique(); 35 | } 36 | 37 | void BlockAllocationListener::allocationChanged(int64_t diff) { 38 | if (diff == 0) { 39 | return; 40 | } 41 | int64_t granted = reserve(diff); 42 | if (granted == 0) { 43 | return; 44 | } 45 | delegated_->allocationChanged(granted); 46 | } 47 | 48 | int64_t BlockAllocationListener::reserve(int64_t diff) { 49 | std::lock_guard lock(mutex_); 50 | usedBytes_ += diff; 51 | int64_t newBlockCount; 52 | if (usedBytes_ == 0) { 53 | newBlockCount = 0; 54 | } else { 55 | // ceil to get the required block number 56 | newBlockCount = (usedBytes_ - 1) / blockSize_ + 1; 57 | } 58 | int64_t bytesGranted = (newBlockCount - blocksReserved_) * blockSize_; 59 | blocksReserved_ = newBlockCount; 60 | peakBytes_ = std::max(peakBytes_, usedBytes_); 61 | return bytesGranted; 62 | } 63 | } // namespace velox4j 64 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/memory/JavaAllocationListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include "velox4j/memory/AllocationListener.h" 20 | 21 | namespace velox4j { 22 | // The JNI wrapper used by JavaAllocationListener. 23 | class JavaAllocationListenerJniWrapper final : public spotify::jni::JavaClass { 24 | public: 25 | explicit JavaAllocationListenerJniWrapper(JNIEnv* env) : JavaClass(env) { 26 | JavaAllocationListenerJniWrapper::initialize(env); 27 | } 28 | 29 | JavaAllocationListenerJniWrapper() : JavaClass(){}; 30 | 31 | const char* getCanonicalName() const override; 32 | 33 | void initialize(JNIEnv* env) override; 34 | 35 | void mapFields() override; 36 | }; 37 | 38 | /// A AllocationListener implementation that is backed by a Java-side 39 | /// allocation listener. The calls to this listener will be redirected to 40 | /// the methods with the same name in Java-side through JNI. 41 | class JavaAllocationListener : public AllocationListener { 42 | public: 43 | // CTOR. 44 | JavaAllocationListener(JNIEnv* env, jobject ref); 45 | 46 | // DTOR. 47 | ~JavaAllocationListener() override; 48 | 49 | void allocationChanged(int64_t diff) override; 50 | const int64_t currentBytes() const override; 51 | const int64_t peakBytes() const override; 52 | 53 | private: 54 | jobject ref_; 55 | std::atomic_int64_t usedBytes_{0L}; 56 | std::atomic_int64_t peakBytes_{0L}; 57 | }; 58 | } // namespace velox4j 59 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/query/Query.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | #include "velox4j/config/Config.h" 19 | 20 | namespace velox4j { 21 | 22 | /// An immutable JSON-able object that represents a query that is associated 23 | /// with a given Velox query plan and the corresponding query configurations. 24 | class Query : public facebook::velox::ISerializable { 25 | public: 26 | Query( 27 | const std::shared_ptr& plan, 28 | const std::shared_ptr& queryConfig, 29 | const std::shared_ptr& connectorConfig); 30 | 31 | const std::shared_ptr& plan() const; 32 | const std::shared_ptr& queryConfig() const; 33 | const std::shared_ptr& connectorConfig() const; 34 | 35 | folly::dynamic serialize() const override; 36 | 37 | std::string toString() const; 38 | 39 | static std::shared_ptr create( 40 | const folly::dynamic& obj, 41 | void* context); 42 | 43 | static void registerSerDe(); 44 | 45 | private: 46 | const std::shared_ptr plan_; 47 | const std::shared_ptr queryConfig_; 48 | const std::shared_ptr connectorConfig_; 49 | }; 50 | } // namespace velox4j 51 | -------------------------------------------------------------------------------- /src/main/cpp/main/velox4j/vector/Vectors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | 15 | #pragma once 16 | 17 | #include 18 | 19 | namespace velox4j { 20 | 21 | /// A customized version of `BaseVector::flattenVector`, 22 | /// mainly to workaround 23 | /// https://github.com/facebookincubator/velox/issues/14492. We also truncate 24 | /// all vectors at `targetSize`, because some Velox operations (E.g., Limit) 25 | /// could result in a RowVector whose children have larger size than itself. So 26 | /// we perform a slice to keep only the data that is in real use. 27 | void flattenVector( 28 | facebook::velox::VectorPtr& vector, 29 | facebook::velox::vector_size_t targetSize); 30 | } // namespace velox4j 31 | -------------------------------------------------------------------------------- /src/main/cpp/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o pipefail 5 | set -u 6 | 7 | BASE_DIR=$(dirname "$0") 8 | NUM_THREADS=$(nproc) 9 | SOURCE_DIR=$BASE_DIR 10 | BUILD_DIR=$BASE_DIR/build 11 | BUILD_TEST_DIR=$BUILD_DIR/test 12 | 13 | # Build C++ so libraries. 14 | cmake -DCMAKE_BUILD_TYPE=Release -DVELOX4J_ENABLE_CCACHE=ON -DVELOX4J_BUILD_TESTING=ON -S "$SOURCE_DIR" -B "$BUILD_DIR" 15 | cmake --build "$BUILD_DIR" -j "$NUM_THREADS" 16 | 17 | # Run tests. 18 | cd "$BUILD_TEST_DIR" 19 | ctest -V 20 | -------------------------------------------------------------------------------- /src/main/cpp/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(BUILD_TESTING ON) 2 | include(CTest) 3 | 4 | add_library(velox4j_test INTERFACE) 5 | target_include_directories(velox4j_test INTERFACE ${CMAKE_CURRENT_LIST_DIR}) 6 | target_link_libraries( 7 | velox4j_test 8 | INTERFACE 9 | velox4j_shared 10 | velox_vector_test_lib 11 | velox_dwio_common_test_utils 12 | velox_file_test_utils 13 | velox_temp_path 14 | velox_exec_test_lib) 15 | set(TEST_OBJECT_FILES $) 16 | 17 | add_executable(velox4j_query_serde_test ${TEST_OBJECT_FILES} 18 | velox4j/query/QuerySerdeTest.cc) 19 | target_link_libraries( 20 | velox4j_query_serde_test velox4j_test) 21 | add_test(velox4j_query_serde_test velox4j_query_serde_test) 22 | 23 | add_executable(velox4j_query_test ${TEST_OBJECT_FILES} 24 | velox4j/query/QueryTest.cc) 25 | target_link_libraries( 26 | velox4j_query_test velox4j_test) 27 | add_test(velox4j_query_test velox4j_query_test) 28 | 29 | add_executable(velox4j_blocking_queue_test 30 | ${TEST_OBJECT_FILES} velox4j/iterator/BlockingQueueTest.cc) 31 | target_link_libraries( 32 | velox4j_blocking_queue_test velox4j_test) 33 | add_test(velox4j_blocking_queue_test velox4j_blocking_queue_test) 34 | -------------------------------------------------------------------------------- /src/main/cpp/test/velox4j/test/Init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | #pragma once 15 | 16 | #include "velox4j/init/Config.h" 17 | #include "velox4j/init/Init.h" 18 | 19 | namespace velox4j { 20 | inline void testingEnsureInitializedForSpark() { 21 | static std::once_flag flag; 22 | auto conf = std::make_shared( 23 | std::vector>{ 24 | {VELOX4J_INIT_PRESET.key, folly::to(Preset::SPARK)}}); 25 | std::call_once(flag, [&]() { initialize(conf); }); 26 | } 27 | } // namespace velox4j 28 | -------------------------------------------------------------------------------- /src/main/cpp/velox-ref-md5.txt: -------------------------------------------------------------------------------- 1 | 8dbc94cd43183f787b5c0e08277cb145 2 | -------------------------------------------------------------------------------- /src/main/cpp/velox-ref.txt: -------------------------------------------------------------------------------- 1 | 8a5c63e734407e24fd9b977c70e8fab6cfdfa29c 2 | -------------------------------------------------------------------------------- /src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerUnsafe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package com.fasterxml.jackson.databind.deser; 15 | 16 | import java.util.Set; 17 | 18 | /** Package-hacking the protected APIs of BeanDeserializer for Velox4J's use. */ 19 | public final class BeanDeserializerUnsafe { 20 | public static Set getIgnorableProps(BeanDeserializer beanDeserializer) { 21 | return beanDeserializer._ignorableProps; 22 | } 23 | 24 | public static Set getIncludableProps(BeanDeserializer beanDeserializer) { 25 | return beanDeserializer._includableProps; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/aggregate/AggregateStep.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.aggregate; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum AggregateStep { 19 | PARTIAL("PARTIAL"), 20 | FINAL("FINAL"), 21 | INTERMEDIATE("INTERMEDIATE"), 22 | SINGLE("SINGLE"); 23 | 24 | private final String value; 25 | 26 | AggregateStep(String value) { 27 | this.value = value; 28 | } 29 | 30 | @JsonValue 31 | public String toValue() { 32 | return value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/collection/Streams.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.collection; 15 | 16 | import java.util.Iterator; 17 | import java.util.Spliterator; 18 | import java.util.Spliterators; 19 | import java.util.stream.Stream; 20 | import java.util.stream.StreamSupport; 21 | 22 | public final class Streams { 23 | public static Stream fromIterator(Iterator itr) { 24 | return StreamSupport.stream( 25 | Spliterators.spliteratorUnknownSize(itr, Spliterator.ORDERED), false); 26 | } 27 | 28 | public static Stream fromIterable(Iterable itr) { 29 | return fromIterator(itr.iterator()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/Assignment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | public class Assignment implements Serializable { 23 | private final String assign; 24 | private final ColumnHandle columnHandle; 25 | 26 | @JsonCreator 27 | public Assignment( 28 | @JsonProperty("assign") String assign, 29 | @JsonProperty("columnHandle") ColumnHandle columnHandle) { 30 | this.assign = assign; 31 | this.columnHandle = columnHandle; 32 | } 33 | 34 | @JsonGetter("assign") 35 | public String getAssign() { 36 | return assign; 37 | } 38 | 39 | @JsonGetter("columnHandle") 40 | public ColumnHandle getColumnHandle() { 41 | return columnHandle; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ColumnHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import org.boostscale.velox4j.serializable.ISerializable; 17 | 18 | public abstract class ColumnHandle extends ISerializable {} 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ColumnType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum ColumnType { 19 | PARTITION_KEY("PartitionKey"), 20 | REGULAR("Regular"), 21 | SYNTHESIZED("Synthesized"), 22 | ROW_INDEX("RowIndex"); 23 | 24 | private final String value; 25 | 26 | ColumnType(String value) { 27 | this.value = value; 28 | } 29 | 30 | @JsonValue 31 | public String toValue() { 32 | return value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/CommitStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum CommitStrategy { 19 | NO_COMMIT("NO_COMMIT"), 20 | TASK_COMMIT("TASK_COMMIT"); 21 | 22 | private final String value; 23 | 24 | CommitStrategy(String value) { 25 | this.value = value; 26 | } 27 | 28 | @JsonValue 29 | public String toValue() { 30 | return value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/CompressionKind.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum CompressionKind { 19 | NONE("none"), 20 | ZLIB("zlib"), 21 | SNAPPY("snappy"), 22 | LZO("lzo"), 23 | ZSTD("zstd"), 24 | LZ4("lz4"), 25 | GZIP("gzip"); 26 | 27 | private final String value; 28 | 29 | CompressionKind(String value) { 30 | this.value = value; 31 | } 32 | 33 | @JsonValue 34 | public String toValue() { 35 | return value; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ConnectorInsertTableHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import org.boostscale.velox4j.serializable.ISerializable; 17 | 18 | public abstract class ConnectorInsertTableHandle extends ISerializable { 19 | protected ConnectorInsertTableHandle() {} 20 | 21 | public abstract boolean supportsMultiThreading(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ConnectorSplit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonGetter; 17 | 18 | import org.boostscale.velox4j.serializable.ISerializable; 19 | 20 | public abstract class ConnectorSplit extends ISerializable { 21 | private final String connectorId; 22 | private final long splitWeight; 23 | private final boolean cacheable; 24 | 25 | protected ConnectorSplit(String connectorId, long splitWeight, boolean cacheable) { 26 | this.connectorId = connectorId; 27 | this.splitWeight = splitWeight; 28 | this.cacheable = cacheable; 29 | } 30 | 31 | @JsonGetter("connectorId") 32 | public String getConnectorId() { 33 | return connectorId; 34 | } 35 | 36 | public long getSplitWeight() { 37 | return splitWeight; 38 | } 39 | 40 | public boolean isCacheable() { 41 | return cacheable; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ConnectorTableHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonGetter; 17 | 18 | import org.boostscale.velox4j.serializable.ISerializable; 19 | 20 | public abstract class ConnectorTableHandle extends ISerializable { 21 | private final String connectorId; 22 | 23 | protected ConnectorTableHandle(String connectorId) { 24 | this.connectorId = connectorId; 25 | } 26 | 27 | @JsonGetter("connectorId") 28 | public String getConnectorId() { 29 | return connectorId; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ExternalStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import org.boostscale.velox4j.jni.CppObject; 17 | 18 | public interface ExternalStream extends CppObject {} 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ExternalStreamConnectorSplit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonGetter; 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | public class ExternalStreamConnectorSplit extends ConnectorSplit { 21 | private final long esId; 22 | 23 | @JsonCreator 24 | public ExternalStreamConnectorSplit( 25 | @JsonProperty("connectorId") String connectorId, @JsonProperty("esId") long esId) { 26 | super(connectorId, 0, false); 27 | this.esId = esId; 28 | } 29 | 30 | @JsonGetter("esId") 31 | public long getEsId() { 32 | return esId; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/ExternalStreamTableHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonProperty; 18 | 19 | public class ExternalStreamTableHandle extends ConnectorTableHandle { 20 | @JsonCreator 21 | public ExternalStreamTableHandle(@JsonProperty("connectorId") String connectorId) { 22 | super(connectorId); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/FileFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum FileFormat { 19 | UNKNOWN("unknown"), 20 | DWRF("dwrf"), 21 | RC("rc"), 22 | RC_TEXT("rc:text"), 23 | RC_BINARY("rc:binary"), 24 | TEXT("text"), 25 | JSON("json"), 26 | PARQUET("parquet"), 27 | NIMBLE("nimble"), 28 | ORC("orc"), 29 | SST("sst"); 30 | 31 | private final String value; 32 | 33 | FileFormat(String value) { 34 | this.value = value; 35 | } 36 | 37 | @JsonValue 38 | public String toValue() { 39 | return value; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/FileNameGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import org.boostscale.velox4j.serializable.ISerializable; 17 | 18 | public abstract class FileNameGenerator extends ISerializable { 19 | protected FileNameGenerator() {} 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/FileProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class FileProperties implements Serializable { 24 | private final Long fileSize; 25 | private final Long modificationTime; 26 | 27 | @JsonCreator 28 | public FileProperties( 29 | @JsonProperty("fileSize") Long fileSize, 30 | @JsonProperty("modificationTime") Long modificationTime) { 31 | this.fileSize = fileSize; 32 | this.modificationTime = modificationTime; 33 | } 34 | 35 | @JsonInclude(JsonInclude.Include.ALWAYS) 36 | @JsonGetter("fileSize") 37 | public Long getFileSize() { 38 | return fileSize; 39 | } 40 | 41 | @JsonInclude(JsonInclude.Include.ALWAYS) 42 | @JsonGetter("modificationTime") 43 | public Long getModificationTime() { 44 | return modificationTime; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/HiveBucketConversion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import java.io.Serializable; 17 | import java.util.List; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | public class HiveBucketConversion implements Serializable { 23 | private final int tableBucketCount; 24 | private final int partitionBucketCount; 25 | private final List bucketColumnHandles; 26 | 27 | @JsonCreator 28 | public HiveBucketConversion( 29 | @JsonProperty("tableBucketCount") int tableBucketCount, 30 | @JsonProperty("partitionBucketCount") int partitionBucketCount, 31 | @JsonProperty("bucketColumnHandles") List bucketColumnHandles) { 32 | this.tableBucketCount = tableBucketCount; 33 | this.partitionBucketCount = partitionBucketCount; 34 | this.bucketColumnHandles = bucketColumnHandles; 35 | } 36 | 37 | @JsonProperty("tableBucketCount") 38 | public int getTableBucketCount() { 39 | return tableBucketCount; 40 | } 41 | 42 | @JsonProperty("partitionBucketCount") 43 | public int getPartitionBucketCount() { 44 | return partitionBucketCount; 45 | } 46 | 47 | @JsonProperty("bucketColumnHandles") 48 | public List getBucketColumnHandles() { 49 | return bucketColumnHandles; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/HiveInsertFileNameGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | 18 | public class HiveInsertFileNameGenerator extends FileNameGenerator { 19 | @JsonCreator 20 | public HiveInsertFileNameGenerator() {} 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/HiveSortingColumn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonGetter; 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | import org.boostscale.velox4j.serializable.ISerializable; 21 | import org.boostscale.velox4j.sort.SortOrder; 22 | 23 | public class HiveSortingColumn extends ISerializable { 24 | private final String sortColumn; 25 | private final SortOrder sortOrder; 26 | 27 | @JsonCreator 28 | public HiveSortingColumn( 29 | @JsonProperty("columnName") String sortColumn, 30 | @JsonProperty("sortOrder") SortOrder sortOrder) { 31 | this.sortColumn = sortColumn; 32 | this.sortOrder = sortOrder; 33 | } 34 | 35 | @JsonGetter("columnName") 36 | public String getSortColumn() { 37 | return sortColumn; 38 | } 39 | 40 | @JsonGetter("sortOrder") 41 | public SortOrder getSortOrder() { 42 | return sortOrder; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/InsertTableHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | public class InsertTableHandle implements Serializable { 23 | private final String connectorId; 24 | private final ConnectorInsertTableHandle connectorInsertTableHandle; 25 | 26 | @JsonCreator 27 | public InsertTableHandle( 28 | @JsonProperty("connectorId") String connectorId, 29 | @JsonProperty("connectorInsertTableHandle") 30 | ConnectorInsertTableHandle connectorInsertTableHandle) { 31 | this.connectorId = connectorId; 32 | this.connectorInsertTableHandle = connectorInsertTableHandle; 33 | } 34 | 35 | @JsonGetter("connectorId") 36 | public String getConnectorId() { 37 | return connectorId; 38 | } 39 | 40 | @JsonGetter("connectorInsertTableHandle") 41 | public ConnectorInsertTableHandle connectorInsertTableHandle() { 42 | return connectorInsertTableHandle; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/RowIdProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | import com.google.common.base.Preconditions; 22 | 23 | public class RowIdProperties implements Serializable { 24 | private final long metadataVersion; 25 | private final long partitionId; 26 | private final String tableGuid; 27 | 28 | @JsonCreator 29 | public RowIdProperties( 30 | @JsonProperty("metadataVersion") long metadataVersion, 31 | @JsonProperty("partitionId") long partitionId, 32 | @JsonProperty("tableGuid") String tableGuid) { 33 | this.metadataVersion = metadataVersion; 34 | this.partitionId = partitionId; 35 | this.tableGuid = Preconditions.checkNotNull(tableGuid); 36 | } 37 | 38 | @JsonGetter("metadataVersion") 39 | public long getMetadataVersion() { 40 | return metadataVersion; 41 | } 42 | 43 | @JsonGetter("partitionId") 44 | public long getPartitionId() { 45 | return partitionId; 46 | } 47 | 48 | @JsonGetter("tableGuid") 49 | public String getTableGuid() { 50 | return tableGuid; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/connector/SubfieldFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.connector; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import org.boostscale.velox4j.filter.Filter; 23 | 24 | public class SubfieldFilter implements Serializable { 25 | private final String subfield; 26 | private final Filter filter; 27 | 28 | @JsonCreator 29 | public SubfieldFilter( 30 | @JsonProperty("subfield") String subfield, @JsonProperty("filter") Filter filter) { 31 | this.subfield = subfield; 32 | this.filter = filter; 33 | } 34 | 35 | @JsonGetter("subfield") 36 | public String getSubfield() { 37 | return subfield; 38 | } 39 | 40 | @JsonGetter("filter") 41 | public Filter getFilter() { 42 | return filter; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/data/RowVector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.data; 15 | 16 | import org.apache.arrow.memory.BufferAllocator; 17 | import org.apache.arrow.vector.VectorSchemaRoot; 18 | 19 | import org.boostscale.velox4j.arrow.Arrow; 20 | import org.boostscale.velox4j.jni.JniApi; 21 | 22 | public class RowVector extends BaseVector { 23 | protected RowVector(JniApi jniApi, long id) { 24 | super(jniApi, id, VectorEncoding.ROW); 25 | } 26 | 27 | @Override 28 | public String toString(BufferAllocator alloc) { 29 | try (final VectorSchemaRoot vsr = Arrow.toArrowVectorSchemaRoot(alloc, this)) { 30 | return vsr.contentToTSVString(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/data/RowVectors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.data; 15 | 16 | import java.util.List; 17 | 18 | import org.boostscale.velox4j.jni.JniApi; 19 | 20 | public class RowVectors { 21 | private final JniApi jniApi; 22 | 23 | public RowVectors(JniApi jniApi) { 24 | this.jniApi = jniApi; 25 | } 26 | 27 | /** 28 | * Partitions the input RowVector into a list of RowVectors where each one has the same keys 29 | * defined by the key indices of `keyChannels`. 30 | */ 31 | public List partitionByKeys(RowVector rowVector, List keyChannels) { 32 | return jniApi.rowVectorPartitionByKeys(rowVector, keyChannels); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/data/SelectivityVector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.data; 15 | 16 | import org.boostscale.velox4j.jni.CppObject; 17 | import org.boostscale.velox4j.jni.StaticJniApi; 18 | 19 | public class SelectivityVector implements CppObject { 20 | private final long id; 21 | 22 | public SelectivityVector(long id) { 23 | this.id = id; 24 | } 25 | 26 | @Override 27 | public long id() { 28 | return id; 29 | } 30 | 31 | public boolean isValid(int idx) { 32 | return StaticJniApi.get().selectivityVectorIsValid(this, idx); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/data/SelectivityVectors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.data; 15 | 16 | import org.boostscale.velox4j.jni.JniApi; 17 | 18 | public class SelectivityVectors { 19 | private final JniApi jniApi; 20 | 21 | public SelectivityVectors(JniApi jniApi) { 22 | this.jniApi = jniApi; 23 | } 24 | 25 | /** Creates an empty selectivity vector with the given length where all bits are available. */ 26 | public SelectivityVector create(int length) { 27 | return jniApi.createSelectivityVector(length); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/data/VectorEncoding.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.data; 15 | 16 | public enum VectorEncoding { 17 | BIASED, 18 | CONSTANT, 19 | DICTIONARY, 20 | FLAT, 21 | SEQUENCE, 22 | ROW, 23 | MAP, 24 | ARRAY, 25 | LAZY, 26 | FUNCTION; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/eval/Evaluation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.eval; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonGetter; 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | import org.boostscale.velox4j.config.Config; 21 | import org.boostscale.velox4j.config.ConnectorConfig; 22 | import org.boostscale.velox4j.expression.TypedExpr; 23 | import org.boostscale.velox4j.serializable.ISerializable; 24 | 25 | public class Evaluation extends ISerializable { 26 | private final TypedExpr expr; 27 | private final Config queryConfig; 28 | private final ConnectorConfig connectorConfig; 29 | 30 | @JsonCreator 31 | public Evaluation( 32 | @JsonProperty("expr") TypedExpr expr, 33 | @JsonProperty("queryConfig") Config queryConfig, 34 | @JsonProperty("connectorConfig") ConnectorConfig connectorConfig) { 35 | this.expr = expr; 36 | this.queryConfig = queryConfig; 37 | this.connectorConfig = connectorConfig; 38 | } 39 | 40 | @JsonGetter("expr") 41 | public TypedExpr expr() { 42 | return expr; 43 | } 44 | 45 | @JsonGetter("queryConfig") 46 | public Config queryConfig() { 47 | return queryConfig; 48 | } 49 | 50 | @JsonGetter("connectorConfig") 51 | public ConnectorConfig connectorConfig() { 52 | return connectorConfig; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/eval/Evaluations.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.eval; 15 | 16 | import org.boostscale.velox4j.jni.JniApi; 17 | 18 | public class Evaluations { 19 | private final JniApi jniApi; 20 | 21 | public Evaluations(JniApi jniApi) { 22 | this.jniApi = jniApi; 23 | } 24 | 25 | public Evaluator createEvaluator(Evaluation evaluation) { 26 | return jniApi.createEvaluator(evaluation); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/eval/Evaluator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.eval; 15 | 16 | import org.boostscale.velox4j.data.BaseVector; 17 | import org.boostscale.velox4j.data.RowVector; 18 | import org.boostscale.velox4j.data.SelectivityVector; 19 | import org.boostscale.velox4j.jni.CppObject; 20 | import org.boostscale.velox4j.jni.JniApi; 21 | 22 | /** 23 | * An API to evaluate a Velox expression for a series of row-vector inputs. 24 | * 25 | *

There are no drivers created for evaluators, so it's user's job to invoke the `eval` API to do 26 | * the evaluation. 27 | */ 28 | public class Evaluator implements CppObject { 29 | private final JniApi jniApi; 30 | private final long id; 31 | 32 | public Evaluator(JniApi jniApi, long id) { 33 | this.jniApi = jniApi; 34 | this.id = id; 35 | } 36 | 37 | @Override 38 | public long id() { 39 | return id; 40 | } 41 | 42 | /** 43 | * Evaluate the expression with given row-vector input. 44 | * 45 | * @param sv A selection vector for evaluating only the selected rows. 46 | * @param input The input row-vector. 47 | * @return The resulted vector. 48 | */ 49 | public BaseVector eval(SelectivityVector sv, RowVector input) { 50 | return jniApi.evaluatorEval(this, sv, input); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/exception/ExceptionDescriber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.exception; 15 | 16 | import java.io.PrintWriter; 17 | import java.io.StringWriter; 18 | 19 | import org.boostscale.velox4j.jni.CalledFromNative; 20 | 21 | public class ExceptionDescriber { 22 | private ExceptionDescriber() {} 23 | 24 | @CalledFromNative 25 | static String describe(Throwable throwable) { 26 | StringWriter sw = new StringWriter(); 27 | PrintWriter pw = new PrintWriter(sw, true); 28 | throwable.printStackTrace(pw); 29 | return sw.getBuffer().toString(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/exception/VeloxException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.exception; 15 | 16 | public class VeloxException extends RuntimeException { 17 | public VeloxException() { 18 | super(); 19 | } 20 | 21 | public VeloxException(String message) { 22 | super(message); 23 | } 24 | 25 | public VeloxException(String message, Throwable cause) { 26 | super(message, cause); 27 | } 28 | 29 | public VeloxException(Throwable cause) { 30 | super(cause); 31 | } 32 | 33 | protected VeloxException( 34 | String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 35 | super(message, cause, enableSuppression, writableStackTrace); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/expression/CallTypedExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.expression; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import org.boostscale.velox4j.type.Type; 23 | 24 | public class CallTypedExpr extends TypedExpr { 25 | private final String functionName; 26 | 27 | @JsonCreator 28 | public CallTypedExpr( 29 | @JsonProperty("type") Type returnType, 30 | @JsonProperty("inputs") List inputs, 31 | @JsonProperty("functionName") String functionName) { 32 | super(returnType, inputs); 33 | this.functionName = functionName; 34 | } 35 | 36 | @JsonGetter("functionName") 37 | public String getFunctionName() { 38 | return functionName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/expression/CastTypedExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.expression; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonGetter; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | import com.google.common.base.Preconditions; 23 | 24 | import org.boostscale.velox4j.type.Type; 25 | 26 | public class CastTypedExpr extends TypedExpr { 27 | private final boolean isTryCast; 28 | 29 | @JsonCreator 30 | private CastTypedExpr( 31 | @JsonProperty("type") Type returnType, 32 | @JsonProperty("inputs") List inputs, 33 | @JsonProperty("isTryCast") boolean isTryCast) { 34 | super(returnType, inputs); 35 | Preconditions.checkArgument( 36 | inputs.size() == 1, 37 | String.format("CastTypedExpr should have 1 input, but has %s", inputs.size())); 38 | this.isTryCast = isTryCast; 39 | } 40 | 41 | public static CastTypedExpr create(Type returnType, TypedExpr input, boolean isTryCast) { 42 | return new CastTypedExpr(returnType, Collections.singletonList(input), isTryCast); 43 | } 44 | 45 | @JsonGetter("isTryCast") 46 | public boolean isTryCast() { 47 | return isTryCast; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/expression/ConcatTypedExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.expression; 15 | 16 | import java.util.List; 17 | import java.util.stream.Collectors; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | import com.google.common.base.Preconditions; 22 | 23 | import org.boostscale.velox4j.type.RowType; 24 | import org.boostscale.velox4j.type.Type; 25 | 26 | public class ConcatTypedExpr extends TypedExpr { 27 | @JsonCreator 28 | private ConcatTypedExpr( 29 | @JsonProperty("type") Type returnType, @JsonProperty("inputs") List inputs) { 30 | super(returnType, inputs); 31 | Preconditions.checkArgument( 32 | returnType instanceof RowType, "ConcatTypedExpr returnType should be RowType"); 33 | } 34 | 35 | public static ConcatTypedExpr create(List names, List inputs) { 36 | Preconditions.checkArgument( 37 | names.size() == inputs.size(), 38 | "ConcatTypedExpr should have same number of names and inputs"); 39 | return new ConcatTypedExpr( 40 | new RowType( 41 | names, inputs.stream().map(TypedExpr::getReturnType).collect(Collectors.toList())), 42 | inputs); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/expression/InputTypedExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.expression; 15 | 16 | import java.util.Collections; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | import org.boostscale.velox4j.type.Type; 22 | 23 | public class InputTypedExpr extends TypedExpr { 24 | @JsonCreator 25 | public InputTypedExpr(@JsonProperty("type") Type returnType) { 26 | super(returnType, Collections.emptyList()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/expression/TypedExpr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.expression; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | 21 | import org.boostscale.velox4j.serializable.ISerializable; 22 | import org.boostscale.velox4j.type.Type; 23 | 24 | public abstract class TypedExpr extends ISerializable { 25 | private final Type returnType; 26 | private final List inputs; 27 | 28 | protected TypedExpr(Type returnType, List inputs) { 29 | this.returnType = returnType; 30 | this.inputs = inputs == null ? Collections.emptyList() : Collections.unmodifiableList(inputs); 31 | } 32 | 33 | @JsonGetter("type") 34 | public Type getReturnType() { 35 | return returnType; 36 | } 37 | 38 | @JsonGetter("inputs") 39 | public List getInputs() { 40 | return inputs; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/filter/AlwaysTrue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.filter; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | 18 | public class AlwaysTrue extends Filter { 19 | @JsonCreator 20 | public AlwaysTrue() { 21 | super(true, "kAlwaysTrue"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/filter/Filter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.filter; 15 | 16 | import com.fasterxml.jackson.annotation.JsonGetter; 17 | 18 | import org.boostscale.velox4j.serializable.ISerializable; 19 | 20 | public abstract class Filter extends ISerializable { 21 | private final boolean nullAllowed; 22 | private final String kind; 23 | 24 | protected Filter(boolean nullAllowed, String kind) { 25 | this.nullAllowed = nullAllowed; 26 | this.kind = kind; 27 | } 28 | 29 | @JsonGetter("nullAllowed") 30 | public boolean isNullAllowed() { 31 | return nullAllowed; 32 | } 33 | 34 | @JsonGetter("kind") 35 | public String getKind() { 36 | return kind; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/iterator/CloseableIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.iterator; 15 | 16 | import java.util.Iterator; 17 | 18 | public interface CloseableIterator extends Iterator, AutoCloseable {} 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/iterator/DownIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.iterator; 15 | 16 | import org.boostscale.velox4j.jni.CalledFromNative; 17 | 18 | /** 19 | * An ExternalStream that is backed by a down-iterator. What is down-iterator: A down-iterator is an 20 | * iterator passed From Java to C++ for Velox to read data from Java. 21 | */ 22 | public interface DownIterator { 23 | enum State { 24 | AVAILABLE(0), 25 | BLOCKED(1), 26 | FINISHED(2); 27 | 28 | private final int id; 29 | 30 | State(int id) { 31 | this.id = id; 32 | } 33 | 34 | public int getId() { 35 | return id; 36 | } 37 | } 38 | 39 | /** Gets the next state. */ 40 | @CalledFromNative 41 | int advance(); 42 | 43 | /** 44 | * Called once `advance` returns `BLOCKED` state to wait until the state gets refreshed, either by 45 | * the next row-vector is ready for reading or by end of stream. 46 | */ 47 | @CalledFromNative 48 | void waitFor() throws InterruptedException; 49 | 50 | /** Called to close the iterator. */ 51 | @CalledFromNative 52 | long get(); 53 | 54 | /** Closes the down-iterator. */ 55 | @CalledFromNative 56 | void close(); 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/iterator/GenericUpIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.iterator; 15 | 16 | import org.boostscale.velox4j.data.RowVector; 17 | import org.boostscale.velox4j.jni.JniApi; 18 | import org.boostscale.velox4j.jni.StaticJniApi; 19 | 20 | public class GenericUpIterator implements UpIterator { 21 | private final JniApi jniApi; 22 | private final long id; 23 | 24 | public GenericUpIterator(JniApi jniApi, long id) { 25 | this.jniApi = jniApi; 26 | this.id = id; 27 | } 28 | 29 | @Override 30 | public State advance() { 31 | return StaticJniApi.get().upIteratorAdvance(this); 32 | } 33 | 34 | @Override 35 | public void waitFor() { 36 | StaticJniApi.get().upIteratorWait(this); 37 | } 38 | 39 | @Override 40 | public RowVector get() { 41 | return jniApi.upIteratorGet(this); 42 | } 43 | 44 | @Override 45 | public long id() { 46 | return id; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/iterator/InfiniteIterator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.iterator; 15 | 16 | public interface InfiniteIterator extends AutoCloseable { 17 | boolean available(); 18 | 19 | void waitFor(); 20 | 21 | T get(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/jni/CalledFromNative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.jni; 15 | 16 | import java.lang.annotation.ElementType; 17 | import java.lang.annotation.Retention; 18 | import java.lang.annotation.RetentionPolicy; 19 | import java.lang.annotation.Target; 20 | 21 | /* 22 | * The methods marked by this annotation can be accessed from native code. 23 | */ 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Target(ElementType.METHOD) 26 | public @interface CalledFromNative {} 27 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/jni/CppObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.jni; 15 | 16 | /** 17 | * A CppObject is a Java-side representation of a C++ side object (usually managed by a C++ smart 18 | * pointer). 19 | */ 20 | public interface CppObject extends AutoCloseable { 21 | long id(); 22 | 23 | /** 24 | * Closes the associated C++ side object. In practice, this only releases the JNI reference of the 25 | * smart pointer that manages the C++ object. Hence, if there are other references alive in C++ 26 | * code, the object will not be immediately destroyed. 27 | */ 28 | @Override 29 | default void close() { 30 | StaticJniApi.get().releaseCppObject(this); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/join/JoinType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.join; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum JoinType { 19 | INNER("INNER"), 20 | LEFT("LEFT"), 21 | RIGHT("RIGHT"), 22 | FULL("FULL"), 23 | LEFT_SEMI_FILTER("LEFT SEMI (FILTER)"), 24 | RIGHT_SEMI_FILTER("RIGHT SEMI (FILTER)"), 25 | LEFT_SEMI_PROJECT("LEFT SEMI (PROJECT)"), 26 | RIGHT_SEMI_PROJECT("RIGHT SEMI (PROJECT)"), 27 | ANTI("ANTI"); 28 | 29 | private final String value; 30 | 31 | JoinType(String value) { 32 | this.value = value; 33 | } 34 | 35 | @JsonValue 36 | public String toValue() { 37 | return value; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/memory/AllocationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.memory; 15 | 16 | import org.boostscale.velox4j.jni.CalledFromNative; 17 | 18 | public interface AllocationListener { 19 | AllocationListener NOOP = new NoopAllocationListener(); 20 | 21 | @CalledFromNative 22 | void allocationChanged(long diff); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/memory/BytesAllocationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.memory; 15 | 16 | import java.util.concurrent.atomic.AtomicLong; 17 | 18 | /** An allocation listener that accumulates the allocated bytes with an internal counter. */ 19 | public class BytesAllocationListener implements AllocationListener { 20 | private final AtomicLong currentBytes = new AtomicLong(0); 21 | private final AtomicLong peakBytes = new AtomicLong(0); 22 | 23 | public BytesAllocationListener() {} 24 | 25 | @Override 26 | public void allocationChanged(long diff) { 27 | long current = currentBytes.addAndGet(diff); 28 | peakBytes.getAndUpdate(prevPeak -> Math.max(prevPeak, current)); 29 | } 30 | 31 | public long currentBytes() { 32 | return currentBytes.get(); 33 | } 34 | 35 | public long peakBytes() { 36 | return peakBytes.get(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/memory/MemoryManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.memory; 15 | 16 | import org.boostscale.velox4j.jni.CppObject; 17 | 18 | /** 19 | * A memory manager for Velox4J. One memory manager can be bound to different Velox4J sessions or to 20 | * only one session per user's need. 21 | * 22 | *

MemoryManager should be closed after use, as it's a CppObject. Once being closed, a memory 23 | * leakage check will be performed, that says, all the sessions that are managed by this memory 24 | * manager should be gracefully released (by calling Session#close) then this memory manager can be 25 | * closed without any leakage. Error will be thrown otherwise. 26 | */ 27 | public class MemoryManager implements CppObject { 28 | private final long id; 29 | 30 | public MemoryManager(long id) { 31 | this.id = id; 32 | } 33 | 34 | @Override 35 | public long id() { 36 | return id; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/memory/NoopAllocationListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.memory; 15 | 16 | public class NoopAllocationListener implements AllocationListener { 17 | NoopAllocationListener() {} 18 | 19 | @Override 20 | public void allocationChanged(long diff) {} 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/plan/FilterNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.plan; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import org.boostscale.velox4j.expression.TypedExpr; 23 | 24 | public class FilterNode extends PlanNode { 25 | private final List sources; 26 | private final TypedExpr filter; 27 | 28 | @JsonCreator 29 | public FilterNode( 30 | @JsonProperty("id") String id, 31 | @JsonProperty("sources") List sources, 32 | @JsonProperty("filter") TypedExpr filter) { 33 | super(id); 34 | this.sources = sources; 35 | this.filter = filter; 36 | } 37 | 38 | @Override 39 | protected List getSources() { 40 | return sources; 41 | } 42 | 43 | @JsonGetter("filter") 44 | public TypedExpr getFilter() { 45 | return filter; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/plan/LimitNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.plan; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | public class LimitNode extends PlanNode { 23 | private final List sources; 24 | private final long offset; 25 | private final long count; 26 | private final boolean partial; 27 | 28 | @JsonCreator 29 | public LimitNode( 30 | @JsonProperty("id") String id, 31 | @JsonProperty("sources") List sources, 32 | @JsonProperty("offset") long offset, 33 | @JsonProperty("count") long count, 34 | @JsonProperty("partial") boolean partial) { 35 | super(id); 36 | this.sources = sources; 37 | this.offset = offset; 38 | this.count = count; 39 | this.partial = partial; 40 | } 41 | 42 | @Override 43 | protected List getSources() { 44 | return sources; 45 | } 46 | 47 | @JsonGetter("offset") 48 | public long getOffset() { 49 | return offset; 50 | } 51 | 52 | @JsonGetter("count") 53 | public long getCount() { 54 | return count; 55 | } 56 | 57 | @JsonGetter("partial") 58 | public boolean isPartial() { 59 | return partial; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/plan/PlanNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.plan; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonGetter; 19 | import com.fasterxml.jackson.annotation.JsonInclude; 20 | 21 | import org.boostscale.velox4j.serializable.ISerializable; 22 | 23 | public abstract class PlanNode extends ISerializable { 24 | private final String id; 25 | 26 | protected PlanNode(String id) { 27 | this.id = id; 28 | } 29 | 30 | @JsonGetter("id") 31 | public String getId() { 32 | return id; 33 | } 34 | 35 | @JsonInclude(JsonInclude.Include.NON_EMPTY) 36 | @JsonGetter("sources") 37 | protected abstract List getSources(); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/plan/ProjectNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.plan; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import org.boostscale.velox4j.expression.TypedExpr; 23 | 24 | public class ProjectNode extends PlanNode { 25 | private final List sources; 26 | private final List names; 27 | private final List projections; 28 | 29 | @JsonCreator 30 | public ProjectNode( 31 | @JsonProperty("id") String id, 32 | @JsonProperty("sources") List sources, 33 | @JsonProperty("names") List names, 34 | @JsonProperty("projections") List projections) { 35 | super(id); 36 | this.sources = sources; 37 | this.names = names; 38 | this.projections = projections; 39 | } 40 | 41 | @Override 42 | protected List getSources() { 43 | return sources; 44 | } 45 | 46 | @JsonGetter("names") 47 | public List getNames() { 48 | return names; 49 | } 50 | 51 | @JsonGetter("projections") 52 | public List getProjections() { 53 | return projections; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/query/Queries.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.query; 15 | 16 | import org.boostscale.velox4j.jni.JniApi; 17 | 18 | public class Queries { 19 | private final JniApi jniApi; 20 | 21 | public Queries(JniApi jniApi) { 22 | this.jniApi = jniApi; 23 | } 24 | 25 | public SerialTask execute(Query query) { 26 | try (final QueryExecutor exec = jniApi.createQueryExecutor(query)) { 27 | return exec.execute(); 28 | } 29 | } 30 | 31 | public QueryExecutor createQueryExecutor(Query query) { 32 | return jniApi.createQueryExecutor(query); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/query/Query.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.query; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonGetter; 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | import org.boostscale.velox4j.config.Config; 21 | import org.boostscale.velox4j.config.ConnectorConfig; 22 | import org.boostscale.velox4j.plan.PlanNode; 23 | import org.boostscale.velox4j.serializable.ISerializable; 24 | 25 | public class Query extends ISerializable { 26 | private final PlanNode plan; 27 | private final Config queryConfig; 28 | private final ConnectorConfig connectorConfig; 29 | 30 | @JsonCreator 31 | public Query( 32 | @JsonProperty("plan") PlanNode plan, 33 | @JsonProperty("queryConfig") Config queryConfig, 34 | @JsonProperty("connectorConfig") ConnectorConfig connectorConfig) { 35 | this.plan = plan; 36 | this.queryConfig = queryConfig; 37 | this.connectorConfig = connectorConfig; 38 | } 39 | 40 | @JsonGetter("plan") 41 | public PlanNode getPlan() { 42 | return plan; 43 | } 44 | 45 | @JsonGetter("queryConfig") 46 | public Config getQueryConfig() { 47 | return queryConfig; 48 | } 49 | 50 | @JsonGetter("connectorConfig") 51 | public ConnectorConfig getConnectorConfig() { 52 | return connectorConfig; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/query/QueryExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.query; 15 | 16 | import org.boostscale.velox4j.jni.CppObject; 17 | import org.boostscale.velox4j.jni.JniApi; 18 | 19 | /** An API for executing a Velox query plan. */ 20 | public class QueryExecutor implements CppObject { 21 | private final JniApi jniApi; 22 | private final long id; 23 | 24 | public QueryExecutor(JniApi jniApi, long id) { 25 | this.jniApi = jniApi; 26 | this.id = id; 27 | } 28 | 29 | @Override 30 | public long id() { 31 | return id; 32 | } 33 | 34 | public SerialTask execute() { 35 | return jniApi.queryExecutorExecute(this); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/query/SerialTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.query; 15 | 16 | import org.boostscale.velox4j.connector.ConnectorSplit; 17 | import org.boostscale.velox4j.data.RowVector; 18 | import org.boostscale.velox4j.iterator.UpIterator; 19 | import org.boostscale.velox4j.jni.JniApi; 20 | import org.boostscale.velox4j.jni.StaticJniApi; 21 | 22 | /** 23 | * An up-iterator implementation that is backed by a Velox task that runs in serial execution mode. 24 | */ 25 | public class SerialTask implements UpIterator { 26 | private final JniApi jniApi; 27 | private final long id; 28 | 29 | public SerialTask(JniApi jniApi, long id) { 30 | this.jniApi = jniApi; 31 | this.id = id; 32 | } 33 | 34 | @Override 35 | public State advance() { 36 | return StaticJniApi.get().upIteratorAdvance(this); 37 | } 38 | 39 | @Override 40 | public void waitFor() { 41 | StaticJniApi.get().upIteratorWait(this); 42 | } 43 | 44 | @Override 45 | public RowVector get() { 46 | return jniApi.upIteratorGet(this); 47 | } 48 | 49 | @Override 50 | public long id() { 51 | return id; 52 | } 53 | 54 | public void addSplit(String planNodeId, ConnectorSplit split) { 55 | StaticJniApi.get().serialTaskAddSplit(this, planNodeId, -1, split); 56 | } 57 | 58 | public void noMoreSplits(String planNodeId) { 59 | StaticJniApi.get().serialTaskNoMoreSplits(this, planNodeId); 60 | } 61 | 62 | public SerialTaskStats collectStats() { 63 | return StaticJniApi.get().serialTaskCollectStats(this); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/resource/PlainResourceFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.resource; 15 | 16 | import java.io.File; 17 | 18 | public class PlainResourceFile implements ResourceFile { 19 | private final String container; 20 | private final String name; 21 | 22 | PlainResourceFile(String container, String name) { 23 | this.container = container; 24 | this.name = name; 25 | } 26 | 27 | @Override 28 | public String container() { 29 | return container; 30 | } 31 | 32 | @Override 33 | public String name() { 34 | return name; 35 | } 36 | 37 | @Override 38 | public void copyTo(File file) { 39 | Resources.copyResource(container + File.separator + name, file); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/resource/ResourceFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.resource; 15 | 16 | import java.io.File; 17 | 18 | /** Represents a virtual file view of a resource file found in classpath. */ 19 | public interface ResourceFile { 20 | String container(); 21 | 22 | String name(); 23 | 24 | void copyTo(File file); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/serde/NativeBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serde; 15 | 16 | /** 17 | * A native bean can be serialized to JSON then be read by C++ code to be deserialized into a C++ 18 | * object. 19 | */ 20 | public interface NativeBean {} 21 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/serializable/ISerializable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serializable; 15 | 16 | import java.io.Serializable; 17 | 18 | import org.boostscale.velox4j.serde.NativeBean; 19 | 20 | /** 21 | * Java binding of Velox's ISerializable API. A ISerializable can be serialized to JSON and 22 | * deserialized from JSON. 23 | */ 24 | public abstract class ISerializable implements NativeBean, Serializable { 25 | protected ISerializable() {} 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/serializable/ISerializableCo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serializable; 15 | 16 | import org.boostscale.velox4j.jni.CppObject; 17 | import org.boostscale.velox4j.jni.StaticJniApi; 18 | 19 | /** Binds a CPP ISerializable object. */ 20 | public class ISerializableCo implements CppObject { 21 | private final long id; 22 | 23 | public ISerializableCo(long id) { 24 | this.id = id; 25 | } 26 | 27 | @Override 28 | public long id() { 29 | return id; 30 | } 31 | 32 | public ISerializable asJava() { 33 | return StaticJniApi.get().iSerializableAsJava(this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/serializable/ISerializables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serializable; 15 | 16 | import org.boostscale.velox4j.jni.JniApi; 17 | 18 | public class ISerializables { 19 | private final JniApi jniApi; 20 | 21 | public ISerializables(JniApi jniApi) { 22 | this.jniApi = jniApi; 23 | } 24 | 25 | public ISerializableCo asCpp(ISerializable iSerializable) { 26 | return jniApi.iSerializableAsCpp(iSerializable); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/sort/SortOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.sort; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | 21 | public class SortOrder implements Serializable { 22 | private final boolean ascending; 23 | private final boolean nullsFirst; 24 | 25 | @JsonCreator 26 | public SortOrder( 27 | @JsonProperty("ascending") boolean ascending, 28 | @JsonProperty("nullsFirst") boolean nullsFirst) { 29 | this.ascending = ascending; 30 | this.nullsFirst = nullsFirst; 31 | } 32 | 33 | @JsonProperty("ascending") 34 | public boolean isAscending() { 35 | return ascending; 36 | } 37 | 38 | @JsonProperty("nullsFirst") 39 | public boolean isNullsFirst() { 40 | return nullsFirst; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/ArrayType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonGetter; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | import com.google.common.base.Preconditions; 23 | 24 | public class ArrayType extends Type { 25 | private final List children; 26 | 27 | @JsonCreator 28 | private ArrayType(@JsonProperty("cTypes") List children) { 29 | Preconditions.checkArgument( 30 | children.size() == 1, 31 | String.format("ArrayType should have 1 child, but has %s", children.size())); 32 | this.children = children; 33 | } 34 | 35 | public static ArrayType create(Type child) { 36 | return new ArrayType(Collections.singletonList(child)); 37 | } 38 | 39 | @JsonGetter("cTypes") 40 | public List getChildren() { 41 | return children; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/BigIntType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class BigIntType extends Type { 17 | public BigIntType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/BooleanType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class BooleanType extends Type { 17 | public BooleanType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/DateType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class DateType extends Type {} 17 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/DecimalType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonGetter; 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | public class DecimalType extends Type { 21 | private final int precision; 22 | private final int scale; 23 | 24 | @JsonCreator 25 | public DecimalType(@JsonProperty("precision") int precision, @JsonProperty("scale") int scale) { 26 | this.precision = precision; 27 | this.scale = scale; 28 | } 29 | 30 | @JsonGetter("precision") 31 | public int getPrecision() { 32 | return precision; 33 | } 34 | 35 | @JsonGetter("scale") 36 | public int getScale() { 37 | return scale; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/DoubleType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class DoubleType extends Type { 17 | public DoubleType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/FunctionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonGetter; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class FunctionType extends Type { 24 | private final List children; 25 | 26 | @JsonCreator 27 | private FunctionType(@JsonProperty("cTypes") List children) { 28 | this.children = children; 29 | } 30 | 31 | public static FunctionType create(List argumentTypes, Type returnType) { 32 | final List mergedTypes = new ArrayList<>(argumentTypes); 33 | mergedTypes.add(returnType); 34 | return new FunctionType(mergedTypes); 35 | } 36 | 37 | @JsonGetter("cTypes") 38 | public List getChildren() { 39 | return children; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/HugeIntType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class HugeIntType extends Type { 17 | public HugeIntType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/IntegerType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class IntegerType extends Type { 17 | public IntegerType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/IntervalDayTimeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class IntervalDayTimeType extends Type { 17 | public IntervalDayTimeType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/IntervalYearMonthType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class IntervalYearMonthType extends Type { 17 | public IntervalYearMonthType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/MapType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | import com.google.common.base.Preconditions; 22 | import com.google.common.collect.ImmutableList; 23 | 24 | public class MapType extends Type { 25 | private final List children; 26 | 27 | @JsonCreator 28 | private MapType(@JsonProperty("cTypes") List children) { 29 | Preconditions.checkArgument( 30 | children.size() == 2, 31 | String.format("MapType should have 2 children, but has %s", children.size())); 32 | this.children = children; 33 | } 34 | 35 | public static MapType create(Type keyType, Type valueType) { 36 | return new MapType(ImmutableList.of(keyType, valueType)); 37 | } 38 | 39 | @JsonGetter("cTypes") 40 | public List getChildren() { 41 | return children; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/OpaqueType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import com.fasterxml.jackson.annotation.JsonCreator; 17 | import com.fasterxml.jackson.annotation.JsonGetter; 18 | import com.fasterxml.jackson.annotation.JsonProperty; 19 | 20 | public class OpaqueType extends Type { 21 | private final String opaque; 22 | 23 | @JsonCreator 24 | public OpaqueType(@JsonProperty("opaque") String opaque) { 25 | this.opaque = opaque; 26 | } 27 | 28 | @JsonGetter("opaque") 29 | public String getOpaque() { 30 | return opaque; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/RealType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class RealType extends Type { 17 | public RealType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/RowType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | import com.google.common.base.Preconditions; 21 | 22 | import org.boostscale.velox4j.exception.VeloxException; 23 | 24 | public class RowType extends Type { 25 | private final List names; 26 | private final List children; 27 | 28 | @JsonCreator 29 | public RowType( 30 | @JsonProperty("names") List names, @JsonProperty("cTypes") List children) { 31 | Preconditions.checkArgument( 32 | names.size() == children.size(), "RowType should have same number of names and children"); 33 | this.names = names; 34 | this.children = children; 35 | } 36 | 37 | @JsonProperty("names") 38 | public List getNames() { 39 | return names; 40 | } 41 | 42 | @JsonProperty("cTypes") 43 | public List getChildren() { 44 | return children; 45 | } 46 | 47 | public int size() { 48 | return names.size(); 49 | } 50 | 51 | public Type findChild(String name) { 52 | int index = names.indexOf(name); 53 | if (index == -1) { 54 | throw new VeloxException("Field " + name + " not found in RowType"); 55 | } 56 | return children.get(index); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/SmallIntType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class SmallIntType extends Type { 17 | public SmallIntType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/TimestampType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class TimestampType extends Type { 17 | public TimestampType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/TinyIntType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class TinyIntType extends Type { 17 | public TinyIntType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | import org.boostscale.velox4j.serializable.ISerializable; 17 | 18 | public abstract class Type extends ISerializable {} 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/UnknownType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class UnknownType extends Type {} 17 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/VarCharType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class VarCharType extends Type { 17 | public VarCharType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/type/VarbinaryType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.type; 15 | 16 | public class VarbinaryType extends Type { 17 | public VarbinaryType() {} 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/ArrayValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | import java.util.Objects; 19 | 20 | import com.fasterxml.jackson.annotation.JsonCreator; 21 | import com.fasterxml.jackson.annotation.JsonGetter; 22 | import com.fasterxml.jackson.annotation.JsonInclude; 23 | import com.fasterxml.jackson.annotation.JsonProperty; 24 | 25 | public class ArrayValue extends Variant { 26 | private final List array; 27 | 28 | @JsonCreator 29 | public ArrayValue(@JsonProperty("value") List array) { 30 | if (array == null) { 31 | this.array = null; 32 | return; 33 | } 34 | Variants.checkSameType(array); 35 | this.array = Collections.unmodifiableList(array); 36 | } 37 | 38 | @JsonInclude(JsonInclude.Include.ALWAYS) 39 | @JsonGetter("value") 40 | public List getArray() { 41 | return array; 42 | } 43 | 44 | @Override 45 | public boolean equals(Object o) { 46 | if (this == o) return true; 47 | if (o == null || getClass() != o.getClass()) return false; 48 | ArrayValue that = (ArrayValue) o; 49 | return Objects.equals(array, that.array); 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | return Objects.hashCode(array); 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "ArrayValue{" + "array=" + array + '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/BigIntValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class BigIntValue extends Variant { 24 | private final Long value; 25 | 26 | @JsonCreator 27 | public BigIntValue(@JsonProperty("value") Long value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public Long getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | BigIntValue that = (BigIntValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "BigIntValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/BooleanValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class BooleanValue extends Variant { 24 | private final Boolean value; 25 | 26 | @JsonCreator 27 | public BooleanValue(@JsonProperty("value") Boolean value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonGetter("value") 32 | @JsonInclude(JsonInclude.Include.ALWAYS) 33 | public Boolean getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | BooleanValue that = (BooleanValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "BooleanValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/DoubleValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class DoubleValue extends Variant { 24 | private final Double value; 25 | 26 | @JsonCreator 27 | public DoubleValue(@JsonProperty("value") Double value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public Double getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | DoubleValue that = (DoubleValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "DoubleValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/HugeIntValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.math.BigInteger; 17 | import java.util.Objects; 18 | 19 | import com.fasterxml.jackson.annotation.JsonCreator; 20 | import com.fasterxml.jackson.annotation.JsonGetter; 21 | import com.fasterxml.jackson.annotation.JsonInclude; 22 | import com.fasterxml.jackson.annotation.JsonProperty; 23 | 24 | public class HugeIntValue extends Variant { 25 | private final BigInteger value; 26 | 27 | @JsonCreator 28 | public HugeIntValue(@JsonProperty("value") BigInteger value) { 29 | this.value = value; 30 | } 31 | 32 | @JsonInclude(JsonInclude.Include.ALWAYS) 33 | @JsonGetter("value") 34 | public BigInteger getValue() { 35 | return value; 36 | } 37 | 38 | @Override 39 | public boolean equals(Object o) { 40 | if (this == o) return true; 41 | if (o == null || getClass() != o.getClass()) return false; 42 | HugeIntValue that = (HugeIntValue) o; 43 | return Objects.equals(value, that.value); 44 | } 45 | 46 | @Override 47 | public int hashCode() { 48 | return Objects.hashCode(value); 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "HugeIntValue{" + "value=" + value + '}'; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/IntegerValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class IntegerValue extends Variant { 24 | private final Integer value; 25 | 26 | @JsonCreator 27 | public IntegerValue(@JsonProperty("value") Integer value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public Integer getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | IntegerValue that = (IntegerValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "IntegerValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/RealValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class RealValue extends Variant { 24 | private final Float value; 25 | 26 | @JsonCreator 27 | public RealValue(@JsonProperty("value") Float value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public Float getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | RealValue realValue = (RealValue) o; 42 | return Objects.equals(value, realValue.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "RealValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/RowValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Collections; 17 | import java.util.List; 18 | import java.util.Objects; 19 | 20 | import com.fasterxml.jackson.annotation.JsonCreator; 21 | import com.fasterxml.jackson.annotation.JsonGetter; 22 | import com.fasterxml.jackson.annotation.JsonInclude; 23 | import com.fasterxml.jackson.annotation.JsonProperty; 24 | 25 | public class RowValue extends Variant { 26 | private final List row; 27 | 28 | @JsonCreator 29 | public RowValue(@JsonProperty("value") List row) { 30 | if (row == null) { 31 | this.row = null; 32 | return; 33 | } 34 | this.row = Collections.unmodifiableList(row); 35 | } 36 | 37 | @JsonInclude(JsonInclude.Include.ALWAYS) 38 | @JsonGetter("value") 39 | public List getRow() { 40 | return row; 41 | } 42 | 43 | @Override 44 | public boolean equals(Object o) { 45 | if (this == o) return true; 46 | if (o == null || getClass() != o.getClass()) return false; 47 | RowValue rowValue = (RowValue) o; 48 | return Objects.equals(row, rowValue.row); 49 | } 50 | 51 | @Override 52 | public int hashCode() { 53 | return Objects.hashCode(row); 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "RowValue{" + "row=" + row + '}'; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/SmallIntValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class SmallIntValue extends Variant { 24 | private final Integer value; 25 | 26 | @JsonCreator 27 | public SmallIntValue(@JsonProperty("value") Integer value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public Integer getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | SmallIntValue that = (SmallIntValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "SmallIntValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/TinyIntValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class TinyIntValue extends Variant { 24 | private final Integer value; 25 | 26 | @JsonCreator 27 | public TinyIntValue(@JsonProperty("value") Integer value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public Integer getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | TinyIntValue that = (TinyIntValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "TinyIntValue{" + "value=" + value + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/VarCharValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.Objects; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonProperty; 22 | 23 | public class VarCharValue extends Variant { 24 | private final String value; 25 | 26 | @JsonCreator 27 | public VarCharValue(@JsonProperty("value") String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonInclude(JsonInclude.Include.ALWAYS) 32 | @JsonGetter("value") 33 | public String getValue() { 34 | return value; 35 | } 36 | 37 | @Override 38 | public boolean equals(Object o) { 39 | if (this == o) return true; 40 | if (o == null || getClass() != o.getClass()) return false; 41 | VarCharValue that = (VarCharValue) o; 42 | return Objects.equals(value, that.value); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return Objects.hashCode(value); 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "VarCharValue{" + "value='" + value + '\'' + '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/Variant.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.io.Serializable; 17 | 18 | import org.boostscale.velox4j.serde.NativeBean; 19 | 20 | /** 21 | * Java binding of Velox's variant API. A Variant can be serialized to JSON and deserialized from 22 | * JSON. 23 | */ 24 | public abstract class Variant implements NativeBean, Serializable { 25 | @Override 26 | public abstract boolean equals(Object obj); 27 | 28 | @Override 29 | public abstract int hashCode(); 30 | 31 | @Override 32 | public abstract String toString(); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/VariantCo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import org.boostscale.velox4j.jni.CppObject; 17 | import org.boostscale.velox4j.jni.StaticJniApi; 18 | 19 | /** Binds a CPP variant object. */ 20 | public class VariantCo implements CppObject { 21 | private final long id; 22 | 23 | public VariantCo(long id) { 24 | this.id = id; 25 | } 26 | 27 | @Override 28 | public long id() { 29 | return id; 30 | } 31 | 32 | public Variant asJava() { 33 | return StaticJniApi.get().variantAsJava(this); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/VariantRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import org.boostscale.velox4j.serde.Serde; 17 | import org.boostscale.velox4j.serde.SerdeRegistry; 18 | import org.boostscale.velox4j.serde.SerdeRegistryFactory; 19 | 20 | public class VariantRegistry { 21 | private static final SerdeRegistry TYPE_REGISTRY = 22 | SerdeRegistryFactory.createForBaseClass(Variant.class).key("type"); 23 | 24 | private VariantRegistry() {} 25 | 26 | public static void registerAll() { 27 | Serde.registerBaseClass(Variant.class); 28 | TYPE_REGISTRY.registerClass("BOOLEAN", BooleanValue.class); 29 | TYPE_REGISTRY.registerClass("TINYINT", TinyIntValue.class); 30 | TYPE_REGISTRY.registerClass("SMALLINT", SmallIntValue.class); 31 | TYPE_REGISTRY.registerClass("INTEGER", IntegerValue.class); 32 | TYPE_REGISTRY.registerClass("BIGINT", BigIntValue.class); 33 | TYPE_REGISTRY.registerClass("HUGEINT", HugeIntValue.class); 34 | TYPE_REGISTRY.registerClass("REAL", RealValue.class); 35 | TYPE_REGISTRY.registerClass("DOUBLE", DoubleValue.class); 36 | TYPE_REGISTRY.registerClass("VARCHAR", VarCharValue.class); 37 | TYPE_REGISTRY.registerClass("VARBINARY", VarBinaryValue.class); 38 | TYPE_REGISTRY.registerClass("TIMESTAMP", TimestampValue.class); 39 | TYPE_REGISTRY.registerClass("ARRAY", ArrayValue.class); 40 | TYPE_REGISTRY.registerClass("MAP", MapValue.class); 41 | TYPE_REGISTRY.registerClass("ROW", RowValue.class); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/variant/Variants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.variant; 15 | 16 | import java.util.List; 17 | 18 | import org.boostscale.velox4j.data.BaseVector; 19 | import org.boostscale.velox4j.jni.JniApi; 20 | import org.boostscale.velox4j.jni.StaticJniApi; 21 | import org.boostscale.velox4j.type.Type; 22 | 23 | public class Variants { 24 | private final JniApi jniApi; 25 | 26 | public Variants(JniApi jniApi) { 27 | this.jniApi = jniApi; 28 | } 29 | 30 | public VariantCo asCpp(Variant variant) { 31 | return jniApi.variantAsCpp(variant); 32 | } 33 | 34 | public BaseVector toVector(Type type, Variant variant) { 35 | return jniApi.variantToVector(type, variant); 36 | } 37 | 38 | public Type inferType(Variant variant) { 39 | return StaticJniApi.get().variantInferType(variant); 40 | } 41 | 42 | public static void checkSameType(List variants) { 43 | if (variants.size() <= 1) { 44 | return; 45 | } 46 | for (int i = 1; i < variants.size(); i++) { 47 | if (variants.get(i).getClass() != variants.get(i - 1).getClass()) { 48 | throw new IllegalArgumentException("All variant values should have same type"); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/window/BoundType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.window; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum BoundType { 19 | UNBOUNDED_PRECEDING("UNBOUNDED PRECEDING"), 20 | PRECEDING("PRECEDING"), 21 | CURRENT_ROW("CURRENT ROW"), 22 | FOLLOWING("FOLLOWING"), 23 | UNBOUNDED_FOLLOWING("UNBOUNDED FOLLOWING"); 24 | 25 | private final String value; 26 | 27 | BoundType(String value) { 28 | this.value = value; 29 | } 30 | 31 | @JsonValue 32 | public String toValue() { 33 | return value; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/window/WindowFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.window; 15 | 16 | import java.io.Serializable; 17 | 18 | import com.fasterxml.jackson.annotation.JsonCreator; 19 | import com.fasterxml.jackson.annotation.JsonGetter; 20 | import com.fasterxml.jackson.annotation.JsonProperty; 21 | 22 | import org.boostscale.velox4j.expression.CallTypedExpr; 23 | 24 | public class WindowFunction implements Serializable { 25 | private final CallTypedExpr functionCall; 26 | private final WindowFrame frame; 27 | private final boolean ignoreNulls; 28 | 29 | @JsonCreator 30 | public WindowFunction( 31 | @JsonProperty("functionCall") CallTypedExpr functionCall, 32 | @JsonProperty("frame") WindowFrame frame, 33 | @JsonProperty("ignoreNulls") boolean ignoreNulls) { 34 | this.functionCall = functionCall; 35 | this.frame = frame; 36 | this.ignoreNulls = ignoreNulls; 37 | } 38 | 39 | @JsonGetter("functionCall") 40 | public CallTypedExpr getFunctionCall() { 41 | return functionCall; 42 | } 43 | 44 | @JsonGetter("frame") 45 | public WindowFrame getFrame() { 46 | return frame; 47 | } 48 | 49 | @JsonGetter("ignoreNulls") 50 | public boolean isIgnoreNulls() { 51 | return ignoreNulls; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/window/WindowType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.window; 15 | 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | public enum WindowType { 19 | RANGE("RANGE"), 20 | ROWS("ROWS"); 21 | 22 | private final String value; 23 | 24 | WindowType(String value) { 25 | this.value = value; 26 | } 27 | 28 | @JsonValue 29 | public String toValue() { 30 | return value; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/boostscale/velox4j/write/TableWriteTraits.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.write; 15 | 16 | import org.boostscale.velox4j.jni.JniApi; 17 | import org.boostscale.velox4j.jni.StaticJniApi; 18 | import org.boostscale.velox4j.type.RowType; 19 | 20 | public class TableWriteTraits { 21 | private final JniApi jniApi; 22 | 23 | public TableWriteTraits(JniApi jniApi) { 24 | this.jniApi = jniApi; 25 | } 26 | 27 | public static RowType outputType() { 28 | return StaticJniApi.get().tableWriteTraitsOutputType(); 29 | } 30 | 31 | public RowType outputType(ColumnStatsSpec columnStatsSpec) { 32 | return jniApi.tableWriteTraitsOutputTypeFromColumnStatsSpec(columnStatsSpec); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/data/SelectivityVectorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.data; 15 | 16 | import org.junit.*; 17 | 18 | import org.boostscale.velox4j.Velox4j; 19 | import org.boostscale.velox4j.memory.BytesAllocationListener; 20 | import org.boostscale.velox4j.memory.MemoryManager; 21 | import org.boostscale.velox4j.session.Session; 22 | import org.boostscale.velox4j.test.Velox4jTests; 23 | 24 | public class SelectivityVectorTest { 25 | private static BytesAllocationListener allocationListener; 26 | private static MemoryManager memoryManager; 27 | private static Session session; 28 | 29 | @BeforeClass 30 | public static void beforeClass() throws Exception { 31 | Velox4jTests.ensureInitialized(); 32 | allocationListener = new BytesAllocationListener(); 33 | memoryManager = Velox4j.newMemoryManager(allocationListener); 34 | } 35 | 36 | @AfterClass 37 | public static void afterClass() throws Exception { 38 | memoryManager.close(); 39 | Assert.assertEquals(0, allocationListener.currentBytes()); 40 | } 41 | 42 | @Before 43 | public void setUp() throws Exception { 44 | session = Velox4j.newSession(memoryManager); 45 | } 46 | 47 | @After 48 | public void tearDown() throws Exception { 49 | session.close(); 50 | } 51 | 52 | @Test 53 | public void testIsValid() { 54 | final int length = 10; 55 | final SelectivityVector sv = session.selectivityVectorOps().create(length); 56 | for (int i = 0; i < length; i++) { 57 | Assert.assertTrue(sv.isValid(i)); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/jni/JniApiTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.jni; 15 | 16 | import org.boostscale.velox4j.memory.MemoryManager; 17 | 18 | public final class JniApiTests { 19 | private JniApiTests() {} 20 | 21 | public static LocalSession createLocalSession(MemoryManager memoryManager) { 22 | return StaticJniApi.get().createSession(memoryManager); 23 | } 24 | 25 | public static JniApi getJniApi(LocalSession session) { 26 | final JniWrapper jniWrapper = new JniWrapper(session.id()); 27 | return new JniApi(jniWrapper); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/serde/ConfigSerdeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serde; 15 | 16 | import org.junit.BeforeClass; 17 | import org.junit.Test; 18 | 19 | import org.boostscale.velox4j.config.Config; 20 | import org.boostscale.velox4j.config.ConnectorConfig; 21 | import org.boostscale.velox4j.test.ConfigTests; 22 | import org.boostscale.velox4j.test.Velox4jTests; 23 | 24 | public class ConfigSerdeTest { 25 | @BeforeClass 26 | public static void beforeClass() { 27 | Velox4jTests.ensureInitialized(); 28 | } 29 | 30 | @Test 31 | public void testConfig() { 32 | final Config config = ConfigTests.randomConfig(); 33 | SerdeTests.testISerializableRoundTrip(config); 34 | } 35 | 36 | @Test 37 | public void testConnectorConfig() { 38 | final ConnectorConfig connConfig = ConfigTests.randomConnectorConfig(); 39 | SerdeTests.testISerializableRoundTrip(connConfig); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/serde/FilterSerdeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serde; 15 | 16 | import org.junit.BeforeClass; 17 | import org.junit.Test; 18 | 19 | import org.boostscale.velox4j.filter.AlwaysTrue; 20 | import org.boostscale.velox4j.test.Velox4jTests; 21 | 22 | public class FilterSerdeTest { 23 | 24 | @BeforeClass 25 | public static void beforeClass() throws Exception { 26 | Velox4jTests.ensureInitialized(); 27 | } 28 | 29 | @Test 30 | public void testAlwaysTrue() { 31 | SerdeTests.testISerializableRoundTrip(new AlwaysTrue()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/serde/QuerySerdeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.serde; 15 | 16 | import org.junit.BeforeClass; 17 | import org.junit.Ignore; 18 | 19 | import org.boostscale.velox4j.query.Query; 20 | import org.boostscale.velox4j.test.ResourceTests; 21 | import org.boostscale.velox4j.test.Velox4jTests; 22 | 23 | public class QuerySerdeTest { 24 | 25 | @BeforeClass 26 | public static void beforeClass() throws Exception { 27 | Velox4jTests.ensureInitialized(); 28 | } 29 | 30 | // Ignored by https://github.com/velox4j/velox4j/issues/104. 31 | @Ignore 32 | public void testReadPlanJsonFromFile() { 33 | final String queryJson = ResourceTests.readResourceAsString("query/example-1.json"); 34 | final Query query = Serde.fromJson(queryJson, Query.class); 35 | SerdeTests.testISerializableRoundTrip(query); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/ConfigTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test; 15 | 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | import java.util.UUID; 19 | 20 | import org.boostscale.velox4j.config.Config; 21 | import org.boostscale.velox4j.config.ConnectorConfig; 22 | 23 | public final class ConfigTests { 24 | private ConfigTests() {} 25 | 26 | public static Config randomConfig() { 27 | final Map entries = new HashMap<>(); 28 | for (int i = 0; i < 100; i++) { 29 | entries.put(UUID.randomUUID().toString(), UUID.randomUUID().toString()); 30 | } 31 | final Config config = Config.create(entries); 32 | return config; 33 | } 34 | 35 | public static ConnectorConfig randomConnectorConfig() { 36 | final Map values = new HashMap<>(); 37 | for (int i = 0; i < 10; i++) { 38 | values.put(UUID.randomUUID().toString(), randomConfig()); 39 | } 40 | return ConnectorConfig.create(values); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/SampleQueryTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test; 15 | 16 | import com.google.common.collect.ImmutableList; 17 | 18 | import org.boostscale.velox4j.iterator.UpIterator; 19 | import org.boostscale.velox4j.type.BigIntType; 20 | import org.boostscale.velox4j.type.RowType; 21 | 22 | public final class SampleQueryTests { 23 | private static final String SAMPLE_QUERY_PATH = "query/example-1.json"; 24 | private static final String SAMPLE_QUERY_OUTPUT_PATH = "query-output/example-1.tsv"; 25 | private static final RowType SAMPLE_QUERY_TYPE = 26 | new RowType( 27 | ImmutableList.of("c0", "a0", "a1"), 28 | ImmutableList.of(new BigIntType(), new BigIntType(), new BigIntType())); 29 | 30 | public static RowType getSchema() { 31 | return SAMPLE_QUERY_TYPE; 32 | } 33 | 34 | public static String readQueryJson() { 35 | return ResourceTests.readResourceAsString(SAMPLE_QUERY_PATH); 36 | } 37 | 38 | public static void assertIterator(UpIterator itr) { 39 | assertIterator(itr, 1); 40 | } 41 | 42 | public static void assertIterator(UpIterator itr, int repeatTimes) { 43 | UpIteratorTests.IteratorAssertionBuilder builder = 44 | UpIteratorTests.assertIterator(itr).assertNumRowVectors(repeatTimes); 45 | for (int i = 0; i < repeatTimes; i++) { 46 | builder = 47 | builder.assertRowVectorToString( 48 | i, ResourceTests.readResourceAsString(SAMPLE_QUERY_OUTPUT_PATH)); 49 | } 50 | builder.run(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/TestThreads.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test; 15 | 16 | import com.google.common.util.concurrent.UncaughtExceptionHandlers; 17 | 18 | public final class TestThreads { 19 | public static Thread newTestThread(Runnable target) { 20 | final Thread t = new Thread(target); 21 | t.setUncaughtExceptionHandler(UncaughtExceptionHandlers.systemExit()); 22 | return t; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/TypeTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test; 15 | 16 | import org.junit.Assert; 17 | 18 | import org.boostscale.velox4j.serde.Serde; 19 | import org.boostscale.velox4j.type.Type; 20 | 21 | public class TypeTests { 22 | public static void assertEquals(Type expected, Type actual) { 23 | Assert.assertEquals(Serde.toPrettyJson(expected), Serde.toPrettyJson(actual)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/Velox4jTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test; 15 | 16 | import java.util.concurrent.atomic.AtomicBoolean; 17 | 18 | import org.boostscale.velox4j.Velox4j; 19 | 20 | public class Velox4jTests { 21 | private static final AtomicBoolean initialized = new AtomicBoolean(false); 22 | 23 | public static void ensureInitialized() { 24 | if (!initialized.compareAndSet(false, true)) { 25 | return; 26 | } 27 | Velox4j.initialize(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/dataset/TestDataFile.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test.dataset; 15 | 16 | import java.io.File; 17 | 18 | import org.boostscale.velox4j.type.RowType; 19 | 20 | /** One specific data file included by a {@link TestDataset}. */ 21 | public interface TestDataFile { 22 | RowType schema(); 23 | 24 | File file(); 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/dataset/TestDataset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test.dataset; 15 | 16 | import java.util.List; 17 | 18 | /** 19 | * An interface to create dataset for testing purpose. The generic type `FID` stands for the ID type 20 | * of all files in the dataset. 21 | */ 22 | public interface TestDataset { 23 | /** Lists all files in the dataset. */ 24 | List listFiles(); 25 | 26 | /** Returns one single test data file by the input file ID. */ 27 | TestDataFile get(FID fid); 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/dataset/tpch/TpchDataset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test.dataset.tpch; 15 | 16 | import org.boostscale.velox4j.test.dataset.TestDataset; 17 | 18 | public interface TpchDataset extends TestDataset {} 19 | -------------------------------------------------------------------------------- /src/test/java/org/boostscale/velox4j/test/dataset/tpch/TpchDatasets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.boostscale.velox4j.test.dataset.tpch; 15 | 16 | /** A factory of {@link TpchDataset} instances. */ 17 | public final class TpchDatasets { 18 | private TpchDatasets() {} 19 | 20 | public static TpchDataset get() { 21 | return DownloadedTpchDataset.get(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/eval-output/field-access-1.txt: -------------------------------------------------------------------------------- 1 | [1, 2, 3] -------------------------------------------------------------------------------- /src/test/resources/eval-output/multiply-1.txt: -------------------------------------------------------------------------------- 1 | [10, 40, 90] -------------------------------------------------------------------------------- /src/test/resources/query-output-type/tpch-table-write-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Type", 3 | "type" : "ROW", 4 | "names" : [ "rows", "fragments", "commitcontext" ], 5 | "cTypes" : [ { 6 | "name" : "Type", 7 | "type" : "BIGINT" 8 | }, { 9 | "name" : "Type", 10 | "type" : "VARBINARY" 11 | }, { 12 | "name" : "Type", 13 | "type" : "VARBINARY" 14 | } ] 15 | } -------------------------------------------------------------------------------- /src/test/resources/query-output/example-1.tsv: -------------------------------------------------------------------------------- 1 | c0 a0 a1 2 | 1 1 10 3 | 2 1 20 4 | 3 1 30 5 | -------------------------------------------------------------------------------- /src/test/resources/query-output/tpch-aggregate-1.tsv: -------------------------------------------------------------------------------- 1 | n_regionkey cnt 2 | 0 50 3 | 1 47 4 | 4 58 5 | 3 77 6 | 2 68 7 | -------------------------------------------------------------------------------- /src/test/resources/query-output/tpch-filter-1.tsv: -------------------------------------------------------------------------------- 1 | n_nationkey n_name n_regionkey n_comment 2 | 4 EGYPT 4 y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d 3 | 6 FRANCE 3 refully final requests. regular, ironi 4 | 7 GERMANY 3 l platelets. regular accounts x-ray: unusual, regular acco 5 | 10 IRAN 4 efully alongside of the slyly final dependencies. 6 | 11 IRAQ 4 nic deposits boost atop the quickly final requests? quickly regula 7 | 13 JORDAN 4 ic deposits are blithely about the carefully regular pa 8 | 19 ROMANIA 3 ular asymptotes are about the furious multipliers. express dependencies nag above the ironically ironic account 9 | 20 SAUDI ARABIA 4 ts. silent requests haggle. closely express packages sleep across the blithely 10 | 22 RUSSIA 3 requests against the platelets use never according to the quickly regular pint 11 | 23 UNITED KINGDOM 3 eans boost carefully special requests. accounts are. carefull 12 | -------------------------------------------------------------------------------- /src/test/resources/query-output/tpch-join-1.tsv: -------------------------------------------------------------------------------- 1 | n_nationkey n_name r_regionkey r_name 2 | 0 ALGERIA 0 AFRICA 3 | 1 ARGENTINA 1 AMERICA 4 | 2 BRAZIL 1 AMERICA 5 | 3 CANADA 1 AMERICA 6 | 4 EGYPT 4 MIDDLE EAST 7 | 5 ETHIOPIA 0 AFRICA 8 | 6 FRANCE 3 EUROPE 9 | 7 GERMANY 3 EUROPE 10 | 8 INDIA 2 ASIA 11 | 9 INDONESIA 2 ASIA 12 | 10 IRAN 4 MIDDLE EAST 13 | 11 IRAQ 4 MIDDLE EAST 14 | 12 JAPAN 2 ASIA 15 | 13 JORDAN 4 MIDDLE EAST 16 | 14 KENYA 0 AFRICA 17 | 15 MOROCCO 0 AFRICA 18 | 16 MOZAMBIQUE 0 AFRICA 19 | 17 PERU 1 AMERICA 20 | 18 CHINA 2 ASIA 21 | 19 ROMANIA 3 EUROPE 22 | 20 SAUDI ARABIA 4 MIDDLE EAST 23 | 21 VIETNAM 2 ASIA 24 | 22 RUSSIA 3 EUROPE 25 | 23 UNITED KINGDOM 3 EUROPE 26 | 24 UNITED STATES 1 AMERICA 27 | -------------------------------------------------------------------------------- /src/test/resources/query-output/tpch-limit-1.tsv: -------------------------------------------------------------------------------- 1 | n_nationkey n_name n_regionkey n_comment 2 | 5 ETHIOPIA 0 ven packages wake quickly. regu 3 | 6 FRANCE 3 refully final requests. regular, ironi 4 | 7 GERMANY 3 l platelets. regular accounts x-ray: unusual, regular acco 5 | -------------------------------------------------------------------------------- /src/test/resources/query-output/tpch-project-1.tsv: -------------------------------------------------------------------------------- 1 | n_nationkey n_comment 2 | 0 haggle. carefully final deposits detect slyly agai 3 | 1 al foxes promise slyly according to the regular accounts. bold requests alon 4 | 2 y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special 5 | 3 eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold 6 | 4 y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d 7 | 5 ven packages wake quickly. regu 8 | 6 refully final requests. regular, ironi 9 | 7 l platelets. regular accounts x-ray: unusual, regular acco 10 | 8 ss excuses cajole slyly across the packages. deposits print aroun 11 | 9 slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull 12 | 10 efully alongside of the slyly final dependencies. 13 | 11 nic deposits boost atop the quickly final requests? quickly regula 14 | 12 ously. final, express gifts cajole a 15 | 13 ic deposits are blithely about the carefully regular pa 16 | 14 pending excuses haggle furiously deposits. pending, express pinto beans wake fluffily past t 17 | 15 rns. blithely bold courts among the closely regular packages use furiously bold platelets? 18 | 16 s. ironic, unusual asymptotes wake blithely r 19 | 17 platelets. blithely pending dependencies use fluffily across the even pinto beans. carefully silent accoun 20 | 18 c dependencies. furiously express notornis sleep slyly regular accounts. ideas sleep. depos 21 | 19 ular asymptotes are about the furious multipliers. express dependencies nag above the ironically ironic account 22 | 20 ts. silent requests haggle. closely express packages sleep across the blithely 23 | 21 hely enticingly express accounts. even, final 24 | 22 requests against the platelets use never according to the quickly regular pint 25 | 23 eans boost carefully special requests. accounts are. carefull 26 | 24 y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be 27 | -------------------------------------------------------------------------------- /src/test/resources/query-output/tpch-table-scan-region.tsv: -------------------------------------------------------------------------------- 1 | r_regionkey r_name r_comment 2 | 0 AFRICA lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to 3 | 1 AMERICA hs use ironic, even requests. s 4 | 2 ASIA ges. thinly even pinto beans ca 5 | 3 EUROPE ly final courts cajole furiously final excuse 6 | 4 MIDDLE EAST uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl 7 | -------------------------------------------------------------------------------- /src/test/resources/table-write-traits/output-type-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Type", 3 | "type" : "ROW", 4 | "names" : [ "rows", "fragments", "commitcontext" ], 5 | "cTypes" : [ { 6 | "name" : "Type", 7 | "type" : "BIGINT" 8 | }, { 9 | "name" : "Type", 10 | "type" : "VARBINARY" 11 | }, { 12 | "name" : "Type", 13 | "type" : "VARBINARY" 14 | } ] 15 | } -------------------------------------------------------------------------------- /src/test/resources/table-write-traits/output-type-with-aggregation-node-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "Type", 3 | "type" : "ROW", 4 | "names" : [ "rows", "fragments", "commitcontext", "foo", "sum" ], 5 | "cTypes" : [ { 6 | "name" : "Type", 7 | "type" : "BIGINT" 8 | }, { 9 | "name" : "Type", 10 | "type" : "VARBINARY" 11 | }, { 12 | "name" : "Type", 13 | "type" : "VARBINARY" 14 | }, { 15 | "name" : "Type", 16 | "type" : "INTEGER" 17 | }, { 18 | "name" : "Type", 19 | "type" : "INTEGER" 20 | } ] 21 | } -------------------------------------------------------------------------------- /src/test/resources/vector-output/append-1.txt: -------------------------------------------------------------------------------- 1 | c0 a0 a1 2 | 1 1 10 3 | 2 1 20 4 | 3 1 30 5 | 1 1 10 6 | 2 1 20 7 | 3 1 30 8 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/append-2.txt: -------------------------------------------------------------------------------- 1 | c0 a0 a1 2 | 1 1 10 3 | 2 1 20 4 | 3 1 30 5 | 1 1 10 6 | 2 1 20 7 | 3 1 30 8 | 1 1 10 9 | 2 1 20 10 | 3 1 30 11 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/partition-by-keys-1.txt: -------------------------------------------------------------------------------- 1 | Vector #0 2 | c0 a0 a1 3 | 1 1 10 4 | 5 | Vector #1 6 | c0 a0 a1 7 | 2 1 20 8 | 9 | Vector #2 10 | c0 a0 a1 11 | 3 1 30 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/partition-by-keys-2.txt: -------------------------------------------------------------------------------- 1 | Vector #0 2 | c0 a0 a1 3 | 1 1 10 4 | 2 1 20 5 | 3 1 30 6 | 7 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/partition-by-keys-3.txt: -------------------------------------------------------------------------------- 1 | Vector #0 2 | c0 a0 a1 3 | 1 1 10 4 | 5 | Vector #1 6 | c0 a0 a1 7 | 2 1 20 8 | 9 | Vector #2 10 | c0 a0 a1 11 | 3 1 30 12 | 13 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/slice-1.txt: -------------------------------------------------------------------------------- 1 | c0 a0 a1 2 | 1 1 10 3 | 2 1 20 4 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/slice-2.txt: -------------------------------------------------------------------------------- 1 | c0 a0 a1 2 | 3 1 30 3 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/to-string-1.txt: -------------------------------------------------------------------------------- 1 | c0 a0 a1 2 | 1 1 10 3 | 2 1 20 4 | 3 1 30 5 | -------------------------------------------------------------------------------- /src/test/resources/vector-output/variant-to-vector-1.txt: -------------------------------------------------------------------------------- 1 | [-5] -------------------------------------------------------------------------------- /src/test/resources/vector-output/variant-to-vector-2.txt: -------------------------------------------------------------------------------- 1 | [[10,-5]] -------------------------------------------------------------------------------- /src/test/resources/vector/rowvector-1.b64: -------------------------------------------------------------------------------- 1 | AAAAAKAAAAB7ImNUeXBlcyI6W3sidHlwZSI6IkJJR0lOVCIsIm5hbWUiOiJUeXBlIn0seyJ0eXBlIjoiQklHSU5UIiwibmFtZSI6IlR5cGUifSx7InR5cGUiOiJCSUdJTlQiLCJuYW1lIjoiVHlwZSJ9XSwibmFtZXMiOlsiYzAiLCJhMCIsImExIl0sInR5cGUiOiJST1ciLCJuYW1lIjoiVHlwZSJ9AwAAAAADAAAAAQAAAAAfAAAAeyJ0eXBlIjoiQklHSU5UIiwibmFtZSI6IlR5cGUifQMAAAAAARgAAAABAAAAAAAAAAIAAAAAAAAAAwAAAAAAAAABAAAAAB8AAAB7InR5cGUiOiJCSUdJTlQiLCJuYW1lIjoiVHlwZSJ9AwAAAAABGAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAEAAAAAHwAAAHsidHlwZSI6IkJJR0lOVCIsIm5hbWUiOiJUeXBlIn0DAAAAAAEYAAAACgAAAAAAAAAUAAAAAAAAAB4AAAAAAAAA --------------------------------------------------------------------------------