try fix build

This commit is contained in:
Alexander Tokmakov 2020-05-19 20:48:28 +03:00
parent 175b7aedf3
commit 4b30b3168c
11 changed files with 83 additions and 64 deletions

11
.gitmodules vendored
View File

@ -95,9 +95,6 @@
[submodule "contrib/rapidjson"] [submodule "contrib/rapidjson"]
path = contrib/rapidjson path = contrib/rapidjson
url = https://github.com/Tencent/rapidjson url = https://github.com/Tencent/rapidjson
[submodule "contrib/cassandra"]
path = contrib/cassandra
url = https://github.com/datastax/cpp-driver.git
[submodule "contrib/fastops"] [submodule "contrib/fastops"]
path = contrib/fastops path = contrib/fastops
url = https://github.com/ClickHouse-Extras/fastops url = https://github.com/ClickHouse-Extras/fastops
@ -160,3 +157,11 @@
[submodule "contrib/openldap"] [submodule "contrib/openldap"]
path = contrib/openldap path = contrib/openldap
url = https://github.com/openldap/openldap.git url = https://github.com/openldap/openldap.git
[submodule "contrib/cassandra"]
path = contrib/cassandra
url = https://github.com/tavplubix/cpp-driver.git
branch = ch-tmp
[submodule "contrib/libuv"]
path = contrib/libuv
url = https://github.com/libuv/libuv.git
branch = v1.x

View File

