diff --git a/.Rbuildignore b/.Rbuildignore
index 67c3eef..d9f8952 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -16,3 +16,4 @@
^LICENSE$
^tests/testthat/test-dbplyr-ch.R$
.ipynb_checkpoints
+^src/vendor/clickhouse-cpp/build
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..3ae520a
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/vendor/clickhouse-cpp"]
+ path = src/vendor/clickhouse-cpp
+ url = git@github.com:ClickHouse/clickhouse-cpp.git
diff --git a/DESCRIPTION b/DESCRIPTION
index ad5b1fe..e655cc6 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -23,8 +23,11 @@ Authors@R: c(
Description: 'Yandex Clickhouse' () is a high-performance relational column-store database to enable
big data exploration and 'analytics' scaling to petabytes of data. Methods are
provided that enable working with 'Yandex Clickhouse' databases via
- 'DBI' methods and using 'dplyr'/'dbplyr' idioms.
+ 'DBI' methods and using 'dplyr'/'dbplyr' idioms.
+ NOTE(mmitkevich): https://github.com/ClickHouse/clickhouse-cpp/commit/87fc1186063b82b8ddf37b1c70c485bdd7504f8d
+ https://github.com/mmitkevich/RClickhouse
License: GPL-2
+SystemRequirements: C++17
Imports:
dplyr (>= 1.1.0),
dbplyr (>= 2.0.0),
@@ -33,7 +36,7 @@ Imports:
Rcpp (>= 0.11.0),
bit64,
cli
-RoxygenNote: 7.2.3
+RoxygenNote: 7.3.2
NeedsCompilation: yes
Depends:
R (>= 3.6.2)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0f5f5cb
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,33 @@
+# Makefile for generating R packages.
+# 2011 Andrew Redd
+#
+# Assumes Makefile is in a folder where package contents are in a subfolder pkg.
+# Roxygen uses the roxygen2 package, and will run automatically on check and all.
+
+PKG_VERSION=$(shell grep -i ^version DESCRIPTION | cut -d : -d \ -f 2)
+PKG_NAME=$(shell grep -i ^package DESCRIPTION | cut -d : -d \ -f 2)
+
+R_FILES := $(wildcard R/*.R)
+SRC_FILES := $(wildcard R/*.R)
+PKG_FILES := DESCRIPTION NAMESPACE $(R_FILES) $(SRC_FILES)
+
+.PHONY: tarball install check clean roxygen
+
+tarball: $(PKG_NAME)_$(PKG_VERSION).tar.gz
+$(PKG_NAME)_$(PKG_VERSION).tar.gz: $(PKG_FILES)
+ R CMD build .
+
+all: clean check install
+
+check: $(PKG_NAME)_$(PKG_VERSION).tar.gz roxygen
+ R CMD check $(PKG_NAME)_$(PKG_VERSION).tar.gz
+
+install: $(PKG_NAME)_$(PKG_VERSION).tar.gz
+ R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
+
+roxygen:
+ Rscript -e "library(roxygen2);roxygenize('.')"
+
+clean:
+ -rm -f $(PKG_NAME)_*.tar.gz
+ -rm -r -f $(PKG_NAME).Rcheck
\ No newline at end of file
diff --git a/man/RClickhouse.Rd b/man/RClickhouse.Rd
index 4ab24c0..73159f9 100644
--- a/man/RClickhouse.Rd
+++ b/man/RClickhouse.Rd
@@ -8,3 +8,37 @@
\description{
provides access to a clickhouse database
}
+\seealso{
+Useful links:
+\itemize{
+ \item \url{https://github.com/IMSMWU/RClickhouse}
+ \item Report bugs at \url{https://github.com/IMSMWU/RClickhouse/issues}
+}
+
+}
+\author{
+\strong{Maintainer}: Christian Hotz-Behofsits \email{christian.hotz-behofsits@wu.ac.at}
+
+Authors:
+\itemize{
+ \item Daniel Winkler \email{daniel.winkler@wu.ac.at}
+ \item Luca Rauchenberger \email{luca.rauchenberger@wu.ac.at}
+ \item Peter Knaus \email{peter.knaus@wu.ac.at}
+ \item Clemens Danninger \email{cran@b8000h.org}
+ \item Daria Yudaeva \email{daria.yudaeva@wu.ac.at}
+ \item Simon Stiebellehner \email{simon.stiebellehner@gmail.com}
+ \item Dan Egnor
+ \item Vlad Losev \email{vladl@google.com}
+ \item Keith Ray \email{keith.ray@gmail.com}
+ \item Zhanyong Wan \email{wan@google.com}
+ \item Markus Heule \email{mheule@google.com}
+ \item Oliver Flasch \email{oflasch@gmail.com}
+ \item Yann Collet (Yann Collet is the author and copyright holder of 'lz4') [copyright holder]
+}
+
+Other contributors:
+\itemize{
+ \item Google [copyright holder]
+}
+
+}
diff --git a/src/Makevars b/src/Makevars
index 1a11836..0256239 100644
--- a/src/Makevars
+++ b/src/Makevars
@@ -1 +1 @@
-include Makevars.common
+include Makevars.common
\ No newline at end of file
diff --git a/src/Makevars.common b/src/Makevars.common
index b68d2c6..3fdd33f 100644
--- a/src/Makevars.common
+++ b/src/Makevars.common
@@ -1,35 +1,42 @@
-PKG_CPPFLAGS = $(SYS_FLAGS) -I. -I../inst/include -I./vendor/clickhouse-cpp -I./vendor/clickhouse-cpp/contrib -I./vendor/clickhouse-cpp/contrib/bigerint
-
-CXX_STD = CXX11
+CXX_STD = CXX17
+PKG_CPPFLAGS = $(SYS_FLAGS) -I. -I../inst/include -I./vendor/clickhouse-cpp -I./vendor/clickhouse-cpp/contrib -I./vendor/clickhouse-cpp/contrib/absl -I./vendor/clickhouse-cpp/contrib/cityhash/cityhash -I./vendor/clickhouse-cpp/contrib/lz4/lz4 -DWITH_OPENSSL=1
+# -I./vendor/clickhouse-cpp/contrib/bigerint
OBJ_FILES = \
-vendor/clickhouse-cpp/clickhouse/columns/string.o \
-vendor/clickhouse-cpp/clickhouse/columns/date.o \
-vendor/clickhouse-cpp/clickhouse/columns/numeric.o \
-vendor/clickhouse-cpp/clickhouse/columns/decimal.o \
-vendor/clickhouse-cpp/clickhouse/columns/tuple.o \
-vendor/clickhouse-cpp/clickhouse/columns/array.o \
-vendor/clickhouse-cpp/clickhouse/columns/factory.o \
-vendor/clickhouse-cpp/clickhouse/columns/nullable.o \
-vendor/clickhouse-cpp/clickhouse/columns/enum.o \
-vendor/clickhouse-cpp/clickhouse/columns/uuid.o \
-vendor/clickhouse-cpp/clickhouse/columns/ip4.o \
-vendor/clickhouse-cpp/clickhouse/columns/ip6.o \
-vendor/clickhouse-cpp/clickhouse/query.o \
-vendor/clickhouse-cpp/clickhouse/base/platform.o \
vendor/clickhouse-cpp/clickhouse/base/socket.o \
+vendor/clickhouse-cpp/clickhouse/base/platform.o \
+vendor/clickhouse-cpp/clickhouse/base/sslsocket.o \
vendor/clickhouse-cpp/clickhouse/base/input.o \
vendor/clickhouse-cpp/clickhouse/base/output.o \
-vendor/clickhouse-cpp/clickhouse/base/coded.o \
vendor/clickhouse-cpp/clickhouse/base/compressed.o \
-vendor/clickhouse-cpp/clickhouse/client.o \
+vendor/clickhouse-cpp/clickhouse/base/wire_format.o \
+vendor/clickhouse-cpp/clickhouse/base/endpoints_iterator.o \
+vendor/clickhouse-cpp/clickhouse/block.o \
+vendor/clickhouse-cpp/clickhouse/query.o \
vendor/clickhouse-cpp/clickhouse/types/types.o \
vendor/clickhouse-cpp/clickhouse/types/type_parser.o \
-vendor/clickhouse-cpp/clickhouse/block.o \
-vendor/clickhouse-cpp/contrib/cityhash/city.o \
-vendor/clickhouse-cpp/contrib/lz4/lz4.o \
-vendor/clickhouse-cpp/contrib/lz4/lz4hc.o
+vendor/clickhouse-cpp/clickhouse/client.o \
+vendor/clickhouse-cpp/clickhouse/columns/ip6.o \
+vendor/clickhouse-cpp/clickhouse/columns/ip4.o \
+vendor/clickhouse-cpp/clickhouse/columns/lowcardinality.o \
+vendor/clickhouse-cpp/clickhouse/columns/numeric.o \
+vendor/clickhouse-cpp/clickhouse/columns/decimal.o \
+vendor/clickhouse-cpp/clickhouse/columns/array.o \
+vendor/clickhouse-cpp/clickhouse/columns/factory.o \
+vendor/clickhouse-cpp/clickhouse/columns/date.o \
+vendor/clickhouse-cpp/clickhouse/columns/enum.o \
+vendor/clickhouse-cpp/clickhouse/columns/tuple.o \
+vendor/clickhouse-cpp/clickhouse/columns/itemview.o \
+vendor/clickhouse-cpp/clickhouse/columns/string.o \
+vendor/clickhouse-cpp/clickhouse/columns/nullable.o \
+vendor/clickhouse-cpp/clickhouse/columns/uuid.o \
+vendor/clickhouse-cpp/clickhouse/columns/column.o \
+vendor/clickhouse-cpp/clickhouse/columns/geo.o \
+vendor/clickhouse-cpp/clickhouse/columns/map.o \
+vendor/clickhouse-cpp/contrib/lz4/lz4/lz4hc.o \
+vendor/clickhouse-cpp/contrib/lz4/lz4/lz4.o \
+vendor/clickhouse-cpp/contrib/cityhash/cityhash/city.o
-PKG_LIBS = $(OBJ_FILES) -lpthread $(SYS_LIBS)
+PKG_LIBS = $(OBJ_FILES) -lpthread -lssl $(SYS_LIBS)
$(SHLIB): $(OBJ_FILES)
diff --git a/src/result.cpp b/src/result.cpp
index e5df40f..f488972 100644
--- a/src/result.cpp
+++ b/src/result.cpp
@@ -1,7 +1,8 @@
#include
+#include
+#include "clickhouse/columns/string.h"
#include "result.h"
-
-
+
// helper function which emits an R warning without causing a longjmp
// see https://stackoverflow.com/questions/24557711/how-to-generate-an-r-warning-safely-in-rcpp
void warn(std::string text) {
@@ -62,6 +63,37 @@ void convertEntries(std::shared_ptr in, NullCol nullCol, RT &out,
}
+// workaround lack of Rcpp::StringVector x; x[i] = std::string_view();
+template<>
+void convertEntries(std::shared_ptr in, NullCol nullCol, Rcpp::StringVector &out,
+ size_t offset, size_t start, size_t end)
+{
+ for(size_t j = start; j < end; j++) {
+ // can't use the ternary operator here, since that would require explicit
+ // conversion from the Clickhouse storage type (which is far messier)
+ if(nullCol && nullCol->IsNull(j)) {
+ out[offset+j-start] = Rcpp::StringVector::get_na();
+ } else {
+ out[offset+j-start] = std::string(in->At(j));
+ }
+ }
+}
+
+template<>
+void convertEntries(std::shared_ptr in, NullCol nullCol, Rcpp::StringVector &out,
+ size_t offset, size_t start, size_t end)
+{
+ for(size_t j = start; j < end; j++) {
+ // can't use the ternary operator here, since that would require explicit
+ // conversion from the Clickhouse storage type (which is far messier)
+ if(nullCol && nullCol->IsNull(j)) {
+ out[offset+j-start] = Rcpp::StringVector::get_na();
+ } else {
+ out[offset+j-start] = std::string(in->At(j));
+ }
+ }
+}
+
template<>
void convertEntries(std::shared_ptr in, NullCol nullCol, Rcpp::StringVector &out,
size_t offset, size_t start, size_t end) {
@@ -104,7 +136,18 @@ void convertEntries(std::shared_ptr
+void convertEntries(std::shared_ptr in,
+ NullCol nullCol, Rcpp::DatetimeVector &out, size_t offset, size_t start, size_t end) {
+ double factor = std::pow(10.,in->GetPrecision());
+ for(size_t j = start; j < end; j++) {
+ if(nullCol && nullCol->IsNull(j)) {
+ out[offset+j-start] = Rcpp::DateVector::get_na();
+ } else {
+ out[offset+j-start] = static_cast(in->At(j)/factor);
+ }
+ }
+}
std::string formatUUID(const ch::UInt128 &v) {
const size_t bufsize = 128/4 + 4 + 1; // 128 bit in hexadecimal + 4 dashes + null terminator
char buf[bufsize];
@@ -292,6 +335,9 @@ std::unique_ptr Result::buildConverter(std::string name, ch::TypeRef
return std::unique_ptr>(new ScalarConverter);
case TC::Date:
return std::unique_ptr>(new ScalarConverter);
+ case TC::DateTime64:
+ return std::unique_ptr>(new ScalarConverter);
+
case TC::Nullable:
{
// downcast to NullableType to access GetNestedType member
diff --git a/src/vendor/clickhouse-cpp b/src/vendor/clickhouse-cpp
new file mode 160000
index 0000000..68e592c
--- /dev/null
+++ b/src/vendor/clickhouse-cpp
@@ -0,0 +1 @@
+Subproject commit 68e592c46910379c7964660bdf485b314d2d785a
diff --git a/src/vendor/clickhouse-cpp/.buckconfig b/src/vendor/clickhouse-cpp/.buckconfig
deleted file mode 100644
index c885451..0000000
--- a/src/vendor/clickhouse-cpp/.buckconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-[cxx]
- gtest_dep = //contrib/gtest:gtest
diff --git a/src/vendor/clickhouse-cpp/.clang-format b/src/vendor/clickhouse-cpp/.clang-format
deleted file mode 100644
index 3f5f374..0000000
--- a/src/vendor/clickhouse-cpp/.clang-format
+++ /dev/null
@@ -1,11 +0,0 @@
-Language: Cpp
-BasedOnStyle: Google
-
-AccessModifierOffset: -4
-AlignConsecutiveAssignments: true
-AllowShortFunctionsOnASingleLine: InlineOnly
-ColumnLimit: 140
-DerivePointerAlignment: false
-FixNamespaceComments: true
-IndentWidth: 4
-PointerAlignment: Left
diff --git a/src/vendor/clickhouse-cpp/.gitattributes b/src/vendor/clickhouse-cpp/.gitattributes
deleted file mode 100644
index 1ff0c42..0000000
--- a/src/vendor/clickhouse-cpp/.gitattributes
+++ /dev/null
@@ -1,63 +0,0 @@
-###############################################################################
-# Set default behavior to automatically normalize line endings.
-###############################################################################
-* text=auto
-
-###############################################################################
-# Set default behavior for command prompt diff.
-#
-# This is need for earlier builds of msysgit that does not have it on by
-# default for csharp files.
-# Note: This is only used by command line
-###############################################################################
-#*.cs diff=csharp
-
-###############################################################################
-# Set the merge driver for project and solution files
-#
-# Merging from the command prompt will add diff markers to the files if there
-# are conflicts (Merging from VS is not affected by the settings below, in VS
-# the diff markers are never inserted). Diff markers may cause the following
-# file extensions to fail to load in VS. An alternative would be to treat
-# these files as binary and thus will always conflict and require user
-# intervention with every merge. To do so, just uncomment the entries below
-###############################################################################
-#*.sln merge=binary
-#*.csproj merge=binary
-#*.vbproj merge=binary
-#*.vcxproj merge=binary
-#*.vcproj merge=binary
-#*.dbproj merge=binary
-#*.fsproj merge=binary
-#*.lsproj merge=binary
-#*.wixproj merge=binary
-#*.modelproj merge=binary
-#*.sqlproj merge=binary
-#*.wwaproj merge=binary
-
-###############################################################################
-# behavior for image files
-#
-# image files are treated as binary by default.
-###############################################################################
-#*.jpg binary
-#*.png binary
-#*.gif binary
-
-###############################################################################
-# diff behavior for common document formats
-#
-# Convert binary document formats to text before diffing them. This feature
-# is only available from the command line. Turn it on by uncommenting the
-# entries below.
-###############################################################################
-#*.doc diff=astextplain
-#*.DOC diff=astextplain
-#*.docx diff=astextplain
-#*.DOCX diff=astextplain
-#*.dot diff=astextplain
-#*.DOT diff=astextplain
-#*.pdf diff=astextplain
-#*.PDF diff=astextplain
-#*.rtf diff=astextplain
-#*.RTF diff=astextplain
diff --git a/src/vendor/clickhouse-cpp/.gitignore b/src/vendor/clickhouse-cpp/.gitignore
deleted file mode 100644
index 4c1637d..0000000
--- a/src/vendor/clickhouse-cpp/.gitignore
+++ /dev/null
@@ -1,276 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-
-# User-specific files
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-# Temporary solution for VS 2015
-vs/
-# Visual Studio Code
-.vscode/
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-bld/
-build/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-
-# Visual Studio 2015 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# DNX
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# TODO: Comment the next line if you want to checkin your web deploy settings
-# but database connection strings (with potential passwords) will be unencrypted
-#*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/packages/*
-# except build/, which is used as an MSBuild target.
-!**/packages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-# NuGet v3's project.json files produces more ignoreable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-node_modules/
-orleans.codegen.cs
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-*.mdf
-*.ldf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-# CodeRush
-.cr/
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Buck
-/buck-out/
-/.buckd/
-/buckaroo/
-.buckconfig.local
-BUCKAROO_DEPS
-
-# Visual Studio Code
-/.vscode/
diff --git a/src/vendor/clickhouse-cpp/.travis.yml b/src/vendor/clickhouse-cpp/.travis.yml
deleted file mode 100644
index 7d38ea0..0000000
--- a/src/vendor/clickhouse-cpp/.travis.yml
+++ /dev/null
@@ -1,54 +0,0 @@
-# Enable C++ support
-language: cpp
-
-matrix:
- include:
- - os: linux
- dist: trusty
- sudo: required
- compiler: gcc
- addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - g++-7
- env:
- - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
-
- - os: linux
- dist: trusty
- sudo: required
- compiler: clang
- addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- - llvm-toolchain-trusty-6.0
- - sourceline: 'ppa:ubuntu-toolchain-r/test'
- packages:
- - g++-7
- - llvm-6.0
- - clang-6.0
- - libstdc++6
- env:
- - MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
-
- - os: osx
- osx_image: xcode8.2
- compiler: clang
-
-before_install:
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo 'deb http://repo.yandex.ru/clickhouse/deb/stable main/' | sudo tee /etc/apt/sources.list.d/clickhouse.list ; fi
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 ; fi
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -q && sudo apt-get install -q -y --allow-unauthenticated clickhouse-server-common ; fi
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo service clickhouse-server start ; fi
-
-# Build steps
-script:
- - eval "${MATRIX_EVAL}"
- - mkdir build
- - cd build
- - cmake .. -DBUILD_TESTS=ON && make
- - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ut/clickhouse-cpp-ut ; fi
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./ut/clickhouse-cpp-ut --gtest_filter='-Client/*' ; fi
diff --git a/src/vendor/clickhouse-cpp/BUCK b/src/vendor/clickhouse-cpp/BUCK
deleted file mode 100644
index 0c86b12..0000000
--- a/src/vendor/clickhouse-cpp/BUCK
+++ /dev/null
@@ -1,20 +0,0 @@
-cxx_library(
- name = 'clickhouse-cpp',
- header_namespace = 'clickhouse',
- exported_headers = subdir_glob([
- ('clickhouse', '**/*.h'),
- ]),
- srcs = glob([
- 'clickhouse/**/*.cpp',
- ]),
- compiler_flags = [
- '-std=c++11',
- ],
- visibility = [
- 'PUBLIC',
- ],
- deps = [
- '//contrib/cityhash:cityhash',
- '//contrib/lz4:lz4',
- ]
-)
diff --git a/src/vendor/clickhouse-cpp/CMakeLists.txt b/src/vendor/clickhouse-cpp/CMakeLists.txt
deleted file mode 100644
index 5190565..0000000
--- a/src/vendor/clickhouse-cpp/CMakeLists.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2)
-
-INCLUDE (cmake/cpp11.cmake)
-INCLUDE (cmake/subdirs.cmake)
-
-OPTION(BUILD_BENCHMARK "Build benchmark" OFF)
-OPTION(BUILD_TESTS "Build tests" OFF)
-
-PROJECT (CLICKHOUSE-CLIENT)
-
- USE_CXX11()
-
- IF ("${CMAKE_BUILD_TYPE}" STREQUAL "")
- set(CMAKE_BUILD_TYPE "Debug")
- ENDIF()
-
- IF (UNIX)
- IF (APPLE)
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wextra -Werror")
- ELSE ()
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -pthread -Wall -Wextra -Werror")
- ENDIF ()
- SET (CMAKE_EXE_LINKER_FLAGS, "${CMAKE_EXE_LINKER_FLAGS} -lpthread")
- ENDIF ()
-
- INCLUDE_DIRECTORIES(.)
- INCLUDE_DIRECTORIES(contrib)
- INCLUDE_DIRECTORIES(contrib/bigerint)
-
- SUBDIRS (
- clickhouse
- contrib/cityhash
- contrib/lz4
- )
-
- IF (BUILD_BENCHMARK)
- SUBDIRS(bench)
- ENDIF (BUILD_BENCHMARK)
-
- IF (BUILD_TESTS)
- SUBDIRS(
- contrib/gtest
- tests/simple
- ut
- )
- ENDIF (BUILD_TESTS)
diff --git a/src/vendor/clickhouse-cpp/LICENSE b/src/vendor/clickhouse-cpp/LICENSE
deleted file mode 100644
index 5e59a61..0000000
--- a/src/vendor/clickhouse-cpp/LICENSE
+++ /dev/null
@@ -1,206 +0,0 @@
-Copyright 2018-2019 Yandex LLC
-Copyright 2017 Pavel Artemkin
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2018-2019 Yandex LLC
- Copyright 2017 Pavel Artemkin
-
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/src/vendor/clickhouse-cpp/README.md b/src/vendor/clickhouse-cpp/README.md
deleted file mode 100644
index 337c968..0000000
--- a/src/vendor/clickhouse-cpp/README.md
+++ /dev/null
@@ -1,73 +0,0 @@
-ClickHouse C++ client [](https://travis-ci.org/ClickHouse/clickhouse-cpp)
-=====
-
-C++ client for [Yandex ClickHouse](https://clickhouse.yandex/)
-
-## Supported data types
-
-* Array(T)
-* Date
-* DateTime
-* Decimal32, Decimal64, Decimal128
-* Enum8, Enum16
-* FixedString(N)
-* Float32, Float64
-* IPv4, IPv6
-* Nullable(T)
-* String
-* Tuple
-* UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64
-
-## Building
-
-```sh
-$ mkdir build .
-$ cd build
-$ cmake .. [-DBUILD_TESTS=ON]
-$ make
-```
-
-## Example
-
-```cpp
-#include
-
-using namespace clickhouse;
-
-/// Initialize client connection.
-Client client(ClientOptions().SetHost("localhost"));
-
-/// Create a table.
-client.Execute("CREATE TABLE IF NOT EXISTS test.numbers (id UInt64, name String) ENGINE = Memory");
-
-/// Insert some values.
-{
- Block block;
-
- auto id = std::make_shared();
- id->Append(1);
- id->Append(7);
-
- auto name = std::make_shared();
- name->Append("one");
- name->Append("seven");
-
- block.AppendColumn("id" , id);
- block.AppendColumn("name", name);
-
- client.Insert("test.numbers", block);
-}
-
-/// Select values inserted in the previous step.
-client.Select("SELECT id, name FROM test.numbers", [] (const Block& block)
- {
- for (size_t i = 0; i < block.GetRowCount(); ++i) {
- std::cout << block[0]->As()->At(i) << " "
- << block[1]->As()->At(i) << "\n";
- }
- }
-);
-
-/// Delete table.
-client.Execute("DROP TABLE test.numbers");
-```
diff --git a/src/vendor/clickhouse-cpp/bench/CMakeLists.txt b/src/vendor/clickhouse-cpp/bench/CMakeLists.txt
deleted file mode 100644
index ac99470..0000000
--- a/src/vendor/clickhouse-cpp/bench/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-ADD_EXECUTABLE (bench
- bench.cpp
-)
-
-TARGET_LINK_LIBRARIES (bench
- clickhouse-cpp-lib
- benchmark
-)
diff --git a/src/vendor/clickhouse-cpp/bench/bench.cpp b/src/vendor/clickhouse-cpp/bench/bench.cpp
deleted file mode 100644
index 9ca8ff7..0000000
--- a/src/vendor/clickhouse-cpp/bench/bench.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include
-
-#include
-
-namespace clickhouse {
-
-Client g_client(ClientOptions()
- .SetHost("localhost")
- .SetPingBeforeQuery(false));
-
-static void SelectNumber(benchmark::State& state) {
- while (state.KeepRunning()) {
- g_client.Select("SELECT number, number, number FROM system.numbers LIMIT 1000",
- [](const Block& block) { block.GetRowCount(); }
- );
- }
-}
-BENCHMARK(SelectNumber);
-
-static void SelectNumberMoreColumns(benchmark::State& state) {
- // Mainly test performance on type name parsing.
- while (state.KeepRunning()) {
- g_client.Select("SELECT "
- "number, number, number, number, number, number, number, number, number, number "
- "FROM system.numbers LIMIT 100",
- [](const Block& block) { block.GetRowCount(); }
- );
- }
-}
-BENCHMARK(SelectNumberMoreColumns);
-
-}
-
-BENCHMARK_MAIN();
diff --git a/src/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt b/src/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt
deleted file mode 100644
index a12d64a..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/CMakeLists.txt
+++ /dev/null
@@ -1,111 +0,0 @@
-SET ( clickhouse-cpp-lib-src
- base/coded.cpp
- base/compressed.cpp
- base/input.cpp
- base/output.cpp
- base/platform.cpp
- base/socket.cpp
-
- columns/array.cpp
- columns/date.cpp
- columns/decimal.cpp
- columns/enum.cpp
- columns/factory.cpp
- columns/ip4.cpp
- columns/ip6.cpp
- columns/nullable.cpp
- columns/numeric.cpp
- columns/string.cpp
- columns/tuple.cpp
- columns/uuid.cpp
-
- types/type_parser.cpp
- types/types.cpp
-
- block.cpp
- client.cpp
- query.cpp
-)
-
-ADD_LIBRARY (clickhouse-cpp-lib SHARED ${clickhouse-cpp-lib-src})
-SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
-
-TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
- cityhash-lib
- lz4-lib
-)
-
-
-ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src})
-TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
- cityhash-lib
- lz4-lib
-)
-
-IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
- INCLUDE (CheckCXXSourceCompiles)
-
- CHECK_CXX_SOURCE_COMPILES("#include \nint main() { return __GLIBCXX__ != 0; }"
- BUILDING_WITH_LIB_STDCXX)
-
- IF (BUILDING_WITH_LIB_STDCXX)
- # there is a problem with __builtin_mul_overflow call at link time
- # the error looks like: ... undefined reference to `__muloti4' ...
- # caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
- # explicit linking to compiler-rt allows to workaround the problem
- SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")
-
- # some workaround for linking issues on linux:
- # /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
- # /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
- # FIXME: that workaround breaks clang build on mingw
- TARGET_LINK_LIBRARIES (clickhouse-cpp-lib gcc_s)
- ENDIF ()
-ENDIF ()
-
-
-INSTALL(TARGETS clickhouse-cpp-lib clickhouse-cpp-lib-static
- ARCHIVE DESTINATION lib
- LIBRARY DESTINATION lib
-)
-
-# general
-INSTALL(FILES block.h DESTINATION include/clickhouse/)
-INSTALL(FILES client.h DESTINATION include/clickhouse/)
-INSTALL(FILES error_codes.h DESTINATION include/clickhouse/)
-INSTALL(FILES exceptions.h DESTINATION include/clickhouse/)
-INSTALL(FILES protocol.h DESTINATION include/clickhouse/)
-INSTALL(FILES query.h DESTINATION include/clickhouse/)
-
-# base
-INSTALL(FILES base/buffer.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/coded.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/compressed.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/input.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/output.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/platform.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/singleton.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/socket.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/string_utils.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/string_view.h DESTINATION include/clickhouse/base/)
-INSTALL(FILES base/wire_format.h DESTINATION include/clickhouse/base/)
-
-# columns
-INSTALL(FILES columns/array.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/column.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/date.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/decimal.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/enum.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/factory.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/ip4.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/ip6.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/nullable.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/numeric.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/string.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/tuple.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/utils.h DESTINATION include/clickhouse/columns/)
-INSTALL(FILES columns/uuid.h DESTINATION include/clickhouse/columns/)
-
-# types
-INSTALL(FILES types/type_parser.h DESTINATION include/clickhouse/types/)
-INSTALL(FILES types/types.h DESTINATION include/clickhouse/types/)
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/buffer.h b/src/vendor/clickhouse-cpp/clickhouse/base/buffer.h
deleted file mode 100644
index 40695d9..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/buffer.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-#include
-#include
-
-namespace clickhouse {
-
-using Buffer = std::vector;
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/coded.cpp b/src/vendor/clickhouse-cpp/clickhouse/base/coded.cpp
deleted file mode 100644
index fbd29a2..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/coded.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "coded.h"
-
-#include
-
-namespace clickhouse {
-
-static const int MAX_VARINT_BYTES = 10;
-
-CodedInputStream::CodedInputStream(ZeroCopyInput* input)
- : input_(input)
-{
-}
-
-bool CodedInputStream::ReadRaw(void* buffer, size_t size) {
- uint8_t* p = static_cast(buffer);
-
- while (size > 0) {
- const void* ptr;
- size_t len = input_->Next(&ptr, size);
-
- memcpy(p, ptr, len);
-
- p += len;
- size -= len;
- }
-
- return true;
-}
-
-bool CodedInputStream::Skip(size_t count) {
- while (count > 0) {
- const void* ptr;
- size_t len = input_->Next(&ptr, count);
-
- if (len == 0) {
- return false;
- }
-
- count -= len;
- }
-
- return true;
-}
-
-bool CodedInputStream::ReadVarint64(uint64_t* value) {
- *value = 0;
-
- for (size_t i = 0; i < MAX_VARINT_BYTES; ++i) {
- uint8_t byte;
-
- if (!input_->ReadByte(&byte)) {
- return false;
- } else {
- *value |= uint64_t(byte & 0x7F) << (7 * i);
-
- if (!(byte & 0x80)) {
- return true;
- }
- }
- }
-
- // TODO skip invalid
- return false;
-}
-
-
-CodedOutputStream::CodedOutputStream(ZeroCopyOutput* output)
- : output_(output)
-{
-}
-
-void CodedOutputStream::Flush() {
- output_->Flush();
-}
-
-void CodedOutputStream::WriteRaw(const void* buffer, int size) {
- output_->Write(buffer, size);
-}
-
-void CodedOutputStream::WriteVarint64(uint64_t value) {
- uint8_t bytes[MAX_VARINT_BYTES];
- int size = 0;
-
- for (size_t i = 0; i < MAX_VARINT_BYTES; ++i) {
- uint8_t byte = value & 0x7F;
- if (value > 0x7F)
- byte |= 0x80;
-
- bytes[size++] = byte;
-
- value >>= 7;
- if (!value) {
- break;
- }
- }
-
- WriteRaw(bytes, size);
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/coded.h b/src/vendor/clickhouse-cpp/clickhouse/base/coded.h
deleted file mode 100644
index a171ac5..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/coded.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#pragma once
-
-#include "input.h"
-#include "output.h"
-
-#include
-
-namespace clickhouse {
-
-/**
- * Class which reads and decodes binary data which is composed of varint-
- * encoded integers and fixed-width pieces.
- */
-class CodedInputStream {
-public:
- /// Create a CodedInputStream that reads from the given ZeroCopyInput.
- explicit CodedInputStream(ZeroCopyInput* input);
-
- // Read an unsigned integer with Varint encoding, truncating to 32 bits.
- // Reading a 32-bit value is equivalent to reading a 64-bit one and casting
- // it to uint32, but may be more efficient.
- bool ReadVarint32(uint32_t* value);
-
- // Read an unsigned integer with Varint encoding.
- bool ReadVarint64(uint64_t* value);
-
- // Read raw bytes, copying them into the given buffer.
- bool ReadRaw(void* buffer, size_t size);
-
- // Like ReadRaw, but reads into a string.
- //
- // Implementation Note: ReadString() grows the string gradually as it
- // reads in the data, rather than allocating the entire requested size
- // upfront. This prevents denial-of-service attacks in which a client
- // could claim that a string is going to be MAX_INT bytes long in order to
- // crash the server because it can't allocate this much space at once.
- bool ReadString(std::string* buffer, int size);
-
- // Skips a number of bytes. Returns false if an underlying read error
- // occurs.
- bool Skip(size_t count);
-
-private:
- ZeroCopyInput* input_;
-};
-
-
-class CodedOutputStream {
-public:
- /// Create a CodedInputStream that writes to the given ZeroCopyOutput.
- explicit CodedOutputStream(ZeroCopyOutput* output);
-
- void Flush();
-
- // Write raw bytes, copying them from the given buffer.
- void WriteRaw(const void* buffer, int size);
-
- /// Write an unsigned integer with Varint encoding.
- void WriteVarint64(const uint64_t value);
-
-private:
- ZeroCopyOutput* output_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp b/src/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp
deleted file mode 100644
index 664100c..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/compressed.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "compressed.h"
-#include "wire_format.h"
-
-#include
-#include
-#include
-#include
-
-#define DBMS_MAX_COMPRESSED_SIZE 0x40000000ULL // 1GB
-
-namespace {
-constexpr size_t HEADER_SIZE = 9;
-}
-
-namespace clickhouse {
-
-CompressedInput::CompressedInput(CodedInputStream* input)
- : input_(input)
-{
-}
-
-CompressedInput::~CompressedInput() {
- if (!mem_.Exhausted()) {
-#if __cplusplus < 201703L
- if (!std::uncaught_exception()) {
-#else
- if (!std::uncaught_exceptions()) {
-#endif
- throw std::runtime_error("some data was not readed");
- }
- }
-}
-
-size_t CompressedInput::DoNext(const void** ptr, size_t len) {
- if (mem_.Exhausted()) {
- if (!Decompress()) {
- return 0;
- }
- }
-
- return mem_.Next(ptr, len);
-}
-
-bool CompressedInput::Decompress() {
- uint128 hash;
- uint32_t compressed = 0;
- uint32_t original = 0;
- uint8_t method = 0;
-
- if (!WireFormat::ReadFixed(input_, &hash)) {
- return false;
- }
- if (!WireFormat::ReadFixed(input_, &method)) {
- return false;
- }
-
- if (method != 0x82) {
- throw std::runtime_error("unsupported compression method " +
- std::to_string(int(method)));
- } else {
- if (!WireFormat::ReadFixed(input_, &compressed)) {
- return false;
- }
- if (!WireFormat::ReadFixed(input_, &original)) {
- return false;
- }
-
- if (compressed > DBMS_MAX_COMPRESSED_SIZE) {
- throw std::runtime_error("compressed data too big");
- }
-
- Buffer tmp(compressed);
-
- // Заполнить заголовок сжатых данных.
- {
- BufferOutput out(&tmp);
- out.Write(&method, sizeof(method));
- out.Write(&compressed, sizeof(compressed));
- out.Write(&original, sizeof(original));
- }
-
- if (!WireFormat::ReadBytes(input_, tmp.data() + 9, compressed - 9)) {
- return false;
- } else {
- if (hash != CityHash128((const char*)tmp.data(), compressed)) {
- throw std::runtime_error("data was corrupted");
- }
- }
-
- data_ = Buffer(original);
- if (LZ4_decompress_safe((const char*)tmp.data() + HEADER_SIZE, (char*)data_.data(), compressed - HEADER_SIZE, original) < 0) {
- throw std::runtime_error("can't decompress data");
- } else {
- mem_.Reset(data_.data(), original);
- }
- }
-
- return true;
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/compressed.h b/src/vendor/clickhouse-cpp/clickhouse/base/compressed.h
deleted file mode 100644
index 8c1b461..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/compressed.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-
-#include "coded.h"
-
-namespace clickhouse {
-
-class CompressedInput : public ZeroCopyInput {
-public:
- CompressedInput(CodedInputStream* input);
- ~CompressedInput();
-
-protected:
- size_t DoNext(const void** ptr, size_t len) override;
-
- bool Decompress();
-
-private:
- CodedInputStream* const input_;
-
- Buffer data_;
- ArrayInput mem_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/input.cpp b/src/vendor/clickhouse-cpp/clickhouse/base/input.cpp
deleted file mode 100644
index f7b7ff6..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/input.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "input.h"
-
-#include
-#include
-
-namespace clickhouse {
-
-size_t ZeroCopyInput::DoRead(void* buf, size_t len) {
- const void* ptr;
- size_t result = DoNext(&ptr, len);
-
- if (result) {
- memcpy(buf, ptr, result);
- }
-
- return result;
-}
-
-ArrayInput::ArrayInput() noexcept
- : data_(nullptr)
- , len_(0)
-{
-}
-
-ArrayInput::ArrayInput(const void* buf, size_t len) noexcept
- : data_(static_cast(buf))
- , len_(len)
-{
-}
-
-ArrayInput::~ArrayInput() = default;
-
-size_t ArrayInput::DoNext(const void** ptr, size_t len) {
- len = std::min(len_, len);
-
- *ptr = data_;
- len_ -= len;
- data_ += len;
-
- return len;
-}
-
-
-BufferedInput::BufferedInput(InputStream* slave, size_t buflen)
- : slave_(slave)
- , array_input_(nullptr, 0)
- , buffer_(buflen)
-{
-}
-
-BufferedInput::~BufferedInput() = default;
-
-void BufferedInput::Reset() {
- array_input_.Reset(nullptr, 0);
-}
-
-size_t BufferedInput::DoNext(const void** ptr, size_t len) {
- if (array_input_.Exhausted()) {
- array_input_.Reset(
- buffer_.data(), slave_->Read(buffer_.data(), buffer_.size())
- );
- }
-
- return array_input_.Next(ptr, len);
-}
-
-size_t BufferedInput::DoRead(void* buf, size_t len) {
- if (array_input_.Exhausted()) {
- if (len > buffer_.size() / 2) {
- return slave_->Read(buf, len);
- }
-
- array_input_.Reset(
- buffer_.data(), slave_->Read(buffer_.data(), buffer_.size())
- );
- }
-
- return array_input_.Read(buf, len);
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/input.h b/src/vendor/clickhouse-cpp/clickhouse/base/input.h
deleted file mode 100644
index 052fab8..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/input.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-namespace clickhouse {
-
-class InputStream {
-public:
- virtual ~InputStream() noexcept (false)
- { }
-
- /// Reads one byte from the stream.
- inline bool ReadByte(uint8_t* byte) {
- return DoRead(byte, sizeof(uint8_t)) == sizeof(uint8_t);
- }
-
- /// Reads some data from the stream.
- inline size_t Read(void* buf, size_t len) {
- return DoRead(buf, len);
- }
-
-protected:
- virtual size_t DoRead(void* buf, size_t len) = 0;
-};
-
-
-class ZeroCopyInput : public InputStream {
-public:
- inline size_t Next(const void** buf, size_t len) {
- return DoNext(buf, len);
- }
-
-protected:
- virtual size_t DoNext(const void** ptr, size_t len) = 0;
-
- size_t DoRead(void* buf, size_t len) override;
-};
-
-
-/**
- * A ZeroCopyInput stream backed by an in-memory array of bytes.
- */
-class ArrayInput : public ZeroCopyInput {
-public:
- ArrayInput() noexcept;
- ArrayInput(const void* buf, size_t len) noexcept;
- ~ArrayInput() override;
-
- /// Number of bytes available in the stream.
- inline size_t Avail() const noexcept {
- return len_;
- }
-
- /// Current read position in the memory block used by this stream.
- inline const uint8_t* Data() const noexcept {
- return data_;
- }
-
- /// Whether there is more data in the stream.
- inline bool Exhausted() const noexcept {
- return !Avail();
- }
-
- inline void Reset(const void* buf, size_t len) noexcept {
- data_ = static_cast(buf);
- len_ = len;
- }
-
-private:
- size_t DoNext(const void** ptr, size_t len) override;
-
-private:
- const uint8_t* data_;
- size_t len_;
-};
-
-
-class BufferedInput : public ZeroCopyInput {
-public:
- BufferedInput(InputStream* slave, size_t buflen = 8192);
- ~BufferedInput() override;
-
- void Reset();
-
-protected:
- size_t DoRead(void* buf, size_t len) override;
- size_t DoNext(const void** ptr, size_t len) override;
-
-private:
- InputStream* const slave_;
- ArrayInput array_input_;
- std::vector buffer_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/output.cpp b/src/vendor/clickhouse-cpp/clickhouse/base/output.cpp
deleted file mode 100644
index dcd25ef..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/output.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "output.h"
-
-#include
-#include
-#include
-
-namespace clickhouse {
-
-void ZeroCopyOutput::DoWrite(const void* data, size_t len) {
- while (len > 0) {
- void* ptr;
- size_t result = DoNext(&ptr, len);
-
- if (result) {
- memcpy(ptr, data, result);
- len -= result;
- data = static_cast(data) + result;
- } else {
- break;
- }
- }
-}
-
-
-ArrayOutput::ArrayOutput(void* buf, size_t len)
- : buf_(static_cast(buf))
- , end_(buf_ + len)
-{
-}
-
-ArrayOutput::~ArrayOutput() = default;
-
-size_t ArrayOutput::DoNext(void** data, size_t len) {
- len = std::min(len, Avail());
-
- *data = buf_;
- buf_ += len;
-
- return len;
-}
-
-
-BufferOutput::BufferOutput(Buffer* buf)
- : buf_(buf)
- , pos_(0)
-{
- assert(buf_);
-}
-
-BufferOutput::~BufferOutput()
-{ }
-
-size_t BufferOutput::DoNext(void** data, size_t len) {
- if (pos_ + len > buf_->size()) {
- buf_->resize(pos_ + len);
- }
-
- *data = buf_->data() + pos_;
- pos_ += len;
-
- return len;
-}
-
-
-BufferedOutput::BufferedOutput(OutputStream* slave, size_t buflen)
- : slave_(slave)
- , buffer_(buflen)
- , array_output_(buffer_.data(), buflen)
-{
-}
-
-BufferedOutput::~BufferedOutput() {
- try
- {
- Flush();
- }
- catch (...)
- {
- // That means we've failed to flush some data e.g. to the socket,
- // but there is nothing we can do at this point (can't bring the socket back),
- // and throwing in destructor is really a bad idea.
- // The best we can do is to log the error and ignore it, but currently there is no logging subsystem.
- }
-}
-
-void BufferedOutput::Reset() {
- array_output_.Reset(buffer_.data(), buffer_.size());
-}
-
-void BufferedOutput::DoFlush() {
- if (array_output_.Data() != buffer_.data()) {
- slave_->Write(buffer_.data(), array_output_.Data() - buffer_.data());
- slave_->Flush();
-
- array_output_.Reset(buffer_.data(), buffer_.size());
- }
-}
-
-size_t BufferedOutput::DoNext(void** data, size_t len) {
- if (array_output_.Avail() < len) {
- Flush();
- }
-
- return array_output_.Next(data, len);
-
-}
-
-void BufferedOutput::DoWrite(const void* data, size_t len) {
- if (array_output_.Avail() < len) {
- Flush();
-
- if (len > buffer_.size() / 2) {
- slave_->Write(data, len);
- return;
- }
- }
-
- array_output_.Write(data, len);
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/output.h b/src/vendor/clickhouse-cpp/clickhouse/base/output.h
deleted file mode 100644
index e53aadf..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/output.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#pragma once
-
-#include "buffer.h"
-
-#include
-#include
-#include
-#include
-
-namespace clickhouse {
-
-class OutputStream {
-public:
- virtual ~OutputStream()
- { }
-
- inline void Flush() {
- DoFlush();
- }
-
- inline void Write(const void* data, size_t len) {
- DoWrite(data, len);
- }
-
-protected:
- virtual void DoFlush() { }
-
- virtual void DoWrite(const void* data, size_t len) = 0;
-};
-
-
-class ZeroCopyOutput : public OutputStream {
-public:
- inline size_t Next(void** data, size_t size) {
- return DoNext(data, size);
- }
-
-protected:
- // Obtains a buffer into which data can be written. Any data written
- // into this buffer will eventually (maybe instantly, maybe later on)
- // be written to the output.
- virtual size_t DoNext(void** data, size_t len) = 0;
-
- void DoWrite(const void* data, size_t len) override;
-};
-
-
-/**
- * A ZeroCopyOutput stream backed by an in-memory array of bytes.
- */
-class ArrayOutput : public ZeroCopyOutput {
-public:
- ArrayOutput(void* buf, size_t len);
- ~ArrayOutput() override;
-
- /// Number of bytes available in the stream.
- inline size_t Avail() const noexcept {
- return end_ - buf_;
- }
-
- /// Current write position in the memory block used by this stream.
- inline const uint8_t* Data() const noexcept {
- return buf_;
- }
-
- /// Whether there is more space in the stream.
- inline bool Exhausted() const noexcept {
- return !Avail();
- }
-
- /// Initializes this stream with a new memory block.
- inline void Reset(void* buf, size_t len) noexcept {
- buf_ = static_cast(buf);
- end_ = buf_ + len;
- }
-
-protected:
- size_t DoNext(void** data, size_t len) override;
-
-private:
- uint8_t* buf_;
- uint8_t* end_;
-};
-
-
-/**
- * A ZeroCopyOutput stream backed by an vector of bytes.
- */
-class BufferOutput : public ZeroCopyOutput {
-public:
- BufferOutput(Buffer* buf);
- ~BufferOutput();
-
-protected:
- size_t DoNext(void** data, size_t len) override;
-
-private:
- Buffer* buf_;
- size_t pos_;
-};
-
-
-class BufferedOutput : public ZeroCopyOutput {
-public:
- BufferedOutput(OutputStream* slave, size_t buflen = 8192);
- ~BufferedOutput() override;
-
- void Reset();
-
-protected:
- void DoFlush() override;
- size_t DoNext(void** data, size_t len) override;
- void DoWrite(const void* data, size_t len) override;
-
-private:
- OutputStream* const slave_;
- Buffer buffer_;
- ArrayOutput array_output_;
-};
-
-template
-void WriteUnaligned(void* buf, const T& value) {
- memcpy(buf, &value, sizeof(value));
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/platform.cpp b/src/vendor/clickhouse-cpp/clickhouse/base/platform.cpp
deleted file mode 100644
index 948df4b..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/platform.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "platform.h"
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/platform.h b/src/vendor/clickhouse-cpp/clickhouse/base/platform.h
deleted file mode 100644
index 9f53da1..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/platform.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#if defined(__linux__)
-# define _linux_
-#elif defined(_WIN64)
-# define _win64_
-# define _win32_
-#elif defined(__WIN32__) || defined(_WIN32)
-# define _win32_
-#elif defined(__APPLE__)
-# define _darwin_
-#endif
-
-#if defined(_win32_) || defined(_win64_)
-# define _win_
-#endif
-
-#if defined(_linux_) || defined (_darwin_)
-# define _unix_
-#endif
-
-#if defined(_MSC_VER)
-# undef NOMINMAX
-# define NOMINMAX
-# include
-# define ssize_t SSIZE_T
-# define HAVE_SSIZE_T 1
-#endif
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/singleton.h b/src/vendor/clickhouse-cpp/clickhouse/base/singleton.h
deleted file mode 100644
index 1786484..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/singleton.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#pragma once
-
-namespace clickhouse {
-
-template
-T* Singleton() {
- static T instance;
- return &instance;
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/socket.cpp b/src/vendor/clickhouse-cpp/clickhouse/base/socket.cpp
deleted file mode 100644
index 86df993..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/socket.cpp
+++ /dev/null
@@ -1,337 +0,0 @@
-#include
-
-#include "socket.h"
-#include "singleton.h"
-#include
-#include
-#include
-#include
-#include
-
-
-#if !defined(_win_)
-# include
-# include
-# include
-# include
-# include
-#else
-# include
-# include
-#endif
-
-namespace clickhouse {
-namespace {
-
-class LocalNames : public std::unordered_set {
-public:
- LocalNames() {
- emplace("localhost");
- emplace("localhost.localdomain");
- emplace("localhost6");
- emplace("localhost6.localdomain6");
- emplace("::1");
- emplace("127.0.0.1");
- }
-
- inline bool IsLocalName(const std::string& name) const noexcept {
- return find(name) != end();
- }
-};
-
-void SetNonBlock(SOCKET fd, bool value) {
-#if defined(_unix_)
- int flags;
- int ret;
- #if defined(O_NONBLOCK)
- if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
- flags = 0;
- if (value) {
- flags |= O_NONBLOCK;
- } else {
- flags &= ~O_NONBLOCK;
- }
- ret = fcntl(fd, F_SETFL, flags);
- #else
- flags = value;
- return ioctl(fd, FIOBIO, &flags);
- #endif
- if (ret == -1) {
- throw std::system_error(
- errno, std::system_category(), "fail to set nonblocking mode");
- }
-#elif defined(_win_)
- unsigned long inbuf = value;
- unsigned long outbuf = 0;
- DWORD written = 0;
-
- if (!inbuf) {
- WSAEventSelect(fd, nullptr, 0);
- }
-
- if (WSAIoctl(fd, FIONBIO, &inbuf, sizeof(inbuf), &outbuf, sizeof(outbuf), &written, 0, 0) == SOCKET_ERROR) {
- throw std::system_error(
- errno, std::system_category(), "fail to set nonblocking mode");
- }
-#endif
-}
-
-} // namespace
-
-NetworkAddress::NetworkAddress(const std::string& host, const std::string& port)
- : info_(nullptr)
-{
- struct addrinfo hints;
- memset(&hints, 0, sizeof(hints));
-
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
-
- if (!Singleton()->IsLocalName(host)) {
- // https://linux.die.net/man/3/getaddrinfo
- // If hints.ai_flags includes the AI_ADDRCONFIG flag,
- // then IPv4 addresses are returned in the list pointed to by res only
- // if the local system has at least one IPv4 address configured,
- // and IPv6 addresses are only returned if the local system
- // has at least one IPv6 address configured.
- // The loopback address is not considered for this case
- // as valid as a configured address.
- hints.ai_flags |= AI_ADDRCONFIG;
- }
-
- const int error = getaddrinfo(host.c_str(), port.c_str(), &hints, &info_);
-
- if (error) {
- throw std::system_error(errno, std::system_category());
- }
-}
-
-NetworkAddress::~NetworkAddress() {
- if (info_) {
- freeaddrinfo(info_);
- }
-}
-
-const struct addrinfo* NetworkAddress::Info() const {
- return info_;
-}
-
-
-SocketHolder::SocketHolder()
- : handle_(-1)
-{
-}
-
-SocketHolder::SocketHolder(SOCKET s)
- : handle_(s)
-{
-}
-
-SocketHolder::SocketHolder(SocketHolder&& other) noexcept
- : handle_(other.handle_)
-{
- other.handle_ = -1;
-}
-
-SocketHolder::~SocketHolder() {
- Close();
-}
-
-void SocketHolder::Close() noexcept {
- if (handle_ != -1) {
-#if defined(_win_)
- closesocket(handle_);
-#else
- close(handle_);
-#endif
- handle_ = -1;
- }
-}
-
-bool SocketHolder::Closed() const noexcept {
- return handle_ == -1;
-}
-
-void SocketHolder::SetTcpKeepAlive(int idle, int intvl, int cnt) noexcept {
- int val = 1;
-
-#if defined(_unix_)
- setsockopt(handle_, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
-# if defined(_linux_)
- setsockopt(handle_, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle));
-# elif defined(_darwin_)
- setsockopt(handle_, IPPROTO_TCP, TCP_KEEPALIVE, &idle, sizeof(idle));
-# else
-# error "platform is not supported"
-# endif
- setsockopt(handle_, IPPROTO_TCP, TCP_KEEPINTVL, &intvl, sizeof(intvl));
- setsockopt(handle_, IPPROTO_TCP, TCP_KEEPCNT, &cnt, sizeof(cnt));
-#else
- setsockopt(handle_, SOL_SOCKET, SO_KEEPALIVE, (const char*)&val, sizeof(val));
- std::ignore = idle = intvl = cnt;
-#endif
-}
-
-SocketHolder& SocketHolder::operator = (SocketHolder&& other) noexcept {
- if (this != &other) {
- Close();
-
- handle_ = other.handle_;
- other.handle_ = -1;
- }
-
- return *this;
-}
-
-SocketHolder::operator SOCKET () const noexcept {
- return handle_;
-}
-
-
-SocketInput::SocketInput(SOCKET s)
- : s_(s)
-{
-}
-
-SocketInput::~SocketInput() = default;
-
-size_t SocketInput::DoRead(void* buf, size_t len) {
- const ssize_t ret = ::recv(s_, (char*)buf, (int)len, 0);
-
- if (ret > 0) {
- return (size_t)ret;
- }
-
- if (ret == 0) {
- throw std::system_error(
- errno, std::system_category(), "closed"
- );
- }
-
- throw std::system_error(
- errno, std::system_category(), "can't receive string data"
- );
-}
-
-
-SocketOutput::SocketOutput(SOCKET s)
- : s_(s)
-{
-}
-
-SocketOutput::~SocketOutput() = default;
-
-void SocketOutput::DoWrite(const void* data, size_t len) {
-#if defined (_linux_)
- static const int flags = MSG_NOSIGNAL;
-#else
- static const int flags = 0;
-#endif
-
- if (::send(s_, (const char*)data, (int)len, flags) != (int)len) {
- throw std::system_error(
- errno, std::system_category(), "fail to send data"
- );
- }
-}
-
-
-NetrworkInitializer::NetrworkInitializer() {
- struct NetrworkInitializerImpl {
- NetrworkInitializerImpl() {
-#if defined (_win_)
- WSADATA data;
- const int result = WSAStartup(MAKEWORD(2, 2), &data);
- if (result) {
- assert(false);
- exit(-1);
- }
-#elif defined(_unix_)
- signal(SIGPIPE, SIG_IGN);
-#endif
- }
- };
-
-
- (void)Singleton();
-}
-
-
-SOCKET SocketConnect(const NetworkAddress& addr) {
- int last_err = 0;
-
- for (auto res = addr.Info(); res != nullptr; res = res->ai_next) {
- int reuse = 1;
- int sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*) &reuse, sizeof(int));
-
- SOCKET s(sockfd);
-
- if (s == -1) {
- continue;
- }
-
- SetNonBlock(s, true);
- int cret = connect(s, res->ai_addr, (int)res->ai_addrlen);
-
- #if defined(_win_)
- // poll to avoid WSAEWOULDBLOCK error
- for(size_t i = 0; i < 10; i++) {
- if(WSAGetLastError() == 0) {
- cret = 0;
- continue;
- }
-
- std::this_thread::sleep_for(std::chrono::seconds(1));
- }
- #endif
-
-
- if (cret != 0) {
- int err = errno;
-
- if (err == EINPROGRESS || err == EAGAIN || err == EWOULDBLOCK) {
- pollfd fd;
- fd.fd = s;
- fd.events = POLLOUT;
- fd.revents = 0;
- ssize_t rval = Poll(&fd, 1, 5000);
-
- if (rval == -1) {
- throw std::system_error(errno, std::system_category(), "fail to connect");
- }
- if (rval > 0) {
- socklen_t len = sizeof(err);
- getsockopt(s, SOL_SOCKET, SO_ERROR, (char*)&err, &len);
-
- if (!err) {
- SetNonBlock(s, false);
- return s;
- }
- last_err = err;
- }
- }
- } else {
- SetNonBlock(s, false);
- return s;
- }
- }
- if (last_err > 0) {
- throw std::system_error(last_err, std::system_category(), "fail to connect");
- }
- throw std::system_error(
- errno, std::system_category(), "fail to connect"
- );
-}
-
-
-ssize_t Poll(struct pollfd* fds, int nfds, int timeout) noexcept {
-#if defined(_win_)
- int rval = WSAPoll(fds, nfds, timeout);
-#else
- return poll(fds, nfds, timeout);
-#endif
- return -1;
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/socket.h b/src/vendor/clickhouse-cpp/clickhouse/base/socket.h
deleted file mode 100644
index a38a829..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/socket.h
+++ /dev/null
@@ -1,113 +0,0 @@
-#pragma once
-
-#include "input.h"
-#include "output.h"
-#include "platform.h"
-
-#include
-#include
-
-#if defined(_win_)
-# pragma comment(lib, "Ws2_32.lib")
-
-# include
-# include
-#else
-# include
-# include
-# include
-# include
-
-# if !defined(SOCKET)
-# define SOCKET int
-# endif
-#endif
-
-struct addrinfo;
-
-namespace clickhouse {
-
-/**
- *
- */
-class NetworkAddress {
-public:
- explicit NetworkAddress(const std::string& host,
- const std::string& port = "0");
- ~NetworkAddress();
-
- const struct addrinfo* Info() const;
-
-private:
- struct addrinfo* info_;
-};
-
-
-class SocketHolder {
-public:
- SocketHolder();
- SocketHolder(SOCKET s);
- SocketHolder(SocketHolder&& other) noexcept;
-
- ~SocketHolder();
-
- void Close() noexcept;
-
- bool Closed() const noexcept;
-
- /// @params idle the time (in seconds) the connection needs to remain
- /// idle before TCP starts sending keepalive probes.
- /// @params intvl the time (in seconds) between individual keepalive probes.
- /// @params cnt the maximum number of keepalive probes TCP should send
- /// before dropping the connection.
- void SetTcpKeepAlive(int idle, int intvl, int cnt) noexcept;
-
- SocketHolder& operator = (SocketHolder&& other) noexcept;
-
- operator SOCKET () const noexcept;
-
-private:
- SocketHolder(const SocketHolder&) = delete;
- SocketHolder& operator = (const SocketHolder&) = delete;
-
- SOCKET handle_;
-};
-
-
-/**
- *
- */
-class SocketInput : public InputStream {
-public:
- explicit SocketInput(SOCKET s);
- ~SocketInput();
-
-protected:
- size_t DoRead(void* buf, size_t len) override;
-
-private:
- SOCKET s_;
-};
-
-class SocketOutput : public OutputStream {
-public:
- explicit SocketOutput(SOCKET s);
- ~SocketOutput();
-
-protected:
- void DoWrite(const void* data, size_t len) override;
-
-private:
- SOCKET s_;
-};
-
-static struct NetrworkInitializer {
- NetrworkInitializer();
-} gNetrworkInitializer;
-
-///
-SOCKET SocketConnect(const NetworkAddress& addr);
-
-ssize_t Poll(struct pollfd* fds, int nfds, int timeout) noexcept;
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/string_utils.h b/src/vendor/clickhouse-cpp/clickhouse/base/string_utils.h
deleted file mode 100644
index f2e66ba..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/string_utils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma once
-
-#include "string_view.h"
-
-#include
-#include
-
-namespace clickhouse {
-
-template
-inline T FromString(const std::string& s) {
- std::istringstream iss(s);
- T result;
- iss >> result;
- return result;
-}
-
-template
-inline T FromString(const StringView& s) {
- std::istringstream iss((std::string(s)));
- T result;
- iss >> result;
- return result;
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/string_view.h b/src/vendor/clickhouse-cpp/clickhouse/base/string_view.h
deleted file mode 100644
index 7d35585..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/string_view.h
+++ /dev/null
@@ -1,135 +0,0 @@
-#pragma once
-
-#include
-#include
-#include
-
-/**
- * A lightweight non-owning read-only view into a subsequence of a string.
- */
-template <
- typename TChar,
- typename TTraits = std::char_traits
->
-class StringViewImpl {
-public:
- using size_type = size_t;
- using traits_type = TTraits;
- using value_type = typename TTraits::char_type;
-
- static constexpr size_type npos = size_type(-1);
-
-public:
- inline StringViewImpl() noexcept
- : data_(nullptr)
- , size_(0)
- {
- }
-
- constexpr inline StringViewImpl(const TChar* data, size_t len) noexcept
- : data_(data)
- , size_(len)
- {
- }
-
- template
- constexpr inline StringViewImpl(const TChar (&str)[len]) noexcept
- : data_(str)
- , size_(len - 1)
- {
- }
-
- inline StringViewImpl(const TChar* begin, const TChar* end) noexcept
- : data_(begin)
- , size_(end - begin)
- {
- assert(begin <= end);
- }
-
- inline StringViewImpl(const std::basic_string& str) noexcept
- : data_(str.data())
- , size_(str.size())
- {
- }
-
- inline TChar at(size_type pos) const {
- if (pos >= size_)
- throw std::out_of_range("pos must be less than len");
- return data_[pos];
- }
-
- inline const TChar* data() const noexcept {
- return data_;
- }
-
- inline bool empty() const noexcept {
- return size_ == 0;
- }
-
- inline bool null() const noexcept {
- assert(size_ == 0);
- return data_ == nullptr;
- }
-
- inline size_type size() const noexcept {
- return size_;
- }
-
-public:
- // Returns a substring [pos, pos + count).
- // If the requested substring extends past the end of the string,
- // or if count == npos, the returned substring is [pos, size()).
- StringViewImpl substr(size_type pos, size_type count = npos) const {
- if (pos >= size_)
- throw std::out_of_range("pos must be less than len");
- if (pos + count >= size_ || count == npos)
- return StringViewImpl(data_ + pos, size_ - pos);
- else
- return StringViewImpl(data_ + pos, count);
- }
-
- inline const std::basic_string to_string() const {
- return std::basic_string(data_, size_);
- }
-
-public:
- inline operator bool () const noexcept {
- return !empty();
- }
-
- inline explicit operator const std::basic_string () const {
- return to_string();
- }
-
- inline TChar operator [] (size_type pos) const noexcept {
- return data_[pos];
- }
-
- inline bool operator < (const StringViewImpl& other) const noexcept {
- if (size_ < other.size_)
- return true;
- if (size_ > other.size_)
- return false;
- return TTraits::compare(data_, other.data_, size_) < 0;
- }
-
- inline bool operator == (const StringViewImpl& other) const noexcept {
- if (size_ == other.size_)
- return TTraits::compare(data_, other.data_, size_) == 0;
- return false;
- }
-
-private:
- const TChar* data_;
- size_t size_;
-};
-
-
-// It creates StringView from literal constant at compile time.
-template
-constexpr inline StringViewImpl MakeStringView(const TChar (&str)[size]) {
- return StringViewImpl(str, size - 1);
-}
-
-
-using StringView = StringViewImpl;
diff --git a/src/vendor/clickhouse-cpp/clickhouse/base/wire_format.h b/src/vendor/clickhouse-cpp/clickhouse/base/wire_format.h
deleted file mode 100644
index f383fcb..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/base/wire_format.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#pragma once
-
-#include "coded.h"
-
-#include
-
-namespace clickhouse {
-
-class WireFormat {
-public:
- template
- static bool ReadFixed(CodedInputStream* input, T* value);
-
- static bool ReadString(CodedInputStream* input, std::string* value);
-
- static bool ReadBytes(CodedInputStream* input, void* buf, size_t len);
-
- static bool ReadUInt64(CodedInputStream* input, uint64_t* value);
-
-
- template
- static void WriteFixed(CodedOutputStream* output, const T& value);
-
- static void WriteBytes(CodedOutputStream* output, const void* buf, size_t len);
-
- static void WriteString(CodedOutputStream* output, const std::string& value);
-
- static void WriteUInt64(CodedOutputStream* output, const uint64_t value);
-};
-
-template
-inline bool WireFormat::ReadFixed(
- CodedInputStream* input,
- T* value)
-{
- return input->ReadRaw(value, sizeof(T));
-}
-
-inline bool WireFormat::ReadString(
- CodedInputStream* input,
- std::string* value)
-{
- uint64_t len;
-
- if (input->ReadVarint64(&len)) {
- if (len > 0x00FFFFFFULL) {
- return false;
- }
- value->resize((size_t)len);
- return input->ReadRaw(&(*value)[0], (size_t)len);
- }
-
- return false;
-}
-
-inline bool WireFormat::ReadBytes(
- CodedInputStream* input, void* buf, size_t len)
-{
- return input->ReadRaw(buf, len);
-}
-
-inline bool WireFormat::ReadUInt64(
- CodedInputStream* input,
- uint64_t* value)
-{
- return input->ReadVarint64(value);
-}
-
-
-template
-inline void WireFormat::WriteFixed(
- CodedOutputStream* output,
- const T& value)
-{
- output->WriteRaw(&value, sizeof(T));
-}
-
-inline void WireFormat::WriteBytes(
- CodedOutputStream* output,
- const void* buf,
- size_t len)
-{
- output->WriteRaw(buf, len);
-}
-
-inline void WireFormat::WriteString(
- CodedOutputStream* output,
- const std::string& value)
-{
- output->WriteVarint64(value.size());
- output->WriteRaw(value.data(), value.size());
-}
-
-inline void WireFormat::WriteUInt64(
- CodedOutputStream* output,
- const uint64_t value)
-{
- output->WriteVarint64(value);
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/block.cpp b/src/vendor/clickhouse-cpp/clickhouse/block.cpp
deleted file mode 100644
index 685173c..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/block.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "block.h"
-
-#include
-
-namespace clickhouse {
-
-Block::Iterator::Iterator(const Block& block)
- : block_(block)
- , idx_(0)
-{
-}
-
-const std::string& Block::Iterator::Name() const {
- return block_.columns_[idx_].name;
-}
-
-TypeRef Block::Iterator::Type() const {
- return block_.columns_[idx_].column->Type();
-}
-
-ColumnRef Block::Iterator::Column() const {
- return block_.columns_[idx_].column;
-}
-
-void Block::Iterator::Next() {
- ++idx_;
-}
-
-bool Block::Iterator::IsValid() const {
- return idx_ < block_.columns_.size();
-}
-
-
-Block::Block()
- : rows_(0)
-{
-}
-
-Block::Block(size_t cols, size_t rows)
- : rows_(rows)
-{
- columns_.reserve(cols);
-}
-
-Block::~Block() = default;
-
-void Block::AppendColumn(const std::string& name, const ColumnRef& col) {
- if (columns_.empty()) {
- rows_ = col->Size();
- } else if (col->Size() != rows_) {
- throw std::runtime_error("all columns in block must have same count of rows. Name: ["+name+"], rows: ["+std::to_string(rows_)+"], columns: [" + std::to_string(col->Size())+"]");
- }
-
- columns_.push_back(ColumnItem{name, col});
-}
-
-/// Count of columns in the block.
-size_t Block::GetColumnCount() const {
- return columns_.size();
-}
-
-const BlockInfo& Block::Info() const {
- return info_;
-}
-
-/// Count of rows in the block.
-size_t Block::GetRowCount() const {
- return rows_;
-}
-
-size_t Block::RefreshRowCount()
-{
- size_t rows = 0UL;
-
- for (size_t idx = 0UL; idx < columns_.size(); ++idx)
- {
- const std::string& name = columns_[idx].name;
- const ColumnRef& col = columns_[idx].column;
-
- if (idx == 0UL)
- rows = col->Size();
- else if (rows != col->Size())
- throw std::runtime_error("all columns in block must have same count of rows. Name: ["+name+"], rows: ["+std::to_string(rows)+"], columns: [" + std::to_string(col->Size())+"]");
- }
-
- rows_ = rows;
- return rows_;
-}
-
-ColumnRef Block::operator [] (size_t idx) const {
- if (idx < columns_.size()) {
- return columns_[idx].column;
- }
-
- throw std::out_of_range("column index is out of range. Index: ["+std::to_string(idx)+"], columns: [" + std::to_string(columns_.size())+"]");
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/block.h b/src/vendor/clickhouse-cpp/clickhouse/block.h
deleted file mode 100644
index b2b2d14..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/block.h
+++ /dev/null
@@ -1,78 +0,0 @@
-#pragma once
-
-#include "columns/column.h"
-
-namespace clickhouse {
-
-struct BlockInfo {
- uint8_t is_overflows = 0;
- int32_t bucket_num = -1;
-};
-
-class Block {
-public:
- /// Allow to iterate over block's columns.
- class Iterator {
- public:
- Iterator(const Block& block);
-
- /// Name of column.
- const std::string& Name() const;
-
- /// Type of column.
- TypeRef Type() const;
-
- /// Reference to column object.
- ColumnRef Column() const;
-
- /// Move to next column.
- void Next();
-
- /// Is the iterator still valid.
- bool IsValid() const;
-
- private:
- Iterator() = delete;
-
- const Block& block_;
- size_t idx_;
- };
-
-public:
- Block();
- Block(size_t cols, size_t rows);
- ~Block();
-
- /// Append named column to the block.
- void AppendColumn(const std::string& name, const ColumnRef& col);
-
- /// Count of columns in the block.
- size_t GetColumnCount() const;
-
- const BlockInfo& Info() const;
-
- /// Count of rows in the block.
- size_t GetRowCount() const;
-
- size_t RefreshRowCount();
-
- const std::string& GetColumnName(size_t idx) const {
- return columns_.at(idx).name;
- }
-
- /// Reference to column by index in the block.
- ColumnRef operator [] (size_t idx) const;
-
-private:
- struct ColumnItem {
- std::string name;
- ColumnRef column;
- };
-
- BlockInfo info_;
- std::vector columns_;
- /// Count of rows in the block.
- size_t rows_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/client.cpp b/src/vendor/clickhouse-cpp/clickhouse/client.cpp
deleted file mode 100644
index 36349ed..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/client.cpp
+++ /dev/null
@@ -1,799 +0,0 @@
-#include "client.h"
-#include "protocol.h"
-
-#include "base/coded.h"
-#include "base/compressed.h"
-#include "base/socket.h"
-#include "base/wire_format.h"
-
-#include "columns/factory.h"
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define DBMS_NAME "ClickHouse"
-#define DBMS_VERSION_MAJOR 1
-#define DBMS_VERSION_MINOR 1
-#define REVISION 54126
-
-#define DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES 50264
-#define DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS 51554
-#define DBMS_MIN_REVISION_WITH_BLOCK_INFO 51903
-#define DBMS_MIN_REVISION_WITH_CLIENT_INFO 54032
-#define DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE 54058
-#define DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO 54060
-
-namespace clickhouse {
-
-struct ClientInfo {
- uint8_t iface_type = 1; // TCP
- uint8_t query_kind;
- std::string initial_user;
- std::string initial_query_id;
- std::string quota_key;
- std::string os_user;
- std::string client_hostname;
- std::string client_name;
- std::string initial_address = "[::ffff:127.0.0.1]:0";
- uint64_t client_version_major = 0;
- uint64_t client_version_minor = 0;
- uint32_t client_revision = 0;
-};
-
-struct ServerInfo {
- std::string name;
- std::string timezone;
- uint64_t version_major;
- uint64_t version_minor;
- uint64_t revision;
-};
-
-std::ostream& operator<<(std::ostream& os, const ClientOptions& opt) {
- os << "Client(" << opt.user << '@' << opt.host << ":" << opt.port
- << " ping_before_query:" << opt.ping_before_query
- << " send_retries:" << opt.send_retries
- << " retry_timeout:" << opt.retry_timeout.count()
- << " compression_method:"
- << (opt.compression_method == CompressionMethod::LZ4 ? "LZ4" : "None")
- << ")";
- return os;
-}
-
-class Client::Impl {
-public:
- Impl(const ClientOptions& opts);
- ~Impl();
-
- void ExecuteQuery(Query query);
-
- void SendCancel();
-
- void Insert(const std::string& table_name, const Block& block);
-
- void Ping();
-
- void ResetConnection();
-
-private:
- bool Handshake();
-
- bool ReceivePacket(uint64_t* server_packet = nullptr);
-
- void SendQuery(const std::string& query);
-
- void SendData(const Block& block);
-
- bool SendHello();
-
- bool ReadBlock(Block* block, CodedInputStream* input);
-
- bool ReceiveHello();
-
- /// Reads data packet form input stream.
- bool ReceiveData();
-
- /// Reads exception packet form input stream.
- bool ReceiveException(bool rethrow = false);
-
- void WriteBlock(const Block& block, CodedOutputStream* output);
-
-private:
- /// In case of network errors tries to reconnect to server and
- /// call fuc several times.
- void RetryGuard(std::function fuc);
-
-private:
- class EnsureNull {
- public:
- inline EnsureNull(QueryEvents* ev, QueryEvents** ptr)
- : ptr_(ptr)
- {
- if (ptr_) {
- *ptr_ = ev;
- }
- }
-
- inline ~EnsureNull() {
- if (ptr_) {
- *ptr_ = nullptr;
- }
- }
-
- private:
- QueryEvents** ptr_;
-
- };
-
-
- const ClientOptions options_;
- QueryEvents* events_;
- int compression_ = CompressionState::Disable;
-
- SocketHolder socket_;
-
- SocketInput socket_input_;
- BufferedInput buffered_input_;
- CodedInputStream input_;
-
- SocketOutput socket_output_;
- BufferedOutput buffered_output_;
- CodedOutputStream output_;
-
- ServerInfo server_info_;
-};
-
-Client::Impl::Impl(const ClientOptions& opts)
- : options_(opts)
- , events_(nullptr)
- , socket_(-1)
- , socket_input_(socket_)
- , buffered_input_(&socket_input_)
- , input_(&buffered_input_)
- , socket_output_(socket_)
- , buffered_output_(&socket_output_)
- , output_(&buffered_output_)
-{
- // TODO: throw on big-endianness of platform
-
- for (int i = 0; ; ) {
- try {
- ResetConnection();
- break;
- } catch (const std::system_error&) {
- if (++i > options_.send_retries) {
- throw;
- }
-
- std::this_thread::sleep_for(options_.retry_timeout);
- }
- }
-
- if (options_.compression_method != CompressionMethod::None) {
- compression_ = CompressionState::Enable;
- }
-}
-
-Client::Impl::~Impl()
-{ }
-
-void Client::Impl::ExecuteQuery(Query query) {
- EnsureNull en(static_cast(&query), &events_);
-
- if (options_.ping_before_query) {
- RetryGuard([this]() { Ping(); });
- }
-
- SendQuery(query.GetText());
-
- while (ReceivePacket()) {
- ;
- }
-}
-
-
-std::string NameToQueryString(const std::string &input)
-{
- std::string output = "`";
- const char *c = input.c_str();
- while (*c) {
- switch (*c) {
- // // needs test cases
- // case '"':
- // output.append("\\\""); break;
- // case '`':
- // output.append("\\`"); break;
- // case '\'':
- // output.append("\\'"); break;
- // case '[':
- // output.append("\\["); break;
- // case ']':
- // output.append("\\]"); break;
- // case '%':
- // output.append("\\%"); break;
- // case '_':
- // output.append("\\_"); break;
- // case '\\':
- // output.append("\\\\"); break;
- default:
- output.push_back(*c); break;
- }
- ++c;
- }
- output += "`";
- return output;
-}
-
-void Client::Impl::Insert(const std::string& table_name, const Block& block) {
- if (options_.ping_before_query) {
- RetryGuard([this]() { Ping(); });
- }
-
- std::vector fields;
- fields.reserve(block.GetColumnCount());
-
- // Enumerate all fields
- for (unsigned int i = 0; i < block.GetColumnCount(); i++) {
- fields.push_back(NameToQueryString(block.GetColumnName(i)));
- }
-
- std::stringstream fields_section;
-
- for (auto elem = fields.begin(); elem != fields.end(); ++elem) {
- if (std::distance(elem, fields.end()) == 1) {
- fields_section << *elem;
- } else {
- fields_section << *elem << ",";
- }
- }
- SendQuery("INSERT INTO " + table_name + " ( " + fields_section.str() + " ) VALUES");
-
- uint64_t server_packet;
- // Receive data packet.
- while (true) {
- bool ret = ReceivePacket(&server_packet);
-
- if (!ret) {
- throw std::runtime_error("fail to receive data packet");
- }
- if (server_packet == ServerCodes::Data) {
- break;
- }
- if (server_packet == ServerCodes::Progress) {
- continue;
- }
- }
-
- // Send data.
- SendData(block);
- // Send empty block as marker of
- // end of data.
- SendData(Block());
-
- // Wait for EOS.
- while (ReceivePacket()) {
- ;
- }
-}
-
-void Client::Impl::Ping() {
- WireFormat::WriteUInt64(&output_, ClientCodes::Ping);
- output_.Flush();
-
- uint64_t server_packet;
- const bool ret = ReceivePacket(&server_packet);
-
- if (!ret || server_packet != ServerCodes::Pong) {
- throw std::runtime_error("fail to ping server");
- }
-}
-
-void Client::Impl::ResetConnection() {
- SocketHolder s(SocketConnect(NetworkAddress(options_.host, std::to_string(options_.port))));
-
- if (s.Closed()) {
- throw std::system_error(errno, std::system_category());
- }
-
- if (options_.tcp_keepalive) {
- s.SetTcpKeepAlive(options_.tcp_keepalive_idle.count(),
- options_.tcp_keepalive_intvl.count(),
- options_.tcp_keepalive_cnt);
- }
-
- socket_ = std::move(s);
- socket_input_ = SocketInput(socket_);
- socket_output_ = SocketOutput(socket_);
- buffered_input_.Reset();
- buffered_output_.Reset();
-
- if (!Handshake()) {
- throw std::runtime_error("fail to connect to " + options_.host);
- }
-}
-
-bool Client::Impl::Handshake() {
- if (!SendHello()) {
- return false;
- }
- if (!ReceiveHello()) {
- return false;
- }
- return true;
-}
-
-bool Client::Impl::ReceivePacket(uint64_t* server_packet) {
- uint64_t packet_type = 0;
-
- if (!input_.ReadVarint64(&packet_type)) {
- return false;
- }
- if (server_packet) {
- *server_packet = packet_type;
- }
-
- switch (packet_type) {
- case ServerCodes::Data: {
- if (!ReceiveData()) {
- throw std::runtime_error("can't read data packet from input stream");
- }
- return true;
- }
-
- case ServerCodes::Exception: {
- ReceiveException();
- return false;
- }
-
- case ServerCodes::ProfileInfo: {
- Profile profile;
-
- if (!WireFormat::ReadUInt64(&input_, &profile.rows)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &profile.blocks)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &profile.bytes)) {
- return false;
- }
- if (!WireFormat::ReadFixed(&input_, &profile.applied_limit)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &profile.rows_before_limit)) {
- return false;
- }
- if (!WireFormat::ReadFixed(&input_, &profile.calculated_rows_before_limit)) {
- return false;
- }
-
- if (events_) {
- events_->OnProfile(profile);
- }
-
- return true;
- }
-
- case ServerCodes::Progress: {
- Progress info;
-
- if (!WireFormat::ReadUInt64(&input_, &info.rows)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &info.bytes)) {
- return false;
- }
- if (REVISION >= DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS) {
- if (!WireFormat::ReadUInt64(&input_, &info.total_rows)) {
- return false;
- }
- }
-
- if (events_) {
- events_->OnProgress(info);
- }
-
- return true;
- }
-
- case ServerCodes::Pong: {
- return true;
- }
-
- case ServerCodes::EndOfStream: {
- if (events_) {
- events_->OnFinish();
- }
- return false;
- }
-
- default:
- throw std::runtime_error("unimplemented " + std::to_string((int)packet_type));
- break;
- }
-
- return false;
-}
-
-bool Client::Impl::ReadBlock(Block* block, CodedInputStream* input) {
- // Additional information about block.
- if (REVISION >= DBMS_MIN_REVISION_WITH_BLOCK_INFO) {
- uint64_t num;
- BlockInfo info;
-
- // BlockInfo
- if (!WireFormat::ReadUInt64(input, &num)) {
- return false;
- }
- if (!WireFormat::ReadFixed(input, &info.is_overflows)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(input, &num)) {
- return false;
- }
- if (!WireFormat::ReadFixed(input, &info.bucket_num)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(input, &num)) {
- return false;
- }
-
- // TODO use data
- }
-
- uint64_t num_columns = 0;
- uint64_t num_rows = 0;
-
- if (!WireFormat::ReadUInt64(input, &num_columns)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(input, &num_rows)) {
- return false;
- }
-
- for (size_t i = 0; i < num_columns; ++i) {
- std::string name;
- std::string type;
-
- if (!WireFormat::ReadString(input, &name)) {
- return false;
- }
- if (!WireFormat::ReadString(input, &type)) {
- return false;
- }
-
- if (ColumnRef col = CreateColumnByType(type)) {
- if (num_rows && !col->Load(input, num_rows)) {
- throw std::runtime_error("can't load");
- }
-
- block->AppendColumn(name, col);
- } else {
- throw std::runtime_error(std::string("unsupported column type: ") + type);
- }
- }
-
- return true;
-}
-
-bool Client::Impl::ReceiveData() {
- Block block;
-
- if (REVISION >= DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES) {
- std::string table_name;
-
- if (!WireFormat::ReadString(&input_, &table_name)) {
- return false;
- }
- }
-
- if (compression_ == CompressionState::Enable) {
- CompressedInput compressed(&input_);
- CodedInputStream coded(&compressed);
-
- if (!ReadBlock(&block, &coded)) {
- return false;
- }
- } else {
- if (!ReadBlock(&block, &input_)) {
- return false;
- }
- }
-
- if (events_) {
- events_->OnData(block);
- if (!events_->OnDataCancelable(block)) {
- SendCancel();
- }
- }
-
- return true;
-}
-
-bool Client::Impl::ReceiveException(bool rethrow) {
- std::unique_ptr e(new Exception);
- Exception* current = e.get();
-
- do {
- bool has_nested = false;
-
- if (!WireFormat::ReadFixed(&input_, ¤t->code)) {
- return false;
- }
- if (!WireFormat::ReadString(&input_, ¤t->name)) {
- return false;
- }
- if (!WireFormat::ReadString(&input_, ¤t->display_text)) {
- return false;
- }
- if (!WireFormat::ReadString(&input_, ¤t->stack_trace)) {
- return false;
- }
- if (!WireFormat::ReadFixed(&input_, &has_nested)) {
- return false;
- }
-
- if (has_nested) {
- current->nested.reset(new Exception);
- current = current->nested.get();
- } else {
- break;
- }
- } while (true);
-
- if (events_) {
- events_->OnServerException(*e);
- }
-
- if (rethrow || options_.rethrow_exceptions) {
- throw ServerException(std::move(e));
- }
-
- return true;
-}
-
-void Client::Impl::SendCancel() {
- WireFormat::WriteUInt64(&output_, ClientCodes::Cancel);
- output_.Flush();
-}
-
-void Client::Impl::SendQuery(const std::string& query) {
- WireFormat::WriteUInt64(&output_, ClientCodes::Query);
- WireFormat::WriteString(&output_, std::string());
-
- /// Client info.
- if (server_info_.revision >= DBMS_MIN_REVISION_WITH_CLIENT_INFO) {
- ClientInfo info;
-
- info.query_kind = 1;
- info.client_name = "ClickHouse client";
- info.client_version_major = DBMS_VERSION_MAJOR;
- info.client_version_minor = DBMS_VERSION_MINOR;
- info.client_revision = REVISION;
-
-
- WireFormat::WriteFixed(&output_, info.query_kind);
- WireFormat::WriteString(&output_, info.initial_user);
- WireFormat::WriteString(&output_, info.initial_query_id);
- WireFormat::WriteString(&output_, info.initial_address);
- WireFormat::WriteFixed(&output_, info.iface_type);
-
- WireFormat::WriteString(&output_, info.os_user);
- WireFormat::WriteString(&output_, info.client_hostname);
- WireFormat::WriteString(&output_, info.client_name);
- WireFormat::WriteUInt64(&output_, info.client_version_major);
- WireFormat::WriteUInt64(&output_, info.client_version_minor);
- WireFormat::WriteUInt64(&output_, info.client_revision);
-
- if (server_info_.revision >= DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO)
- WireFormat::WriteString(&output_, info.quota_key);
- }
-
- /// Per query settings.
- //if (settings)
- // settings->serialize(*out);
- //else
- WireFormat::WriteString(&output_, std::string());
-
- WireFormat::WriteUInt64(&output_, Stages::Complete);
- WireFormat::WriteUInt64(&output_, compression_);
- WireFormat::WriteString(&output_, query);
- // Send empty block as marker of
- // end of data
- SendData(Block());
-
- output_.Flush();
-}
-
-
-void Client::Impl::WriteBlock(const Block& block, CodedOutputStream* output) {
- // Additional information about block.
- if (server_info_.revision >= DBMS_MIN_REVISION_WITH_BLOCK_INFO) {
- WireFormat::WriteUInt64(output, 1);
- WireFormat::WriteFixed (output, block.Info().is_overflows);
- WireFormat::WriteUInt64(output, 2);
- WireFormat::WriteFixed (output, block.Info().bucket_num);
- WireFormat::WriteUInt64(output, 0);
- }
-
- WireFormat::WriteUInt64(output, block.GetColumnCount());
- WireFormat::WriteUInt64(output, block.GetRowCount());
-
- for (Block::Iterator bi(block); bi.IsValid(); bi.Next()) {
- WireFormat::WriteString(output, bi.Name());
- WireFormat::WriteString(output, bi.Type()->GetName());
-
- bi.Column()->Save(output);
- }
-}
-
-void Client::Impl::SendData(const Block& block) {
- WireFormat::WriteUInt64(&output_, ClientCodes::Data);
-
- if (server_info_.revision >= DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES) {
- WireFormat::WriteString(&output_, std::string());
- }
-
- if (compression_ == CompressionState::Enable) {
- switch (options_.compression_method) {
- case CompressionMethod::None: {
- assert(false);
- break;
- }
-
- case CompressionMethod::LZ4: {
- Buffer tmp;
- // Serialize block's data
- {
- BufferOutput out(&tmp);
- CodedOutputStream coded(&out);
- WriteBlock(block, &coded);
- }
- // Reserver space for data
- Buffer buf;
- buf.resize(9 + LZ4_compressBound(tmp.size()));
-
- // Compress data
- int size = LZ4_compress_default((const char*)tmp.data(), (char*)buf.data() + 9, tmp.size(), static_cast(buf.size() - 9));
- buf.resize(9 + size);
-
- // Fill header
- uint8_t* p = buf.data();
- // Compression method
- WriteUnaligned(p, (uint8_t)0x82); p += 1;
- // Compressed data size with header
- WriteUnaligned(p, (uint32_t)buf.size()); p += 4;
- // Original data size
- WriteUnaligned(p, (uint32_t)tmp.size());
-
- WireFormat::WriteFixed(&output_, CityHash128(
- (const char*)buf.data(), buf.size()));
- WireFormat::WriteBytes(&output_, buf.data(), buf.size());
- break;
- }
- }
- } else {
- WriteBlock(block, &output_);
- }
-
- output_.Flush();
-}
-
-bool Client::Impl::SendHello() {
- WireFormat::WriteUInt64(&output_, ClientCodes::Hello);
- WireFormat::WriteString(&output_, std::string(DBMS_NAME) + " client");
- WireFormat::WriteUInt64(&output_, DBMS_VERSION_MAJOR);
- WireFormat::WriteUInt64(&output_, DBMS_VERSION_MINOR);
- WireFormat::WriteUInt64(&output_, REVISION);
- WireFormat::WriteString(&output_, options_.default_database);
- WireFormat::WriteString(&output_, options_.user);
- WireFormat::WriteString(&output_, options_.password);
-
- output_.Flush();
-
- return true;
-}
-
-bool Client::Impl::ReceiveHello() {
- uint64_t packet_type = 0;
-
- if (!input_.ReadVarint64(&packet_type)) {
- return false;
- }
-
- if (packet_type == ServerCodes::Hello) {
- if (!WireFormat::ReadString(&input_, &server_info_.name)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &server_info_.version_major)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &server_info_.version_minor)) {
- return false;
- }
- if (!WireFormat::ReadUInt64(&input_, &server_info_.revision)) {
- return false;
- }
-
- if (server_info_.revision >= DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE) {
- if (!WireFormat::ReadString(&input_, &server_info_.timezone)) {
- return false;
- }
- }
-
- return true;
- } else if (packet_type == ServerCodes::Exception) {
- ReceiveException(true);
- return false;
- }
-
- return false;
-}
-
-void Client::Impl::RetryGuard(std::function func) {
- for (int i = 0; i <= options_.send_retries; ++i) {
- try {
- func();
- return;
- } catch (const std::system_error&) {
- bool ok = true;
-
- try {
- std::this_thread::sleep_for(options_.retry_timeout);
- ResetConnection();
- } catch (...) {
- ok = false;
- }
-
- if (!ok) {
- throw;
- }
- }
- }
-}
-
-Client::Client(const ClientOptions& opts)
- : options_(opts)
- , impl_(new Impl(opts))
-{
-}
-
-Client::~Client()
-{ }
-
-void Client::Execute(const Query& query) {
- impl_->ExecuteQuery(query);
-}
-
-void Client::Select(const std::string& query, SelectCallback cb) {
- Execute(Query(query).OnData(cb));
-}
-
-void Client::SelectCancelable(const std::string& query, SelectCancelableCallback cb) {
- Execute(Query(query).OnDataCancelable(cb));
-}
-
-void Client::Select(const Query& query) {
- Execute(query);
-}
-
-void Client::Insert(const std::string& table_name, const Block& block) {
- impl_->Insert(table_name, block);
-}
-
-void Client::Ping() {
- impl_->Ping();
-}
-
-void Client::ResetConnection() {
- impl_->ResetConnection();
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/client.h b/src/vendor/clickhouse-cpp/clickhouse/client.h
deleted file mode 100644
index 6953e7d..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/client.h
+++ /dev/null
@@ -1,115 +0,0 @@
-#pragma once
-
-#include "query.h"
-#include "exceptions.h"
-
-#include "columns/array.h"
-#include "columns/date.h"
-#include "columns/decimal.h"
-#include "columns/enum.h"
-#include "columns/ip4.h"
-#include "columns/ip6.h"
-#include "columns/nullable.h"
-#include "columns/numeric.h"
-#include "columns/string.h"
-#include "columns/tuple.h"
-#include "columns/uuid.h"
-
-#include
-#include
-#include
-#include
-
-namespace clickhouse {
-
-/// Methods of block compression.
-enum class CompressionMethod {
- None = -1,
- LZ4 = 1,
-};
-
-struct ClientOptions {
-#define DECLARE_FIELD(name, type, setter, default) \
- type name = default; \
- inline ClientOptions& setter(const type& value) { \
- name = value; \
- return *this; \
- }
-
- /// Hostname of the server.
- DECLARE_FIELD(host, std::string, SetHost, std::string());
- /// Service port.
- DECLARE_FIELD(port, int, SetPort, 9000);
-
- /// Default database.
- DECLARE_FIELD(default_database, std::string, SetDefaultDatabase, "default");
- /// User name.
- DECLARE_FIELD(user, std::string, SetUser, "default");
- /// Access password.
- DECLARE_FIELD(password, std::string, SetPassword, std::string());
-
- /// By default all exceptions received during query execution will be
- /// passed to OnException handler. Set rethrow_exceptions to true to
- /// enable throwing exceptions with standard c++ exception mechanism.
- DECLARE_FIELD(rethrow_exceptions, bool, SetRethrowException, true);
-
- /// Ping server every time before execute any query.
- DECLARE_FIELD(ping_before_query, bool, SetPingBeforeQuery, false);
- /// Count of retry to send request to server.
- DECLARE_FIELD(send_retries, int, SetSendRetries, 1);
- /// Amount of time to wait before next retry.
- DECLARE_FIELD(retry_timeout, std::chrono::seconds, SetRetryTimeout, std::chrono::seconds(5));
-
- /// Compression method.
- DECLARE_FIELD(compression_method, CompressionMethod, SetCompressionMethod, CompressionMethod::None);
-
- /// TCP Keep alive options
- DECLARE_FIELD(tcp_keepalive, bool, TcpKeepAlive, false);
- DECLARE_FIELD(tcp_keepalive_idle, std::chrono::seconds, SetTcpKeepAliveIdle, std::chrono::seconds(60));
- DECLARE_FIELD(tcp_keepalive_intvl, std::chrono::seconds, SetTcpKeepAliveInterval, std::chrono::seconds(5));
- DECLARE_FIELD(tcp_keepalive_cnt, int, SetTcpKeepAliveCount, 3);
-
-#undef DECLARE_FIELD
-};
-
-std::ostream& operator<<(std::ostream& os, const ClientOptions& options);
-
-/**
- *
- */
-class Client {
-public:
- Client(const ClientOptions& opts);
- ~Client();
-
- /// Intends for execute arbitrary queries.
- void Execute(const Query& query);
-
- /// Intends for execute select queries. Data will be returned with
- /// one or more call of \p cb.
- void Select(const std::string& query, SelectCallback cb);
-
- /// Executes a select query which can be canceled by returning false from
- /// the data handler function \p cb.
- void SelectCancelable(const std::string& query, SelectCancelableCallback cb);
-
- /// Alias for Execute.
- void Select(const Query& query);
-
- /// Intends for insert block of data into a table \p table_name.
- void Insert(const std::string& table_name, const Block& block);
-
- /// Ping server for aliveness.
- void Ping();
-
- /// Reset connection with initial params.
- void ResetConnection();
-
-private:
- ClientOptions options_;
-
- class Impl;
- std::unique_ptr impl_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/array.cpp b/src/vendor/clickhouse-cpp/clickhouse/columns/array.cpp
deleted file mode 100644
index 7af64dd..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/array.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "array.h"
-#include
-
-namespace clickhouse {
-
-ColumnArray::ColumnArray(ColumnRef data)
- : Column(Type::CreateArray(data->Type()))
- , data_(data)
- , offsets_(std::make_shared())
-{
-}
-
-void ColumnArray::AppendAsColumn(ColumnRef array) {
- if (!data_->Type()->IsEqual(array->Type())) {
- throw std::runtime_error(
- "can't append column of type " + array->Type()->GetName() + " "
- "to column type " + data_->Type()->GetName());
- }
-
- if (offsets_->Size() == 0) {
- offsets_->Append(array->Size());
- } else {
- offsets_->Append((*offsets_)[offsets_->Size() - 1] + array->Size());
- }
-
- data_->Append(array);
-}
-
-ColumnRef ColumnArray::GetAsColumn(size_t n) const {
- return data_->Slice(GetOffset(n), GetSize(n));
-}
-
-ColumnRef ColumnArray::Slice(size_t begin, size_t size) {
- auto result = std::make_shared(GetAsColumn(begin));
- result->OffsetsIncrease(1);
-
- for (size_t i = 1; i < size; i++)
- {
- result->Append(std::make_shared(GetAsColumn(begin + i)));
- }
-
- return result;
-}
-
-void ColumnArray::Append(ColumnRef column) {
- if (auto col = column->As()) {
- if (!col->data_->Type()->IsEqual(data_->Type())) {
- return;
- }
-
- for (size_t i = 0; i < col->Size(); ++i) {
- AppendAsColumn(col->GetAsColumn(i));
- }
- }
-}
-
-bool ColumnArray::Load(CodedInputStream* input, size_t rows) {
- if (!offsets_->Load(input, rows)) {
- return false;
- }
- if (!data_->Load(input, (*offsets_)[rows - 1])) {
- return false;
- }
- return true;
-}
-
-void ColumnArray::Save(CodedOutputStream* output) {
- offsets_->Save(output);
- data_->Save(output);
-}
-
-void ColumnArray::Clear() {
- offsets_->Clear();
- data_->Clear();
-}
-
-size_t ColumnArray::Size() const {
- return offsets_->Size();
-}
-
-void ColumnArray::OffsetsIncrease(size_t n) {
- offsets_->Append(n);
-}
-
-size_t ColumnArray::GetOffset(size_t n) const {
- return (n == 0) ? 0 : (*offsets_)[n - 1];
-}
-
-size_t ColumnArray::GetSize(size_t n) const {
- return (n == 0) ? (*offsets_)[n] : ((*offsets_)[n] - (*offsets_)[n - 1]);
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/array.h b/src/vendor/clickhouse-cpp/clickhouse/columns/array.h
deleted file mode 100644
index 50ddcab..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/array.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#pragma once
-
-#include "numeric.h"
-
-namespace clickhouse {
-
-/**
- * Represents column of Array(T).
- */
-class ColumnArray : public Column {
-public:
- ColumnArray(ColumnRef data);
-
- /// Converts input column to array and appends
- /// as one row to the current column.
- void AppendAsColumn(ColumnRef array);
-
- /// Convets array at pos n to column.
- /// Type of element of result column same as type of array element.
- ColumnRef GetAsColumn(size_t n) const;
-
-public:
- /// Appends content of given column to the end of current one.
- void Append(ColumnRef column) override;
-
- /// Loads column data from input stream.
- bool Load(CodedInputStream* input, size_t rows) override;
-
- /// Saves column data to output stream.
- void Save(CodedOutputStream* output) override;
-
- /// Clear column data .
- void Clear() override;
-
- /// Returns count of rows in the column.
- size_t Size() const override;
-
- /// Makes slice of the current column.
- ColumnRef Slice(size_t, size_t) override;
-
- void OffsetsIncrease(size_t);
-
-private:
- size_t GetOffset(size_t n) const;
-
- size_t GetSize(size_t n) const;
-
-private:
- ColumnRef data_;
- std::shared_ptr offsets_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/column.h b/src/vendor/clickhouse-cpp/clickhouse/columns/column.h
deleted file mode 100644
index b0a9dee..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/column.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#pragma once
-
-#include "../base/coded.h"
-#include "../base/input.h"
-#include "../types/types.h"
-
-namespace clickhouse {
-
-using ColumnRef = std::shared_ptr;
-
-/**
- * An abstract base of all columns classes.
- */
-class Column : public std::enable_shared_from_this {
-public:
- explicit inline Column(TypeRef type) : type_(type) {}
-
- virtual ~Column() {}
-
- /// Downcast pointer to the specific column's subtype.
- template
- inline std::shared_ptr As() {
- return std::dynamic_pointer_cast(shared_from_this());
- }
-
- /// Downcast pointer to the specific column's subtype.
- template
- inline std::shared_ptr As() const {
- return std::dynamic_pointer_cast(shared_from_this());
- }
-
- /// Get type object of the column.
- inline TypeRef Type() const { return type_; }
-
- /// Appends content of given column to the end of current one.
- virtual void Append(ColumnRef column) = 0;
-
- /// Loads column data from input stream.
- virtual bool Load(CodedInputStream* input, size_t rows) = 0;
-
- /// Saves column data to output stream.
- virtual void Save(CodedOutputStream* output) = 0;
-
- /// Clear column data .
- virtual void Clear() = 0;
-
- /// Returns count of rows in the column.
- virtual size_t Size() const = 0;
-
- /// Makes slice of the current column.
- virtual ColumnRef Slice(size_t begin, size_t len) = 0;
-
-protected:
- TypeRef type_;
-};
-
-} // namespace clickhouse
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/date.cpp b/src/vendor/clickhouse-cpp/clickhouse/columns/date.cpp
deleted file mode 100644
index a66a449..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/date.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-#include "date.h"
-
-namespace clickhouse {
-
-ColumnDate::ColumnDate()
- : Column(Type::CreateDate())
- , data_(std::make_shared())
-{
-}
-
-void ColumnDate::Append(const std::time_t& value) {
- /// TODO: This code is fundamentally wrong.
- data_->Append(static_cast(value / std::time_t(86400)));
-}
-
-void ColumnDate::Clear() {
- data_->Clear();
-}
-
-std::time_t ColumnDate::At(size_t n) const {
- return static_cast(data_->At(n)) * 86400;
-}
-
-void ColumnDate::Append(ColumnRef column) {
- if (auto col = column->As()) {
- data_->Append(col->data_);
- }
-}
-
-bool ColumnDate::Load(CodedInputStream* input, size_t rows) {
- return data_->Load(input, rows);
-}
-
-void ColumnDate::Save(CodedOutputStream* output) {
- data_->Save(output);
-}
-
-size_t ColumnDate::Size() const {
- return data_->Size();
-}
-
-ColumnRef ColumnDate::Slice(size_t begin, size_t len) {
- auto col = data_->Slice(begin, len)->As();
- auto result = std::make_shared();
-
- result->data_->Append(col);
-
- return result;
-}
-
-
-ColumnDateTime::ColumnDateTime()
- : Column(Type::CreateDateTime())
- , data_(std::make_shared())
-{
-}
-
-void ColumnDateTime::Append(const std::time_t& value) {
- data_->Append(static_cast(value));
-}
-
-std::time_t ColumnDateTime::At(size_t n) const {
- return data_->At(n);
-}
-
-void ColumnDateTime::Append(ColumnRef column) {
- if (auto col = column->As()) {
- data_->Append(col->data_);
- }
-}
-
-bool ColumnDateTime::Load(CodedInputStream* input, size_t rows) {
- return data_->Load(input, rows);
-}
-
-void ColumnDateTime::Save(CodedOutputStream* output) {
- data_->Save(output);
-}
-
-size_t ColumnDateTime::Size() const {
- return data_->Size();
-}
-
-void ColumnDateTime::Clear() {
- data_->Clear();
-}
-
-ColumnRef ColumnDateTime::Slice(size_t begin, size_t len) {
- auto col = data_->Slice(begin, len)->As();
- auto result = std::make_shared();
-
- result->data_->Append(col);
-
- return result;
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/date.h b/src/vendor/clickhouse-cpp/clickhouse/columns/date.h
deleted file mode 100644
index 92a62d7..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/date.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#pragma once
-
-#include "numeric.h"
-
-#include
-
-namespace clickhouse {
-
-/** */
-class ColumnDate : public Column {
-public:
- ColumnDate();
-
- /// Appends one element to the end of column.
- /// TODO: The implementation is fundamentally wrong.
- void Append(const std::time_t& value);
-
- /// Returns element at given row number.
- /// TODO: The implementation is fundamentally wrong.
- std::time_t At(size_t n) const;
-
- /// Appends content of given column to the end of current one.
- void Append(ColumnRef column) override;
-
- /// Loads column data from input stream.
- bool Load(CodedInputStream* input, size_t rows) override;
-
- /// Saves column data to output stream.
- void Save(CodedOutputStream* output) override;
-
- /// Clear column data .
- void Clear() override;
-
- /// Returns count of rows in the column.
- size_t Size() const override;
-
- /// Makes slice of the current column.
- ColumnRef Slice(size_t begin, size_t len) override;
-
-private:
- std::shared_ptr data_;
-};
-
-/** */
-class ColumnDateTime : public Column {
-public:
- ColumnDateTime();
-
- /// Appends one element to the end of column.
- void Append(const std::time_t& value);
-
- /// Returns element at given row number.
- std::time_t At(size_t n) const;
-
- /// Appends content of given column to the end of current one.
- void Append(ColumnRef column) override;
-
- /// Loads column data from input stream.
- bool Load(CodedInputStream* input, size_t rows) override;
-
- /// Clear column data .
- void Clear() override;
-
- /// Saves column data to output stream.
- void Save(CodedOutputStream* output) override;
-
- /// Returns count of rows in the column.
- size_t Size() const override;
-
- /// Makes slice of the current column.
- ColumnRef Slice(size_t begin, size_t len) override;
-
-private:
- std::shared_ptr data_;
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp b/src/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp
deleted file mode 100644
index 576eed0..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/decimal.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-#include "decimal.h"
-
-#include
-
-namespace clickhouse {
-
-ColumnDecimal::ColumnDecimal(size_t precision, size_t scale)
- : Column(Type::CreateDecimal(precision, scale))
-{
- if (precision <= 9) {
- data_ = std::make_shared();
- } else if (precision <= 18) {
- data_ = std::make_shared();
- } else {
- data_ = std::make_shared();
- }
-}
-
-ColumnDecimal::ColumnDecimal(TypeRef type)
- : Column(type)
-{
-}
-
-void ColumnDecimal::Append(const BigInt& value) {
- if (data_->Type()->GetCode() == Type::Int32) {
- //data_->As()->Append(static_cast(value));
- static_cast>(data_->As())->Append(static_cast(value.to_long()));
- } else if (data_->Type()->GetCode() == Type::Int64) {
- //data_->As()->Append(static_cast(value));
- static_cast>(data_->As())->Append(static_cast(value.to_long_long()));
- } else {
- //data_->As()->Append(static_cast(value));
- static_cast>(data_->As())->Append(static_cast(value));
- }
-}
-
-void ColumnDecimal::Append(const std::string& value) {
- BigInt int_value = 0;
- auto c = value.begin();
- auto end = value.end();
- bool sign = true;
- bool has_dot = false;
-
- int zeros = 0;
-
- while (c != end) {
- if (*c == '-') {
- sign = false;
- if (c != value.begin()) {
- break;
- }
- } else if (*c == '.' && !has_dot) {
- size_t distance = std::distance(c, end) - 1;
- auto scale = std::static_pointer_cast(type_)->GetScale();
-
- if (distance <= scale) {
- zeros = scale - distance;
- } else {
- std::advance(end, scale - distance);
- }
-
- has_dot = true;
- } else if (*c >= '0' && *c <= '9') {
- int_value *= 10;
- int_value += *c - '0';
- } else {
- throw std::runtime_error(std::string("unexpected symbol '") + (*c) + "' in decimal value");
- }
- ++c;
- }
-
- if (c != end) {
- throw std::runtime_error("unexpected symbol '-' in decimal value");
- }
-
- while (zeros) {
- int_value *= 10;
- --zeros;
- }
-
- Append(sign ? int_value : -int_value);
-}
-
-BigInt ColumnDecimal::At(size_t i) const {
- if (data_->Type()->GetCode() == Type::Int32) {
- return static_cast(data_->As()->At(i));
- } else if (data_->Type()->GetCode() == Type::Int64) {
- return static_cast(data_->As()->At(i));
- } else {
- return data_->As()->At(i);
- }
-}
-
-void ColumnDecimal::Append(ColumnRef column) {
- if (auto col = column->As()) {
- data_->Append(col->data_);
- }
-}
-
-bool ColumnDecimal::Load(CodedInputStream* input, size_t rows) {
- return data_->Load(input, rows);
-}
-
-void ColumnDecimal::Save(CodedOutputStream* output) {
- data_->Save(output);
-}
-
-void ColumnDecimal::Clear() {
- data_->Clear();
-}
-
-size_t ColumnDecimal::Size() const {
- return data_->Size();
-}
-
-ColumnRef ColumnDecimal::Slice(size_t begin, size_t len) {
- std::shared_ptr slice(new ColumnDecimal(type_));
- slice->data_ = data_->Slice(begin, len);
- return slice;
-}
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/decimal.h b/src/vendor/clickhouse-cpp/clickhouse/columns/decimal.h
deleted file mode 100644
index bc0abfd..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/decimal.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#pragma once
-
-#include "column.h"
-#include "numeric.h"
-
-namespace clickhouse {
-
-/**
- * Represents a column of decimal type.
- */
-class ColumnDecimal : public Column {
-public:
- ColumnDecimal(size_t precision, size_t scale);
-
- void Append(const BigInt& value);
- void Append(const std::string& value);
-
- BigInt At(size_t i) const;
-
-public:
- void Append(ColumnRef column) override;
- bool Load(CodedInputStream* input, size_t rows) override;
- void Save(CodedOutputStream* output) override;
- void Clear() override;
- size_t Size() const override;
- ColumnRef Slice(size_t begin, size_t len) override;
-
-private:
- /// Depending on a precision it can be one of:
- /// - ColumnInt32
- /// - ColumnInt64
- /// - ColumnInt128
- ColumnRef data_;
-
- explicit ColumnDecimal(TypeRef type); // for `Slice(…)`
-};
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp b/src/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp
deleted file mode 100644
index 33ee72b..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/enum.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-#include "enum.h"
-#include "utils.h"
-
-namespace clickhouse {
-
-template
-ColumnEnum::ColumnEnum(TypeRef type)
- : Column(type)
-{
-}
-
-template
-ColumnEnum::ColumnEnum(TypeRef type, const std::vector& data)
- : Column(type)
- , data_(data)
-{
-}
-
-template
-void ColumnEnum::Append(const T& value, bool checkValue) {
- if (checkValue) {
- // TODO: type_->HasEnumValue(value), "Enum type doesn't have value " + std::to_string(value);
- }
- data_.push_back(value);
-}
-
-template
-void ColumnEnum::Append(const std::string& name) {
- data_.push_back(std::static_pointer_cast(type_)->GetEnumValue(name));
-}
-
-template
-void ColumnEnum::Clear() {
- data_.clear();
-}
-
-template
-const T& ColumnEnum::At(size_t n) const {
- return data_.at(n);
-}
-
-template
-const std::string ColumnEnum::NameAt(size_t n) const {
- return std::static_pointer_cast(type_)->GetEnumName(data_.at(n));
-}
-
-template
-const T& ColumnEnum::operator[] (size_t n) const {
- return data_[n];
-}
-
-template
-void ColumnEnum::SetAt(size_t n, const T& value, bool checkValue) {
- if (checkValue) {
- // TODO: type_->HasEnumValue(value), "Enum type doesn't have value " + std::to_string(value);
- }
- data_.at(n) = value;
-}
-
-template
-void ColumnEnum::SetNameAt(size_t n, const std::string& name) {
- data_.at(n) = std::static_pointer_cast(type_)->GetEnumValue(name);
-}
-
-template
-void ColumnEnum::Append(ColumnRef column) {
- if (auto col = column->As>()) {
- data_.insert(data_.end(), col->data_.begin(), col->data_.end());
- }
-}
-
-template
-bool ColumnEnum::Load(CodedInputStream* input, size_t rows) {
- data_.resize(rows);
- return input->ReadRaw(data_.data(), data_.size() * sizeof(T));
-}
-
-template
-void ColumnEnum::Save(CodedOutputStream* output) {
- output->WriteRaw(data_.data(), data_.size() * sizeof(T));
-}
-
-template
-size_t ColumnEnum::Size() const {
- return data_.size();
-}
-
-template
-ColumnRef ColumnEnum::Slice(size_t begin, size_t len) {
- return std::make_shared>(type_, SliceVector(data_, begin, len));
-}
-
-template class ColumnEnum;
-template class ColumnEnum;
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/enum.h b/src/vendor/clickhouse-cpp/clickhouse/columns/enum.h
deleted file mode 100644
index 4877866..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/enum.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#pragma once
-
-#include "column.h"
-
-namespace clickhouse {
-
-
-template
-class ColumnEnum : public Column {
-public:
- ColumnEnum(TypeRef type);
- ColumnEnum(TypeRef type, const std::vector& data);
-
- /// Appends one element to the end of column.
- void Append(const T& value, bool checkValue = false);
- void Append(const std::string& name);
-
- /// Returns element at given row number.
- const T& At(size_t n) const;
- const std::string NameAt(size_t n) const;
-
- /// Returns element at given row number.
- const T& operator[] (size_t n) const;
-
- /// Set element at given row number.
- void SetAt(size_t n, const T& value, bool checkValue = false);
- void SetNameAt(size_t n, const std::string& name);
-
-public:
- /// Appends content of given column to the end of current one.
- void Append(ColumnRef column) override;
-
- /// Loads column data from input stream.
- bool Load(CodedInputStream* input, size_t rows) override;
-
- /// Saves column data to output stream.
- void Save(CodedOutputStream* output) override;
-
- /// Clear column data .
- void Clear() override;
-
- /// Returns count of rows in the column.
- size_t Size() const override;
-
- /// Makes slice of the current column.
- ColumnRef Slice(size_t begin, size_t len) override;
-
-private:
- std::vector data_;
-};
-
-using ColumnEnum8 = ColumnEnum;
-using ColumnEnum16 = ColumnEnum;
-
-}
diff --git a/src/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp b/src/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp
deleted file mode 100644
index 22285b9..0000000
--- a/src/vendor/clickhouse-cpp/clickhouse/columns/factory.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-#include "factory.h"
-
-#include "array.h"
-#include "date.h"
-#include "decimal.h"
-#include "enum.h"
-#include "ip4.h"
-#include "ip6.h"
-#include "nothing.h"
-#include "nullable.h"
-#include "numeric.h"
-#include "string.h"
-#include "tuple.h"
-#include "uuid.h"
-
-#include "../types/type_parser.h"
-
-#include
-
-namespace clickhouse {
-namespace {
-
-static ColumnRef CreateTerminalColumn(const TypeAst& ast) {
- switch (ast.code) {
- case Type::Void:
- return std::make_shared();
-
- case Type::UInt8:
- return std::make_shared();
- case Type::UInt16:
- return std::make_shared();
- case Type::UInt32:
- return std::make_shared();
- case Type::UInt64:
- return std::make_shared();
-
- case Type::Int8:
- return std::make_shared();
- case Type::Int16:
- return std::make_shared();
- case Type::Int32:
- return std::make_shared();
- case Type::Int64:
- return std::make_shared();
-
- case Type::Float32:
- return std::make_shared();
- case Type::Float64:
- return std::make_shared();
-
- case Type::Decimal:
- return std::make_shared(ast.elements.front().value, ast.elements.back().value);
- case Type::Decimal32:
- return std::make_shared(9, ast.elements.front().value);
- case Type::Decimal64:
- return std::make_shared(18, ast.elements.front().value);
- case Type::Decimal128:
- return std::make_shared(38, ast.elements.front().value);
-
- case Type::String:
- return std::make_shared();
- case Type::FixedString:
- return std::make_shared(ast.elements.front().value);
-
- case Type::DateTime:
- return std::make_shared();
- case Type::Date:
- return std::make_shared();
-
- case Type::IPv4:
- return std::make_shared();
- case Type::IPv6:
- return std::make_shared();
-
- case Type::UUID:
- return std::make_shared();
-
- default:
- return nullptr;
- }
-}
-
-static ColumnRef CreateColumnFromAst(const TypeAst& ast) {
- switch (ast.meta) {
- case TypeAst::Array: {
- return std::make_shared(
- CreateColumnFromAst(ast.elements.front())
- );
- }
-
- case TypeAst::Nullable: {
- return std::make_shared(
- CreateColumnFromAst(ast.elements.front()),
- std::make_shared()
- );
- }
-
- case TypeAst::Terminal: {
- return CreateTerminalColumn(ast);
- }
-
- case TypeAst::Tuple: {
- std::vector columns;
-
- columns.reserve(ast.elements.size());
- for (const auto& elem : ast.elements) {
- if (auto col = CreateColumnFromAst(elem)) {
- columns.push_back(col);
- } else {
- return nullptr;
- }
- }
-
- return std::make_shared(columns);
- }
-
- case TypeAst::Enum: {
- std::vector