Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions be/src/udf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
22 changes: 22 additions & 0 deletions be/src/udf/udf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// under the License.

#include "udf/udf.h"
#include "common/logging.h"
#include "olap/hll.h"

#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions be/src/udf/udf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include <boost/cstdint.hpp>
#include <string.h>

#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
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 8 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Usage: $0 <options>
--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
Expand Down Expand Up @@ -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 ;;
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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 "***************************************"
Expand Down