-
Notifications
You must be signed in to change notification settings - Fork 16
Initial commit of substrait-cpp #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| AccessModifierOffset: -1 | ||
| AlignAfterOpenBracket: AlwaysBreak | ||
| AlignConsecutiveAssignments: false | ||
| AlignConsecutiveDeclarations: false | ||
| AlignEscapedNewlinesLeft: true | ||
| AlignOperands: false | ||
| AlignTrailingComments: false | ||
| AllowAllParametersOfDeclarationOnNextLine: false | ||
| AllowShortBlocksOnASingleLine: false | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortFunctionsOnASingleLine: Empty | ||
| AllowShortIfStatementsOnASingleLine: false | ||
| AllowShortLoopsOnASingleLine: false | ||
| AlwaysBreakAfterReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: true | ||
| AlwaysBreakTemplateDeclarations: true | ||
| BinPackArguments: false | ||
| BinPackParameters: false | ||
| BraceWrapping: | ||
| AfterClass: false | ||
| AfterControlStatement: false | ||
| AfterEnum: false | ||
| AfterFunction: false | ||
| AfterNamespace: false | ||
| AfterObjCDeclaration: false | ||
| AfterStruct: false | ||
| AfterUnion: false | ||
| BeforeCatch: false | ||
| BeforeElse: false | ||
| IndentBraces: false | ||
| BreakBeforeBinaryOperators: None | ||
| BreakBeforeBraces: Attach | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializersBeforeComma: false | ||
| BreakAfterJavaFieldAnnotations: false | ||
| BreakStringLiterals: false | ||
| ColumnLimit: 80 | ||
| CommentPragmas: '^ IWYU pragma:' | ||
| ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: true | ||
| DerivePointerAlignment: false | ||
| DisableFormat: false | ||
| ForEachMacros: [ FOR_EACH, FOR_EACH_R, FOR_EACH_RANGE, ] | ||
| IncludeCategories: | ||
| - Regex: '^<.*\.h(pp)?>' | ||
| Priority: 1 | ||
| - Regex: '^<.*' | ||
| Priority: 2 | ||
| - Regex: '.*' | ||
| Priority: 3 | ||
| IndentCaseLabels: true | ||
| IndentWidth: 2 | ||
| IndentWrappedFunctionNames: false | ||
| KeepEmptyLinesAtTheStartOfBlocks: false | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: None | ||
| ObjCBlockIndentWidth: 2 | ||
| ObjCSpaceAfterProperty: false | ||
| ObjCSpaceBeforeProtocolList: false | ||
| PenaltyBreakBeforeFirstCallParameter: 1 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyReturnTypeOnItsOwnLine: 200 | ||
| PointerAlignment: Left | ||
| ReflowComments: true | ||
| SortIncludes: true | ||
| SpaceAfterCStyleCast: false | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceInEmptyParentheses: false | ||
| SpacesBeforeTrailingComments: 1 | ||
| SpacesInAngles: false | ||
| SpacesInContainerLiterals: true | ||
| SpacesInCStyleCastParentheses: false | ||
| SpacesInParentheses: false | ||
| SpacesInSquareBrackets: false | ||
| Standard: Cpp11 | ||
| TabWidth: 8 | ||
| UseTab: Never | ||
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,5 @@ | |
| *.exe | ||
| *.out | ||
| *.app | ||
|
|
||
| src/proto/substrait | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [submodule "third_party/yaml-cpp"] | ||
| path = third_party/yaml-cpp | ||
| url = https://github.com/jbeder/yaml-cpp.git | ||
| [submodule "third_party/googletest"] | ||
| path = third_party/googletest | ||
| url = https://github.com/google/googletest.git | ||
| [submodule "third_party/substrait"] | ||
| path = third_party/substrait | ||
| url = https://github.com/substrait-io/substrait.git | ||
| [submodule "third_party/fmt"] | ||
| path = third_party/fmt | ||
| url = https://github.com/fmtlib/fmt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| cmake_minimum_required(VERSION 3.10) | ||
|
|
||
| # set the project name | ||
| project(substrait-cpp) | ||
|
|
||
| message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
|
||
| option( | ||
| BUILD_TESTING | ||
| "Enable substrait-cpp tests. This will enable all other build options automatically." | ||
| ON) | ||
|
|
||
| find_package(Protobuf REQUIRED) | ||
| include_directories(${PROTOBUF_INCLUDE_DIRS}) | ||
|
|
||
| add_subdirectory(third_party) | ||
| include_directories(src) | ||
| add_subdirectory(src) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| .PHONY: all clean build debug release | ||
|
|
||
| BUILD_TYPE := Release | ||
|
|
||
| all: debug | ||
|
|
||
| clean: | ||
| @rm -rf build-* | ||
|
|
||
| build-common: | ||
| @mkdir -p build-${BUILD_TYPE} | ||
| @cd build-${BUILD_TYPE} && \ | ||
| cmake -Wno-dev \ | ||
| -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||
| -DPREFER_STATIC_LIBS=OFF \ | ||
| $(FORCE_COLOR) \ | ||
| .. | ||
|
|
||
| build: | ||
| VERBOSE=1 cmake --build build-${BUILD_TYPE} -j $${CPU_COUNT:-`nproc`} || \ | ||
| cmake --build build-${BUILD_TYPE} | ||
|
|
||
| debug: | ||
| @$(MAKE) build-common BUILD_TYPE=Debug | ||
| @$(MAKE) build BUILD_TYPE=Debug | ||
|
|
||
| release: | ||
| @$(MAKE) build-common BUILD_TYPE=Release | ||
| @$(MAKE) build BUILD_TYPE=Release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,36 @@ | ||
| # substrait-cpp | ||
|
|
||
| Planned home for CPP libraries to help build/consume Substrait query plans. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| We provide scripts to help developers setup and install substrait-cpp dependencies. | ||
|
|
||
| ### Get the substrait-cpp Source | ||
| ``` | ||
| git clone --recursive https://github.com/substrait-io/substrait-cpp.git | ||
| cd substrait-cpp | ||
| # if you are updating an existing checkout | ||
| git submodule sync --recursive | ||
| git submodule update --init --recursive | ||
| ``` | ||
|
|
||
| ### Setting up on Linux (Ubuntu 20.04 or later) | ||
|
|
||
| Once you have checked out substrait-cpp, you can setup and build like so: | ||
|
|
||
| ```shell | ||
| $ ./scripts/setup-ubuntu.sh | ||
| $ make | ||
| ``` | ||
|
|
||
| ## Community | ||
|
|
||
| The main communication channel with the substrait through the | ||
| [substrait chanel](http://substrait.slack.com). | ||
|
|
||
|
|
||
| ## License | ||
|
|
||
| substrait-cpp is licensed under the Apache 2.0 License. A copy of the license | ||
| [can be found here.](LICENSE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| #!/bin/bash | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # github_checkout $REPO $VERSION $GIT_CLONE_PARAMS clones or re-uses an existing clone of the | ||
| # specified repo, checking out the requested version. | ||
| function github_checkout { | ||
| local REPO=$1 | ||
| shift | ||
| local VERSION=$1 | ||
| shift | ||
| local GIT_CLONE_PARAMS=$@ | ||
| local DIRNAME=$(basename $REPO) | ||
| cd "${DEPENDENCY_DIR}" | ||
| if [ -z "${DIRNAME}" ]; then | ||
| echo "Failed to get repo name from ${REPO}" | ||
| exit 1 | ||
| fi | ||
| if [ -d "${DIRNAME}" ] && prompt "${DIRNAME} already exists. Delete?"; then | ||
| rm -rf "${DIRNAME}" | ||
| fi | ||
| if [ ! -d "${DIRNAME}" ]; then | ||
| git clone -q -b $VERSION $GIT_CLONE_PARAMS "https://github.com/${REPO}.git" | ||
| fi | ||
| cd "${DIRNAME}" | ||
| } | ||
|
|
||
|
|
||
| # get_cxx_flags [$CPU_ARCH] | ||
| # Sets and exports the variable VELOX_CXX_FLAGS with appropriate compiler flags. | ||
| # If $CPU_ARCH is set then we use that else we determine best possible set of flags | ||
| # to use based on current cpu architecture. | ||
| # The goal of this function is to consolidate all architecture specific flags to one | ||
| # location. | ||
| # The values that CPU_ARCH can take are as follows: | ||
| # arm64 : Target Apple silicon. | ||
| # aarch64: Target general 64 bit arm cpus. | ||
| # avx: Target Intel CPUs with AVX. | ||
| # sse: Target Intel CPUs with sse. | ||
| # Echo's the appropriate compiler flags which can be captured as so | ||
| # CXX_FLAGS=$(get_cxx_flags) or | ||
| # CXX_FLAGS=$(get_cxx_flags "avx") | ||
|
|
||
| function get_cxx_flags { | ||
| local CPU_ARCH=$1 | ||
|
|
||
| local OS | ||
| OS=$(uname) | ||
| local MACHINE | ||
| MACHINE=$(uname -m) | ||
|
|
||
| if [ -z "$CPU_ARCH" ]; then | ||
|
|
||
| if [ "$OS" = "Darwin" ]; then | ||
|
|
||
| if [ "$MACHINE" = "x86_64" ]; then | ||
| local CPU_CAPABILITIES | ||
| CPU_CAPABILITIES=$(sysctl -a | grep machdep.cpu.features | awk '{print tolower($0)}') | ||
|
|
||
| if [[ $CPU_CAPABILITIES =~ "avx" ]]; then | ||
| CPU_ARCH="avx" | ||
| else | ||
| CPU_ARCH="sse" | ||
| fi | ||
|
|
||
| elif [[ $(sysctl -a | grep machdep.cpu.brand_string) =~ "Apple" ]]; then | ||
| # Apple silicon. | ||
| CPU_ARCH="arm64" | ||
| fi | ||
| else [ "$OS" = "Linux" ]; | ||
|
|
||
| local CPU_CAPABILITIES | ||
| CPU_CAPABILITIES=$(cat /proc/cpuinfo | grep flags | head -n 1| awk '{print tolower($0)}') | ||
|
|
||
| if [[ "$CPU_CAPABILITIES" =~ "avx" ]]; then | ||
| CPU_ARCH="avx" | ||
| elif [[ "$CPU_CAPABILITIES" =~ "sse" ]]; then | ||
| CPU_ARCH="sse" | ||
| elif [ "$MACHINE" = "aarch64" ]; then | ||
| CPU_ARCH="aarch64" | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| case $CPU_ARCH in | ||
|
|
||
| "arm64") | ||
| echo -n "-mcpu=apple-m1+crc -std=c++17" | ||
| ;; | ||
|
|
||
| "avx") | ||
| echo -n "-mavx2 -mfma -mavx -mf16c -mlzcnt -std=c++17" | ||
| ;; | ||
|
|
||
| "sse") | ||
| echo -n "-msse4.2 -std=c++17" | ||
| ;; | ||
|
|
||
| "aarch64") | ||
| echo -n "-mcpu=neoverse-n1 -std=c++17" | ||
| ;; | ||
| *) | ||
| echo -n "Architecture not supported!" | ||
| esac | ||
|
|
||
| } | ||
|
|
||
| function cmake_install { | ||
| local NAME=$(basename "$(pwd)") | ||
| local BINARY_DIR=_build | ||
| if [ -d "${BINARY_DIR}" ] && prompt "Do you want to rebuild ${NAME}?"; then | ||
| rm -rf "${BINARY_DIR}" | ||
| fi | ||
| mkdir -p "${BINARY_DIR}" | ||
| CPU_TARGET="${CPU_TARGET:-avx}" | ||
| COMPILER_FLAGS=$(get_cxx_flags $CPU_TARGET) | ||
|
|
||
| # CMAKE_POSITION_INDEPENDENT_CODE is required so that Velox can be built into dynamic libraries \ | ||
| cmake -Wno-dev -B"${BINARY_DIR}" \ | ||
| -GNinja \ | ||
| -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ | ||
| -DCMAKE_CXX_STANDARD=17 \ | ||
| "${INSTALL_PREFIX+-DCMAKE_PREFIX_PATH=}${INSTALL_PREFIX-}" \ | ||
| "${INSTALL_PREFIX+-DCMAKE_INSTALL_PREFIX=}${INSTALL_PREFIX-}" \ | ||
| -DCMAKE_CXX_FLAGS="$COMPILER_FLAGS" \ | ||
| -DBUILD_TESTING=OFF \ | ||
| "$@" | ||
| ninja -C "${BINARY_DIR}" install | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a cmake expert but why do we do
find_packageforprotobufbut not foryaml-cpp?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we have to use 'protoc' command to compile substrait protocol files before we compile this project.