@ -1,10 +1,14 @@
if (NOT DEFINED ENABLE_CASSANDRA OR ENABLE_CASSANDRA) if (NOT DEFINED ENABLE_CASSANDRA OR ENABLE_CASSANDRA)
if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/cassandra") if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/libuv")
message (WARNING "submodule contrib/libuv is missing. to fix try run: \n git submodule update --init --recursive")
elseif (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/cassandra")
message (WARNING "submodule contrib/cassandra is missing. to fix try run: \n git submodule update --init --recursive") message (WARNING "submodule contrib/cassandra is missing. to fix try run: \n git submodule update --init --recursive")
else() else()
set(LIBUV_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/libuv")
set (CASSANDRA_INCLUDE_DIR set (CASSANDRA_INCLUDE_DIR
"${ClickHouse_SOURCE_DIR}/contrib/cassandra/include/") "${ClickHouse_SOURCE_DIR}/contrib/cassandra/include/")
set (CASSANDRA_LIBRARY cassandra) set (LIBUV_LIBRARY uv_a)
set (CASSANDRA_LIBRARY cassandra_static)
set (USE_CASSANDRA 1) set (USE_CASSANDRA 1)
set(CASS_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/cassandra") set(CASS_ROOT_DIR "${ClickHouse_SOURCE_DIR}/contrib/cassandra")

View File

@ -319,5 +319,6 @@ if (USE_FASTOPS)
endif() endif()
if (USE_CASSANDRA) if (USE_CASSANDRA)
add_subdirectory(libuv)
add_subdirectory(cassandra) add_subdirectory(cassandra)
endif() endif()

2
contrib/cassandra vendored

@ -1 +1 @@
Subproject commit fd9b73d4acfd85293ab304be64e2e1e2109e521d Subproject commit 5c0f2a62bdc63dcc390d771c9afaa9dc34eb8e5b

1
contrib/libuv vendored Submodule

@ -0,0 +1 @@
Subproject commit cc51217a317e96510fbb284721d5e6bc2af31e33

View File

@ -356,6 +356,11 @@ if (USE_OPENCL)
target_include_directories (clickhouse_common_io SYSTEM BEFORE PRIVATE ${OpenCL_INCLUDE_DIRS}) target_include_directories (clickhouse_common_io SYSTEM BEFORE PRIVATE ${OpenCL_INCLUDE_DIRS})
endif () endif ()
if (USE_CASSANDRA)
dbms_target_link_libraries(PRIVATE ${CASSANDRA_LIBRARY})
dbms_target_include_directories (SYSTEM BEFORE PRIVATE ${CASS_INCLUDE_DIR})
endif()
dbms_target_include_directories (PUBLIC ${DBMS_INCLUDE_DIR}) dbms_target_include_directories (PUBLIC ${DBMS_INCLUDE_DIR})
target_include_directories (clickhouse_common_io PUBLIC ${DBMS_INCLUDE_DIR}) target_include_directories (clickhouse_common_io PUBLIC ${DBMS_INCLUDE_DIR})

View File

@ -22,14 +22,14 @@ namespace ErrorCodes
} }
CassandraBlockInputStream::CassandraBlockInputStream( CassandraBlockInputStream::CassandraBlockInputStream(
CassSession *session, CassSession *session_,
const std::string &query_str, const std::string &query_str_,
const DB::Block &sample_block, const DB::Block &sample_block,
const size_t max_block_size) const size_t max_block_size_)
: session{session} : session(session_)
, statement{cass_statement_new(query_str.c_str(), 0)} , statement(cass_statement_new(query_str_.c_str(), 0))
, query_str{query_str} , query_str(query_str_)
, max_block_size{max_block_size} , max_block_size(max_block_size_)
{ {
cass_statement_set_paging_size(statement, max_block_size); cass_statement_set_paging_size(statement, max_block_size);
this->has_more_pages = cass_true; this->has_more_pages = cass_true;
@ -51,77 +51,77 @@ namespace
{ {
switch (type) switch (type)
{ {
case ValueType::UInt8: case ValueType::vtUInt8:
{ {
cass_uint32_t _value; cass_uint32_t _value;
cass_value_get_uint32(value, &_value); cass_value_get_uint32(value, &_value);
static_cast<ColumnUInt8 &>(column).insertValue(_value); static_cast<ColumnUInt8 &>(column).insertValue(_value);
break; break;
} }
case ValueType::UInt16: case ValueType::vtUInt16:
{ {
cass_uint32_t _value; cass_uint32_t _value;
cass_value_get_uint32(value, &_value); cass_value_get_uint32(value, &_value);
static_cast<ColumnUInt16 &>(column).insertValue(_value); static_cast<ColumnUInt16 &>(column).insertValue(_value);
break; break;
} }
case ValueType::UInt32: case ValueType::vtUInt32:
{ {
cass_uint32_t _value; cass_uint32_t _value;
cass_value_get_uint32(value, &_value); cass_value_get_uint32(value, &_value);
static_cast<ColumnUInt32 &>(column).insertValue(_value); static_cast<ColumnUInt32 &>(column).insertValue(_value);
break; break;
} }
case ValueType::UInt64: case ValueType::vtUInt64:
{ {
cass_int64_t _value; cass_int64_t _value;
cass_value_get_int64(value, &_value); cass_value_get_int64(value, &_value);
static_cast<ColumnUInt64 &>(column).insertValue(_value); static_cast<ColumnUInt64 &>(column).insertValue(_value);
break; break;
} }
case ValueType::Int8: case ValueType::vtInt8:
{ {
cass_int8_t _value; cass_int8_t _value;
cass_value_get_int8(value, &_value); cass_value_get_int8(value, &_value);
static_cast<ColumnInt8 &>(column).insertValue(_value); static_cast<ColumnInt8 &>(column).insertValue(_value);
break; break;
} }
case ValueType::Int16: case ValueType::vtInt16:
{ {
cass_int16_t _value; cass_int16_t _value;
cass_value_get_int16(value, &_value); cass_value_get_int16(value, &_value);
static_cast<ColumnInt16 &>(column).insertValue(_value); static_cast<ColumnInt16 &>(column).insertValue(_value);
break; break;
} }
case ValueType::Int32: case ValueType::vtInt32:
{ {
cass_int32_t _value; cass_int32_t _value;
cass_value_get_int32(value, &_value); cass_value_get_int32(value, &_value);
static_cast<ColumnInt32 &>(column).insertValue(_value); static_cast<ColumnInt32 &>(column).insertValue(_value);
break; break;
} }
case ValueType::Int64: case ValueType::vtInt64:
{ {
cass_int64_t _value; cass_int64_t _value;
cass_value_get_int64(value, &_value); cass_value_get_int64(value, &_value);
static_cast<ColumnInt64 &>(column).insertValue(_value); static_cast<ColumnInt64 &>(column).insertValue(_value);
break; break;
} }
case ValueType::Float32: case ValueType::vtFloat32:
{ {
cass_float_t _value; cass_float_t _value;
cass_value_get_float(value, &_value); cass_value_get_float(value, &_value);
static_cast<ColumnFloat32 &>(column).insertValue(_value); static_cast<ColumnFloat32 &>(column).insertValue(_value);
break; break;
} }
case ValueType::Float64: case ValueType::vtFloat64:
{ {
cass_double_t _value; cass_double_t _value;
cass_value_get_double(value, &_value); cass_value_get_double(value, &_value);
static_cast<ColumnFloat64 &>(column).insertValue(_value); static_cast<ColumnFloat64 &>(column).insertValue(_value);
break; break;
} }
case ValueType::String: case ValueType::vtString:
{ {
const char* _value; const char* _value;
size_t _value_length; size_t _value_length;
@ -129,21 +129,21 @@ namespace
static_cast<ColumnString &>(column).insertData(_value, _value_length); static_cast<ColumnString &>(column).insertData(_value, _value_length);
break; break;
} }
case ValueType::Date: case ValueType::vtDate:
{ {
cass_int64_t _value; cass_int64_t _value;
cass_value_get_int64(value, &_value); cass_value_get_int64(value, &_value);
static_cast<ColumnUInt16 &>(column).insertValue(UInt32{cass_date_from_epoch(_value)}); // FIXME static_cast<ColumnUInt16 &>(column).insertValue(UInt32{cass_date_from_epoch(_value)}); // FIXME
break; break;
} }
case ValueType::DateTime: case ValueType::vtDateTime:
{ {
cass_int64_t _value; cass_int64_t _value;
cass_value_get_int64(value, &_value); cass_value_get_int64(value, &_value);
static_cast<ColumnUInt32 &>(column).insertValue(_value); static_cast<ColumnUInt32 &>(column).insertValue(_value);
break; break;
} }
case ValueType::UUID: case ValueType::vtUUID:
{ {
CassUuid _value; CassUuid _value;
cass_value_get_uuid(value, &_value); cass_value_get_uuid(value, &_value);
@ -166,7 +166,7 @@ namespace
MutableColumns columns(description.sample_block.columns()); MutableColumns columns(description.sample_block.columns());
CassFuture* query_future = cass_session_execute(session, statement); CassFuture* query_future = cass_session_execute(session, statement);
const CassResult* result = cass_future_get_result(query_future); const CassResult* result_tmp = cass_future_get_result(query_future);
if (result == nullptr) { if (result == nullptr) {
const char* error_message; const char* error_message;
@ -176,12 +176,12 @@ namespace
throw Exception{error_message, ErrorCodes::CASSANDRA_INTERNAL_ERROR}; throw Exception{error_message, ErrorCodes::CASSANDRA_INTERNAL_ERROR};
} }
const CassRow* row = cass_result_first_row(result); const CassRow* row = cass_result_first_row(result_tmp);
const CassValue* map = cass_row_get_column(row, 0); const CassValue* map = cass_row_get_column(row, 0);
CassIterator* iterator = cass_iterator_from_map(map); CassIterator* iterator_tmp = cass_iterator_from_map(map);
while (cass_iterator_next(iterator)) { while (cass_iterator_next(iterator_tmp)) {
const CassValue* _key = cass_iterator_get_map_key(iterator); const CassValue* _key = cass_iterator_get_map_key(iterator_tmp);
const CassValue* _value = cass_iterator_get_map_value(iterator); const CassValue* _value = cass_iterator_get_map_value(iterator_tmp);
auto pair_values = {std::make_pair(_key, 0ul), std::make_pair(_value, 1ul)}; auto pair_values = {std::make_pair(_key, 0ul), std::make_pair(_value, 1ul)};
for (const auto &[value, idx]: pair_values) { for (const auto &[value, idx]: pair_values) {
if (description.types[idx].second) { if (description.types[idx].second) {
@ -194,13 +194,13 @@ namespace
} }
} }
has_more_pages = cass_result_has_more_pages(result); has_more_pages = cass_result_has_more_pages(result_tmp);
if (has_more_pages) { if (has_more_pages) {
cass_statement_set_paging_state(statement, result); cass_statement_set_paging_state(statement, result_tmp);
} }
cass_result_free(result); cass_result_free(result_tmp);
return description.sample_block.cloneWithColumns(std::move(columns)); return description.sample_block.cloneWithColumns(std::move(columns));
} }

View File

@ -15,7 +15,8 @@ namespace DB
const Poco::Util::AbstractConfiguration & config, const Poco::Util::AbstractConfiguration & config,
const std::string & config_prefix, const std::string & config_prefix,
Block & sample_block, Block & sample_block,
const Context & /* context */) -> DictionarySourcePtr { const Context & /* context */,
bool /*check_config*/) -> DictionarySourcePtr {
#if USE_CASSANDRA #if USE_CASSANDRA
return std::make_unique<CassandraDictionarySource>(dict_struct, config, config_prefix + ".cassandra", sample_block); return std::make_unique<CassandraDictionarySource>(dict_struct, config, config_prefix + ".cassandra", sample_block);
#else #else
@ -49,42 +50,42 @@ namespace ErrorCodes
static const size_t max_block_size = 8192; static const size_t max_block_size = 8192;
CassandraDictionarySource::CassandraDictionarySource( CassandraDictionarySource::CassandraDictionarySource(
const DB::DictionaryStructure &dict_struct, const DB::DictionaryStructure & dict_struct_,
const std::string &host, const std::string & host_,
UInt16 port, UInt16 port_,
const std::string &user, const std::string & user_,
const std::string &password, const std::string & password_,
const std::string &method, const std::string & method_,
const std::string &db, const std::string & db_,
const DB::Block &sample_block) const DB::Block & sample_block_)
: dict_struct{dict_struct} : dict_struct(dict_struct_)
, host{host} , host(host_)
, port{port} , port(port_)
, user{user} , user(user_)
, password{password} , password(password_)
, method{method} , method(method_)
, db{db} , db(db_)
, sample_block{sample_block} , sample_block(sample_block_)
, cluster{cass_cluster_new()} , cluster(cass_cluster_new())
, session{cass_session_new()} , session(cass_session_new())
{ {
cass_cluster_set_contact_points(cluster, toConnectionString(host, port).c_str()); cass_cluster_set_contact_points(cluster, toConnectionString(host, port).c_str());
} }
CassandraDictionarySource::CassandraDictionarySource( CassandraDictionarySource::CassandraDictionarySource(
const DB::DictionaryStructure &dict_struct, const DB::DictionaryStructure & dict_struct_,
const Poco::Util::AbstractConfiguration &config, const Poco::Util::AbstractConfiguration & config,
const std::string &config_prefix, const std::string & config_prefix,
DB::Block &sample_block) DB::Block & sample_block_)
: CassandraDictionarySource( : CassandraDictionarySource(
dict_struct, dict_struct_,
config.getString(config_prefix + ".host"), config.getString(config_prefix + ".host"),
config.getUInt(config_prefix + ".port"), config.getUInt(config_prefix + ".port"),
config.getString(config_prefix + ".user", ""), config.getString(config_prefix + ".user", ""),
config.getString(config_prefix + ".password", ""), config.getString(config_prefix + ".password", ""),
config.getString(config_prefix + ".method", ""), config.getString(config_prefix + ".method", ""),
config.getString(config_prefix + ".db", ""), config.getString(config_prefix + ".db", ""),
sample_block) sample_block_)
{ {
} }

View File

@ -16,6 +16,8 @@ SRCS(
CacheDictionary_generate1.cpp CacheDictionary_generate1.cpp
CacheDictionary_generate2.cpp CacheDictionary_generate2.cpp
CacheDictionary_generate3.cpp CacheDictionary_generate3.cpp
CassandraBlockInputStream.cpp
CassandraDictionarySource.cpp
ClickHouseDictionarySource.cpp ClickHouseDictionarySource.cpp
ComplexKeyCacheDictionary.cpp ComplexKeyCacheDictionary.cpp
ComplexKeyCacheDictionary_createAttributeWithType.cpp ComplexKeyCacheDictionary_createAttributeWithType.cpp
@ -24,8 +26,8 @@ SRCS(
ComplexKeyCacheDictionary_generate3.cpp ComplexKeyCacheDictionary_generate3.cpp
ComplexKeyCacheDictionary_setAttributeValue.cpp ComplexKeyCacheDictionary_setAttributeValue.cpp
ComplexKeyCacheDictionary_setDefaultAttributeValue.cpp ComplexKeyCacheDictionary_setDefaultAttributeValue.cpp
ComplexKeyHashedDictionary.cpp
ComplexKeyDirectDictionary.cpp ComplexKeyDirectDictionary.cpp
ComplexKeyHashedDictionary.cpp
DictionaryBlockInputStreamBase.cpp DictionaryBlockInputStreamBase.cpp
DictionaryFactory.cpp DictionaryFactory.cpp
DictionarySourceFactory.cpp DictionarySourceFactory.cpp

View File

@ -281,10 +281,10 @@ SRCS(
rand64.cpp rand64.cpp
randConstant.cpp randConstant.cpp
rand.cpp rand.cpp
randomFixedString.cpp
randomPrintableASCII.cpp randomPrintableASCII.cpp
randomString.cpp randomString.cpp
randomStringUTF8.cpp randomStringUTF8.cpp
randomFixedString.cpp
regexpQuoteMeta.cpp regexpQuoteMeta.cpp
registerFunctionsArithmetic.cpp registerFunctionsArithmetic.cpp
registerFunctionsComparison.cpp registerFunctionsComparison.cpp

View File

@ -2,7 +2,7 @@
import warnings import warnings
import pymysql.cursors import pymysql.cursors
import pymongo import pymongo
import cassandra import cassandra.cluster
import redis import redis
import aerospike import aerospike
from tzlocal import get_localzone from tzlocal import get_localzone