From ec97c12ce21c225e1d3e32715f35fa89474c4a30 Mon Sep 17 00:00:00 2001 From: sherman-the-tank Date: Mon, 6 Apr 2020 13:49:36 +0800 Subject: [PATCH] Fixed the build --- CMakeLists.txt | 35 ++++++++++++++----------- cmake/FindLZ4.cmake | 27 +++++++++++++++++++ src/codec/test/ResultSchemaProvider.cpp | 35 ++++++++++++++++--------- src/codec/test/ResultSchemaProvider.h | 24 +++++++++++------ 4 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 cmake/FindLZ4.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index bc9ede4e5..0acd872e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,7 @@ find_package(OpenSSL REQUIRED) find_package(Krb5 REQUIRED gssapi) find_package(GPERF 2.8 REQUIRED) find_package(Libunwind REQUIRED) +find_package(LZ4 MODULE) find_package(LibLZMA MODULE) find_package(Rocksdb REQUIRED) @@ -269,6 +270,20 @@ if(ENABLE_FUZZ_TEST) endif() endif() +# All thrift libraries +set(THRIFT_LIBRARIES + thriftcpp2 + thrift + thriftprotocol + async + protocol + transport + concurrency + security + thriftfrozen2 + thrift-core +) + macro(nebula_add_executable) cmake_parse_arguments( nebula_exec # prefix @@ -349,21 +364,6 @@ include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR}/src/kvstore/plugins/hbase) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L ${NEBULA_THIRDPARTY_ROOT}/lib") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L ${NEBULA_THIRDPARTY_ROOT}/lib64") -# All thrift libraries -set(THRIFT_LIBRARIES - thriftcpp2 - thrift - thriftprotocol - async - esrotocol - -dependency - tranport - concurrency - security - thriftfrozen2 - thrift-core -) - set(ROCKSDB_LIBRARIES ${Rocksdb_LIBRARY}) # All compression libraries @@ -372,6 +372,10 @@ if (LIBLZMA_FOUND) include_directories(SYSTEM ${LIBLZMA_INCLUDE_DIRS}) list(APPEND COMPRESSION_LIBRARIES ${LIBLZMA_LIBRARIES}) endif() +if (LZ4_FOUND) + include_directories(SYSTEM ${LZ4_INCLUDE_DIR}) + list(APPEND COMPRESSION_LIBRARIES ${LZ4_LIBRARY}) +endif() if (NOT ENABLE_JEMALLOC OR ENABLE_ASAN) set(JEMALLOC_LIB ) @@ -408,7 +412,6 @@ macro(nebula_link_libraries target) event double-conversion resolv - s2 ${COMPRESSION_LIBRARIES} ${JEMALLOC_LIB} ${OPENSSL_SSL_LIBRARY} diff --git a/cmake/FindLZ4.cmake b/cmake/FindLZ4.cmake new file mode 100644 index 000000000..746cad7c3 --- /dev/null +++ b/cmake/FindLZ4.cmake @@ -0,0 +1,27 @@ +# Finds liblz4. +# +# This module defines: +# LZ4_FOUND +# LZ4_INCLUDE_DIR +# LZ4_LIBRARY +# + +find_path(LZ4_INCLUDE_DIR NAMES lz4.h) + +find_library(LZ4_LIBRARY_DEBUG NAMES lz4d) +find_library(LZ4_LIBRARY_RELEASE NAMES lz4) + +include(SelectLibraryConfigurations) +SELECT_LIBRARY_CONFIGURATIONS(LZ4) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + LZ4 DEFAULT_MSG + LZ4_LIBRARY LZ4_INCLUDE_DIR +) + +if (LZ4_FOUND) + message(STATUS "Found LZ4: ${LZ4_LIBRARY}") +endif() + +mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY) diff --git a/src/codec/test/ResultSchemaProvider.cpp b/src/codec/test/ResultSchemaProvider.cpp index c1400f26d..04f4c20fc 100644 --- a/src/codec/test/ResultSchemaProvider.cpp +++ b/src/codec/test/ResultSchemaProvider.cpp @@ -29,14 +29,14 @@ const char* ResultSchemaProvider::ResultSchemaField::name() const { } -const PropertyType ResultSchemaProvider::ResultSchemaField::type() const { +PropertyType ResultSchemaProvider::ResultSchemaField::type() const { DCHECK(!!column_); return column_->get_type(); } -bool ResultSchemaProvider::ResultSchemaField::isValid() const { - return column_ != nullptr; +bool ResultSchemaProvider::ResultSchemaField::nullable() const { + LOG(FATAL) << "Not Supported"; } @@ -49,6 +49,14 @@ const Value& ResultSchemaProvider::ResultSchemaField::defaultValue() const { LOG(FATAL) << "Not Supported"; } +size_t ResultSchemaProvider::ResultSchemaField::size() const { + return 0; +} + +size_t ResultSchemaProvider::ResultSchemaField::offset() const { + return 0; +} + /*********************************** * @@ -88,7 +96,7 @@ const char* ResultSchemaProvider::getFieldName(int64_t index) const { } -const PropertyType ResultSchemaProvider::getFieldType(int64_t index) const { +PropertyType ResultSchemaProvider::getFieldType(int64_t index) const { if (index < 0 || index >= static_cast(columns_.size())) { return PropertyType::UNKNOWN; } @@ -97,7 +105,7 @@ const PropertyType ResultSchemaProvider::getFieldType(int64_t index) const { } -const PropertyType ResultSchemaProvider::getFieldType(const folly::StringPiece name) const { +PropertyType ResultSchemaProvider::getFieldType(const folly::StringPiece name) const { auto index = getFieldIndex(name); if (index < 0) { return PropertyType::UNKNOWN; @@ -106,22 +114,23 @@ const PropertyType ResultSchemaProvider::getFieldType(const folly::StringPiece n } -std::shared_ptr -ResultSchemaProvider::field(int64_t index) const { +const meta::SchemaProviderIf::Field* ResultSchemaProvider::field(int64_t index) const { if (index < 0 || index >= static_cast(columns_.size())) { - return std::shared_ptr(); + return nullptr; } - return std::make_shared(&(columns_[index])); + field_.reset(new ResultSchemaField(&(columns_[index]))); + return field_.get(); } -std::shared_ptr -ResultSchemaProvider::field(const folly::StringPiece name) const { +const meta::SchemaProviderIf::Field* ResultSchemaProvider::field( + const folly::StringPiece name) const { auto index = getFieldIndex(name); if (index < 0) { - return std::shared_ptr(); + return nullptr; } - return std::make_shared(&(columns_[index])); + field_.reset(new ResultSchemaField(&(columns_[index]))); + return field_.get(); } } // namespace nebula diff --git a/src/codec/test/ResultSchemaProvider.h b/src/codec/test/ResultSchemaProvider.h index e1857dcb0..72fffe83e 100644 --- a/src/codec/test/ResultSchemaProvider.h +++ b/src/codec/test/ResultSchemaProvider.h @@ -21,10 +21,12 @@ class ResultSchemaProvider : public meta::SchemaProviderIf { explicit ResultSchemaField(const meta::cpp2::ColumnDef* col = nullptr); const char* name() const override; - const meta::cpp2::PropertyType type() const override; - bool isValid() const override; + meta::cpp2::PropertyType type() const override; + bool nullable() const override; bool hasDefault() const override; const Value& defaultValue() const override; + size_t size() const override; + size_t offset() const override; private: const meta::cpp2::ColumnDef* column_; @@ -41,18 +43,21 @@ class ResultSchemaProvider : public meta::SchemaProviderIf { size_t getNumFields() const noexcept override; + size_t size() const noexcept override { + LOG(FATAL) << "Not Supported"; + } + int64_t getFieldIndex(const folly::StringPiece name) const override; const char* getFieldName(int64_t index) const override; - const meta::cpp2::PropertyType getFieldType(int64_t index) const override; - const meta::cpp2::PropertyType getFieldType(const folly::StringPiece name) + meta::cpp2::PropertyType getFieldType(int64_t index) const override; + meta::cpp2::PropertyType getFieldType(const folly::StringPiece name) const override; - std::shared_ptr - field(int64_t index) const override; + const meta::SchemaProviderIf::Field* field(int64_t index) const override; - std::shared_ptr - field(const folly::StringPiece name) const override; + const meta::SchemaProviderIf::Field* field(const folly::StringPiece name) + const override; protected: SchemaVer schemaVer_{0}; @@ -61,6 +66,9 @@ class ResultSchemaProvider : public meta::SchemaProviderIf { // Map of Hash64(field_name) -> array index std::unordered_map nameIndex_; + // The current field + mutable std::shared_ptr field_; + // Default constructor, only used by SchemaWriter explicit ResultSchemaProvider(SchemaVer ver = 0) : schemaVer_(ver) {} };