Compare commits
2 Commits
T0805-MG-f
...
T0785-MG-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebe54d759e | ||
|
|
492a13d5e7 |
@@ -2,7 +2,6 @@
|
||||
Checks: '*,
|
||||
-abseil-string-find-str-contains,
|
||||
-altera-struct-pack-align,
|
||||
-altera-unroll-loops,
|
||||
-android-*,
|
||||
-cert-err58-cpp,
|
||||
-cppcoreguidelines-avoid-c-arrays,
|
||||
|
||||
@@ -32,7 +32,7 @@ for file in $modified_files; do
|
||||
fi
|
||||
|
||||
echo "Running header checker..."
|
||||
$project_folder/tools/header-checker.py $tmpdir/$file $file --amend-year
|
||||
$project_folder/tools/header-checker.py $tmpdir/$file
|
||||
code=$?
|
||||
|
||||
if [ $code -ne 0 ]; then
|
||||
|
||||
2
.github/workflows/daily_benchmark.yaml
vendored
2
.github/workflows/daily_benchmark.yaml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
|
||||
28
.github/workflows/diff.yaml
vendored
28
.github/workflows/diff.yaml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
- name: Build community binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -45,7 +45,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
- name: Build combined ASAN, UBSAN and coverage binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests. It is restricted to 2 threads intentionally, because higher concurrency makes the timing related tests unstable.
|
||||
cd build
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
- name: Compute code coverage
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Compute code coverage.
|
||||
cd tools/github
|
||||
@@ -109,7 +109,7 @@ jobs:
|
||||
|
||||
- name: Run clang-tidy
|
||||
run: |
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Restrict clang-tidy results only to the modified parts
|
||||
git diff -U0 master... -- src ':!*.hpp' | ./tools/github/clang-tidy/clang-tidy-diff.py -p 1 -j $THREADS -path build | tee ./build/clang_tidy_output.txt
|
||||
@@ -136,7 +136,7 @@ jobs:
|
||||
- name: Build debug binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -149,7 +149,7 @@ jobs:
|
||||
- name: Run leftover CTest tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run leftover CTest tests (all except unit and benchmark tests).
|
||||
cd build
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
- name: Run cppcheck and clang-format
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run cppcheck and clang-format.
|
||||
cd tools/github
|
||||
@@ -212,7 +212,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -238,7 +238,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -272,7 +272,7 @@ jobs:
|
||||
- name: Create enterprise DEB package
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
cd build
|
||||
|
||||
@@ -319,7 +319,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -360,7 +360,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
|
||||
6
.github/workflows/full_clang_tidy.yaml
vendored
6
.github/workflows/full_clang_tidy.yaml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
- name: Build debug binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -36,10 +36,10 @@ jobs:
|
||||
|
||||
- name: Run clang-tidy
|
||||
run: |
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# The results are also written to standard output in order to retain them in the logs
|
||||
./tools/github/clang-tidy/run-clang-tidy.py -p build -j $THREADS -clang-tidy-binary=/opt/toolchain-v4/bin/clang-tidy "$PWD/src/*" |
|
||||
./tools/github/clang-tidy/run-clang-tidy.py -p build -j $THREADS -clang-tidy-binary=/opt/toolchain-v3/bin/clang-tidy "$PWD/src/*" |
|
||||
tee ./build/full_clang_tidy_output.txt
|
||||
|
||||
- name: Summarize clang-tidy results
|
||||
|
||||
24
.github/workflows/release_centos8.yaml
vendored
24
.github/workflows/release_centos8.yaml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Build community binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
- name: Build coverage binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
- name: Compute code coverage
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Compute code coverage.
|
||||
cd tools/github
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
- name: Build debug binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
- name: Run leftover CTest tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run leftover CTest tests (all except unit and benchmark tests).
|
||||
cd build
|
||||
@@ -166,7 +166,7 @@ jobs:
|
||||
- name: Run cppcheck and clang-format
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run cppcheck and clang-format.
|
||||
cd tools/github
|
||||
@@ -198,7 +198,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -211,7 +211,7 @@ jobs:
|
||||
- name: Create enterprise RPM package
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
cd build
|
||||
|
||||
@@ -233,7 +233,7 @@ jobs:
|
||||
- name: Run micro benchmark tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run micro benchmark tests.
|
||||
cd build
|
||||
@@ -272,7 +272,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
|
||||
26
.github/workflows/release_debian10.yaml
vendored
26
.github/workflows/release_debian10.yaml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Build community binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
- name: Build coverage binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
- name: Compute code coverage
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Compute code coverage.
|
||||
cd tools/github
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
- name: Build debug binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
- name: Run leftover CTest tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run leftover CTest tests (all except unit and benchmark tests).
|
||||
cd build
|
||||
@@ -166,7 +166,7 @@ jobs:
|
||||
- name: Run cppcheck and clang-format
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run cppcheck and clang-format.
|
||||
cd tools/github
|
||||
@@ -198,7 +198,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -211,7 +211,7 @@ jobs:
|
||||
- name: Create enterprise DEB package
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
cd build
|
||||
|
||||
@@ -232,7 +232,7 @@ jobs:
|
||||
- name: Run micro benchmark tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run micro benchmark tests.
|
||||
cd build
|
||||
@@ -271,7 +271,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -333,7 +333,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
|
||||
24
.github/workflows/release_ubuntu2004.yaml
vendored
24
.github/workflows/release_ubuntu2004.yaml
vendored
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Build community binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -39,7 +39,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -64,7 +64,7 @@ jobs:
|
||||
- name: Build coverage binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -77,7 +77,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
- name: Compute code coverage
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Compute code coverage.
|
||||
cd tools/github
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
- name: Build debug binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -134,7 +134,7 @@ jobs:
|
||||
- name: Run leftover CTest tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run leftover CTest tests (all except unit and benchmark tests).
|
||||
cd build
|
||||
@@ -166,7 +166,7 @@ jobs:
|
||||
- name: Run cppcheck and clang-format
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run cppcheck and clang-format.
|
||||
cd tools/github
|
||||
@@ -198,7 +198,7 @@ jobs:
|
||||
- name: Build release binaries
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Initialize dependencies.
|
||||
./init
|
||||
@@ -211,7 +211,7 @@ jobs:
|
||||
- name: Create enterprise DEB package
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
cd build
|
||||
|
||||
@@ -232,7 +232,7 @@ jobs:
|
||||
- name: Run micro benchmark tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run micro benchmark tests.
|
||||
cd build
|
||||
@@ -271,7 +271,7 @@ jobs:
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
# Activate toolchain.
|
||||
source /opt/toolchain-v4/activate
|
||||
source /opt/toolchain-v3/activate
|
||||
|
||||
# Run unit tests.
|
||||
cd build
|
||||
|
||||
@@ -322,8 +322,7 @@ if (UBSAN)
|
||||
# To make the program abort on undefined behavior, use UBSAN_OPTIONS=halt_on_error=1.
|
||||
endif()
|
||||
|
||||
set(MG_PYTHON_VERSION "" CACHE STRING "Specify the exact Python version used by the query modules")
|
||||
set(MG_PYTHON_PATH "" CACHE STRING "Specify the exact Python path used by the query modules")
|
||||
set(MG_PYTHON_VERSION "" CACHE STRING "Specify the exact python version used by the query modules")
|
||||
|
||||
# Add subprojects
|
||||
include_directories(src)
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# Try to find jemalloc library
|
||||
#
|
||||
# Use this module as:
|
||||
# find_package(Jemalloc)
|
||||
#
|
||||
# or:
|
||||
# find_package(Jemalloc REQUIRED)
|
||||
#
|
||||
# This will define the following variables:
|
||||
#
|
||||
# Jemalloc_FOUND True if the system has the jemalloc library.
|
||||
# Jemalloc_INCLUDE_DIRS Include directories needed to use jemalloc.
|
||||
# Jemalloc_LIBRARIES Libraries needed to link to jemalloc.
|
||||
#
|
||||
# The following cache variables may also be set:
|
||||
#
|
||||
# Jemalloc_INCLUDE_DIR The directory containing jemalloc/jemalloc.h.
|
||||
# Jemalloc_LIBRARY The path to the jemalloc static library.
|
||||
|
||||
find_path(Jemalloc_INCLUDE_DIR NAMES jemalloc/jemalloc.h PATH_SUFFIXES include)
|
||||
|
||||
find_library(Jemalloc_LIBRARY NAMES libjemalloc.a PATH_SUFFIXES lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Jemalloc
|
||||
FOUND_VAR Jemalloc_FOUND
|
||||
REQUIRED_VARS
|
||||
Jemalloc_LIBRARY
|
||||
Jemalloc_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(Jemalloc_FOUND)
|
||||
set(Jemalloc_LIBRARIES ${Jemalloc_LIBRARY})
|
||||
set(Jemalloc_INCLUDE_DIRS ${Jemalloc_INCLUDE_DIR})
|
||||
else()
|
||||
if(Jemalloc_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Cannot find jemalloc!")
|
||||
else()
|
||||
message(WARNING "jemalloc is not found!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(Jemalloc_FOUND AND NOT TARGET Jemalloc::Jemalloc)
|
||||
add_library(Jemalloc::Jemalloc UNKNOWN IMPORTED)
|
||||
set_target_properties(Jemalloc::Jemalloc
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION "${Jemalloc_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Jemalloc_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
Jemalloc_INCLUDE_DIR
|
||||
Jemalloc_LIBRARY
|
||||
)
|
||||
@@ -14,14 +14,9 @@ TOOLCHAIN_BUILD_DEPS=(
|
||||
expat-devel libipt-devel libbabeltrace-devel xz-devel python3-devel # gdb
|
||||
texinfo # gdb
|
||||
libcurl-devel # cmake
|
||||
curl # snappy
|
||||
readline-devel # cmake and llvm
|
||||
libffi-devel libxml2-devel perl-Digest-MD5 # llvm
|
||||
libedit-devel pcre-devel automake bison # swig
|
||||
file
|
||||
openssl-devel
|
||||
gmp-devel
|
||||
gperf
|
||||
)
|
||||
|
||||
TOOLCHAIN_RUN_DEPS=(
|
||||
@@ -31,10 +26,10 @@ TOOLCHAIN_RUN_DEPS=(
|
||||
expat libipt libbabeltrace xz-libs python3 # for gdb
|
||||
readline # for cmake and llvm
|
||||
libffi libxml2 # for llvm
|
||||
openssl-devel
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
git # source code control
|
||||
make pkgconfig # build system
|
||||
curl wget # for downloading libs
|
||||
libuuid-devel java-11-openjdk # required by antlr
|
||||
@@ -100,12 +95,8 @@ install() {
|
||||
echo "NOTE: export LANG=en_US.utf8"
|
||||
fi
|
||||
yum install -y epel-release
|
||||
yum remove -y ius-release
|
||||
yum install -y \
|
||||
https://repo.ius.io/ius-release-el7.rpm
|
||||
yum update -y
|
||||
yum install -y wget python3 python3-pip
|
||||
yum install -y git224
|
||||
yum install -y wget git python3 python3-pip
|
||||
for pkg in $1; do
|
||||
if [ "$pkg" == libipt ]; then
|
||||
if ! yum list installed libipt >/dev/null 2>/dev/null; then
|
||||
|
||||
@@ -13,14 +13,9 @@ TOOLCHAIN_BUILD_DEPS=(
|
||||
zlib-devel # zlib library used for all builds
|
||||
expat-devel libipt-devel libbabeltrace-devel xz-devel python36-devel texinfo # for gdb
|
||||
libcurl-devel # for cmake
|
||||
curl # snappy
|
||||
readline-devel # for cmake and llvm
|
||||
libffi-devel libxml2-devel # for llvm
|
||||
libedit-devel pcre-devel automake bison # for swig
|
||||
file
|
||||
openssl-devel
|
||||
gmp-devel
|
||||
gperf
|
||||
)
|
||||
|
||||
TOOLCHAIN_RUN_DEPS=(
|
||||
@@ -30,7 +25,6 @@ TOOLCHAIN_RUN_DEPS=(
|
||||
expat libipt libbabeltrace xz-libs python36 # for gdb
|
||||
readline # for cmake and llvm
|
||||
libffi libxml2 # for llvm
|
||||
openssl-devel
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
|
||||
@@ -15,12 +15,6 @@ TOOLCHAIN_BUILD_DEPS=(
|
||||
libcurl4-openssl-dev # for cmake
|
||||
libreadline-dev # for cmake and llvm
|
||||
libffi-dev libxml2-dev # for llvm
|
||||
curl # snappy
|
||||
file # for libunwind
|
||||
libssl-dev # for libevent
|
||||
libgmp-dev # for gdb
|
||||
gperf # for proxygen
|
||||
git # for fbthrift
|
||||
libedit-dev libpcre3-dev automake bison # for swig
|
||||
)
|
||||
|
||||
@@ -32,7 +26,6 @@ TOOLCHAIN_RUN_DEPS=(
|
||||
libcurl4 # for cmake
|
||||
libreadline7 # for cmake and llvm
|
||||
libffi6 libxml2 # for llvm
|
||||
libssl-dev # for libevent
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
|
||||
@@ -16,12 +16,6 @@ TOOLCHAIN_BUILD_DEPS=(
|
||||
libreadline-dev # for cmake and llvm
|
||||
libffi-dev libxml2-dev # for llvm
|
||||
libedit-dev libpcre3-dev automake bison # for swig
|
||||
curl # snappy
|
||||
file # for libunwind
|
||||
libssl-dev # for libevent
|
||||
libgmp-dev
|
||||
gperf # for proxygen
|
||||
git # for fbthrift
|
||||
)
|
||||
|
||||
TOOLCHAIN_RUN_DEPS=(
|
||||
@@ -33,7 +27,6 @@ TOOLCHAIN_RUN_DEPS=(
|
||||
file # for CPack
|
||||
libreadline8 # for cmake and llvm
|
||||
libffi7 libxml2 # for llvm
|
||||
libssl-dev # for libevent
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
|
||||
63
environment/os/debian-9.sh
Executable file
63
environment/os/debian-9.sh
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
source "$DIR/../util.sh"
|
||||
|
||||
TOOLCHAIN_BUILD_DEPS=(
|
||||
coreutils gcc g++ build-essential make # generic build tools
|
||||
wget # used for archive download
|
||||
gnupg # used for archive signature verification
|
||||
tar gzip bzip2 xz-utils unzip # used for archive unpacking
|
||||
zlib1g-dev # zlib library used for all builds
|
||||
libexpat1-dev libipt-dev libbabeltrace-dev libbabeltrace-ctf-dev liblzma-dev python3-dev texinfo # for gdb
|
||||
libcurl4-openssl-dev # for cmake
|
||||
libreadline-dev # for cmake and llvm
|
||||
libffi-dev libxml2-dev # for llvm
|
||||
libedit-dev libpcre3-dev automake bison # for swig
|
||||
)
|
||||
|
||||
TOOLCHAIN_RUN_DEPS=(
|
||||
make # generic build tools
|
||||
tar gzip bzip2 xz-utils # used for archive unpacking
|
||||
zlib1g # zlib library used for all builds
|
||||
libexpat1 libipt1 libbabeltrace1 libbabeltrace-ctf1 liblzma5 python3 # for gdb
|
||||
libcurl3 # for cmake
|
||||
libreadline7 # for cmake and llvm
|
||||
libffi6 libxml2 # for llvm
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
git # source code control
|
||||
make pkg-config # build system
|
||||
curl wget # for downloading libs
|
||||
uuid-dev default-jre-headless # required by antlr
|
||||
libreadline-dev # for memgraph console
|
||||
libpython3-dev python3-dev # for query modules
|
||||
libssl-dev
|
||||
libseccomp-dev
|
||||
python3 python-virtualenv python3-pip # for qa, macro_benchmark and stress tests
|
||||
python3-yaml # for the configuration generator
|
||||
libcurl4-openssl-dev # mg-requests
|
||||
sbcl # for custom Lisp C++ preprocessing
|
||||
doxygen graphviz # source documentation generators
|
||||
mono-runtime mono-mcs nodejs zip unzip default-jdk-headless # for driver tests
|
||||
autoconf # for jemalloc code generation
|
||||
libtool # for protobuf code generation
|
||||
)
|
||||
|
||||
list() {
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
check() {
|
||||
check_all_dpkg "$1"
|
||||
}
|
||||
|
||||
install() {
|
||||
install_all_apt "$1"
|
||||
}
|
||||
|
||||
deps=$2"[*]"
|
||||
"$1" "${!deps}"
|
||||
@@ -16,12 +16,6 @@ TOOLCHAIN_BUILD_DEPS=(
|
||||
libcurl4-openssl-dev # cmake
|
||||
libreadline-dev # cmake and llvm
|
||||
libffi-dev libxml2-dev # llvm
|
||||
curl # snappy
|
||||
file
|
||||
git # for thrift
|
||||
libgmp-dev # for gdb
|
||||
gperf # for proxygen
|
||||
libssl-dev
|
||||
libedit-dev libpcre3-dev automake bison # swig
|
||||
)
|
||||
|
||||
@@ -33,7 +27,6 @@ TOOLCHAIN_RUN_DEPS=(
|
||||
libcurl4 # for cmake
|
||||
libreadline7 # for cmake and llvm
|
||||
libffi6 libxml2 # for llvm
|
||||
libssl-dev # for libevent
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
|
||||
@@ -15,12 +15,6 @@ TOOLCHAIN_BUILD_DEPS=(
|
||||
libcurl4-openssl-dev # for cmake
|
||||
libreadline-dev # for cmake and llvm
|
||||
libffi-dev libxml2-dev # for llvm
|
||||
curl # snappy
|
||||
file
|
||||
git # for thrift
|
||||
libgmp-dev # for gdb
|
||||
gperf # for proxygen
|
||||
libssl-dev
|
||||
libedit-dev libpcre3-dev automake bison # for swig
|
||||
)
|
||||
|
||||
@@ -32,7 +26,6 @@ TOOLCHAIN_RUN_DEPS=(
|
||||
libcurl4 # for cmake
|
||||
libreadline8 # for cmake and llvm
|
||||
libffi7 libxml2 # for llvm
|
||||
libssl-dev # for libevent
|
||||
)
|
||||
|
||||
MEMGRAPH_BUILD_DEPS=(
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
24d23
|
||||
< find_dependency(mvfst)
|
||||
@@ -1,16 +0,0 @@
|
||||
55,57c55,57
|
||||
< # Disable RTTI.
|
||||
< string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
< set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
||||
---
|
||||
> # # Disable RTTI.
|
||||
> # string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
> # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
||||
80,82c80,82
|
||||
< # Disable RTTI.
|
||||
< string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
< set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
---
|
||||
> # # Disable RTTI.
|
||||
> # string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
> # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,75 +0,0 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQINBEzEOZIBEACxg/IuXERlDB48JBWmF4NxNUuuup1IhJAJyFGFSKh3OGAO2Ard
|
||||
sNuRLjANsFXA7m7P5eTFcG+BoHHuAVYmKnI3PPZtHVLnUt4pGItPczQZ2BE1WpcI
|
||||
ayjGTBJeKItX3Npqg9D/odO9WWS1i3FQPVdrLn0YH37/BA66jeMQCRo7g7GLpaNf
|
||||
IrvYGsqTbxCwsmA37rpE7oyU4Yrf74HT091WBsRIoq/MelhbxTDMR8eu/dUGZQVc
|
||||
Kj3lN55RepwWwUUKyqarY0zMt4HkFJ7v7yRL+Cvzy92Ouv4Wf2FlhNtEs5LE4Tax
|
||||
W0PO5AEmUoKjX87SezQK0f652018b4u6Ex52cY7p+n5TII/UyoowH6+tY8UHo9yb
|
||||
fStrqgNE/mY2bhA6+AwCaOUGsFzVVPTbjtxL3HacUP/jlA1h78V8VTvTs5d55iG7
|
||||
jSqR9o05wje8rwNiXXK0xtiJahyNzL97Kn/DgPSqPIi45G+8nxWSPFM5eunBKRl9
|
||||
vAnsvwrdPRsR6YR3uMHTuVhQX9/CY891MHkaZJ6wydWtKt3yQwJLYqwo5d4DwnUX
|
||||
CduUwSKv+6RmtWI5ZmTQYOcBRcZyGKml9X9Q8iSbm6cnpFXmLrNQwCJN+D3SiYGc
|
||||
MtbltZo0ysPMa6Xj5xFaYqWk/BI4iLb2Gs+ByGo/+a0Eq4XYBMOpitNniQARAQAB
|
||||
tCdMYXNzZSBDb2xsaW4gPGxhc3NlLmNvbGxpbkB0dWthYW5pLm9yZz6JAlEEEwEK
|
||||
ADsCGwMCHgECF4AECwkIBwMVCggFFgIDAQAWIQQ2kMJAzlG0Zw0wrRw47nV9aRhG
|
||||
IAUCYEt9dQUJFxeR4wAKCRA47nV9aRhGIBNDEACxD6vJ+enZwe3IgkJh5JtLsC9b
|
||||
MWCQRlPW1EVMsg96Cb5Rtron1eN1pp1TlzENJu1/C7C/VEsr9WwOPg26Men7fNf/
|
||||
O21QM9IBWd/uB0Pu333WqKh92ESS5x9ST9DrG39nVGSPkQQBMuia72VrA+crPnwT
|
||||
/h/u1IN6/sff5VDIU24rUiqW2Npy733dANruj7Ny0scRXVPltnVdhqwPHt6qNjC1
|
||||
t+/cCnwHgW1BR1RYXBPpB42z/m29dL9rPrG0YPGWs2Bc+EATUICfEE6eIvwfciue
|
||||
IJTjKT9Y9DrogJC2AYFhjC7N04OKdCB2hFs4BjexJwr4X0GJO7LhFl03c951AsIE
|
||||
GHwrucRPB5bo2vmvQ8IvZn7CmtdUJzXv9JlyU6p+MIK1pz7TK6GgSOSffQIXZn6e
|
||||
nUPtm9mEwuncOfmW8/ODYPs1gCWYgyiFJx8h7eEu+M4MxHSFBs7MwXf/Ae2fSp+M
|
||||
P/p198qB8fC5oVBnF95qb0Qi0uc1D+Gb+gpBF+ymMb+s/VBOR3QWiym7AzBrJ62g
|
||||
UnbC9jMLGnSRI+7p7raUfMTgXr5/oQoBw7ExJVltSSRrim2YH/t4CV47mO6dR9J3
|
||||
1RtsTFIRNhz+07XPsETcuCV/dgqeC8fOFLt9MY17Sufhb1DcGy4urZBOIhXcpTV7
|
||||
vHVj5IYH5nYOT49NRYkCOAQTAQIAIgUCTMQ5kgIbAwYLCQgHAwIGFQgCCQoLBBYC
|
||||
AwECHgECF4AACgkQOO51fWkYRiAg4A/7BXKwoRaXrMbMPOW7vuVF7c2IKB2Yqzn1
|
||||
vLBCwuEHkqY237lDcXY4/5LR+1gcZ3Duw1n/BRSm0FBdvyX/JTWiWNSDUkKAO/0l
|
||||
T2Tg44YLrDT3bzwu8dbU9xQt6kH+SCOHvv5Oe4k79l5mro6fF3H1M0bN63x/YoFY
|
||||
ojy09D7/JptY82oR4f/VdKnfZLJcCViCb0wp8SD2NkDAudKg+K+7PD8HlTWklQQg
|
||||
TZdRXxVZKIJeU42aJDqnRbAhJd64YHyClhqut9F5LUmiP5qfLfNhkKDhNOwk2Blr
|
||||
BGBJkSd7wPyzcX4Mun/L6YspHjbeVMt9TD7HQlo+OOd2OjAHCx6pqwkXnzeLPEaE
|
||||
cPdQ1SHgrBViAxX3DNPubLP0Knw8XwFu96EuhHZgexE1W7bB4LFsJyXAc5k1PqPD
|
||||
CLsAauxmvI2OfI7opG/8wyxDvNgoPjG8fZNAgY0REqPC0JnTXChH31IxUmhNotH8
|
||||
tD3DDTZOHw05n5MwwUrEE9xiETVDfFQcMLfxZ9KLz+BC2g1t5LYublRgnCMNJzFg
|
||||
sNUMM02CphABzl/LCLnumr0eyQQ/weV4twEhLwSDmqLYHL0EdYW0Y3CnnU9vmYxQ
|
||||
cXKbstS71sEJJYBBmSBbf9GxkOY8BRNtwVwY0kPgxv1WqdVBiAFvfB+pyAsrax9B
|
||||
3UeB7ZSwRD6JAhwEEAEKAAYFAlS25GwACgkQlbYYGy0z6ew92Q//ZA9/6piQtoW4
|
||||
PwP/1DtWGyKU8hwR+9FG669iPk/dAG+yoEJtFMOUpg/FUFmCX8Bc4oEHsCVyLxKt
|
||||
DcCVUIRcYNSFi5hTZaBEbwsOlDT37gtlfIIu34hhHRccKaLnN/N9gNMNw8wGh9xg
|
||||
Q/KtxZwcbk/bZIlDkKTJkFBRAekdEGAFDWb/AZOy+LQxS8ZAh1eWkfV0i8opmK9k
|
||||
gPXtLE0WSsqtYyGs58z+BFE9NH3tEUwK6jSvtuLwQl4UrICNbKthcpb8WwH6UXzb
|
||||
q3QNSYVOpf/cqRdBJA6bvb/ku/xyKVL08lGmxD9v1b137R7mafDAFPTsvH2Mt/0V
|
||||
YuhtWav3r1Bl9QksDxt2DTS8wiWDUBetGqOVdcw7vBrXPEWDNBmxeJXsiJ7zJlR+
|
||||
9wrJOm6RV2+l1IPxu96EaPS+kTNBijKrhxb67bww8BTEWTd0wcdJmgWRkM8SIstp
|
||||
IKqd0L2TFYph2/NtrBhRg+DIEPJPpSTGsUMcCEXCZPQ+cIdlQKsWpk0tZ62DlvEl
|
||||
r7E+wgUSQolRfx5KrpZifiS2zQlhzdXv28CJhsVbLyw5fUAWUKIH/dCo5NKsNLk2
|
||||
Lc5DH9VWnFgxAAtW290FqeK/4ulMq7Vs1dQSwyHM2Ni3QqqeaiOrh8gbSY5CMLFN
|
||||
Y3HYRwuTYPa3AobsozCzBj0Zdf/6AFe5Ag0ETMQ5kgEQAL/FwKdjxgPxtSpgq1SM
|
||||
zgZtTTyLqhgGD3NZfadHWHYRIL38NDV3JeTA79Y2zj2dj7KQPDT+0aqeizTV2E3j
|
||||
P3iCQ53VOT4consBaQAgKexpptnS+T1DobtICFJ0GGzf0HRj6KO2zSOuOitWPWlU
|
||||
wbvX7M0LLI2+hqlx0jTPqbJFZ/Za6KTtbS6xdCPVUpUqYZQpokEZcwQmUp8Q+lGo
|
||||
JD2sNYCZyap63X/aAOgCGr2RXYddOH5e8vGzGW+mwtCv+WQ9Ay35mGqI5MqkbZd1
|
||||
Qbuv2b1647E/QEEucfRHVbJVKGGPpFMUJtcItyyIt5jo+r9CCL4Cs47dF/9/RNwu
|
||||
NvpvHXUyqMBQdWNZRMx4k/NGD/WviPi9m6mIMui6rOQsSOaqYdcUX4Nq2Orr3Oaz
|
||||
2JPQdUfeI23iot1vK8hxvUCQTV3HfJghizN6spVl0yQOKBiE8miJRgrjHilH3hTb
|
||||
xoo42xDkNAq+CQo3QAm1ibDxKCDq0RcWPjcCRAN/Q5MmpcodpdKkzV0yGIS4g7s5
|
||||
frVrgV/kox2r4/Yxsr8K909+4H82AjTKGX/BmsQFCTAqBk6p7I0zxjIqJ/w33TZB
|
||||
Q0Pn4r3WIlUPafzY6a9/LAvN1fHRxf9SpCByJsszD03Qu5f5TB8gthsdnVmTo7jj
|
||||
iordEKMtw2aEMLzdWWTQ/TNVABEBAAGJAjwEGAEKACYCGwwWIQQ2kMJAzlG0Zw0w
|
||||
rRw47nV9aRhGIAUCYEt9YAUJFxeRzgAKCRA47nV9aRhGIMLtD/9HuKM4pngImcuz
|
||||
YwzQmdv4j26YYyh4jVsKEmVWTiRcehEgUIlrWkCu3qzd5NK+RetS7kJ8MPnzEUfj
|
||||
YbpdC6yrF6n1mSrZZ4VJMkV2ev37bIgXM+Wp1mCAGbjNxQnjn9RabT/gjIqmGuRn
|
||||
AP7RsSeOSuO/gO9h2Pteciz23ussTilB+8cTooQEQQZe6Kv/zukvL+ccSehLHsZ7
|
||||
qVfRUAmtt8nFkXXE+s8jfLfhqstaI2/RJu5witaPcXM8Mnz2E95aASAbZy0eQot9
|
||||
0Pvf07n9yuC3tueTvzvlXx3h5U3yT44tIOmzANIQjay1TGdm+RBJ2ZYyhyLawlZ2
|
||||
NVUXXSp4QZZXPA0UWbF+pb7Q9cdKDNFVuvGBljuea0Yd0T2o+ibDq43HziX9ll+l
|
||||
SXk9mqvW1UcDOaxWrSsm1Gc1O9g3wqH5xHAhtY8GPh/7VgAawskPkmnlkMW6pYPy
|
||||
zibbeISJL1gd1jIT63y6aoVrtNoo+wYJm280ROflh4+5QOo6QJ+jm70fkXSG/qJ5
|
||||
a8/qCPTHkJc/rpkL6/TDQAJURi9RhDAC0gb40HtusbN1LZEA+i0cWTmYXap+DB4Y
|
||||
R4pApilpaG87M+VUokR4xpnx7vTb2MPa7Mdenvi9FEGnKXadmT8038vlfzz5GGUT
|
||||
MlVin9BQPTpdA+PpRiJvKJgVDeAFOg==
|
||||
=asTC
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
@@ -8,15 +8,6 @@ if (NPROC EQUAL 0)
|
||||
set(NPROC 1)
|
||||
endif()
|
||||
|
||||
find_package(Boost 1.78 REQUIRED)
|
||||
find_package(BZip2 1.0.6 REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
set(GFLAGS_NOTHREADS OFF)
|
||||
find_package(gflags REQUIRED)
|
||||
find_package(fmt 8.0.1)
|
||||
find_package(Jemalloc REQUIRED)
|
||||
find_package(ZLIB 1.2.11 REQUIRED)
|
||||
|
||||
set(LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# convenience functions
|
||||
@@ -111,13 +102,19 @@ import_external_library(antlr4 STATIC
|
||||
|
||||
# Setup google benchmark.
|
||||
import_external_library(benchmark STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/benchmark/${CMAKE_INSTALL_LIBDIR}/libbenchmark.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/benchmark/lib/libbenchmark.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/benchmark/include
|
||||
# Skip testing. The tests don't compile with Clang 8.
|
||||
CMAKE_ARGS -DBENCHMARK_ENABLE_TESTING=OFF)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# setup fmt format
|
||||
FetchContent_Declare(fmt
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fmt)
|
||||
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
|
||||
# setup rapidcheck (it cannot be external, since it doesn't have install
|
||||
# target)
|
||||
set(RC_ENABLE_GTEST ON CACHE BOOL "Build Google Test integration" FORCE)
|
||||
@@ -143,19 +140,58 @@ import_library(gtest_main STATIC ${GTEST_MAIN_LIBRARY} ${GTEST_INCLUDE_DIR} gtes
|
||||
import_library(gmock STATIC ${GMOCK_LIBRARY} ${GTEST_INCLUDE_DIR} gtest-proj)
|
||||
import_library(gmock_main STATIC ${GMOCK_MAIN_LIBRARY} ${GTEST_INCLUDE_DIR} gtest-proj)
|
||||
|
||||
# setup google flags
|
||||
set(GFLAGS_NO_FILENAMES "0")
|
||||
if ("${CMAKE_BUILD_TYPE}" MATCHES "^(R|r)(E|e)(L|l).+")
|
||||
set(GFLAGS_NO_FILENAMES "1")
|
||||
endif()
|
||||
|
||||
# setup google flags
|
||||
import_external_library(gflags STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gflags/lib/libgflags.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gflags/include
|
||||
# Not needed, since gflags is C++ only.
|
||||
NO_C_COMPILER
|
||||
# Don't register installation in ~/.cmake
|
||||
CMAKE_ARGS -DREGISTER_INSTALL_PREFIX=OFF
|
||||
-DBUILD_gflags_nothreads_LIB=OFF
|
||||
-DGFLAGS_NO_FILENAMES=${GFLAGS_NO_FILENAMES})
|
||||
|
||||
# Setup cppitertools
|
||||
import_header_library(cppitertools ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# Setup json
|
||||
import_header_library(json ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# Setup bzip2
|
||||
import_external_library(bzip2 STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bzip2/libbz2.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bzip2
|
||||
# bzip2's Makefile has -g CFLAG which is redundant
|
||||
CONFIGURE_COMMAND sed -i "s/-Wall -Winline -O2 -g/-Wall -Winline -O2/g" ${CMAKE_CURRENT_SOURCE_DIR}/bzip2/Makefile
|
||||
BUILD_COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/bzip2
|
||||
CC=${CMAKE_C_COMPILER}
|
||||
CXX=${CMAKE_CXX_COMPILER}
|
||||
INSTALL_COMMAND true)
|
||||
|
||||
# Setup zlib
|
||||
set(ZLIB_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/zlib)
|
||||
set(ZLIB_LIBRARIES ${ZLIB_ROOT}/lib/libz.a)
|
||||
set(ZLIB_INCLUDE_DIRS ${ZLIB_ROOT}/include)
|
||||
import_external_library(zlib STATIC
|
||||
${ZLIB_LIBRARIES}
|
||||
${ZLIB_INCLUDE_DIRS}
|
||||
CMAKE_ARGS -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=true
|
||||
BUILD_COMMAND $(MAKE) zlibstatic)
|
||||
|
||||
# Setup RocksDB
|
||||
import_external_library(rocksdb STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/lib/librocksdb.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/include
|
||||
CMAKE_ARGS -DUSE_RTTI=ON
|
||||
DEPENDS gflags-proj
|
||||
CMAKE_ARGS -Dgflags_DIR=${CMAKE_CURRENT_SOURCE_DIR}/gflags/lib/cmake/gflags
|
||||
-DUSE_RTTI=ON
|
||||
-DWITH_TESTS=OFF
|
||||
-DGFLAGS_NOTHREADS=OFF
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=true
|
||||
BUILD_COMMAND $(MAKE) rocksdb)
|
||||
@@ -196,6 +232,8 @@ FetchContent_Declare(spdlog
|
||||
|
||||
FetchContent_MakeAvailable(spdlog)
|
||||
|
||||
include(jemalloc.cmake)
|
||||
|
||||
# Setup librdkafka.
|
||||
import_external_library(librdkafka STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/librdkafka/lib/librdkafka.a
|
||||
@@ -203,13 +241,12 @@ import_external_library(librdkafka STATIC
|
||||
CMAKE_ARGS -DRDKAFKA_BUILD_STATIC=ON
|
||||
-DRDKAFKA_BUILD_EXAMPLES=OFF
|
||||
-DRDKAFKA_BUILD_TESTS=OFF
|
||||
-DWITH_ZSTD=OFF
|
||||
-DENABLE_LZ4_EXT=OFF
|
||||
-DCMAKE_INSTALL_LIBDIR=lib
|
||||
-DWITH_SSL=ON
|
||||
# If we want SASL, we need to install it on build machines
|
||||
-DWITH_SASL=OFF)
|
||||
target_link_libraries(librdkafka INTERFACE ${OPENSSL_LIBRARIES} ZLIB::ZLIB)
|
||||
target_link_libraries(librdkafka INTERFACE ${OPENSSL_LIBRARIES} zlib)
|
||||
|
||||
import_library(librdkafka++ STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/librdkafka/lib/librdkafka++.a
|
||||
@@ -224,6 +261,9 @@ import_external_library(protobuf STATIC
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND true)
|
||||
|
||||
set(BOOST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/boost/lib)
|
||||
set(BOOST_ROOT ${BOOST_ROOT} PARENT_SCOPE)
|
||||
|
||||
import_external_library(pulsar STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pulsar/pulsar-client-cpp/lib/libpulsarwithdeps.a
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/pulsar/install/include
|
||||
@@ -240,8 +280,10 @@ import_external_library(pulsar STATIC
|
||||
-DBOOST_ROOT=${BOOST_ROOT}
|
||||
-DCMAKE_PREFIX_PATH=${PROTOBUF_ROOT}
|
||||
-DProtobuf_INCLUDE_DIRS=${PROTOBUF_ROOT}/include
|
||||
-DZLIB_LIBRARIES=${ZLIB_LIBRARIES}
|
||||
-DZLIB_INCLUDE_DIRS=${ZLIB_INCLUDE_DIRS}
|
||||
-DBUILD_PYTHON_WRAPPER=OFF
|
||||
-DBUILD_PERF_TOOLS=OFF
|
||||
-DUSE_LOG4CXX=OFF
|
||||
BUILD_COMMAND $(MAKE) pulsarStaticWithDeps)
|
||||
add_dependencies(pulsar-proj protobuf)
|
||||
add_dependencies(pulsar-proj protobuf zlib)
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt
|
||||
index a8503bb..11362cf 100644
|
||||
--- a/runtime/Cpp/runtime/CMakeLists.txt
|
||||
+++ b/runtime/Cpp/runtime/CMakeLists.txt
|
||||
@@ -5,8 +5,8 @@ set(THIRDPARTY_DIR ${CMAKE_BINARY_DIR}/runtime/thirdparty)
|
||||
set(UTFCPP_DIR ${THIRDPARTY_DIR}/utfcpp)
|
||||
ExternalProject_Add(
|
||||
utfcpp
|
||||
- GIT_REPOSITORY "git://github.com/nemtrif/utfcpp"
|
||||
- GIT_TAG "v3.1.1"
|
||||
+ GIT_REPOSITORY "https://github.com/nemtrif/utfcpp"
|
||||
+ GIT_TAG "v3.2.1"
|
||||
SOURCE_DIR ${UTFCPP_DIR}
|
||||
UPDATE_DISCONNECTED 1
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${UTFCPP_DIR}/install -Dgtest_force_shared_crt=ON
|
||||
@@ -118,7 +118,7 @@ set_target_properties(antlr4_static
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
|
||||
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")
|
||||
|
||||
-install(TARGETS antlr4_shared
|
||||
+install(TARGETS antlr4_shared OPTIONAL
|
||||
DESTINATION lib
|
||||
EXPORT antlr4-targets)
|
||||
install(TARGETS antlr4_static
|
||||
diff --git a/runtime/Cpp/runtime/src/support/Any.h b/runtime/Cpp/runtime/src/support/Any.h
|
||||
index 468db98..65a473b 100644
|
||||
--- a/runtime/Cpp/runtime/src/support/Any.h
|
||||
+++ b/runtime/Cpp/runtime/src/support/Any.h
|
||||
@@ -122,12 +122,12 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
- template<int N = 0, typename std::enable_if<N == N && std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
|
||||
+ template<int N = 0, typename std::enable_if<N == N && std::is_copy_constructible<T>::value, int>::type = 0>
|
||||
Base* clone() const {
|
||||
return new Derived<T>(value);
|
||||
}
|
||||
|
||||
- template<int N = 0, typename std::enable_if<N == N && !std::is_nothrow_copy_constructible<T>::value, int>::type = 0>
|
||||
+ template<int N = 0, typename std::enable_if<N == N && !std::is_copy_constructible<T>::value, int>::type = 0>
|
||||
Base* clone() const {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 6761929..6a369af 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -220,6 +220,7 @@ else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -momit-leaf-frame-pointer")
|
||||
endif()
|
||||
endif()
|
||||
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-copy -Wno-unused-but-set-variable")
|
||||
endif()
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
@@ -997,7 +998,7 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS)
|
||||
|
||||
if(ROCKSDB_BUILD_SHARED)
|
||||
install(
|
||||
- TARGETS ${ROCKSDB_SHARED_LIB}
|
||||
+ TARGETS ${ROCKSDB_SHARED_LIB} OPTIONAL
|
||||
EXPORT RocksDBTargets
|
||||
COMPONENT runtime
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
@@ -164,26 +164,39 @@ file_get_try_double "${primary_urls[antlr4-generator]}" "${secondary_urls[antlr4
|
||||
|
||||
antlr4_tag="4.9.2" # v4.9.2
|
||||
repo_clone_try_double "${primary_urls[antlr4-code]}" "${secondary_urls[antlr4-code]}" "antlr4" "$antlr4_tag" true
|
||||
pushd antlr4
|
||||
git apply ../antlr4.patch
|
||||
popd
|
||||
# remove shared library from install dependencies
|
||||
sed -i 's/install(TARGETS antlr4_shared/install(TARGETS antlr4_shared OPTIONAL/' antlr4/runtime/Cpp/runtime/CMakeLists.txt
|
||||
# fix issue https://github.com/antlr/antlr4/issues/3194 - should update Antlr commit once the PR related to the issue gets merged
|
||||
sed -i 's/std::is_nothrow_copy_constructible/std::is_copy_constructible/' antlr4/runtime/Cpp/runtime/src/support/Any.h
|
||||
# replace the utf8cpp version which is used because the older one uses gtest that doesn't
|
||||
# compile with the newer compilers because of uninitialized variable
|
||||
# the newer utf8cpp switched to ftest
|
||||
sed -i 's/v3.1.1/v3.2.1/' antlr4/runtime/Cpp/runtime/CMakeLists.txt
|
||||
|
||||
# cppitertools v2.0 2019-12-23
|
||||
cppitertools_ref="cb3635456bdb531121b82b4d2e3afc7ae1f56d47"
|
||||
repo_clone_try_double "${primary_urls[cppitertools]}" "${secondary_urls[cppitertools]}" "cppitertools" "$cppitertools_ref"
|
||||
|
||||
# fmt
|
||||
fmt_tag="8.0.1" # (2021-07-03)
|
||||
repo_clone_try_double "${primary_urls[fmt]}" "${secondary_urls[fmt]}" "fmt" "$fmt_tag" true
|
||||
|
||||
# rapidcheck
|
||||
rapidcheck_tag="7bc7d302191a4f3d0bf005692677126136e02f60" # (2020-05-04)
|
||||
repo_clone_try_double "${primary_urls[rapidcheck]}" "${secondary_urls[rapidcheck]}" "rapidcheck" "$rapidcheck_tag"
|
||||
|
||||
# google benchmark
|
||||
benchmark_tag="v1.6.0"
|
||||
benchmark_tag="v1.1.0"
|
||||
repo_clone_try_double "${primary_urls[gbenchmark]}" "${secondary_urls[gbenchmark]}" "benchmark" "$benchmark_tag" true
|
||||
|
||||
# google test
|
||||
googletest_tag="release-1.8.0"
|
||||
repo_clone_try_double "${primary_urls[gtest]}" "${secondary_urls[gtest]}" "googletest" "$googletest_tag" true
|
||||
|
||||
# google flags
|
||||
gflags_tag="b37ceb03a0e56c9f15ce80409438a555f8a67b7c" # custom version (May 6, 2017)
|
||||
repo_clone_try_double "${primary_urls[gflags]}" "${secondary_urls[gflags]}" "gflags" "$gflags_tag"
|
||||
|
||||
# libbcrypt
|
||||
libbcrypt_tag="8aa32ad94ebe06b76853b0767c910c9fbf7ccef4" # custom version (Dec 16, 2016)
|
||||
repo_clone_try_double "${primary_urls[libbcrypt]}" "${secondary_urls[libbcrypt]}" "libbcrypt" "$libbcrypt_tag"
|
||||
@@ -202,11 +215,18 @@ cd json
|
||||
file_get_try_double "${primary_urls[nlohmann]}" "${secondary_urls[nlohmann]}"
|
||||
cd ..
|
||||
|
||||
bzip2_tag="0405487e2b1de738e7f1c8afb50d19cf44e8d580" # v1.0.6 (May 26, 2011)
|
||||
repo_clone_try_double "${primary_urls[bzip2]}" "${secondary_urls[bzip2]}" "bzip2" "$bzip2_tag"
|
||||
|
||||
zlib_tag="v1.2.11" # v1.2.11.
|
||||
repo_clone_try_double "${primary_urls[zlib]}" "${secondary_urls[zlib]}" "zlib" "$zlib_tag" true
|
||||
# remove shared library from install dependencies
|
||||
sed -i 's/install(TARGETS zlib zlibstatic/install(TARGETS zlibstatic/g' zlib/CMakeLists.txt
|
||||
|
||||
rocksdb_tag="v6.14.6" # (2020-10-14)
|
||||
repo_clone_try_double "${primary_urls[rocksdb]}" "${secondary_urls[rocksdb]}" "rocksdb" "$rocksdb_tag" true
|
||||
pushd rocksdb
|
||||
git apply ../rocksdb.patch
|
||||
popd
|
||||
# remove shared library from install dependencies
|
||||
sed -i 's/TARGETS ${ROCKSDB_SHARED_LIB}/TARGETS ${ROCKSDB_SHARED_LIB} OPTIONAL/' rocksdb/CMakeLists.txt
|
||||
|
||||
# mgclient
|
||||
mgclient_tag="v1.3.0" # (2021-09-23)
|
||||
@@ -224,6 +244,25 @@ repo_clone_try_double "${primary_urls[mgconsole]}" "${secondary_urls[mgconsole]}
|
||||
spdlog_tag="v1.9.2" # (2021-08-12)
|
||||
repo_clone_try_double "${primary_urls[spdlog]}" "${secondary_urls[spdlog]}" "spdlog" "$spdlog_tag" true
|
||||
|
||||
jemalloc_tag="ea6b3e973b477b8061e0076bb257dbd7f3faa756" # (2021-02-11)
|
||||
repo_clone_try_double "${primary_urls[jemalloc]}" "${secondary_urls[jemalloc]}" "jemalloc" "$jemalloc_tag"
|
||||
pushd jemalloc
|
||||
# ThreadPool select job randomly, and there can be some threads that had been
|
||||
# performed some memory heavy task before and will be inactive for some time,
|
||||
# but until it will became active again, the memory will not be freed since by
|
||||
# default each thread has it's own arena, but there should be not more then
|
||||
# 4*CPU arenas (see opt.nareans description).
|
||||
#
|
||||
# By enabling percpu_arena number of arenas limited to number of CPUs and hence
|
||||
# this problem should go away.
|
||||
#
|
||||
# muzzy_decay_ms -- use MADV_FREE when available on newer Linuxes, to
|
||||
# avoid spurious latencies and additional work associated with
|
||||
# MADV_DONTNEED. See
|
||||
# https://github.com/ClickHouse/ClickHouse/issues/11121 for motivation.
|
||||
./autogen.sh --with-malloc-conf="percpu_arena:percpu,oversize_threshold:0,muzzy_decay_ms:5000,dirty_decay_ms:5000"
|
||||
popd
|
||||
|
||||
# librdkafka
|
||||
librdkafka_tag="v1.7.0" # (2021-05-06)
|
||||
repo_clone_try_double "${primary_urls[librdkafka]}" "${secondary_urls[librdkafka]}" "librdkafka" "$librdkafka_tag" true
|
||||
@@ -235,6 +274,15 @@ pushd protobuf
|
||||
./autogen.sh && ./configure CC=clang CXX=clang++ --prefix=$(pwd)/lib
|
||||
popd
|
||||
|
||||
# boost
|
||||
file_get_try_double "${primary_urls[boost]}" "${secondary_urls[boost]}"
|
||||
tar -xzf boost_1_77_0.tar.gz
|
||||
mv boost_1_77_0 boost
|
||||
pushd boost
|
||||
./bootstrap.sh --prefix=$(pwd)/lib --with-libraries="system,regex" --with-toolset=clang
|
||||
./b2 toolset=clang -j$(nproc) install variant=release
|
||||
popd
|
||||
|
||||
#pulsar
|
||||
pulsar_tag="v2.8.1"
|
||||
repo_clone_try_double "${primary_urls[pulsar]}" "${secondary_urls[pulsar]}" "pulsar" "$pulsar_tag" true
|
||||
|
||||
@@ -5,7 +5,7 @@ set -Eeuo pipefail
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SUPPORTED_OS=(centos-7 centos-8 debian-9 debian-10 debian-11 ubuntu-18.04 ubuntu-20.04)
|
||||
PROJECT_ROOT="$SCRIPT_DIR/../.."
|
||||
TOOLCHAIN_VERSION="toolchain-v4"
|
||||
TOOLCHAIN_VERSION="toolchain-v3"
|
||||
ACTIVATE_TOOLCHAIN="source /opt/${TOOLCHAIN_VERSION}/activate"
|
||||
HOST_OUTPUT_DIR="$PROJECT_ROOT/build/output"
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
set(audit_src_files log.cpp)
|
||||
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_library(mg-audit STATIC ${audit_src_files})
|
||||
target_link_libraries(mg-audit json gflags fmt::fmt)
|
||||
target_link_libraries(mg-audit mg-utils mg-storage-v2)
|
||||
|
||||
@@ -5,9 +5,6 @@ set(auth_src_files
|
||||
module.cpp)
|
||||
|
||||
find_package(Seccomp REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
|
||||
add_library(mg-auth STATIC ${auth_src_files})
|
||||
target_link_libraries(mg-auth json libbcrypt gflags fmt::fmt)
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
set(communication_src_files
|
||||
bolt/v1/value.cpp
|
||||
buffer.cpp
|
||||
@@ -9,8 +6,10 @@ set(communication_src_files
|
||||
helpers.cpp
|
||||
init.cpp)
|
||||
|
||||
find_package(Boost REQUIRED)
|
||||
|
||||
add_library(mg-communication STATIC ${communication_src_files})
|
||||
target_link_libraries(mg-communication Threads::Threads mg-utils mg-io fmt::fmt gflags)
|
||||
target_link_libraries(mg-communication Boost::headers Threads::Threads mg-utils mg-io fmt::fmt gflags)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(mg-communication ${OPENSSL_LIBRARIES})
|
||||
|
||||
@@ -89,8 +89,7 @@ class Server final {
|
||||
alive_.store(true);
|
||||
|
||||
if (!socket_.Bind(endpoint_)) {
|
||||
spdlog::error(
|
||||
utils::MessageWithLink("Cannot bind to socket on endpoint {}.", endpoint_, "https://memgr.ph/socket"));
|
||||
spdlog::error(utils::MessageWithLink("Cannot bind to socket on endpoint {}.", endpoint_, "https://memgr.ph/socket"));
|
||||
alive_.store(false);
|
||||
return false;
|
||||
}
|
||||
@@ -103,8 +102,9 @@ class Server final {
|
||||
|
||||
listener_.Start();
|
||||
|
||||
thread_ = std::thread([this]() {
|
||||
utils::ThreadSetName(fmt::format("{} server", service_name_));
|
||||
std::string service_name(service_name_);
|
||||
thread_ = std::thread([this, service_name]() {
|
||||
utils::ThreadSetName(fmt::format("{} server", service_name));
|
||||
|
||||
spdlog::info("{} server is fully armed and operational", service_name_);
|
||||
spdlog::info("{} listening on {}", service_name_, socket_.endpoint());
|
||||
|
||||
94
src/communication/websocket/listener.hpp
Normal file
94
src/communication/websocket/listener.hpp
Normal file
@@ -0,0 +1,94 @@
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
|
||||
#include "communication/websocket/session.hpp"
|
||||
#include "utils/spin_lock.hpp"
|
||||
#include "utils/synchronized.hpp"
|
||||
|
||||
namespace communication::websocket {
|
||||
template <typename TSession, typename TSessionData>
|
||||
class Listener : public std::enable_shared_from_this<Listener<TSession, TSessionData>> {
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
|
||||
public:
|
||||
template <typename... Args>
|
||||
static std::shared_ptr<Listener> Create(Args &&...args) {
|
||||
return std::shared_ptr<Listener>{new Listener(std::forward<Args>(args)...)};
|
||||
}
|
||||
|
||||
// Start accepting incoming connections
|
||||
void Run() {
|
||||
// The new connection gets its own strand
|
||||
acceptor_.async_accept(ioc_, [shared_this = this->shared_from_this()](auto ec, auto socket) {
|
||||
shared_this->OnAccept(ec, std::move(socket));
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
Listener(boost::asio::io_context &ioc, tcp::endpoint endpoint, TSessionData *data)
|
||||
: data_{data}, ioc_(ioc), acceptor_(ioc) {
|
||||
boost::beast::error_code ec;
|
||||
|
||||
// Open the acceptor
|
||||
acceptor_.open(endpoint.protocol(), ec);
|
||||
if (ec) {
|
||||
LogError(ec, "open");
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow address reuse
|
||||
acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec);
|
||||
if (ec) {
|
||||
LogError(ec, "set_option");
|
||||
return;
|
||||
}
|
||||
|
||||
// Bind to the server address
|
||||
acceptor_.bind(endpoint, ec);
|
||||
if (ec) {
|
||||
LogError(ec, "bind");
|
||||
return;
|
||||
}
|
||||
|
||||
acceptor_.listen(boost::asio::socket_base::max_listen_connections, ec);
|
||||
if (ec) {
|
||||
LogError(ec, "listen");
|
||||
return;
|
||||
}
|
||||
|
||||
spdlog::info("WebSocket server is listening on {}:{}", endpoint.address(), endpoint.port());
|
||||
}
|
||||
|
||||
void OnAccept(boost::beast::error_code ec, tcp::socket socket) {
|
||||
if (ec) {
|
||||
return LogError(ec, "accept");
|
||||
}
|
||||
|
||||
Session<TSession, TSessionData>::Create(std::move(socket), data_)->Run();
|
||||
Run();
|
||||
}
|
||||
|
||||
TSessionData *data_;
|
||||
boost::asio::io_context &ioc_;
|
||||
tcp::acceptor acceptor_;
|
||||
};
|
||||
} // namespace communication::websocket
|
||||
69
src/communication/websocket/server.hpp
Normal file
69
src/communication/websocket/server.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
#include "communication/websocket/listener.hpp"
|
||||
#include "io/network/endpoint.hpp"
|
||||
|
||||
namespace communication::websocket {
|
||||
|
||||
template <typename TSession, typename TSessionData>
|
||||
class Server final {
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
|
||||
public:
|
||||
explicit Server(io::network::Endpoint endpoint, TSessionData *data)
|
||||
: ioc_{},
|
||||
listener_{Listener<TSession, TSessionData>::Create(
|
||||
ioc_, tcp::endpoint{boost::asio::ip::make_address(endpoint.address), endpoint.port}, data)} {}
|
||||
|
||||
Server(const Server &) = delete;
|
||||
Server(Server &&) = delete;
|
||||
Server &operator=(const Server &) = delete;
|
||||
Server &operator=(Server &&) = delete;
|
||||
|
||||
~Server() {
|
||||
MG_ASSERT(!background_thread_ || (ioc_.stopped() && !background_thread_->joinable()),
|
||||
"Server wasn't shutdown properly");
|
||||
}
|
||||
|
||||
void Start() {
|
||||
MG_ASSERT(!background_thread_, "The server was already started!");
|
||||
listener_->Run();
|
||||
background_thread_.emplace([this] { ioc_.run(); });
|
||||
}
|
||||
|
||||
void Shutdown() { ioc_.stop(); }
|
||||
|
||||
void AwaitShutdown() {
|
||||
if (background_thread_ && background_thread_->joinable()) {
|
||||
background_thread_->join();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsRunning() const { return background_thread_ && !ioc_.stopped(); }
|
||||
|
||||
private:
|
||||
boost::asio::io_context ioc_;
|
||||
|
||||
std::shared_ptr<Listener<TSession, TSessionData>> listener_;
|
||||
std::optional<std::thread> background_thread_;
|
||||
};
|
||||
} // namespace communication::websocket
|
||||
157
src/communication/websocket/session.hpp
Normal file
157
src/communication/websocket/session.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include <boost/asio/dispatch.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/strand.hpp>
|
||||
#include <boost/beast/core/tcp_stream.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
|
||||
#include "communication/buffer.hpp"
|
||||
#include "communication/session.hpp"
|
||||
|
||||
namespace communication::websocket {
|
||||
void LogError(boost::beast::error_code ec, const std::string_view what) {
|
||||
spdlog::warn("Websocket session failed on {}: {}", what, ec.message());
|
||||
}
|
||||
|
||||
template <typename TSession, typename TSessionData>
|
||||
class Session : public std::enable_shared_from_this<Session<TSession, TSessionData>> {
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
|
||||
public:
|
||||
template <typename... Args>
|
||||
static std::shared_ptr<Session> Create(Args &&...args) {
|
||||
return std::shared_ptr<Session>{new Session{std::forward<Args>(args)...}};
|
||||
}
|
||||
|
||||
void Run() {
|
||||
boost::asio::dispatch(strand_, [shared_this = this->shared_from_this()] { shared_this->OnRun(); });
|
||||
}
|
||||
|
||||
private:
|
||||
explicit Session(tcp::socket &&socket, TSessionData *data)
|
||||
: endpoint_(socket.local_endpoint()),
|
||||
ws_(std::move(socket)),
|
||||
strand_{boost::asio::make_strand(ws_.get_executor())},
|
||||
data_{data} {}
|
||||
|
||||
void OnRun() {
|
||||
ws_.set_option(boost::beast::websocket::stream_base::timeout::suggested(boost::beast::role_type::server));
|
||||
boost::asio::socket_base::keep_alive option(true);
|
||||
ws_.set_option(boost::beast::websocket::stream_base::decorator([](boost::beast::websocket::response_type &res) {
|
||||
res.set(boost::beast::http::field::server, "Memgraph WS");
|
||||
res.set(boost::beast::http::field::sec_websocket_protocol, "binary");
|
||||
}));
|
||||
|
||||
ws_.binary(true);
|
||||
// This buffer will hold the HTTP request as raw characters
|
||||
|
||||
// This buffer is required for reading HTTP messages
|
||||
// flat_buffer buffer;
|
||||
|
||||
// Read the HTTP request ourselves
|
||||
// boost::beast::http::request<http::string_body> req;
|
||||
// http::read(sock, buffer, req);
|
||||
// std::cout << "bu
|
||||
// Read into our buffer until we reach the end of the HTTP request.
|
||||
// No parsing takes place here, we are just accumulating data.
|
||||
|
||||
// boost::beast::net::read_until(sock, net::dynamic_buffer(s), "\r\n\r\n");
|
||||
|
||||
// Now accept the connection, using the buffered data.
|
||||
// ws_.accept(net::buffer(s));
|
||||
ws_.async_accept(boost::asio::bind_executor(
|
||||
strand_, [shared_this = this->shared_from_this()](auto ec) { shared_this->OnAccept(ec); }));
|
||||
}
|
||||
|
||||
void OnAccept(boost::beast::error_code ec) {
|
||||
if (ec) {
|
||||
return LogError(ec, "accept");
|
||||
}
|
||||
|
||||
session_data_.emplace(this->shared_from_this());
|
||||
|
||||
// run on the strand
|
||||
boost::asio::dispatch(strand_, [shared_this = this->shared_from_this()] { shared_this->DoRead(); });
|
||||
}
|
||||
|
||||
void DoWrite(const uint8_t *data, size_t len, bool have_more = false) {
|
||||
boost::beast::error_code ec;
|
||||
ws_.write(boost::asio::const_buffer{data, len}, ec);
|
||||
if (ec) {
|
||||
return LogError(ec, "write");
|
||||
}
|
||||
}
|
||||
|
||||
void DoRead() {
|
||||
auto buf = session_data_->input_buffer_.write_end()->Allocate();
|
||||
|
||||
auto mutable_buffer = std::make_unique<boost::asio::mutable_buffer>(buf.data, buf.len);
|
||||
|
||||
ws_.async_read_some(
|
||||
*mutable_buffer,
|
||||
boost::asio::bind_executor(
|
||||
strand_, [mutable_buffer = std::move(mutable_buffer), shared_this = this->shared_from_this()](
|
||||
auto ec, auto bytes_transferred) { shared_this->OnRead(ec, bytes_transferred); }));
|
||||
}
|
||||
|
||||
void OnRead(boost::beast::error_code ec, size_t bytes_transferred) {
|
||||
if (ec == boost::beast::websocket::error::closed) {
|
||||
return;
|
||||
}
|
||||
if (ec) {
|
||||
return LogError(ec, "read");
|
||||
}
|
||||
|
||||
session_data_->input_buffer_.write_end()->Written(bytes_transferred);
|
||||
|
||||
try {
|
||||
session_data_->session_.Execute();
|
||||
} catch (const SessionClosedException &e) {
|
||||
spdlog::info("Closed connection");
|
||||
return;
|
||||
}
|
||||
DoRead();
|
||||
}
|
||||
|
||||
boost::asio::ip::tcp::endpoint endpoint_;
|
||||
boost::beast::websocket::stream<boost::beast::tcp_stream> ws_;
|
||||
boost::beast::flat_buffer buffer_;
|
||||
boost::asio::strand<decltype(ws_)::executor_type> strand_;
|
||||
|
||||
TSessionData *data_;
|
||||
|
||||
struct SessionData {
|
||||
explicit SessionData(std::shared_ptr<Session<TSession, TSessionData>> session)
|
||||
: output_stream_([session](const uint8_t *data, size_t len, bool have_more) {
|
||||
session->DoWrite(data, len, have_more);
|
||||
return true;
|
||||
}),
|
||||
session_(session->data_,
|
||||
io::network::Endpoint{session->endpoint_.address().to_string(), session->endpoint_.port()},
|
||||
input_buffer_.read_end(), &output_stream_) {}
|
||||
|
||||
Buffer input_buffer_;
|
||||
communication::OutputStream output_stream_;
|
||||
TSession session_;
|
||||
};
|
||||
|
||||
std::optional<SessionData> session_data_;
|
||||
};
|
||||
} // namespace communication::websocket
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -10,14 +10,11 @@
|
||||
// licenses/APL.txt.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
namespace integrations {
|
||||
constexpr int64_t kDefaultCheckBatchLimit{1};
|
||||
constexpr std::chrono::milliseconds kDefaultCheckTimeout{30000};
|
||||
constexpr std::chrono::milliseconds kMinimumInterval{1};
|
||||
constexpr int64_t kMinimumSize{1};
|
||||
const std::string kReducted{"<REDUCTED>"};
|
||||
} // namespace integrations
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -126,18 +126,6 @@ Consumer::Consumer(ConsumerInfo info, ConsumerFunction consumer_function)
|
||||
|
||||
std::string error;
|
||||
|
||||
for (const auto &[key, value] : info_.public_configs) {
|
||||
if (conf->set(key, value, error) != RdKafka::Conf::CONF_OK) {
|
||||
throw SettingCustomConfigFailed(info_.consumer_name, error, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &[key, value] : info_.private_configs) {
|
||||
if (conf->set(key, value, error) != RdKafka::Conf::CONF_OK) {
|
||||
throw SettingCustomConfigFailed(info_.consumer_name, error, key, kReducted);
|
||||
}
|
||||
}
|
||||
|
||||
if (conf->set("event_cb", this, error) != RdKafka::Conf::CONF_OK) {
|
||||
throw ConsumerFailedToInitializeException(info_.consumer_name, error);
|
||||
}
|
||||
@@ -440,11 +428,11 @@ void Consumer::ConsumerRebalanceCb::rebalance_cb(RdKafka::KafkaConsumer *consume
|
||||
}
|
||||
auto maybe_error = consumer->assign(partitions);
|
||||
if (maybe_error != RdKafka::ErrorCode::ERR_NO_ERROR) {
|
||||
spdlog::warn("Assigning offset of consumer {} failed: {}", consumer_name_, RdKafka::err2str(maybe_error));
|
||||
spdlog::warn("Assigning offset of consumer {} failed: {}", consumer_name_, RdKafka::err2str(err));
|
||||
}
|
||||
maybe_error = consumer->commitSync(partitions);
|
||||
if (maybe_error != RdKafka::ErrorCode::ERR_NO_ERROR) {
|
||||
spdlog::warn("Commiting offsets of consumer {} failed: {}", consumer_name_, RdKafka::err2str(maybe_error));
|
||||
spdlog::warn("Commiting offsets of consumer {} failed: {}", consumer_name_, RdKafka::err2str(err));
|
||||
}
|
||||
}
|
||||
void Consumer::ConsumerRebalanceCb::set_offset(int64_t offset) { offset_ = offset; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -86,8 +86,6 @@ struct ConsumerInfo {
|
||||
std::string bootstrap_servers;
|
||||
std::chrono::milliseconds batch_interval;
|
||||
int64_t batch_size;
|
||||
std::unordered_map<std::string, std::string> public_configs;
|
||||
std::unordered_map<std::string, std::string> private_configs;
|
||||
};
|
||||
|
||||
/// Memgraphs Kafka consumer wrapper.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include <string>
|
||||
|
||||
#include "utils/exceptions.hpp"
|
||||
|
||||
@@ -22,46 +22,37 @@ class KafkaStreamException : public utils::BasicException {
|
||||
|
||||
class ConsumerFailedToInitializeException : public KafkaStreamException {
|
||||
public:
|
||||
ConsumerFailedToInitializeException(std::string_view consumer_name, std::string_view error)
|
||||
ConsumerFailedToInitializeException(const std::string &consumer_name, const std::string &error)
|
||||
: KafkaStreamException("Failed to initialize Kafka consumer {} : {}", consumer_name, error) {}
|
||||
};
|
||||
|
||||
class SettingCustomConfigFailed : public ConsumerFailedToInitializeException {
|
||||
public:
|
||||
SettingCustomConfigFailed(std::string_view consumer_name, std::string_view error, std::string_view key,
|
||||
std::string_view value)
|
||||
: ConsumerFailedToInitializeException(
|
||||
consumer_name,
|
||||
fmt::format(R"(failed to set custom config ("{}": "{}"), because of error {})", key, value, error)) {}
|
||||
};
|
||||
|
||||
class ConsumerRunningException : public KafkaStreamException {
|
||||
public:
|
||||
explicit ConsumerRunningException(std::string_view consumer_name)
|
||||
explicit ConsumerRunningException(const std::string &consumer_name)
|
||||
: KafkaStreamException("Kafka consumer {} is already running", consumer_name) {}
|
||||
};
|
||||
|
||||
class ConsumerStoppedException : public KafkaStreamException {
|
||||
public:
|
||||
explicit ConsumerStoppedException(std::string_view consumer_name)
|
||||
explicit ConsumerStoppedException(const std::string &consumer_name)
|
||||
: KafkaStreamException("Kafka consumer {} is already stopped", consumer_name) {}
|
||||
};
|
||||
|
||||
class ConsumerCheckFailedException : public KafkaStreamException {
|
||||
public:
|
||||
explicit ConsumerCheckFailedException(std::string_view consumer_name, std::string_view error)
|
||||
explicit ConsumerCheckFailedException(const std::string &consumer_name, const std::string &error)
|
||||
: KafkaStreamException("Kafka consumer {} check failed: {}", consumer_name, error) {}
|
||||
};
|
||||
|
||||
class ConsumerStartFailedException : public KafkaStreamException {
|
||||
public:
|
||||
explicit ConsumerStartFailedException(std::string_view consumer_name, std::string_view error)
|
||||
explicit ConsumerStartFailedException(const std::string &consumer_name, const std::string &error)
|
||||
: KafkaStreamException("Starting Kafka consumer {} failed: {}", consumer_name, error) {}
|
||||
};
|
||||
|
||||
class TopicNotFoundException : public KafkaStreamException {
|
||||
public:
|
||||
TopicNotFoundException(std::string_view consumer_name, std::string_view topic_name)
|
||||
TopicNotFoundException(const std::string &consumer_name, const std::string &topic_name)
|
||||
: KafkaStreamException("Kafka consumer {} cannot find topic {}", consumer_name, topic_name) {}
|
||||
};
|
||||
} // namespace integrations::kafka
|
||||
|
||||
@@ -4,8 +4,5 @@ set(io_src_files
|
||||
network/socket.cpp
|
||||
network/utils.cpp)
|
||||
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_library(mg-io STATIC ${io_src_files})
|
||||
target_link_libraries(mg-io stdc++fs Threads::Threads fmt::fmt mg-utils)
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
find_package(gflags REQUIRED)
|
||||
find_package(BZip2 REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# STATIC library used to store key-value pairs
|
||||
add_library(mg-kvstore STATIC kvstore.cpp)
|
||||
target_link_libraries(mg-kvstore stdc++fs mg-utils rocksdb BZip2::BZip2 ZLIB::ZLIB gflags)
|
||||
target_link_libraries(mg-kvstore stdc++fs mg-utils rocksdb bzip2 zlib gflags)
|
||||
|
||||
# STATIC library for dummy key-value storage
|
||||
# add_library(mg-kvstore-dummy STATIC kvstore_dummy.cpp)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
|
||||
#include "communication/bolt/v1/constants.hpp"
|
||||
#include "communication/websocket/server.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "py/py.hpp"
|
||||
#include "query/auth_checker.hpp"
|
||||
@@ -1177,8 +1178,8 @@ int main(int argc, char **argv) {
|
||||
spdlog::warn(utils::MessageWithLink("Using non-secure Bolt connection (without SSL).", "https://memgr.ph/ssl"));
|
||||
}
|
||||
|
||||
ServerT server({FLAGS_bolt_address, static_cast<uint16_t>(FLAGS_bolt_port)}, &session_data, &context,
|
||||
FLAGS_bolt_session_inactivity_timeout, service_name, FLAGS_bolt_num_workers);
|
||||
auto server = communication::websocket::Server<BoltSession, SessionData>{
|
||||
{FLAGS_bolt_address, static_cast<uint16_t>(FLAGS_bolt_port)}, &session_data};
|
||||
|
||||
// Setup telemetry
|
||||
std::optional<telemetry::Telemetry> telemetry;
|
||||
@@ -1212,7 +1213,7 @@ int main(int argc, char **argv) {
|
||||
};
|
||||
InitSignalHandlers(shutdown);
|
||||
|
||||
MG_ASSERT(server.Start(), "Couldn't start the Bolt server!");
|
||||
server.Start();
|
||||
server.AwaitShutdown();
|
||||
query::procedure::gModuleRegistry.UnloadAllModules();
|
||||
|
||||
|
||||
@@ -2,11 +2,9 @@ set(memory_src_files
|
||||
new_delete.cpp
|
||||
memory_control.cpp)
|
||||
|
||||
find_package(Jemalloc REQUIRED)
|
||||
|
||||
add_library(mg-memory STATIC ${memory_src_files})
|
||||
target_link_libraries(mg-memory mg-utils fmt)
|
||||
|
||||
if (ENABLE_JEMALLOC)
|
||||
target_link_libraries(mg-memory Jemalloc::Jemalloc)
|
||||
target_link_libraries(mg-memory jemalloc)
|
||||
endif()
|
||||
|
||||
@@ -30,7 +30,6 @@ set(mg_query_sources
|
||||
plan/rule_based_planner.cpp
|
||||
plan/variable_start_planner.cpp
|
||||
procedure/mg_procedure_impl.cpp
|
||||
procedure/mg_procedure_helpers.cpp
|
||||
procedure/module.cpp
|
||||
procedure/py_module.cpp
|
||||
serialization/property_value.cpp
|
||||
@@ -48,9 +47,6 @@ add_dependencies(mg-query generate_lcp_query)
|
||||
target_include_directories(mg-query PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
||||
target_link_libraries(mg-query dl cppitertools Boost::headers)
|
||||
target_link_libraries(mg-query mg-integrations-pulsar mg-integrations-kafka mg-storage-v2 mg-license mg-utils mg-kvstore mg-memory)
|
||||
if(NOT "${MG_PYTHON_PATH}" STREQUAL "")
|
||||
set(Python3_ROOT_DIR "${MG_PYTHON_PATH}")
|
||||
endif()
|
||||
if("${MG_PYTHON_VERSION}" STREQUAL "")
|
||||
find_package(Python3 3.5 REQUIRED COMPONENTS Development)
|
||||
else()
|
||||
|
||||
@@ -54,7 +54,9 @@ cpp<#
|
||||
size_t size = 0;
|
||||
slk::Load(&size, reader);
|
||||
self->${member}.resize(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (size_t i = 0;
|
||||
i < size;
|
||||
++i) {
|
||||
self->${member}[i] = query::LoadAstPointer<query::${type}>(storage, reader);
|
||||
}
|
||||
cpp<#))
|
||||
@@ -73,7 +75,9 @@ cpp<#
|
||||
#>cpp
|
||||
size_t size = 0;
|
||||
slk::Load(&size, reader);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (size_t i = 0;
|
||||
i < size;
|
||||
++i) {
|
||||
query::PropertyIx key;
|
||||
slk::Load(&key, reader, storage);
|
||||
auto *value = query::LoadAstPointer<query::Expression>(storage, reader);
|
||||
@@ -89,34 +93,6 @@ cpp<#
|
||||
}
|
||||
cpp<#)
|
||||
|
||||
(defun slk-save-expression-map (member)
|
||||
#>cpp
|
||||
size_t size = self.${member}.size();
|
||||
slk::Save(size, builder);
|
||||
for (const auto &entry : self.${member}) {
|
||||
query::SaveAstPointer(entry.first, builder);
|
||||
query::SaveAstPointer(entry.second, builder);
|
||||
}
|
||||
cpp<#)
|
||||
|
||||
(defun slk-load-expression-map (member)
|
||||
#>cpp
|
||||
size_t size = 0;
|
||||
slk::Load(&size, reader);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
auto *key = query::LoadAstPointer<query::Expression>(storage, reader);
|
||||
auto *value = query::LoadAstPointer<query::Expression>(storage, reader);
|
||||
self->${member}.emplace(key, value);
|
||||
}
|
||||
cpp<#)
|
||||
|
||||
(defun clone-expression-map (source dest)
|
||||
#>cpp
|
||||
for (const auto &[key, value] : ${source}) {
|
||||
${dest}[key->Clone(storage)] = value->Clone(storage);
|
||||
}
|
||||
cpp<#)
|
||||
|
||||
(defun slk-load-name-ix (name-type)
|
||||
(lambda (member)
|
||||
#>cpp
|
||||
@@ -1843,7 +1819,9 @@ cpp<#
|
||||
size_t size = 0;
|
||||
slk::Load(&size, reader);
|
||||
self->${member}.resize(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (size_t i = 0;
|
||||
i < size;
|
||||
++i) {
|
||||
slk::Load(&self->${member}[i], reader, storage);
|
||||
}
|
||||
cpp<#)
|
||||
@@ -2553,7 +2531,7 @@ cpp<#
|
||||
:slk-save #'slk-save-ast-pointer
|
||||
:slk-load (slk-load-ast-pointer "Expression"))
|
||||
|
||||
(topic_names "std::variant<Expression*, std::vector<std::string>>" :initval "nullptr"
|
||||
(topic_names "std::variant<Expression*, std::vector<std::string>>" :initval "nullptr"
|
||||
:clone #'clone-variant-topic-names
|
||||
:scope :public)
|
||||
(consumer_group "std::string" :scope :public)
|
||||
@@ -2563,17 +2541,7 @@ cpp<#
|
||||
|
||||
(service_url "Expression *" :initval "nullptr" :scope :public
|
||||
:slk-save #'slk-save-ast-pointer
|
||||
:slk-load (slk-load-ast-pointer "Expression"))
|
||||
|
||||
(configs "std::unordered_map<Expression *, Expression *>" :scope :public
|
||||
:slk-save #'slk-save-expression-map
|
||||
:slk-load #'slk-load-expression-map
|
||||
:clone #'clone-expression-map)
|
||||
|
||||
(credentials "std::unordered_map<Expression *, Expression *>" :scope :public
|
||||
:slk-save #'slk-save-expression-map
|
||||
:slk-load #'slk-load-expression-map
|
||||
:clone #'clone-expression-map))
|
||||
:slk-load (slk-load-ast-pointer "Expression")))
|
||||
|
||||
(:public
|
||||
(lcp:define-enum action
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -564,7 +564,7 @@ std::string_view ToString(const CommonStreamConfigKey key) {
|
||||
__VA_ARGS__ \
|
||||
};
|
||||
|
||||
GENERATE_STREAM_CONFIG_KEY_ENUM(Kafka, TOPICS, CONSUMER_GROUP, BOOTSTRAP_SERVERS, CONFIGS, CREDENTIALS);
|
||||
GENERATE_STREAM_CONFIG_KEY_ENUM(Kafka, TOPICS, CONSUMER_GROUP, BOOTSTRAP_SERVERS);
|
||||
|
||||
std::string_view ToString(const KafkaConfigKey key) {
|
||||
switch (key) {
|
||||
@@ -574,10 +574,6 @@ std::string_view ToString(const KafkaConfigKey key) {
|
||||
return "CONSUMER_GROUP";
|
||||
case KafkaConfigKey::BOOTSTRAP_SERVERS:
|
||||
return "BOOTSTRAP_SERVERS";
|
||||
case KafkaConfigKey::CONFIGS:
|
||||
return "CONFIGS";
|
||||
case KafkaConfigKey::CREDENTIALS:
|
||||
return "CREDENTIALS";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -588,21 +584,6 @@ void MapCommonStreamConfigs(auto &memory, StreamQuery &stream_query) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitConfigKeyValuePair(MemgraphCypher::ConfigKeyValuePairContext *ctx) {
|
||||
MG_ASSERT(ctx->literal().size() == 2);
|
||||
return std::pair{ctx->literal(0)->accept(this).as<Expression *>(), ctx->literal(1)->accept(this).as<Expression *>()};
|
||||
}
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitConfigMap(MemgraphCypher::ConfigMapContext *ctx) {
|
||||
std::unordered_map<Expression *, Expression *> map;
|
||||
for (auto *key_value_pair : ctx->configKeyValuePair()) {
|
||||
// If the queries are cached, then only the stripped query is parsed, so the actual keys cannot be determined
|
||||
// here. That means duplicates cannot be checked.
|
||||
map.insert(key_value_pair->accept(this).as<std::pair<Expression *, Expression *>>());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitKafkaCreateStream(MemgraphCypher::KafkaCreateStreamContext *ctx) {
|
||||
auto *stream_query = storage_->Create<StreamQuery>();
|
||||
stream_query->action_ = StreamQuery::Action::CREATE_STREAM;
|
||||
@@ -616,10 +597,6 @@ antlrcpp::Any CypherMainVisitor::visitKafkaCreateStream(MemgraphCypher::KafkaCre
|
||||
MapConfig<true, std::vector<std::string>, Expression *>(memory_, KafkaConfigKey::TOPICS, stream_query->topic_names_);
|
||||
MapConfig<false, std::string>(memory_, KafkaConfigKey::CONSUMER_GROUP, stream_query->consumer_group_);
|
||||
MapConfig<false, Expression *>(memory_, KafkaConfigKey::BOOTSTRAP_SERVERS, stream_query->bootstrap_servers_);
|
||||
MapConfig<false, std::unordered_map<Expression *, Expression *>>(memory_, KafkaConfigKey::CONFIGS,
|
||||
stream_query->configs_);
|
||||
MapConfig<false, std::unordered_map<Expression *, Expression *>>(memory_, KafkaConfigKey::CREDENTIALS,
|
||||
stream_query->credentials_);
|
||||
|
||||
MapCommonStreamConfigs(memory_, *stream_query);
|
||||
|
||||
@@ -655,33 +632,18 @@ antlrcpp::Any CypherMainVisitor::visitKafkaCreateStreamConfig(MemgraphCypher::Ka
|
||||
|
||||
if (ctx->TOPICS()) {
|
||||
ThrowIfExists(memory_, KafkaConfigKey::TOPICS);
|
||||
constexpr auto topics_key = static_cast<uint8_t>(KafkaConfigKey::TOPICS);
|
||||
const auto topics_key = static_cast<uint8_t>(KafkaConfigKey::TOPICS);
|
||||
GetTopicNames(memory_[topics_key], ctx->topicNames(), *this);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (ctx->CONSUMER_GROUP()) {
|
||||
ThrowIfExists(memory_, KafkaConfigKey::CONSUMER_GROUP);
|
||||
constexpr auto consumer_group_key = static_cast<uint8_t>(KafkaConfigKey::CONSUMER_GROUP);
|
||||
const auto consumer_group_key = static_cast<uint8_t>(KafkaConfigKey::CONSUMER_GROUP);
|
||||
memory_[consumer_group_key] = JoinSymbolicNamesWithDotsAndMinus(*this, *ctx->consumerGroup);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (ctx->CONFIGS()) {
|
||||
ThrowIfExists(memory_, KafkaConfigKey::CONFIGS);
|
||||
constexpr auto configs_key = static_cast<uint8_t>(KafkaConfigKey::CONFIGS);
|
||||
memory_.emplace(configs_key, ctx->configsMap->accept(this).as<std::unordered_map<Expression *, Expression *>>());
|
||||
return {};
|
||||
}
|
||||
|
||||
if (ctx->CREDENTIALS()) {
|
||||
ThrowIfExists(memory_, KafkaConfigKey::CREDENTIALS);
|
||||
constexpr auto credentials_key = static_cast<uint8_t>(KafkaConfigKey::CREDENTIALS);
|
||||
memory_.emplace(credentials_key,
|
||||
ctx->credentialsMap->accept(this).as<std::unordered_map<Expression *, Expression *>>());
|
||||
return {};
|
||||
}
|
||||
|
||||
MG_ASSERT(ctx->BOOTSTRAP_SERVERS());
|
||||
ThrowIfExists(memory_, KafkaConfigKey::BOOTSTRAP_SERVERS);
|
||||
if (!ctx->bootstrapServers->StringLiteral()) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -269,16 +269,6 @@ class CypherMainVisitor : public antlropencypher::MemgraphCypherBaseVisitor {
|
||||
*/
|
||||
antlrcpp::Any visitCreateStream(MemgraphCypher::CreateStreamContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return StreamQuery*
|
||||
*/
|
||||
antlrcpp::Any visitConfigKeyValuePair(MemgraphCypher::ConfigKeyValuePairContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return StreamQuery*
|
||||
*/
|
||||
antlrcpp::Any visitConfigMap(MemgraphCypher::ConfigMapContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return StreamQuery*
|
||||
*/
|
||||
@@ -859,9 +849,7 @@ class CypherMainVisitor : public antlropencypher::MemgraphCypherBaseVisitor {
|
||||
ParsingContext context_;
|
||||
AstStorage *storage_;
|
||||
|
||||
std::unordered_map<uint8_t, std::variant<Expression *, std::string, std::vector<std::string>,
|
||||
std::unordered_map<Expression *, Expression *>>>
|
||||
memory_;
|
||||
std::unordered_map<uint8_t, std::variant<Expression *, std::string, std::vector<std::string>>> memory_;
|
||||
// Set of identifiers from queries.
|
||||
std::unordered_set<std::string> users_identifiers;
|
||||
// Identifiers that user didn't name.
|
||||
|
||||
@@ -35,9 +35,7 @@ memgraphCypherKeyword : cypherKeyword
|
||||
| COMMIT
|
||||
| COMMITTED
|
||||
| CONFIG
|
||||
| CONFIGS
|
||||
| CONSUMER_GROUP
|
||||
| CREDENTIALS
|
||||
| CSV
|
||||
| DATA
|
||||
| DELIMITER
|
||||
@@ -308,15 +306,9 @@ commonCreateStreamConfig : TRANSFORM transformationName=procedureName
|
||||
|
||||
createStream : kafkaCreateStream | pulsarCreateStream ;
|
||||
|
||||
configKeyValuePair : literal ':' literal ;
|
||||
|
||||
configMap : '{' ( configKeyValuePair ( ',' configKeyValuePair )* )? '}' ;
|
||||
|
||||
kafkaCreateStreamConfig : TOPICS topicNames
|
||||
| CONSUMER_GROUP consumerGroup=symbolicNameWithDotsAndMinus
|
||||
| BOOTSTRAP_SERVERS bootstrapServers=literal
|
||||
| CONFIGS configsMap=configMap
|
||||
| CREDENTIALS credentialsMap=configMap
|
||||
| commonCreateStreamConfig
|
||||
;
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ CLEAR : C L E A R ;
|
||||
COMMIT : C O M M I T ;
|
||||
COMMITTED : C O M M I T T E D ;
|
||||
CONFIG : C O N F I G ;
|
||||
CONFIGS : C O N F I G S;
|
||||
CONSUMER_GROUP : C O N S U M E R UNDERSCORE G R O U P ;
|
||||
CREDENTIALS : C R E D E N T I A L S ;
|
||||
CSV : C S V ;
|
||||
DATA : D A T A ;
|
||||
DELIMITER : D E L I M I T E R ;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -564,26 +564,10 @@ Callback::CallbackFunction GetKafkaCreateCallback(StreamQuery *stream_query, Exp
|
||||
}
|
||||
auto common_stream_info = GetCommonStreamInfo(stream_query, evaluator);
|
||||
|
||||
const auto get_config_map = [&evaluator](std::unordered_map<Expression *, Expression *> map,
|
||||
std::string_view map_name) -> std::unordered_map<std::string, std::string> {
|
||||
std::unordered_map<std::string, std::string> config_map;
|
||||
for (const auto [key_expr, value_expr] : map) {
|
||||
const auto key = key_expr->Accept(evaluator);
|
||||
const auto value = value_expr->Accept(evaluator);
|
||||
if (!key.IsString() || !value.IsString()) {
|
||||
throw SemanticException("{} must contain only string keys and values!", map_name);
|
||||
}
|
||||
config_map.emplace(key.ValueString(), value.ValueString());
|
||||
}
|
||||
return config_map;
|
||||
};
|
||||
|
||||
return [interpreter_context, stream_name = stream_query->stream_name_,
|
||||
topic_names = EvaluateTopicNames(evaluator, stream_query->topic_names_),
|
||||
consumer_group = std::move(consumer_group), common_stream_info = std::move(common_stream_info),
|
||||
bootstrap_servers = std::move(bootstrap), owner = StringPointerToOptional(username),
|
||||
configs = get_config_map(stream_query->configs_, "Configs"),
|
||||
credentials = get_config_map(stream_query->credentials_, "Credentials")]() mutable {
|
||||
bootstrap_servers = std::move(bootstrap), owner = StringPointerToOptional(username)]() mutable {
|
||||
std::string bootstrap = bootstrap_servers
|
||||
? std::move(*bootstrap_servers)
|
||||
: std::string{interpreter_context->config.default_kafka_bootstrap_servers};
|
||||
@@ -591,9 +575,7 @@ Callback::CallbackFunction GetKafkaCreateCallback(StreamQuery *stream_query, Exp
|
||||
{.common_info = std::move(common_stream_info),
|
||||
.topics = std::move(topic_names),
|
||||
.consumer_group = std::move(consumer_group),
|
||||
.bootstrap_servers = std::move(bootstrap),
|
||||
.configs = std::move(configs),
|
||||
.credentials = std::move(credentials)},
|
||||
.bootstrap_servers = std::move(bootstrap)},
|
||||
std::move(owner));
|
||||
|
||||
return std::vector<std::vector<TypedValue>>{};
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include "query/procedure/mg_procedure_helpers.hpp"
|
||||
|
||||
namespace query::procedure {
|
||||
MgpUniquePtr<mgp_value> GetStringValueOrSetError(const char *string, mgp_memory *memory, mgp_result *result) {
|
||||
procedure::MgpUniquePtr<mgp_value> value{nullptr, mgp_value_destroy};
|
||||
const auto success =
|
||||
TryOrSetError([&] { return procedure::CreateMgpObject(value, mgp_value_make_string, string, memory); }, result);
|
||||
if (!success) {
|
||||
value.reset();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool InsertResultOrSetError(mgp_result *result, mgp_result_record *record, const char *result_name, mgp_value *value) {
|
||||
if (const auto err = mgp_result_record_insert(record, result_name, value); err != MGP_ERROR_NO_ERROR) {
|
||||
const auto error_msg = fmt::format("Unable to set the result for {}, error = {}", result_name, err);
|
||||
static_cast<void>(mgp_result_set_error_msg(result, error_msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace query::procedure
|
||||
@@ -15,8 +15,6 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "mg_procedure.h"
|
||||
|
||||
namespace query::procedure {
|
||||
@@ -47,23 +45,4 @@ mgp_error CreateMgpObject(MgpUniquePtr<TObj> &obj, TFunc func, TArgs &&...args)
|
||||
obj.reset(raw_obj);
|
||||
return err;
|
||||
}
|
||||
|
||||
template <typename Fun>
|
||||
[[nodiscard]] bool TryOrSetError(Fun &&func, mgp_result *result) {
|
||||
if (const auto err = func(); err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return false;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
const auto error_msg = fmt::format("Unexpected error ({})!", err);
|
||||
static_cast<void>(mgp_result_set_error_msg(result, error_msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] MgpUniquePtr<mgp_value> GetStringValueOrSetError(const char *string, mgp_memory *memory,
|
||||
mgp_result *result);
|
||||
|
||||
[[nodiscard]] bool InsertResultOrSetError(mgp_result *result, mgp_result_record *record, const char *result_name,
|
||||
mgp_value *value);
|
||||
} // namespace query::procedure
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -18,9 +18,7 @@ extern "C" {
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "py/py.hpp"
|
||||
#include "query/procedure/mg_procedure_helpers.hpp"
|
||||
#include "query/procedure/py_module.hpp"
|
||||
@@ -55,8 +53,6 @@ class BuiltinModule final : public Module {
|
||||
|
||||
void AddTransformation(std::string_view name, mgp_trans trans);
|
||||
|
||||
std::optional<std::filesystem::path> Path() const override { return std::nullopt; }
|
||||
|
||||
private:
|
||||
/// Registered procedures
|
||||
std::map<std::string, mgp_proc, std::less<>> procedures_;
|
||||
@@ -137,20 +133,6 @@ void RegisterMgLoad(ModuleRegistry *module_registry, utils::RWLock *lock, Builti
|
||||
module->AddProcedure("load", std::move(load));
|
||||
}
|
||||
|
||||
namespace {
|
||||
[[nodiscard]] bool IsFileEditable(const std::optional<std::filesystem::path> &path) {
|
||||
return path && access(path->c_str(), W_OK) == 0;
|
||||
}
|
||||
|
||||
std::string GetPathString(const std::optional<std::filesystem::path> &path) {
|
||||
if (!path) {
|
||||
return "builtin";
|
||||
}
|
||||
|
||||
return std::filesystem::canonical(*path).generic_string();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void RegisterMgProcedures(
|
||||
// We expect modules to be sorted by name.
|
||||
const std::map<std::string, std::unique_ptr<Module>, std::less<>> *all_modules, BuiltinModule *module) {
|
||||
@@ -165,80 +147,57 @@ void RegisterMgProcedures(
|
||||
static_assert(
|
||||
std::is_same_v<decltype(module->Procedures()), const std::map<std::string, mgp_proc, std::less<>> *>,
|
||||
"Expected module procedures to be sorted by name");
|
||||
|
||||
const auto path = module->Path();
|
||||
const auto path_string = GetPathString(path);
|
||||
const auto is_editable = IsFileEditable(path);
|
||||
|
||||
for (const auto &[proc_name, proc] : *module->Procedures()) {
|
||||
mgp_result_record *record{nullptr};
|
||||
{
|
||||
const auto success = TryOrSetError([&] { return mgp_result_new_record(result, &record); }, result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto path_value = GetStringValueOrSetError(path_string.c_str(), memory, result);
|
||||
if (!path_value) {
|
||||
if (const auto err = mgp_result_new_record(result, &record); err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unexpected error"));
|
||||
return;
|
||||
}
|
||||
|
||||
MgpUniquePtr<mgp_value> is_editable_value{nullptr, mgp_value_destroy};
|
||||
{
|
||||
const auto success = TryOrSetError(
|
||||
[&] { return CreateMgpObject(is_editable_value, mgp_value_make_bool, is_editable, memory); }, result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
utils::pmr::string full_name(module_name, memory->impl);
|
||||
full_name.append(1, '.');
|
||||
full_name.append(proc_name);
|
||||
const auto name_value = GetStringValueOrSetError(full_name.c_str(), memory, result);
|
||||
if (!name_value) {
|
||||
MgpUniquePtr<mgp_value> name_value{nullptr, mgp_value_destroy};
|
||||
if (const auto err = CreateMgpObject(name_value, mgp_value_make_string, full_name.c_str(), memory);
|
||||
err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unexpected error"));
|
||||
return;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << module_name << ".";
|
||||
PrintProcSignature(proc, &ss);
|
||||
const auto signature = ss.str();
|
||||
const auto signature_value = GetStringValueOrSetError(signature.c_str(), memory, result);
|
||||
if (!signature_value) {
|
||||
MgpUniquePtr<mgp_value> signature_value{nullptr, mgp_value_destroy};
|
||||
if (const auto err = CreateMgpObject(signature_value, mgp_value_make_string, signature.c_str(), memory);
|
||||
err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unexpected error"));
|
||||
return;
|
||||
}
|
||||
|
||||
MgpUniquePtr<mgp_value> is_write_value{nullptr, mgp_value_destroy};
|
||||
{
|
||||
const auto success = TryOrSetError(
|
||||
[&, &proc = proc] {
|
||||
return CreateMgpObject(is_write_value, mgp_value_make_bool, proc.is_write_procedure ? 1 : 0, memory);
|
||||
},
|
||||
result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "name", name_value.get())) {
|
||||
if (const auto err =
|
||||
CreateMgpObject(is_write_value, mgp_value_make_bool, proc.is_write_procedure ? 1 : 0, memory);
|
||||
err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unexpected error"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "signature", signature_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "is_write", is_write_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "path", path_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "is_editable", is_editable_value.get())) {
|
||||
const auto err1 = mgp_result_record_insert(record, "name", name_value.get());
|
||||
const auto err2 = mgp_result_record_insert(record, "signature", signature_value.get());
|
||||
const auto err3 = mgp_result_record_insert(record, "is_write", is_write_value.get());
|
||||
if (err1 != MGP_ERROR_NO_ERROR || err2 != MGP_ERROR_NO_ERROR || err3 != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unable to set the result!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -248,8 +207,6 @@ void RegisterMgProcedures(
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "name", Call<mgp_type *>(mgp_type_string)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "signature", Call<mgp_type *>(mgp_type_string)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "is_write", Call<mgp_type *>(mgp_type_bool)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "path", Call<mgp_type *>(mgp_type_string)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "is_editable", Call<mgp_type *>(mgp_type_bool)) == MGP_ERROR_NO_ERROR);
|
||||
module->AddProcedure("procedures", std::move(procedures));
|
||||
}
|
||||
|
||||
@@ -262,52 +219,32 @@ void RegisterMgTransformations(const std::map<std::string, std::unique_ptr<Modul
|
||||
static_assert(
|
||||
std::is_same_v<decltype(module->Transformations()), const std::map<std::string, mgp_trans, std::less<>> *>,
|
||||
"Expected module transformations to be sorted by name");
|
||||
|
||||
const auto path = module->Path();
|
||||
const auto path_string = GetPathString(path);
|
||||
const auto is_editable = IsFileEditable(path);
|
||||
|
||||
for (const auto &[trans_name, proc] : *module->Transformations()) {
|
||||
mgp_result_record *record{nullptr};
|
||||
{
|
||||
const auto success = TryOrSetError([&] { return mgp_result_new_record(result, &record); }, result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto path_value = GetStringValueOrSetError(path_string.c_str(), memory, result);
|
||||
if (!path_value) {
|
||||
if (const auto err = mgp_result_new_record(result, &record); err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unexpected error"));
|
||||
return;
|
||||
}
|
||||
|
||||
MgpUniquePtr<mgp_value> is_editable_value{nullptr, mgp_value_destroy};
|
||||
{
|
||||
const auto success = TryOrSetError(
|
||||
[&] { return CreateMgpObject(is_editable_value, mgp_value_make_bool, is_editable, memory); }, result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
utils::pmr::string full_name(module_name, memory->impl);
|
||||
full_name.append(1, '.');
|
||||
full_name.append(trans_name);
|
||||
|
||||
const auto name_value = GetStringValueOrSetError(full_name.c_str(), memory, result);
|
||||
if (!name_value) {
|
||||
MgpUniquePtr<mgp_value> name_value{nullptr, mgp_value_destroy};
|
||||
if (const auto err = CreateMgpObject(name_value, mgp_value_make_string, full_name.c_str(), memory);
|
||||
err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unexpected error"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "name", name_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "path", path_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InsertResultOrSetError(result, record, "is_editable", is_editable_value.get())) {
|
||||
if (const auto err = mgp_result_record_insert(record, "name", name_value.get()); err != MGP_ERROR_NO_ERROR) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Unable to set the result!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -315,8 +252,6 @@ void RegisterMgTransformations(const std::map<std::string, std::unique_ptr<Modul
|
||||
};
|
||||
mgp_proc procedures("transformations", transformations_cb, utils::NewDeleteResource(), false);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "name", Call<mgp_type *>(mgp_type_string)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "path", Call<mgp_type *>(mgp_type_string)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&procedures, "is_editable", Call<mgp_type *>(mgp_type_bool)) == MGP_ERROR_NO_ERROR);
|
||||
module->AddProcedure("transformations", std::move(procedures));
|
||||
}
|
||||
|
||||
@@ -362,8 +297,6 @@ class SharedLibraryModule final : public Module {
|
||||
|
||||
const std::map<std::string, mgp_trans, std::less<>> *Transformations() const override;
|
||||
|
||||
std::optional<std::filesystem::path> Path() const override { return file_path_; }
|
||||
|
||||
private:
|
||||
/// Path as requested for loading the module from a library.
|
||||
std::filesystem::path file_path_;
|
||||
@@ -421,8 +354,8 @@ bool SharedLibraryModule::Load(const std::filesystem::path &file_path) {
|
||||
return with_error(error);
|
||||
}
|
||||
for (auto &trans : module_def->transformations) {
|
||||
const auto error_code = MgpTransAddFixedResult(&trans.second);
|
||||
if (error_code != MGP_ERROR_NO_ERROR) {
|
||||
const bool was_result_added = MgpTransAddFixedResult(&trans.second);
|
||||
if (!was_result_added) {
|
||||
const auto error =
|
||||
fmt::format("Unable to add result to transformation in module {}; add result failed", file_path);
|
||||
return with_error(error);
|
||||
@@ -491,7 +424,6 @@ class PythonModule final : public Module {
|
||||
|
||||
const std::map<std::string, mgp_proc, std::less<>> *Procedures() const override;
|
||||
const std::map<std::string, mgp_trans, std::less<>> *Transformations() const override;
|
||||
std::optional<std::filesystem::path> Path() const override { return file_path_; }
|
||||
|
||||
private:
|
||||
std::filesystem::path file_path_;
|
||||
@@ -745,9 +677,9 @@ template <typename T>
|
||||
concept ModuleProperties = utils::SameAsAnyOf<T, mgp_proc, mgp_trans>;
|
||||
|
||||
template <ModuleProperties T>
|
||||
std::optional<std::pair<ModulePtr, const T *>> MakePairIfPropFound(const ModuleRegistry &module_registry,
|
||||
std::string_view fully_qualified_name,
|
||||
utils::MemoryResource *memory) {
|
||||
std::optional<std::pair<procedure::ModulePtr, const T *>> MakePairIfPropFound(const ModuleRegistry &module_registry,
|
||||
std::string_view fully_qualified_name,
|
||||
utils::MemoryResource *memory) {
|
||||
auto prop_fun = [](auto &module) {
|
||||
if constexpr (std::is_same_v<T, mgp_proc>) {
|
||||
return module->Procedures();
|
||||
@@ -768,13 +700,13 @@ std::optional<std::pair<ModulePtr, const T *>> MakePairIfPropFound(const ModuleR
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<std::pair<ModulePtr, const mgp_proc *>> FindProcedure(const ModuleRegistry &module_registry,
|
||||
std::string_view fully_qualified_procedure_name,
|
||||
utils::MemoryResource *memory) {
|
||||
std::optional<std::pair<procedure::ModulePtr, const mgp_proc *>> FindProcedure(
|
||||
const ModuleRegistry &module_registry, std::string_view fully_qualified_procedure_name,
|
||||
utils::MemoryResource *memory) {
|
||||
return MakePairIfPropFound<mgp_proc>(module_registry, fully_qualified_procedure_name, memory);
|
||||
}
|
||||
|
||||
std::optional<std::pair<ModulePtr, const mgp_trans *>> FindTransformation(
|
||||
std::optional<std::pair<procedure::ModulePtr, const mgp_trans *>> FindTransformation(
|
||||
const ModuleRegistry &module_registry, std::string_view fully_qualified_transformation_name,
|
||||
utils::MemoryResource *memory) {
|
||||
return MakePairIfPropFound<mgp_trans>(module_registry, fully_qualified_transformation_name, memory);
|
||||
|
||||
@@ -45,8 +45,6 @@ class Module {
|
||||
virtual const std::map<std::string, mgp_proc, std::less<>> *Procedures() const = 0;
|
||||
/// Returns registered transformations of this module
|
||||
virtual const std::map<std::string, mgp_trans, std::less<>> *Transformations() const = 0;
|
||||
|
||||
virtual std::optional<std::filesystem::path> Path() const = 0;
|
||||
};
|
||||
|
||||
/// Proxy for a registered Module, acquires a read lock from ModuleRegistry.
|
||||
|
||||
@@ -181,7 +181,6 @@ PyObject *PyVerticesIteratorGet(PyVerticesIterator *self, PyObject *Py_UNUSED(ig
|
||||
return nullptr;
|
||||
}
|
||||
if (vertex == nullptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return MakePyVertex(*vertex, self->py_graph);
|
||||
@@ -196,7 +195,6 @@ PyObject *PyVerticesIteratorNext(PyVerticesIterator *self, PyObject *Py_UNUSED(i
|
||||
return nullptr;
|
||||
}
|
||||
if (vertex == nullptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return MakePyVertex(*vertex, self->py_graph);
|
||||
@@ -253,7 +251,6 @@ PyObject *PyEdgesIteratorGet(PyEdgesIterator *self, PyObject *Py_UNUSED(ignored)
|
||||
return nullptr;
|
||||
}
|
||||
if (edge == nullptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return MakePyEdge(*edge, self->py_graph);
|
||||
@@ -268,7 +265,6 @@ PyObject *PyEdgesIteratorNext(PyEdgesIterator *self, PyObject *Py_UNUSED(ignored
|
||||
return nullptr;
|
||||
}
|
||||
if (edge == nullptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return MakePyEdge(*edge, self->py_graph);
|
||||
@@ -1244,7 +1240,6 @@ PyObject *PyPropertiesIteratorGet(PyPropertiesIterator *self, PyObject *Py_UNUSE
|
||||
return nullptr;
|
||||
}
|
||||
if (property == nullptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
py::Object py_name(PyUnicode_FromString(property->name));
|
||||
@@ -1263,7 +1258,6 @@ PyObject *PyPropertiesIteratorNext(PyPropertiesIterator *self, PyObject *Py_UNUS
|
||||
return nullptr;
|
||||
}
|
||||
if (property == nullptr) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
py::Object py_name(PyUnicode_FromString(property->name));
|
||||
|
||||
@@ -58,8 +58,7 @@ concept Stream = requires(TStream stream) {
|
||||
stream.Check(std::optional<std::chrono::milliseconds>{}, std::optional<int64_t>{},
|
||||
ConsumerFunction<typename TStream::Message>{})
|
||||
} -> std::same_as<void>;
|
||||
requires std::same_as<std::decay_t<decltype(std::declval<typename TStream::StreamInfo>().common_info)>,
|
||||
CommonStreamInfo>;
|
||||
{ typename TStream::StreamInfo{}.common_info } -> std::same_as<CommonStreamInfo>;
|
||||
|
||||
requires ConvertableToMgpMessage<typename TStream::Message>;
|
||||
requires ConvertableToJson<typename TStream::StreamInfo>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -13,8 +13,6 @@
|
||||
|
||||
#include <json/json.hpp>
|
||||
|
||||
#include "integrations/constants.hpp"
|
||||
|
||||
namespace query::stream {
|
||||
KafkaStream::KafkaStream(std::string stream_name, StreamInfo stream_info,
|
||||
ConsumerFunction<integrations::kafka::Message> consumer_function) {
|
||||
@@ -25,8 +23,6 @@ KafkaStream::KafkaStream(std::string stream_name, StreamInfo stream_info,
|
||||
.bootstrap_servers = std::move(stream_info.bootstrap_servers),
|
||||
.batch_interval = stream_info.common_info.batch_interval,
|
||||
.batch_size = stream_info.common_info.batch_size,
|
||||
.public_configs = std::move(stream_info.configs),
|
||||
.private_configs = std::move(stream_info.credentials),
|
||||
};
|
||||
consumer_.emplace(std::move(consumer_info), std::move(consumer_function));
|
||||
};
|
||||
@@ -38,9 +34,7 @@ KafkaStream::StreamInfo KafkaStream::Info(std::string transformation_name) const
|
||||
.transformation_name = std::move(transformation_name)},
|
||||
.topics = info.topics,
|
||||
.consumer_group = info.consumer_group,
|
||||
.bootstrap_servers = info.bootstrap_servers,
|
||||
.configs = info.public_configs,
|
||||
.credentials = info.private_configs};
|
||||
.bootstrap_servers = info.bootstrap_servers};
|
||||
}
|
||||
|
||||
void KafkaStream::Start() { consumer_->Start(); }
|
||||
@@ -60,10 +54,6 @@ namespace {
|
||||
const std::string kTopicsKey{"topics"};
|
||||
const std::string kConsumerGroupKey{"consumer_group"};
|
||||
const std::string kBoostrapServers{"bootstrap_servers"};
|
||||
const std::string kConfigs{"configs"};
|
||||
const std::string kCredentials{"credentials"};
|
||||
|
||||
const std::unordered_map<std::string, std::string> kDefaultConfigsMap;
|
||||
} // namespace
|
||||
|
||||
void to_json(nlohmann::json &data, KafkaStream::StreamInfo &&info) {
|
||||
@@ -71,8 +61,6 @@ void to_json(nlohmann::json &data, KafkaStream::StreamInfo &&info) {
|
||||
data[kTopicsKey] = std::move(info.topics);
|
||||
data[kConsumerGroupKey] = info.consumer_group;
|
||||
data[kBoostrapServers] = std::move(info.bootstrap_servers);
|
||||
data[kConfigs] = std::move(info.configs);
|
||||
data[kCredentials] = std::move(info.credentials);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &data, KafkaStream::StreamInfo &info) {
|
||||
@@ -80,9 +68,6 @@ void from_json(const nlohmann::json &data, KafkaStream::StreamInfo &info) {
|
||||
data.at(kTopicsKey).get_to(info.topics);
|
||||
data.at(kConsumerGroupKey).get_to(info.consumer_group);
|
||||
data.at(kBoostrapServers).get_to(info.bootstrap_servers);
|
||||
// These values might not be present in the persisted JSON object
|
||||
info.configs = data.value(kConfigs, kDefaultConfigsMap);
|
||||
info.credentials = data.value(kCredentials, kDefaultConfigsMap);
|
||||
}
|
||||
|
||||
PulsarStream::PulsarStream(std::string stream_name, StreamInfo stream_info,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -24,8 +24,6 @@ struct KafkaStream {
|
||||
std::vector<std::string> topics;
|
||||
std::string consumer_group;
|
||||
std::string bootstrap_servers;
|
||||
std::unordered_map<std::string, std::string> configs;
|
||||
std::unordered_map<std::string, std::string> credentials;
|
||||
};
|
||||
|
||||
using Message = integrations::kafka::Message;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <json/json.hpp>
|
||||
|
||||
#include "integrations/constants.hpp"
|
||||
#include "mg_procedure.h"
|
||||
#include "query/db_accessor.hpp"
|
||||
#include "query/discard_value_stream.hpp"
|
||||
@@ -30,7 +29,6 @@
|
||||
#include "query/stream/sources.hpp"
|
||||
#include "query/typed_value.hpp"
|
||||
#include "utils/event_counter.hpp"
|
||||
#include "utils/logging.hpp"
|
||||
#include "utils/memory.hpp"
|
||||
#include "utils/on_scope_exit.hpp"
|
||||
#include "utils/pmr/string.hpp"
|
||||
@@ -160,6 +158,43 @@ void from_json(const nlohmann::json &data, StreamStatus<TStream> &status) {
|
||||
from_json(data, status.info);
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename Fun>
|
||||
[[nodiscard]] bool TryOrSetError(Fun &&func, mgp_result *result) {
|
||||
if (const auto err = func(); err == MGP_ERROR_UNABLE_TO_ALLOCATE) {
|
||||
static_cast<void>(mgp_result_set_error_msg(result, "Not enough memory!"));
|
||||
return false;
|
||||
} else if (err != MGP_ERROR_NO_ERROR) {
|
||||
const auto error_msg = fmt::format("Unexpected error ({})!", err);
|
||||
static_cast<void>(mgp_result_set_error_msg(result, error_msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto GetStringValueOrSetError(const char *string, mgp_memory *memory, mgp_result *result) {
|
||||
procedure::MgpUniquePtr<mgp_value> value{nullptr, mgp_value_destroy};
|
||||
const auto success =
|
||||
TryOrSetError([&] { return procedure::CreateMgpObject(value, mgp_value_make_string, string, memory); }, result);
|
||||
if (!success) {
|
||||
value.reset();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool InsertResultOrSetError(mgp_result *result, mgp_result_record *record, const auto *result_name,
|
||||
mgp_value *value) {
|
||||
if (const auto err = mgp_result_record_insert(record, result_name, value); err != MGP_ERROR_NO_ERROR) {
|
||||
const auto error_msg = fmt::format("Unable to set the result for {}, error = {}", result_name, err);
|
||||
static_cast<void>(mgp_result_set_error_msg(result, error_msg.c_str()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Streams::Streams(InterpreterContext *interpreter_context, std::filesystem::path directory)
|
||||
: interpreter_context_(interpreter_context), storage_(std::move(directory)) {
|
||||
RegisterProcedures();
|
||||
@@ -210,12 +245,10 @@ void Streams::RegisterKafkaProcedures() {
|
||||
constexpr std::string_view consumer_group_result_name = "consumer_group";
|
||||
constexpr std::string_view topics_result_name = "topics";
|
||||
constexpr std::string_view bootstrap_servers_result_name = "bootstrap_servers";
|
||||
constexpr std::string_view configs_result_name = "configs";
|
||||
constexpr std::string_view credentials_result_name = "credentials";
|
||||
|
||||
auto get_stream_info = [this, proc_name, consumer_group_result_name, topics_result_name,
|
||||
bootstrap_servers_result_name, configs_result_name, credentials_result_name](
|
||||
mgp_list *args, mgp_graph * /*graph*/, mgp_result *result, mgp_memory *memory) {
|
||||
bootstrap_servers_result_name](mgp_list *args, mgp_graph * /*graph*/, mgp_result *result,
|
||||
mgp_memory *memory) {
|
||||
auto *arg_stream_name = procedure::Call<mgp_value *>(mgp_list_at, args, 0);
|
||||
const auto *stream_name = procedure::Call<const char *>(mgp_value_get_string, arg_stream_name);
|
||||
auto lock_ptr = streams_.Lock();
|
||||
@@ -227,22 +260,20 @@ void Streams::RegisterKafkaProcedures() {
|
||||
const auto info = stream_source_ptr->Info(kafka_stream.transformation_name);
|
||||
mgp_result_record *record{nullptr};
|
||||
{
|
||||
const auto success =
|
||||
procedure::TryOrSetError([&] { return mgp_result_new_record(result, &record); }, result);
|
||||
const auto success = TryOrSetError([&] { return mgp_result_new_record(result, &record); }, result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const auto consumer_group_value =
|
||||
procedure::GetStringValueOrSetError(info.consumer_group.c_str(), memory, result);
|
||||
const auto consumer_group_value = GetStringValueOrSetError(info.consumer_group.c_str(), memory, result);
|
||||
if (!consumer_group_value) {
|
||||
return;
|
||||
}
|
||||
|
||||
procedure::MgpUniquePtr<mgp_list> topic_names{nullptr, mgp_list_destroy};
|
||||
{
|
||||
const auto success = procedure::TryOrSetError(
|
||||
const auto success = TryOrSetError(
|
||||
[&] {
|
||||
return procedure::CreateMgpObject(topic_names, mgp_list_make_empty, info.topics.size(), memory);
|
||||
},
|
||||
@@ -253,7 +284,7 @@ void Streams::RegisterKafkaProcedures() {
|
||||
}
|
||||
|
||||
for (const auto &topic : info.topics) {
|
||||
auto topic_value = procedure::GetStringValueOrSetError(topic.c_str(), memory, result);
|
||||
auto topic_value = GetStringValueOrSetError(topic.c_str(), memory, result);
|
||||
if (!topic_value) {
|
||||
return;
|
||||
}
|
||||
@@ -262,93 +293,33 @@ void Streams::RegisterKafkaProcedures() {
|
||||
|
||||
procedure::MgpUniquePtr<mgp_value> topics_value{nullptr, mgp_value_destroy};
|
||||
{
|
||||
const auto success = procedure::TryOrSetError(
|
||||
[&] { return procedure::CreateMgpObject(topics_value, mgp_value_make_list, topic_names.get()); },
|
||||
const auto success = TryOrSetError(
|
||||
[&] {
|
||||
return procedure::CreateMgpObject(topics_value, mgp_value_make_list, topic_names.release());
|
||||
},
|
||||
result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
static_cast<void>(topic_names.release());
|
||||
}
|
||||
|
||||
const auto bootstrap_servers_value =
|
||||
procedure::GetStringValueOrSetError(info.bootstrap_servers.c_str(), memory, result);
|
||||
GetStringValueOrSetError(info.bootstrap_servers.c_str(), memory, result);
|
||||
if (!bootstrap_servers_value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto convert_config_map =
|
||||
[result, memory](const std::unordered_map<std::string, std::string> &configs_to_convert)
|
||||
-> procedure::MgpUniquePtr<mgp_value> {
|
||||
procedure::MgpUniquePtr<mgp_value> configs_value{nullptr, mgp_value_destroy};
|
||||
procedure::MgpUniquePtr<mgp_map> configs{nullptr, mgp_map_destroy};
|
||||
{
|
||||
const auto success = procedure::TryOrSetError(
|
||||
[&] { return procedure::CreateMgpObject(configs, mgp_map_make_empty, memory); }, result);
|
||||
if (!success) {
|
||||
return configs_value;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &[key, value] : configs_to_convert) {
|
||||
auto value_value = procedure::GetStringValueOrSetError(value.c_str(), memory, result);
|
||||
if (!value_value) {
|
||||
return configs_value;
|
||||
}
|
||||
configs->items.emplace(key, std::move(*value_value));
|
||||
}
|
||||
|
||||
{
|
||||
const auto success = procedure::TryOrSetError(
|
||||
[&] { return procedure::CreateMgpObject(configs_value, mgp_value_make_map, configs.get()); },
|
||||
result);
|
||||
if (!success) {
|
||||
return configs_value;
|
||||
}
|
||||
static_cast<void>(configs.release());
|
||||
}
|
||||
return configs_value;
|
||||
};
|
||||
|
||||
const auto configs_value = convert_config_map(info.configs);
|
||||
if (configs_value == nullptr) {
|
||||
if (!InsertResultOrSetError(result, record, consumer_group_result_name.data(),
|
||||
consumer_group_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
using CredentialsType = decltype(KafkaStream::StreamInfo::credentials);
|
||||
CredentialsType reducted_credentials;
|
||||
std::transform(info.credentials.begin(), info.credentials.end(),
|
||||
std::inserter(reducted_credentials, reducted_credentials.end()),
|
||||
[](const auto &pair) -> CredentialsType::value_type {
|
||||
return {pair.first, integrations::kReducted};
|
||||
});
|
||||
|
||||
const auto credentials_value = convert_config_map(reducted_credentials);
|
||||
if (credentials_value == nullptr) {
|
||||
if (!InsertResultOrSetError(result, record, topics_result_name.data(), topics_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, consumer_group_result_name.data(),
|
||||
consumer_group_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, topics_result_name.data(), topics_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, bootstrap_servers_result_name.data(),
|
||||
bootstrap_servers_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, configs_result_name.data(),
|
||||
configs_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, credentials_result_name.data(),
|
||||
credentials_value.get())) {
|
||||
if (!InsertResultOrSetError(result, record, bootstrap_servers_result_name.data(),
|
||||
bootstrap_servers_value.get())) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
@@ -369,10 +340,6 @@ void Streams::RegisterKafkaProcedures() {
|
||||
MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&proc, bootstrap_servers_result_name.data(),
|
||||
procedure::Call<mgp_type *>(mgp_type_string)) == MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&proc, configs_result_name.data(), procedure::Call<mgp_type *>(mgp_type_map)) ==
|
||||
MGP_ERROR_NO_ERROR);
|
||||
MG_ASSERT(mgp_proc_add_result(&proc, credentials_result_name.data(), procedure::Call<mgp_type *>(mgp_type_map)) ==
|
||||
MGP_ERROR_NO_ERROR);
|
||||
|
||||
procedure::gModuleRegistry.RegisterMgProcedure(proc_name, std::move(proc));
|
||||
}
|
||||
@@ -396,21 +363,20 @@ void Streams::RegisterPulsarProcedures() {
|
||||
const auto info = stream_source_ptr->Info(pulsar_stream.transformation_name);
|
||||
mgp_result_record *record{nullptr};
|
||||
{
|
||||
const auto success =
|
||||
procedure::TryOrSetError([&] { return mgp_result_new_record(result, &record); }, result);
|
||||
const auto success = TryOrSetError([&] { return mgp_result_new_record(result, &record); }, result);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto service_url_value = procedure::GetStringValueOrSetError(info.service_url.c_str(), memory, result);
|
||||
auto service_url_value = GetStringValueOrSetError(info.service_url.c_str(), memory, result);
|
||||
if (!service_url_value) {
|
||||
return;
|
||||
}
|
||||
|
||||
procedure::MgpUniquePtr<mgp_list> topic_names{nullptr, mgp_list_destroy};
|
||||
{
|
||||
const auto success = procedure::TryOrSetError(
|
||||
const auto success = TryOrSetError(
|
||||
[&] {
|
||||
return procedure::CreateMgpObject(topic_names, mgp_list_make_empty, info.topics.size(), memory);
|
||||
},
|
||||
@@ -421,7 +387,7 @@ void Streams::RegisterPulsarProcedures() {
|
||||
}
|
||||
|
||||
for (const auto &topic : info.topics) {
|
||||
auto topic_value = procedure::GetStringValueOrSetError(topic.c_str(), memory, result);
|
||||
auto topic_value = GetStringValueOrSetError(topic.c_str(), memory, result);
|
||||
if (!topic_value) {
|
||||
return;
|
||||
}
|
||||
@@ -430,7 +396,7 @@ void Streams::RegisterPulsarProcedures() {
|
||||
|
||||
procedure::MgpUniquePtr<mgp_value> topics_value{nullptr, mgp_value_destroy};
|
||||
{
|
||||
const auto success = procedure::TryOrSetError(
|
||||
const auto success = TryOrSetError(
|
||||
[&] {
|
||||
return procedure::CreateMgpObject(topics_value, mgp_value_make_list, topic_names.release());
|
||||
},
|
||||
@@ -440,12 +406,11 @@ void Streams::RegisterPulsarProcedures() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, topics_result_name.data(), topics_value.get())) {
|
||||
if (!InsertResultOrSetError(result, record, topics_result_name.data(), topics_value.get())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!procedure::InsertResultOrSetError(result, record, service_url_result_name.data(),
|
||||
service_url_value.get())) {
|
||||
if (!InsertResultOrSetError(result, record, service_url_result_name.data(), service_url_value.get())) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "utils/rw_lock.hpp"
|
||||
#include "utils/synchronized.hpp"
|
||||
|
||||
class StreamsTest;
|
||||
namespace query {
|
||||
|
||||
struct InterpreterContext;
|
||||
@@ -74,8 +73,6 @@ using TransformationResult = std::vector<std::vector<TypedValue>>;
|
||||
///
|
||||
/// This class is responsible for all query supported actions to happen.
|
||||
class Streams final {
|
||||
friend StreamsTest;
|
||||
|
||||
public:
|
||||
/// Initializes the streams.
|
||||
///
|
||||
|
||||
@@ -2,9 +2,6 @@ set(requests_src_files
|
||||
requests.cpp)
|
||||
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
|
||||
add_library(mg-requests STATIC ${requests_src_files})
|
||||
target_link_libraries(mg-requests mg-utils spdlog::spdlog fmt::fmt gflags json ${CURL_LIBRARIES})
|
||||
|
||||
@@ -3,9 +3,6 @@ set(rpc_src_files
|
||||
protocol.cpp
|
||||
server.cpp)
|
||||
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_library(mg-rpc STATIC ${rpc_src_files})
|
||||
target_link_libraries(mg-rpc Threads::Threads mg-communication mg-utils mg-io fmt::fmt gflags)
|
||||
target_link_libraries(mg-rpc mg-slk)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
set(slk_src_files
|
||||
streams.cpp)
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_library(mg-slk STATIC ${slk_src_files})
|
||||
target_link_libraries(mg-slk gflags)
|
||||
target_link_libraries(mg-slk mg-utils)
|
||||
|
||||
@@ -30,9 +30,6 @@ set(storage_v2_src_files
|
||||
|
||||
#######################
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_library(mg-storage-v2 STATIC ${storage_v2_src_files})
|
||||
target_link_libraries(mg-storage-v2 Threads::Threads mg-utils gflags)
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@ set(utils_src_files
|
||||
uuid.cpp)
|
||||
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_library(mg-utils STATIC ${utils_src_files})
|
||||
target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -79,15 +79,36 @@ Date::Date(const DateParameters &date_parameters) {
|
||||
day = date_parameters.day;
|
||||
}
|
||||
|
||||
Date UtcToday() { return UtcLocalDateTime().date; }
|
||||
namespace {
|
||||
tm GetUtcFromSystemClockOrThrow() {
|
||||
namespace chrono = std::chrono;
|
||||
const auto today = chrono::system_clock::to_time_t(chrono::system_clock::now());
|
||||
tm utc_today;
|
||||
if (!gmtime_r(&today, &utc_today)) {
|
||||
throw temporal::InvalidArgumentException("Can't access clock's UTC time");
|
||||
}
|
||||
return utc_today;
|
||||
}
|
||||
|
||||
LocalTime UtcLocalTime() { return UtcLocalDateTime().local_time; }
|
||||
int64_t TMYearToUtcYear(int year) { return year + 1900; }
|
||||
|
||||
int64_t TMMonthToUtcMonth(int month) { return month + 1; }
|
||||
} // namespace
|
||||
|
||||
Date UtcToday() {
|
||||
const auto utc_today = GetUtcFromSystemClockOrThrow();
|
||||
return Date({TMYearToUtcYear(utc_today.tm_year), TMMonthToUtcMonth(utc_today.tm_mon), utc_today.tm_mday});
|
||||
}
|
||||
|
||||
LocalTime UtcLocalTime() {
|
||||
const auto utc_today = GetUtcFromSystemClockOrThrow();
|
||||
return LocalTime({utc_today.tm_hour, utc_today.tm_min, utc_today.tm_sec});
|
||||
}
|
||||
|
||||
LocalDateTime UtcLocalDateTime() {
|
||||
namespace chrono = std::chrono;
|
||||
using TpMicros = chrono::time_point<chrono::system_clock, chrono::microseconds>;
|
||||
TpMicros ts = chrono::time_point_cast<chrono::microseconds>(chrono::system_clock::now());
|
||||
return LocalDateTime(ts.time_since_epoch().count());
|
||||
const auto utc_today = GetUtcFromSystemClockOrThrow();
|
||||
return LocalDateTime({TMYearToUtcYear(utc_today.tm_year), TMMonthToUtcMonth(utc_today.tm_mon), utc_today.tm_mday},
|
||||
{utc_today.tm_hour, utc_today.tm_min, utc_today.tm_sec});
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
set(test_prefix memgraph__benchmark__)
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_custom_target(memgraph__benchmark)
|
||||
|
||||
function(add_benchmark test_cpp)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <benchmark/benchmark_api.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "data_structures/ring_buffer.hpp"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <benchmark/benchmark_api.h>
|
||||
|
||||
#include "communication/result_stream_faker.hpp"
|
||||
#include "query/config.hpp"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <benchmark/benchmark_api.h>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <benchmark/benchmark_api.h>
|
||||
|
||||
#include "query/context.hpp"
|
||||
#include "utils/tsc.hpp"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <benchmark/benchmark.h>
|
||||
#include <benchmark/benchmark_api.h>
|
||||
|
||||
#include "query/frontend/stripped.hpp"
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ std::optional<rpc::ClientPool> client_pool;
|
||||
static void BenchmarkRpc(benchmark::State &state) {
|
||||
std::string data(state.range(0), 'a');
|
||||
while (state.KeepRunning()) {
|
||||
clients[state.thread_index()]->Call<Echo>(data);
|
||||
clients[state.thread_index]->Call<Echo>(data);
|
||||
}
|
||||
state.SetItemsProcessed(state.iterations());
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ const uint64_t kMaxNum = 10000000;
|
||||
class SkipListSetInsertFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0) {
|
||||
if (state.thread_index == 0) {
|
||||
list = utils::SkipList<uint64_t>();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class SkipListSetInsertFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(SkipListSetInsertFixture, Insert)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -64,7 +64,7 @@ BENCHMARK_REGISTER_F(SkipListSetInsertFixture, Insert)
|
||||
class StdSetInsertFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0) {
|
||||
if (state.thread_index == 0) {
|
||||
container = {};
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class StdSetInsertFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(StdSetInsertFixture, Insert)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -95,7 +95,7 @@ BENCHMARK_REGISTER_F(StdSetInsertFixture, Insert)
|
||||
class StdSetWithPoolAllocatorInsertFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0) {
|
||||
if (state.thread_index == 0) {
|
||||
container.clear();
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class StdSetWithPoolAllocatorInsertFixture : public benchmark::Fixture {
|
||||
|
||||
BENCHMARK_DEFINE_F(StdSetWithPoolAllocatorInsertFixture, Insert)
|
||||
(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -132,7 +132,7 @@ BENCHMARK_REGISTER_F(StdSetWithPoolAllocatorInsertFixture, Insert)
|
||||
class SkipListSetFindFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0 && list.size() == 0) {
|
||||
if (state.thread_index == 0 && list.size() == 0) {
|
||||
auto acc = list.access();
|
||||
for (uint64_t i = 0; i < kMaxNum; ++i) {
|
||||
acc.insert(i);
|
||||
@@ -145,7 +145,7 @@ class SkipListSetFindFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(SkipListSetFindFixture, Find)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -169,7 +169,7 @@ BENCHMARK_REGISTER_F(SkipListSetFindFixture, Find)
|
||||
class StdSetFindFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0 && container.size() == 0) {
|
||||
if (state.thread_index == 0 && container.size() == 0) {
|
||||
for (uint64_t i = 0; i < kMaxNum; ++i) {
|
||||
container.insert(i);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class StdSetFindFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(StdSetFindFixture, Find)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -199,7 +199,7 @@ BENCHMARK_REGISTER_F(StdSetFindFixture, Find)->ThreadRange(1, kThreadsNum)->Unit
|
||||
class StdSetWithPoolAllocatorFindFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0 && container.size() == 0) {
|
||||
if (state.thread_index == 0 && container.size() == 0) {
|
||||
for (uint64_t i = 0; i < kMaxNum; ++i) {
|
||||
container.insert(i);
|
||||
}
|
||||
@@ -214,7 +214,7 @@ class StdSetWithPoolAllocatorFindFixture : public benchmark::Fixture {
|
||||
|
||||
BENCHMARK_DEFINE_F(StdSetWithPoolAllocatorFindFixture, Find)
|
||||
(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -252,7 +252,7 @@ bool operator<(const MapObject &a, uint64_t b) { return a.key < b; }
|
||||
class SkipListMapInsertFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0) {
|
||||
if (state.thread_index == 0) {
|
||||
list = utils::SkipList<MapObject>();
|
||||
}
|
||||
}
|
||||
@@ -262,7 +262,7 @@ class SkipListMapInsertFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(SkipListMapInsertFixture, Insert)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -286,7 +286,7 @@ BENCHMARK_REGISTER_F(SkipListMapInsertFixture, Insert)
|
||||
class StdMapInsertFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0) {
|
||||
if (state.thread_index == 0) {
|
||||
container = {};
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,7 @@ class StdMapInsertFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(StdMapInsertFixture, Insert)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -317,7 +317,7 @@ BENCHMARK_REGISTER_F(StdMapInsertFixture, Insert)
|
||||
class StdMapWithPoolAllocatorInsertFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0) {
|
||||
if (state.thread_index == 0) {
|
||||
container = {};
|
||||
}
|
||||
}
|
||||
@@ -330,7 +330,7 @@ class StdMapWithPoolAllocatorInsertFixture : public benchmark::Fixture {
|
||||
|
||||
BENCHMARK_DEFINE_F(StdMapWithPoolAllocatorInsertFixture, Insert)
|
||||
(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -354,7 +354,7 @@ BENCHMARK_REGISTER_F(StdMapWithPoolAllocatorInsertFixture, Insert)
|
||||
class SkipListMapFindFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0 && list.size() == 0) {
|
||||
if (state.thread_index == 0 && list.size() == 0) {
|
||||
auto acc = list.access();
|
||||
for (uint64_t i = 0; i < kMaxNum; ++i) {
|
||||
acc.insert({i, 0});
|
||||
@@ -367,7 +367,7 @@ class SkipListMapFindFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(SkipListMapFindFixture, Find)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -391,7 +391,7 @@ BENCHMARK_REGISTER_F(SkipListMapFindFixture, Find)
|
||||
class StdMapFindFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0 && container.size() == 0) {
|
||||
if (state.thread_index == 0 && container.size() == 0) {
|
||||
for (uint64_t i = 0; i < kMaxNum; ++i) {
|
||||
container.insert({i, 0});
|
||||
}
|
||||
@@ -404,7 +404,7 @@ class StdMapFindFixture : public benchmark::Fixture {
|
||||
};
|
||||
|
||||
BENCHMARK_DEFINE_F(StdMapFindFixture, Find)(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -421,7 +421,7 @@ BENCHMARK_REGISTER_F(StdMapFindFixture, Find)->ThreadRange(1, kThreadsNum)->Unit
|
||||
class StdMapWithPoolAllocatorFindFixture : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const benchmark::State &state) override {
|
||||
if (state.thread_index() == 0 && container.size() == 0) {
|
||||
if (state.thread_index == 0 && container.size() == 0) {
|
||||
for (uint64_t i = 0; i < kMaxNum; ++i) {
|
||||
container.insert({i, 0});
|
||||
}
|
||||
@@ -436,7 +436,7 @@ class StdMapWithPoolAllocatorFindFixture : public benchmark::Fixture {
|
||||
|
||||
BENCHMARK_DEFINE_F(StdMapWithPoolAllocatorFindFixture, Find)
|
||||
(benchmark::State &state) {
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, kMaxNum);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// NOLINTNEXTLINE(google-runtime-references)
|
||||
static void PropertyStoreSet(benchmark::State &state) {
|
||||
storage::PropertyStore store;
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, state.range(0) - 1);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -45,7 +45,7 @@ BENCHMARK(PropertyStoreSet)->RangeMultiplier(2)->Range(1, 1024)->Unit(benchmark:
|
||||
// NOLINTNEXTLINE(google-runtime-references)
|
||||
static void StdMapSet(benchmark::State &state) {
|
||||
std::map<storage::PropertyId, storage::PropertyValue> store;
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, state.range(0) - 1);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -69,7 +69,7 @@ static void PropertyStoreGet(benchmark::State &state) {
|
||||
auto prop = storage::PropertyId::FromUint(i);
|
||||
store.SetProperty(prop, storage::PropertyValue(0));
|
||||
}
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, state.range(0) - 1);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
@@ -93,7 +93,7 @@ static void StdMapGet(benchmark::State &state) {
|
||||
auto prop = storage::PropertyId::FromUint(i);
|
||||
store.emplace(prop, storage::PropertyValue(0));
|
||||
}
|
||||
std::mt19937 gen(state.thread_index());
|
||||
std::mt19937 gen(state.thread_index);
|
||||
std::uniform_int_distribution<uint64_t> dist(0, state.range(0) - 1);
|
||||
uint64_t counter = 0;
|
||||
while (state.KeepRunning()) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
set(test_prefix memgraph__concurrent__)
|
||||
|
||||
find_package(gflags)
|
||||
|
||||
add_custom_target(memgraph__concurrent)
|
||||
|
||||
function(add_concurrent_test test_cpp)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<p>Check console for Cypher query outputs...</p>
|
||||
<script>
|
||||
const driver = neo4j.driver(
|
||||
"bolt://localhost:9999",
|
||||
"bolt://localhost:7687",
|
||||
neo4j.auth.basic("", ""),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_executable(memgraph__e2e__isolation_levels isolation_levels.cpp)
|
||||
target_link_libraries(memgraph__e2e__isolation_levels gflags mgclient mg-utils mg-io Threads::Threads)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
add_subdirectory(procedures)
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_executable(memgraph__e2e__memory__control memory_control.cpp)
|
||||
target_link_libraries(memgraph__e2e__memory__control gflags mgclient mg-utils mg-io Threads::Threads)
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_executable(memgraph__e2e__replication__constraints constraints.cpp)
|
||||
target_link_libraries(memgraph__e2e__replication__constraints gflags mgclient mg-utils mg-io Threads::Threads)
|
||||
|
||||
|
||||
@@ -421,13 +421,10 @@ def test_set_offset(kafka_producer, kafka_topics, connection, transformation):
|
||||
assert comparison_check("Final Message", res[0])
|
||||
common.execute_and_fetch_all(cursor, "MATCH (n) DETACH DELETE n")
|
||||
|
||||
|
||||
def test_info_procedure(kafka_topics, connection):
|
||||
cursor = connection.cursor()
|
||||
stream_name = 'test_stream'
|
||||
configs = {"sasl.username": "michael.scott"}
|
||||
local = "localhost:9092"
|
||||
credentials = {"sasl.password": "S3cr3tP4ssw0rd"}
|
||||
consumer_group = "ConsumerGr"
|
||||
common.execute_and_fetch_all(
|
||||
cursor,
|
||||
@@ -435,21 +432,13 @@ def test_info_procedure(kafka_topics, connection):
|
||||
f"TOPICS {','.join(kafka_topics)} "
|
||||
f"TRANSFORM pulsar_transform.simple "
|
||||
f"CONSUMER_GROUP {consumer_group} "
|
||||
f"BOOTSTRAP_SERVERS '{local}' "
|
||||
f"CONFIGS {configs} "
|
||||
f"CREDENTIALS {credentials}"
|
||||
f"BOOTSTRAP_SERVERS '{local}'"
|
||||
)
|
||||
|
||||
stream_info = common.execute_and_fetch_all(
|
||||
cursor, f"CALL mg.kafka_stream_info('{stream_name}') YIELD *")
|
||||
stream_info = common.execute_and_fetch_all(cursor, f"CALL mg.kafka_stream_info('{stream_name}') YIELD *")
|
||||
|
||||
reducted_credentials = {key: "<REDUCTED>" for (
|
||||
key, value) in credentials.items()}
|
||||
|
||||
expected_stream_info = [
|
||||
(local, configs, consumer_group, reducted_credentials, kafka_topics)]
|
||||
expected_stream_info = [(local, consumer_group, kafka_topics)]
|
||||
common.validate_info(stream_info, expected_stream_info)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main([__file__, "-rA"]))
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_executable(memgraph__e2e__temporal_roundtrip roundtrip.cpp)
|
||||
target_link_libraries(memgraph__e2e__temporal_roundtrip PUBLIC mgclient mg-utils gflags)
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_library(memgraph__e2e__triggers_common STATIC common.hpp common.cpp)
|
||||
target_link_libraries(memgraph__e2e__triggers_common PUBLIC gflags mgclient mg-utils)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
set(test_prefix memgraph__manual__)
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
|
||||
add_custom_target(memgraph__manual)
|
||||
|
||||
function(add_manual_test test_cpp)
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
set(test_prefix memgraph__unit__)
|
||||
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(gflags REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
add_custom_target(memgraph__unit)
|
||||
|
||||
set(memgraph_unit_main main.cpp)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -9,10 +9,20 @@
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
//
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
@@ -28,7 +38,6 @@
|
||||
#include <json/json.hpp>
|
||||
//////////////////////////////////////////////////////
|
||||
#include <antlr4-runtime.h>
|
||||
#include <gmock/gmock-matchers.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -78,37 +87,23 @@ class Base {
|
||||
}
|
||||
}
|
||||
|
||||
TypedValue GetLiteral(Expression *expression, const bool use_parameter_lookup,
|
||||
const std::optional<int> &token_position = std::nullopt) const {
|
||||
if (use_parameter_lookup) {
|
||||
auto *param_lookup = dynamic_cast<ParameterLookup *>(expression);
|
||||
if (param_lookup == nullptr) {
|
||||
ADD_FAILURE();
|
||||
return {};
|
||||
}
|
||||
if (token_position) {
|
||||
EXPECT_EQ(param_lookup->token_position_, *token_position);
|
||||
}
|
||||
return TypedValue(parameters_.AtTokenPosition(param_lookup->token_position_));
|
||||
}
|
||||
|
||||
auto *literal = dynamic_cast<PrimitiveLiteral *>(expression);
|
||||
if (literal == nullptr) {
|
||||
ADD_FAILURE();
|
||||
return {};
|
||||
}
|
||||
if (token_position) {
|
||||
EXPECT_EQ(literal->token_position_, *token_position);
|
||||
}
|
||||
return TypedValue(literal->value_);
|
||||
}
|
||||
|
||||
template <class TValue>
|
||||
void CheckLiteral(Expression *expression, const TValue &expected,
|
||||
const std::optional<int> &token_position = std::nullopt) const {
|
||||
TypedValue value;
|
||||
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
|
||||
TypedValue expected_tv(expected);
|
||||
const auto use_parameter_lookup = !expected_tv.IsNull() && context_.is_query_cached;
|
||||
TypedValue value = GetLiteral(expression, use_parameter_lookup, token_position);
|
||||
if (!expected_tv.IsNull() && context_.is_query_cached) {
|
||||
auto *param_lookup = dynamic_cast<ParameterLookup *>(expression);
|
||||
ASSERT_TRUE(param_lookup);
|
||||
if (token_position) EXPECT_EQ(param_lookup->token_position_, *token_position);
|
||||
value = TypedValue(parameters_.AtTokenPosition(param_lookup->token_position_));
|
||||
} else {
|
||||
auto *literal = dynamic_cast<PrimitiveLiteral *>(expression);
|
||||
ASSERT_TRUE(literal);
|
||||
if (token_position) ASSERT_EQ(literal->token_position_, *token_position);
|
||||
value = TypedValue(literal->value_);
|
||||
}
|
||||
EXPECT_TRUE(TypedValue::BoolEqual{}(value, expected_tv));
|
||||
}
|
||||
};
|
||||
@@ -211,7 +206,6 @@ class MockModule : public procedure::Module {
|
||||
const std::map<std::string, mgp_proc, std::less<>> *Procedures() const override { return &procedures; }
|
||||
|
||||
const std::map<std::string, mgp_trans, std::less<>> *Transformations() const override { return &transformations; }
|
||||
std::optional<std::filesystem::path> Path() const override { return std::nullopt; };
|
||||
|
||||
std::map<std::string, mgp_proc, std::less<>> procedures{};
|
||||
std::map<std::string, mgp_trans, std::less<>> transformations{};
|
||||
@@ -2818,7 +2812,7 @@ TEST_P(CypherMainVisitorTest, CallProcedureYieldAsterisk) {
|
||||
ASSERT_TRUE(identifier->user_declared_);
|
||||
identifier_names.push_back(identifier->name_);
|
||||
}
|
||||
ASSERT_THAT(identifier_names, UnorderedElementsAre("name", "signature", "is_write", "path", "is_editable"));
|
||||
ASSERT_THAT(identifier_names, UnorderedElementsAre("name", "signature", "is_write"));
|
||||
ASSERT_EQ(identifier_names, call_proc->result_fields_);
|
||||
CheckCallProcedureDefaultMemoryLimit(ast_generator, *call_proc);
|
||||
}
|
||||
@@ -2843,7 +2837,7 @@ TEST_P(CypherMainVisitorTest, CallProcedureYieldAsteriskReturnAsterisk) {
|
||||
ASSERT_TRUE(identifier->user_declared_);
|
||||
identifier_names.push_back(identifier->name_);
|
||||
}
|
||||
ASSERT_THAT(identifier_names, UnorderedElementsAre("name", "signature", "is_write", "path", "is_editable"));
|
||||
ASSERT_THAT(identifier_names, UnorderedElementsAre("name", "signature", "is_write"));
|
||||
ASSERT_EQ(identifier_names, call_proc->result_fields_);
|
||||
CheckCallProcedureDefaultMemoryLimit(ast_generator, *call_proc);
|
||||
}
|
||||
@@ -3585,8 +3579,6 @@ void ValidateMostlyEmptyStreamQuery(Base &ast_generator, const std::string &quer
|
||||
EXPECT_EQ(parsed_query->bootstrap_servers_, nullptr);
|
||||
EXPECT_NO_FATAL_FAILURE(CheckOptionalExpression(ast_generator, parsed_query->batch_limit_, batch_limit));
|
||||
EXPECT_NO_FATAL_FAILURE(CheckOptionalExpression(ast_generator, parsed_query->timeout_, timeout));
|
||||
EXPECT_TRUE(parsed_query->configs_.empty());
|
||||
EXPECT_TRUE(parsed_query->credentials_.empty());
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, DropStream) {
|
||||
@@ -3668,9 +3660,7 @@ void ValidateCreateKafkaStreamQuery(Base &ast_generator, const std::string &quer
|
||||
const std::string_view transform_name, const std::string_view consumer_group,
|
||||
const std::optional<TypedValue> &batch_interval,
|
||||
const std::optional<TypedValue> &batch_size,
|
||||
const std::string_view bootstrap_servers,
|
||||
const std::unordered_map<std::string, std::string> &configs,
|
||||
const std::unordered_map<std::string, std::string> &credentials) {
|
||||
const std::string_view bootstrap_servers = "") {
|
||||
SCOPED_TRACE(query_string);
|
||||
StreamQuery *parsed_query{nullptr};
|
||||
ASSERT_NO_THROW(parsed_query = dynamic_cast<StreamQuery *>(ast_generator.ParseQuery(query_string))) << query_string;
|
||||
@@ -3684,31 +3674,14 @@ void ValidateCreateKafkaStreamQuery(Base &ast_generator, const std::string &quer
|
||||
EXPECT_EQ(parsed_query->batch_limit_, nullptr);
|
||||
if (bootstrap_servers.empty()) {
|
||||
EXPECT_EQ(parsed_query->bootstrap_servers_, nullptr);
|
||||
} else {
|
||||
EXPECT_NE(parsed_query->bootstrap_servers_, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto evaluate_config_map = [&ast_generator](const std::unordered_map<Expression *, Expression *> &config_map) {
|
||||
std::unordered_map<std::string, std::string> evaluated_config_map;
|
||||
const auto expr_to_str = [&ast_generator](Expression *expression) {
|
||||
return std::string{ast_generator.GetLiteral(expression, ast_generator.context_.is_query_cached).ValueString()};
|
||||
};
|
||||
std::transform(config_map.begin(), config_map.end(),
|
||||
std::inserter(evaluated_config_map, evaluated_config_map.end()),
|
||||
[&expr_to_str](const auto expr_pair) {
|
||||
return std::pair{expr_to_str(expr_pair.first), expr_to_str(expr_pair.second)};
|
||||
});
|
||||
return evaluated_config_map;
|
||||
};
|
||||
|
||||
using testing::UnorderedElementsAreArray;
|
||||
EXPECT_THAT(evaluate_config_map(parsed_query->configs_), UnorderedElementsAreArray(configs.begin(), configs.end()));
|
||||
EXPECT_THAT(evaluate_config_map(parsed_query->credentials_),
|
||||
UnorderedElementsAreArray(credentials.begin(), credentials.end()));
|
||||
EXPECT_NE(parsed_query->bootstrap_servers_, nullptr);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
auto &ast_generator = *GetParam();
|
||||
|
||||
TestInvalidQuery("CREATE KAFKA STREAM", ast_generator);
|
||||
TestInvalidQuery("CREATE KAFKA STREAM invalid stream name TOPICS topic1 TRANSFORM transform", ast_generator);
|
||||
TestInvalidQuery("CREATE KAFKA STREAM stream TOPICS invalid topic name TRANSFORM transform", ast_generator);
|
||||
@@ -3735,13 +3708,6 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
TestInvalidQuery("CREATE KAFKA STREAM stream TOPICS topic1 TRANSFORM transform BOOTSTRAP_SERVERS localhost:9092",
|
||||
ast_generator);
|
||||
TestInvalidQuery("CREATE KAFKA STREAM stream TOPICS topic1 TRANSFORM transform BOOTSTRAP_SERVERS", ast_generator);
|
||||
// the keys must be string literals
|
||||
TestInvalidQuery("CREATE KAFKA STREAM stream TOPICS topic1 TRANSFORM transform CONFIGS { symbolicname : 'string' }",
|
||||
ast_generator);
|
||||
TestInvalidQuery(
|
||||
"CREATE KAFKA STREAM stream TOPICS topic1 TRANSFORM transform CREDENTIALS { symbolicname : 'string' }",
|
||||
ast_generator);
|
||||
TestInvalidQuery("CREATE KAFKA STREAM stream TOPICS topic1 TRANSFORM transform CREDENTIALS 2", ast_generator);
|
||||
|
||||
const std::vector<std::string> topic_names{"topic1_name.with_dot", "topic1_name.with_multiple.dots",
|
||||
"topic-name.with-multiple.dots-and-dashes"};
|
||||
@@ -3761,37 +3727,34 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
ValidateCreateKafkaStreamQuery(
|
||||
ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} TRANSFORM {}", kStreamName, topic_names_as_str, kTransformName),
|
||||
kStreamName, topic_names, kTransformName, "", std::nullopt, std::nullopt, {}, {}, {});
|
||||
kStreamName, topic_names, kTransformName, "", std::nullopt, std::nullopt);
|
||||
|
||||
ValidateCreateKafkaStreamQuery(ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} TRANSFORM {} CONSUMER_GROUP {} ",
|
||||
kStreamName, topic_names_as_str, kTransformName, kConsumerGroup),
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, std::nullopt, std::nullopt,
|
||||
{}, {}, {});
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, std::nullopt,
|
||||
std::nullopt);
|
||||
|
||||
ValidateCreateKafkaStreamQuery(ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TRANSFORM {} TOPICS {} BATCH_INTERVAL {}",
|
||||
kStreamName, kTransformName, topic_names_as_str, kBatchInterval),
|
||||
kStreamName, topic_names, kTransformName, "", batch_interval_value, std::nullopt, {},
|
||||
{}, {});
|
||||
kStreamName, topic_names, kTransformName, "", batch_interval_value, std::nullopt);
|
||||
|
||||
ValidateCreateKafkaStreamQuery(ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} BATCH_SIZE {} TOPICS {} TRANSFORM {}",
|
||||
kStreamName, kBatchSize, topic_names_as_str, kTransformName),
|
||||
kStreamName, topic_names, kTransformName, "", std::nullopt, batch_size_value, {}, {},
|
||||
{});
|
||||
kStreamName, topic_names, kTransformName, "", std::nullopt, batch_size_value);
|
||||
|
||||
ValidateCreateKafkaStreamQuery(ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS '{}' BATCH_SIZE {} TRANSFORM {}",
|
||||
kStreamName, topic_names_as_str, kBatchSize, kTransformName),
|
||||
kStreamName, topic_names, kTransformName, "", std::nullopt, batch_size_value, {}, {},
|
||||
{});
|
||||
kStreamName, topic_names, kTransformName, "", std::nullopt, batch_size_value);
|
||||
|
||||
ValidateCreateKafkaStreamQuery(
|
||||
ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} TRANSFORM {} CONSUMER_GROUP {} BATCH_INTERVAL {} BATCH_SIZE {}",
|
||||
kStreamName, topic_names_as_str, kTransformName, kConsumerGroup, kBatchInterval, kBatchSize),
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, {}, {}, {});
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value);
|
||||
using namespace std::string_literals;
|
||||
const auto host1 = "localhost:9094"s;
|
||||
ValidateCreateKafkaStreamQuery(
|
||||
@@ -3799,16 +3762,14 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} CONSUMER_GROUP {} BATCH_SIZE {} BATCH_INTERVAL {} TRANSFORM {} "
|
||||
"BOOTSTRAP_SERVERS '{}'",
|
||||
kStreamName, topic_names_as_str, kConsumerGroup, kBatchSize, kBatchInterval, kTransformName, host1),
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, host1, {},
|
||||
{});
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, host1);
|
||||
|
||||
ValidateCreateKafkaStreamQuery(
|
||||
ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} CONSUMER_GROUP {} TOPICS {} BATCH_INTERVAL {} TRANSFORM {} BATCH_SIZE {} "
|
||||
"BOOTSTRAP_SERVERS '{}'",
|
||||
kStreamName, kConsumerGroup, topic_names_as_str, kBatchInterval, kTransformName, kBatchSize, host1),
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, host1, {},
|
||||
{});
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, host1);
|
||||
|
||||
const auto host2 = "localhost:9094,localhost:1994,168.1.1.256:345"s;
|
||||
ValidateCreateKafkaStreamQuery(
|
||||
@@ -3816,8 +3777,7 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} BOOTSTRAP_SERVERS '{}' CONSUMER_GROUP {} TRANSFORM {} "
|
||||
"BATCH_INTERVAL {} BATCH_SIZE {}",
|
||||
kStreamName, topic_names_as_str, host2, kConsumerGroup, kTransformName, kBatchInterval, kBatchSize),
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, host2, {},
|
||||
{});
|
||||
kStreamName, topic_names, kTransformName, kConsumerGroup, batch_interval_value, batch_size_value, host2);
|
||||
};
|
||||
|
||||
for (const auto &topic_name : topic_names) {
|
||||
@@ -3832,7 +3792,7 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} TRANSFORM {} CONSUMER_GROUP {}",
|
||||
kStreamName, kTopicName, kTransformName, consumer_group),
|
||||
kStreamName, {kTopicName}, kTransformName, consumer_group, std::nullopt,
|
||||
std::nullopt, {}, {}, {});
|
||||
std::nullopt);
|
||||
};
|
||||
|
||||
using namespace std::literals;
|
||||
@@ -3842,44 +3802,6 @@ TEST_P(CypherMainVisitorTest, CreateKafkaStream) {
|
||||
for (const auto consumer_group : consumer_groups) {
|
||||
EXPECT_NO_FATAL_FAILURE(check_consumer_group(consumer_group));
|
||||
}
|
||||
|
||||
auto check_config_map = [&](const std::unordered_map<std::string, std::string> &config_map) {
|
||||
const std::string kTopicName{"topic1"};
|
||||
|
||||
const auto map_as_str = std::invoke([&config_map] {
|
||||
std::stringstream buffer;
|
||||
buffer << '{';
|
||||
if (!config_map.empty()) {
|
||||
const auto &first_item = *config_map.begin();
|
||||
buffer << fmt::format("'{}': '{}'", first_item.first, first_item.second);
|
||||
for (auto it = ++config_map.begin(); it != config_map.end(); ++it) {
|
||||
buffer << fmt::format(", '{}': '{}'", it->first, it->second);
|
||||
}
|
||||
}
|
||||
buffer << '}';
|
||||
return std::move(buffer).str();
|
||||
});
|
||||
|
||||
ValidateCreateKafkaStreamQuery(ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} TRANSFORM {} CONFIGS {}", kStreamName,
|
||||
kTopicName, kTransformName, map_as_str),
|
||||
kStreamName, {kTopicName}, kTransformName, "", std::nullopt, std::nullopt, {},
|
||||
config_map, {});
|
||||
|
||||
ValidateCreateKafkaStreamQuery(ast_generator,
|
||||
fmt::format("CREATE KAFKA STREAM {} TOPICS {} TRANSFORM {} CREDENTIALS {}",
|
||||
kStreamName, kTopicName, kTransformName, map_as_str),
|
||||
kStreamName, {kTopicName}, kTransformName, "", std::nullopt, std::nullopt, {}, {},
|
||||
config_map);
|
||||
};
|
||||
|
||||
const std::array<std::unordered_map<std::string, std::string>, 3> config_maps = {
|
||||
std::unordered_map<std::string, std::string>{}, std::unordered_map<std::string, std::string>{{"key", "value"}},
|
||||
std::unordered_map<std::string, std::string>{{"key.with.dot", "value.with.doth"},
|
||||
{"key with space", "value with space"}}};
|
||||
for (const auto &map_to_test : config_maps) {
|
||||
EXPECT_NO_FATAL_FAILURE(check_config_map(map_to_test));
|
||||
}
|
||||
}
|
||||
|
||||
void ValidateCreatePulsarStreamQuery(Base &ast_generator, const std::string &query_string,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -59,8 +59,6 @@ struct ConsumerTest : public ::testing::Test {
|
||||
.bootstrap_servers = cluster.Bootstraps(),
|
||||
.batch_interval = kDefaultBatchInterval,
|
||||
.batch_size = kDefaultBatchSize,
|
||||
.public_configs = {},
|
||||
.private_configs = {},
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
// License, and you may not use this file except in compliance with the Business Source License.
|
||||
//
|
||||
// As of the Change Date specified in that file, in accordance with
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt.
|
||||
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -15,15 +15,12 @@
|
||||
#include <utility>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "integrations/constants.hpp"
|
||||
#include "integrations/kafka/exceptions.hpp"
|
||||
#include "kafka_mock.hpp"
|
||||
#include "query/config.hpp"
|
||||
#include "query/interpreter.hpp"
|
||||
#include "query/stream/streams.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
#include "test_utils.hpp"
|
||||
|
||||
using Streams = query::stream::Streams;
|
||||
using StreamInfo = query::stream::KafkaStream::StreamInfo;
|
||||
@@ -81,17 +78,6 @@ class StreamsTest : public ::testing::Test {
|
||||
EXPECT_EQ(check_data.is_running, status.is_running);
|
||||
}
|
||||
|
||||
void CheckConfigAndCredentials(const StreamCheckData &check_data) {
|
||||
const auto locked_streams = streams_->streams_.ReadLock();
|
||||
const auto &stream = locked_streams->at(check_data.name);
|
||||
const auto *stream_data = std::get_if<query::stream::Streams::StreamData<query::stream::KafkaStream>>(&stream);
|
||||
ASSERT_NE(stream_data, nullptr);
|
||||
const auto stream_info =
|
||||
stream_data->stream_source->ReadLock()->Info(check_data.info.common_info.transformation_name);
|
||||
EXPECT_TRUE(
|
||||
std::equal(check_data.info.configs.begin(), check_data.info.configs.end(), stream_info.configs.begin()));
|
||||
}
|
||||
|
||||
void StartStream(StreamCheckData &check_data) {
|
||||
streams_->Start(check_data.name);
|
||||
check_data.is_running = true;
|
||||
@@ -197,13 +183,6 @@ TEST_F(StreamsTest, RestoreStreams) {
|
||||
stream_info.common_info.batch_interval = std::chrono::milliseconds((i + 1) * 10);
|
||||
stream_info.common_info.batch_size = 1000 + i;
|
||||
stream_check_data.owner = std::string{"owner"} + iteration_postfix;
|
||||
|
||||
if (i == 1 || i == 3) {
|
||||
stream_info.configs.emplace(std::string{"sasl.username"}, std::string{"username"} + iteration_postfix);
|
||||
}
|
||||
if (i == 2 || i == 3) {
|
||||
stream_info.credentials.emplace(std::string{"sasl.password"}, std::string{"password"} + iteration_postfix);
|
||||
}
|
||||
}
|
||||
|
||||
mock_cluster_.CreateTopic(stream_info.topics[0]);
|
||||
@@ -219,7 +198,6 @@ TEST_F(StreamsTest, RestoreStreams) {
|
||||
EXPECT_EQ(stream_check_datas.size(), streams_->GetStreamInfo().size());
|
||||
for (const auto &check_data : stream_check_datas) {
|
||||
ASSERT_NO_FATAL_FAILURE(CheckStreamStatus(check_data));
|
||||
ASSERT_NO_FATAL_FAILURE(CheckConfigAndCredentials(check_data));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -275,32 +253,3 @@ TEST_F(StreamsTest, CheckWithTimeout) {
|
||||
EXPECT_LE(timeout, elapsed);
|
||||
EXPECT_LE(elapsed, timeout * 1.2);
|
||||
}
|
||||
|
||||
TEST_F(StreamsTest, CheckInvalidConfig) {
|
||||
auto stream_info = CreateDefaultStreamInfo();
|
||||
const auto stream_name = GetDefaultStreamName();
|
||||
constexpr auto kInvalidConfigName = "doesnt.exist";
|
||||
constexpr auto kConfigValue = "myprecious";
|
||||
stream_info.configs.emplace(kInvalidConfigName, kConfigValue);
|
||||
const auto checker = [](const std::string_view message) {
|
||||
EXPECT_TRUE(message.find(kInvalidConfigName) != std::string::npos) << message;
|
||||
EXPECT_TRUE(message.find(kConfigValue) != std::string::npos) << message;
|
||||
};
|
||||
EXPECT_THROW_WITH_MSG(streams_->Create<query::stream::KafkaStream>(stream_name, stream_info, std::nullopt),
|
||||
integrations::kafka::SettingCustomConfigFailed, checker);
|
||||
}
|
||||
|
||||
TEST_F(StreamsTest, CheckInvalidCredentials) {
|
||||
auto stream_info = CreateDefaultStreamInfo();
|
||||
const auto stream_name = GetDefaultStreamName();
|
||||
constexpr auto kInvalidCredentialName = "doesnt.exist";
|
||||
constexpr auto kCredentialValue = "myprecious";
|
||||
stream_info.credentials.emplace(kInvalidCredentialName, kCredentialValue);
|
||||
const auto checker = [](const std::string_view message) {
|
||||
EXPECT_TRUE(message.find(kInvalidCredentialName) != std::string::npos) << message;
|
||||
EXPECT_TRUE(message.find(integrations::kReducted) != std::string::npos) << message;
|
||||
EXPECT_TRUE(message.find(kCredentialValue) == std::string::npos) << message;
|
||||
};
|
||||
EXPECT_THROW_WITH_MSG(streams_->Create<query::stream::KafkaStream>(stream_name, stream_info, std::nullopt),
|
||||
integrations::kafka::SettingCustomConfigFailed, checker);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2022 Memgraph Ltd.
|
||||
// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -34,16 +34,4 @@ TResult ExpectNoError(const char *file, int line, TFunc func, TArgs &&...args) {
|
||||
}
|
||||
} // namespace test_utils
|
||||
|
||||
#define EXPECT_MGP_NO_ERROR(type, ...) test_utils::ExpectNoError<type>(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define EXPECT_THROW_WITH_MSG(statement, expected_exception, msg_checker) \
|
||||
EXPECT_THROW( \
|
||||
{ \
|
||||
try { \
|
||||
statement; \
|
||||
} catch (const expected_exception &e) { \
|
||||
EXPECT_NO_FATAL_FAILURE(msg_checker(e.what())); \
|
||||
throw; \
|
||||
} \
|
||||
}, \
|
||||
expected_exception);
|
||||
#define EXPECT_MGP_NO_ERROR(type, ...) test_utils::ExpectNoError<type>(__FILE__, __LINE__, __VA_ARGS__)
|
||||
@@ -1,14 +1,9 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from string import Template
|
||||
|
||||
BSL_HEADER = Template(
|
||||
"""// Copyright $year Memgraph Ltd.
|
||||
BSL_HEADER = """// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@@ -18,90 +13,34 @@ BSL_HEADER = Template(
|
||||
// the Business Source License, use of this software will be governed
|
||||
// by the Apache License, Version 2.0, included in the file
|
||||
// licenses/APL.txt."""
|
||||
)
|
||||
|
||||
MEL_HEADER = Template(
|
||||
"""// Copyright $year Memgraph Ltd.
|
||||
MEL_HEADER = """// Copyright 2021 Memgraph Ltd.
|
||||
//
|
||||
// Licensed as a Memgraph Enterprise file under the Memgraph Enterprise
|
||||
// License (the "License"); by using this file, you agree to be bound by the terms of the License, and you may not use
|
||||
// this file except in compliance with the License. You may obtain a copy of the License at https://memgraph.com/legal.
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def is_header_correct(content, header):
|
||||
return content.startswith(header)
|
||||
|
||||
|
||||
def str2bool(v):
|
||||
if isinstance(v, bool):
|
||||
return v
|
||||
if v.lower() in ("yes", "true", "t", "y", "1"):
|
||||
return True
|
||||
elif v.lower() in ("no", "false", "f", "n", "0"):
|
||||
return False
|
||||
else:
|
||||
raise argparse.ArgumentTypeError("Boolean value expected.")
|
||||
|
||||
|
||||
def replace_header(tmp_path, real_path, year):
|
||||
with open(tmp_path) as f:
|
||||
lines = f.readlines()
|
||||
lines[0] = f"// Copyright {year} Memgraph Ltd.\n"
|
||||
with open(real_path, "w") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
|
||||
def red(s):
|
||||
return f"\x1b[31m{s}\x1b[0m"
|
||||
|
||||
|
||||
def yellow(s):
|
||||
return f"\x1b[33m{s}\x1b[0m"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("file", help="File to check.", nargs="?")
|
||||
parser.add_argument("real_file", help="Real path to the file.", nargs="?")
|
||||
parser.add_argument(
|
||||
"--amend-year",
|
||||
type=str2bool,
|
||||
default=False,
|
||||
const=True,
|
||||
nargs="?",
|
||||
help="Will modify the license if only year is not correct.",
|
||||
)
|
||||
parser.add_argument("file", help="directory with source files", nargs="?")
|
||||
|
||||
args = parser.parse_args()
|
||||
with open(args.file, "r") as f:
|
||||
with open(args.file, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
year = datetime.today().year
|
||||
bls_header_complete = BSL_HEADER.substitute({"year": year})
|
||||
mel_header_complete = MEL_HEADER.substitute({"year": year})
|
||||
|
||||
has_header = is_header_correct(content, bls_header_complete) or is_header_correct(content, mel_header_complete)
|
||||
has_header = content.startswith(BSL_HEADER) or content.startswith(MEL_HEADER)
|
||||
if not has_header:
|
||||
|
||||
if args.amend_year:
|
||||
replaced_content = re.sub(r"Copyright [0-9]{4}", f"Copyright {year}", content, 1)
|
||||
is_header_corrected = is_header_correct(replaced_content, bls_header_complete) or is_header_correct(
|
||||
replaced_content, mel_header_complete
|
||||
)
|
||||
if is_header_corrected:
|
||||
replace_header(args.file, args.real_file, year)
|
||||
sys.stdout.writelines(yellow(f"Changing year in header for {args.real_file}!\n"))
|
||||
sys.exit(1)
|
||||
def red(s):
|
||||
return f"\x1b[31m{s}\x1b[0m"
|
||||
|
||||
sys.stdout.writelines(
|
||||
red("The file is missing a correct header. Please add/check the BSL or MEL license header!\n")
|
||||
)
|
||||
sys.stdout.writelines(red("The file is missing a header. Please add the BSL or MEL license header!\n"))
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -3,14 +3,10 @@ set(VERSION_STRING ${MEMGRAPH_VERSION})
|
||||
configure_file(../../src/version.hpp.in version.hpp @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
find_package(gflags REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# Memgraph Dump Target
|
||||
add_executable(mg_dump mg_dump/main.cpp)
|
||||
target_include_directories(mg_dump PRIVATE ${MGCLIENT_INCLUDE_DIR})
|
||||
target_link_libraries(mg_dump gflags spdlog fmt::fmt mgclient Threads::Threads)
|
||||
target_link_libraries(mg_dump gflags spdlog fmt mgclient pthread)
|
||||
install(TARGETS mg_dump RUNTIME DESTINATION bin)
|
||||
|
||||
# Target for building all the tool executables.
|
||||
|
||||
Reference in New Issue
Block a user