From d5c8a1f12be6c9ee42ffab3ff80a0ef1a712a2bd Mon Sep 17 00:00:00 2001 From: linjianghong Date: Fri, 31 May 2019 06:48:02 +0000 Subject: [PATCH] feat: release udf headers & lib remove internal headers from udf.h release udf headers & lib --- be/src/udf/CMakeLists.txt | 8 ++++++++ be/src/udf/udf.cpp | 22 ++++++++++++++++++++++ be/src/udf/udf.h | 6 ++++-- build.sh | 13 ++++++++----- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/be/src/udf/CMakeLists.txt b/be/src/udf/CMakeLists.txt index ca745b640641a0..1587d0176f6ead 100755 --- a/be/src/udf/CMakeLists.txt +++ b/be/src/udf/CMakeLists.txt @@ -16,6 +16,8 @@ # under the License. # where to put generated libraries +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/udf") # where to put generated binaries @@ -45,5 +47,11 @@ set (UDF_TEST_LINK_LIBS -lboost_date_time gtest) +set_target_properties(DorisUdf PROPERTIES PUBLIC_HEADER "udf.h;uda_test_harness.h") +INSTALL(TARGETS DorisUdf + ARCHIVE DESTINATION ${OUTPUT_DIR}/udf + LIBRARY DESTINATION ${OUTPUT_DIR}/udf/lib + PUBLIC_HEADER DESTINATION ${OUTPUT_DIR}/udf/include) + #ADD_BE_TEST(udf_test) #ADD_BE_TEST(uda_test) diff --git a/be/src/udf/udf.cpp b/be/src/udf/udf.cpp index ce671bc55dac57..58ba7b92c944fd 100755 --- a/be/src/udf/udf.cpp +++ b/be/src/udf/udf.cpp @@ -16,6 +16,8 @@ // under the License. #include "udf/udf.h" +#include "common/logging.h" +#include "olap/hll.h" #include #include @@ -363,6 +365,26 @@ StringVal::StringVal(FunctionContext* context, int len) : ptr(context->impl()->allocate_local(len)) { } +bool StringVal::resize(FunctionContext* ctx, int new_len) { + if (new_len <= len) { + len = new_len; + return true; + } + if (UNLIKELY(new_len > StringVal::MAX_LENGTH)) { + len = 0; + is_null = true; + return false; + } + auto* new_ptr = ctx->impl()->allocate_local(new_len); + if (new_ptr != nullptr) { + memcpy(new_ptr, ptr, len); + ptr = new_ptr; + len = new_len; + return true; + } + return false; +} + StringVal StringVal::copy_from(FunctionContext* ctx, const uint8_t* buf, size_t len) { StringVal result(ctx, len); if (!result.is_null) { diff --git a/be/src/udf/udf.h b/be/src/udf/udf.h index 49fe5ddbef7d1c..80a2666c91137e 100755 --- a/be/src/udf/udf.h +++ b/be/src/udf/udf.h @@ -21,8 +21,8 @@ #include #include -#include "common/logging.h" -#include "olap/hll.h" +//#include "common/logging.h" +//#include "olap/hll.h" // This is the only Doris header required to develop UDFs and UDAs. This header // contains the types that need to be used and the FunctionContext object. The context @@ -623,6 +623,8 @@ struct StringVal : public AnyVal { // Creates a StringVal, which memory is avaliable when this funciont context is used next time static StringVal create_temp_string_val(FunctionContext* ctx, int len); + bool resize(FunctionContext* context, int len); + bool operator==(const StringVal& other) const { if (is_null != other.is_null) { return false; diff --git a/build.sh b/build.sh index 0217675cb35a3d..e4eb999ca48946 100755 --- a/build.sh +++ b/build.sh @@ -51,7 +51,7 @@ Usage: $0 --be build Backend --fe build Frontend --clean clean and build target - + Eg. $0 build Backend and Frontend without clean $0 --be build Backend without clean @@ -90,7 +90,7 @@ else BUILD_FE=0 CLEAN=0 RUN_UT=0 - while true; do + while true; do case "$1" in --be) BUILD_BE=1 ; shift ;; --fe) BUILD_FE=1 ; shift ;; @@ -119,7 +119,7 @@ echo "Build generated code" cd ${DORIS_HOME}/gensrc if [ ${CLEAN} -eq 1 ]; then make clean -fi +fi make cd ${DORIS_HOME} @@ -173,11 +173,14 @@ if [ ${BUILD_FE} -eq 1 ]; then fi if [ ${BUILD_BE} -eq 1 ]; then install -d ${DORIS_OUTPUT}/be/bin ${DORIS_OUTPUT}/be/conf \ - ${DORIS_OUTPUT}/be/lib/ + ${DORIS_OUTPUT}/be/lib/ \ + ${DORIS_OUTPUT}/udf/lib ${DORIS_OUTPUT}/udf/include - cp -r -p ${DORIS_HOME}/be/output/bin/* ${DORIS_OUTPUT}/be/bin/ + cp -r -p ${DORIS_HOME}/be/output/bin/* ${DORIS_OUTPUT}/be/bin/ cp -r -p ${DORIS_HOME}/be/output/conf/* ${DORIS_OUTPUT}/be/conf/ cp -r -p ${DORIS_HOME}/be/output/lib/* ${DORIS_OUTPUT}/be/lib/ + cp -r -p ${DORIS_HOME}/be/output/udf/lib/* ${DORIS_OUTPUT}/udf/lib/ + cp -r -p ${DORIS_HOME}/be/output/udf/include/* ${DORIS_OUTPUT}/udf/include/ fi echo "***************************************"