aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-05-02 11:58:24 +0300
committervvvv <vvvv@ydb.tech>2023-05-02 11:58:24 +0300
commit625fcf76cf864730295fbf638b88ebef2dddd3e4 (patch)
treef9a19c1ea65334453a74e74f9a423c7fcbf5ee05
parentb654d995830b11f09b4ba6dcd3c815add8a50093 (diff)
downloadydb-625fcf76cf864730295fbf638b88ebef2dddd3e4.tar.gz
Tests for string PG kernels
-rw-r--r--ydb/library/yql/parser/pg_wrapper/CMakeLists.darwin-x86_64.txt1
-rw-r--r--ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-x86_64.txt1
-rw-r--r--ydb/library/yql/parser/pg_wrapper/CMakeLists.windows-x86_64.txt1
-rw-r--r--ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp96
-rw-r--r--ydb/library/yql/parser/pg_wrapper/arena_ctx.h24
-rw-r--r--ydb/library/yql/parser/pg_wrapper/arrow.h5
-rw-r--r--ydb/library/yql/parser/pg_wrapper/parser.cpp86
-rw-r--r--ydb/library/yql/parser/pg_wrapper/ut/codegen_ut.cpp228
9 files changed, 283 insertions, 160 deletions
diff --git a/ydb/library/yql/parser/pg_wrapper/CMakeLists.darwin-x86_64.txt b/ydb/library/yql/parser/pg_wrapper/CMakeLists.darwin-x86_64.txt
index 72c6e0c44c..84678ff368 100644
--- a/ydb/library/yql/parser/pg_wrapper/CMakeLists.darwin-x86_64.txt
+++ b/ydb/library/yql/parser/pg_wrapper/CMakeLists.darwin-x86_64.txt
@@ -128,6 +128,7 @@ target_link_libraries(yql-parser-pg_wrapper PUBLIC
OpenSSL::OpenSSL
)
target_sources(yql-parser-pg_wrapper PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/parser.cpp
diff --git a/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-aarch64.txt b/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-aarch64.txt
index b16ecbe2e8..6ed349d3a1 100644
--- a/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-aarch64.txt
+++ b/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-aarch64.txt
@@ -127,6 +127,7 @@ target_link_libraries(yql-parser-pg_wrapper PUBLIC
OpenSSL::OpenSSL
)
target_sources(yql-parser-pg_wrapper PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/parser.cpp
diff --git a/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-x86_64.txt b/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-x86_64.txt
index 58e4727d26..9067668235 100644
--- a/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-x86_64.txt
+++ b/ydb/library/yql/parser/pg_wrapper/CMakeLists.linux-x86_64.txt
@@ -129,6 +129,7 @@ target_link_libraries(yql-parser-pg_wrapper PUBLIC
OpenSSL::OpenSSL
)
target_sources(yql-parser-pg_wrapper PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/parser.cpp
diff --git a/ydb/library/yql/parser/pg_wrapper/CMakeLists.windows-x86_64.txt b/ydb/library/yql/parser/pg_wrapper/CMakeLists.windows-x86_64.txt
index 0e1d5a27f8..4a83ff5250 100644
--- a/ydb/library/yql/parser/pg_wrapper/CMakeLists.windows-x86_64.txt
+++ b/ydb/library/yql/parser/pg_wrapper/CMakeLists.windows-x86_64.txt
@@ -145,6 +145,7 @@ target_link_libraries(yql-parser-pg_wrapper PUBLIC
OpenSSL::OpenSSL
)
target_sources(yql-parser-pg_wrapper PRIVATE
+ ${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/arrow_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/parser.cpp
diff --git a/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp b/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp
new file mode 100644
index 0000000000..4ca471c3e6
--- /dev/null
+++ b/ydb/library/yql/parser/pg_wrapper/arena_ctx.cpp
@@ -0,0 +1,96 @@
+#include "arena_ctx.h"
+
+#define TypeName PG_TypeName
+#define SortBy PG_SortBy
+#undef SIZEOF_SIZE_T
+extern "C" {
+#include "postgres.h"
+#include "nodes/memnodes.h"
+#include "utils/memutils.h"
+}
+
+namespace NYql {
+
+void *MyAllocSetAlloc(MemoryContext context, Size size) {
+ auto fullSize = size + MAXIMUM_ALIGNOF - 1 + sizeof(void*);
+ auto ptr = TArenaMemoryContext::GetCurrentPool().Allocate(fullSize);
+ auto aligned = (void*)MAXALIGN(ptr + sizeof(void*));
+ *(MemoryContext *)(((char *)aligned) - sizeof(void *)) = context;
+ return aligned;
+}
+
+void MyAllocSetFree(MemoryContext context, void* pointer) {
+}
+
+void* MyAllocSetRealloc(MemoryContext context, void* pointer, Size size) {
+ if (!size) {
+ return nullptr;
+ }
+
+ void* ret = MyAllocSetAlloc(context, size);
+ if (pointer) {
+ memmove(ret, pointer, size);
+ }
+
+ return ret;
+}
+
+void MyAllocSetReset(MemoryContext context) {
+}
+
+void MyAllocSetDelete(MemoryContext context) {
+}
+
+Size MyAllocSetGetChunkSpace(MemoryContext context, void* pointer) {
+ return 0;
+}
+
+bool MyAllocSetIsEmpty(MemoryContext context) {
+ return false;
+}
+
+void MyAllocSetStats(MemoryContext context,
+ MemoryStatsPrintFunc printfunc, void *passthru,
+ MemoryContextCounters *totals,
+ bool print_to_stderr) {
+}
+
+void MyAllocSetCheck(MemoryContext context) {
+}
+
+const MemoryContextMethods MyMethods = {
+ MyAllocSetAlloc,
+ MyAllocSetFree,
+ MyAllocSetRealloc,
+ MyAllocSetReset,
+ MyAllocSetDelete,
+ MyAllocSetGetChunkSpace,
+ MyAllocSetIsEmpty,
+ MyAllocSetStats
+#ifdef MEMORY_CONTEXT_CHECKING
+ ,MyAllocSetCheck
+#endif
+};
+
+__thread TArenaMemoryContext* TArenaMemoryContext::Current = nullptr;
+
+TArenaMemoryContext::TArenaMemoryContext() {
+ Prev = Current;
+ Current = this;
+ PrevContext = CurrentMemoryContext;
+
+ CurrentMemoryContext = (MemoryContext)malloc(sizeof(MemoryContextData));
+ MemoryContextCreate(CurrentMemoryContext,
+ T_AllocSetContext,
+ &MyMethods,
+ nullptr,
+ "arena");
+}
+
+TArenaMemoryContext::~TArenaMemoryContext() {
+ free(CurrentMemoryContext);
+ CurrentMemoryContext = PrevContext;
+ Current = Prev;
+}
+
+}
diff --git a/ydb/library/yql/parser/pg_wrapper/arena_ctx.h b/ydb/library/yql/parser/pg_wrapper/arena_ctx.h
new file mode 100644
index 0000000000..f7b98999c5
--- /dev/null
+++ b/ydb/library/yql/parser/pg_wrapper/arena_ctx.h
@@ -0,0 +1,24 @@
+#pragma once
+#include <util/memory/segmented_string_pool.h>
+
+struct MemoryContextData;
+typedef struct MemoryContextData *MemoryContext;
+
+namespace NYql {
+
+class TArenaMemoryContext {
+public:
+ TArenaMemoryContext();
+ ~TArenaMemoryContext();
+ static segmented_string_pool& GetCurrentPool() {
+ return Current->Pool;
+ }
+
+private:
+ segmented_string_pool Pool;
+ static __thread TArenaMemoryContext* Current;
+ TArenaMemoryContext* Prev = nullptr;
+ MemoryContext PrevContext = nullptr;
+};
+
+}
diff --git a/ydb/library/yql/parser/pg_wrapper/arrow.h b/ydb/library/yql/parser/pg_wrapper/arrow.h
index 02db8daca5..b93b73e589 100644
--- a/ydb/library/yql/parser/pg_wrapper/arrow.h
+++ b/ydb/library/yql/parser/pg_wrapper/arrow.h
@@ -6,6 +6,8 @@
#include <ydb/library/yql/minikql/mkql_type_builder.h>
#include <ydb/library/yql/minikql/arrow/arrow_util.h>
+#include "arena_ctx.h"
+
extern "C" {
#include "postgres.h"
#include "fmgr.h"
@@ -244,7 +246,7 @@ Y_NO_INLINE arrow::Datum GenericExecImpl(const arrow::compute::ExecBatch& batch,
builder.Add(NUdf::TBlockItem{});
} else {
auto ptr = (const char*)ret;
- auto len = state.IsCStringResult ? 1 + strlen(ptr) : VARSIZE((const text*)ptr);
+ auto len = state.IsCStringResult ? 1 + strlen(ptr) : VARHDRSZ + VARSIZE((const text*)ptr);
builder.Add(NUdf::TBlockItem(NUdf::TStringRef(ptr, len)));
}
}
@@ -354,6 +356,7 @@ Y_NO_INLINE arrow::Status GenericExec(arrow::compute::KernelContext* ctx, const
Y_ENSURE(hasArrays);
Y_ENSURE(state.flinfo->fn_strict == IsStrict);
Y_ENSURE(state.IsFixedResult == IsFixedResult);
+ TArenaMemoryContext arena;
GenericExecImpl2<TFunc, IsStrict, IsFixedResult, TArgsPolicy>(hasScalars, hasNulls, ctx, batch, length, state, res);
return arrow::Status::OK();
}
diff --git a/ydb/library/yql/parser/pg_wrapper/parser.cpp b/ydb/library/yql/parser/pg_wrapper/parser.cpp
index 4dbee8cd7d..bff1b533bb 100644
--- a/ydb/library/yql/parser/pg_wrapper/parser.cpp
+++ b/ydb/library/yql/parser/pg_wrapper/parser.cpp
@@ -1,7 +1,7 @@
#include "parser.h"
+#include "arena_ctx.h"
#include <util/generic/scope.h>
-#include <util/memory/segmented_string_pool.h>
#include <fcntl.h>
#include <stdint.h>
@@ -157,73 +157,6 @@ void pg_query_free_error(PgQueryError *error) {
free(error);
}
-struct TAlloc {
- segmented_string_pool Pool;
-};
-
-__thread TAlloc* CurrentAlloc;
-
-void *MyAllocSetAlloc(MemoryContext context, Size size) {
- auto fullSize = size + MAXIMUM_ALIGNOF - 1 + sizeof(void*);
- auto ptr = CurrentAlloc->Pool.Allocate(fullSize);
- auto aligned = (void*)MAXALIGN(ptr + sizeof(void*));
- *(MemoryContext *)(((char *)aligned) - sizeof(void *)) = context;
- return aligned;
-}
-
-void MyAllocSetFree(MemoryContext context, void* pointer) {
-}
-
-void* MyAllocSetRealloc(MemoryContext context, void* pointer, Size size) {
- if (!size) {
- return nullptr;
- }
-
- void* ret = MyAllocSetAlloc(context, size);
- if (pointer) {
- memmove(ret, pointer, size);
- }
-
- return ret;
-}
-
-void MyAllocSetReset(MemoryContext context) {
-}
-
-void MyAllocSetDelete(MemoryContext context) {
-}
-
-Size MyAllocSetGetChunkSpace(MemoryContext context, void* pointer) {
- return 0;
-}
-
-bool MyAllocSetIsEmpty(MemoryContext context) {
- return false;
-}
-
-void MyAllocSetStats(MemoryContext context,
- MemoryStatsPrintFunc printfunc, void *passthru,
- MemoryContextCounters *totals,
- bool print_to_stderr) {
-}
-
-void MyAllocSetCheck(MemoryContext context) {
-}
-
-const MemoryContextMethods MyMethods = {
- MyAllocSetAlloc,
- MyAllocSetFree,
- MyAllocSetRealloc,
- MyAllocSetReset,
- MyAllocSetDelete,
- MyAllocSetGetChunkSpace,
- MyAllocSetIsEmpty,
- MyAllocSetStats
-#ifdef MEMORY_CONTEXT_CHECKING
- ,MyAllocSetCheck
-#endif
-};
-
}
namespace NYql {
@@ -242,29 +175,14 @@ void PGParse(const TString& input, IPGParseEvents& events) {
PgQueryInternalParsetreeAndError parsetree_and_error;
- auto prevCurrentMemoryContext = CurrentMemoryContext;
+ TArenaMemoryContext arena;
auto prevErrorContext = ErrorContext;
-
- CurrentMemoryContext = (MemoryContext)malloc(sizeof(MemoryContextData));
- MemoryContextCreate(CurrentMemoryContext,
- T_AllocSetContext,
- &MyMethods,
- nullptr,
- "parser");
ErrorContext = CurrentMemoryContext;
Y_DEFER {
- free(CurrentMemoryContext);
- CurrentMemoryContext = prevCurrentMemoryContext;
ErrorContext = prevErrorContext;
};
- TAlloc alloc;
- CurrentAlloc = &alloc;
- Y_DEFER {
- CurrentAlloc = nullptr;
- };
-
parsetree_and_error = pg_query_raw_parse(input.c_str());
Y_DEFER {
if (parsetree_and_error.error) {
diff --git a/ydb/library/yql/parser/pg_wrapper/ut/codegen_ut.cpp b/ydb/library/yql/parser/pg_wrapper/ut/codegen_ut.cpp
index aa7d1f0357..18d18a0752 100644
--- a/ydb/library/yql/parser/pg_wrapper/ut/codegen_ut.cpp
+++ b/ydb/library/yql/parser/pg_wrapper/ut/codegen_ut.cpp
@@ -5,6 +5,7 @@
#include <arrow/compute/kernel.h>
#include <arrow/array/builder_primitive.h>
+#include <arrow/array/builder_binary.h>
#include <llvm/IR/Module.h>
@@ -24,7 +25,7 @@ using namespace NYql;
using namespace NYql::NCodegen;
extern "C" {
-extern TExecFunc arrow_date_eq();
+#include <ydb/library/yql/parser/pg_wrapper/pg_kernels_fwd.inc>
}
enum class EKernelFlavor {
@@ -35,23 +36,28 @@ enum class EKernelFlavor {
};
Y_UNIT_TEST_SUITE(TPgCodegen) {
- void PgFuncImpl(EKernelFlavor flavor, bool constArg) {
+ void PgFuncImpl(EKernelFlavor flavor, bool constArg, bool fixed) {
+ const TString& name = fixed ? "date_eq" : "textout";
TExecFunc execFunc;
ICodegen::TPtr codegen;
switch (flavor) {
case EKernelFlavor::DefArg: {
- execFunc = &GenericExec<TPgDirectFunc<&date_eq>, true, true, TDefaultArgsPolicy>;
+ if (fixed) {
+ execFunc = &GenericExec<TPgDirectFunc<&date_eq>, true, true, TDefaultArgsPolicy>;
+ } else {
+ execFunc = &GenericExec<TPgDirectFunc<&textout>, true, false, TDefaultArgsPolicy>;
+ }
break;
}
case EKernelFlavor::Cpp: {
- execFunc = arrow_date_eq();
+ execFunc = fixed ? arrow_date_eq() : arrow_textout();
break;
}
case EKernelFlavor::BitCode: {
codegen = ICodegen::Make(ETarget::Native);
- auto bitcode = NResource::Find("/llvm_bc/PgFuncs1");
+ auto bitcode = NResource::Find(fixed ? "/llvm_bc/PgFuncs1" : "/llvm_bc/PgFuncs3");
codegen->LoadBitCode(bitcode, "Funcs");
- auto func = codegen->GetModule().getFunction("arrow_date_eq");
+ auto func = codegen->GetModule().getFunction(std::string("arrow_" + name));
codegen->AddGlobalMapping("GetPGKernelState", (const void*)&GetPGKernelState);
codegen->Verify();
codegen->ExportSymbol(func);
@@ -63,46 +69,68 @@ Y_UNIT_TEST_SUITE(TPgCodegen) {
break;
}
case EKernelFlavor::Ideal: {
- execFunc = [](arrow::compute::KernelContext* ctx, const arrow::compute::ExecBatch& batch, arrow::Datum* res) {
- size_t length = batch.values[0].length();
- //NUdf::TFixedSizeArrayBuilder<ui64, true> builder(NKikimr::NMiniKQL::TTypeInfoHelper(), arrow::uint64(), *arrow::default_memory_pool(), length);
- NUdf::TTypedBufferBuilder<ui64> dataBuilder(arrow::default_memory_pool());
- NUdf::TTypedBufferBuilder<ui8> nullBuilder(arrow::default_memory_pool());
- dataBuilder.Reserve(length);
- nullBuilder.Reserve(length);
- auto out = dataBuilder.MutableData();
- auto outNulls = nullBuilder.MutableData();
- NUdf::TFixedSizeBlockReader<ui64, false> reader1;
- NUdf::TFixedSizeBlockReader<ui64, false> reader2;
- const auto& array1 = *batch.values[0].array();
- const auto ptr1 = array1.GetValues<ui64>(1);
- if (batch.values[1].is_array()) {
- const auto& array2 = *batch.values[1].array();
- const auto ptr2 = array2.GetValues<ui64>(1);
- for (size_t i = 0; i < length; ++i) {
- //auto x = reader1.GetItem(array1, i).As<ui64>();
- //auto y = reader2.GetItem(array2, i).As<ui64>();
- auto x = ptr1[i];
- auto y = ptr2[i];
- out[i] = x == y ? 1 : 0;
- outNulls[i] = false;
+ if (fixed) {
+ execFunc = [](arrow::compute::KernelContext* ctx, const arrow::compute::ExecBatch& batch, arrow::Datum* res) {
+ size_t length = batch.values[0].length();
+ //NUdf::TFixedSizeArrayBuilder<ui64, true> builder(NKikimr::NMiniKQL::TTypeInfoHelper(), arrow::uint64(), *arrow::default_memory_pool(), length);
+ NUdf::TTypedBufferBuilder<ui64> dataBuilder(arrow::default_memory_pool());
+ NUdf::TTypedBufferBuilder<ui8> nullBuilder(arrow::default_memory_pool());
+ dataBuilder.Reserve(length);
+ nullBuilder.Reserve(length);
+ auto out = dataBuilder.MutableData();
+ auto outNulls = nullBuilder.MutableData();
+ NUdf::TFixedSizeBlockReader<ui64, false> reader1;
+ NUdf::TFixedSizeBlockReader<ui64, false> reader2;
+ const auto& array1 = *batch.values[0].array();
+ const auto ptr1 = array1.GetValues<ui64>(1);
+ if (batch.values[1].is_array()) {
+ const auto& array2 = *batch.values[1].array();
+ const auto ptr2 = array2.GetValues<ui64>(1);
+ for (size_t i = 0; i < length; ++i) {
+ //auto x = reader1.GetItem(array1, i).As<ui64>();
+ //auto y = reader2.GetItem(array2, i).As<ui64>();
+ auto x = ptr1[i];
+ auto y = ptr2[i];
+ out[i] = x == y ? 1 : 0;
+ outNulls[i] = false;
+ }
+ } else {
+ ui64 yConst = reader2.GetScalarItem(*batch.values[1].scalar()).As<ui64>();
+ for (size_t i = 0; i < length; ++i) {
+ auto x = ptr1[i];
+ out[i] = x == yConst ? 1 : 0;
+ outNulls[i] = false;
+ }
}
- } else {
- ui64 yConst = reader2.GetScalarItem(*batch.values[1].scalar()).As<ui64>();
+
+ std::shared_ptr<arrow::Buffer> nulls;
+ nulls = nullBuilder.Finish();
+ nulls = NUdf::MakeDenseBitmap(nulls->data(), length, arrow::default_memory_pool());
+ std::shared_ptr<arrow::Buffer> data = dataBuilder.Finish();
+
+ *res = arrow::ArrayData::Make(arrow::uint64(), length ,{ data, nulls});
+ return arrow::Status::OK();
+ };
+ } else {
+ execFunc = [](arrow::compute::KernelContext* ctx, const arrow::compute::ExecBatch& batch, arrow::Datum* res) {
+ size_t length = batch.values[0].length();
+ NUdf::TStringArrayBuilder<arrow::BinaryType, true, NUdf::EPgStringType::None> builder(NKikimr::NMiniKQL::TTypeInfoHelper(), arrow::binary(), *ctx->memory_pool(), length);
+ NUdf::TStringBlockReader<arrow::BinaryType, true> reader;
+ const auto& array = *batch.values[0].array();
for (size_t i = 0; i < length; ++i) {
- auto x = ptr1[i];
- out[i] = x == yConst ? 1 : 0;
- outNulls[i] = false;
+ auto item = reader.GetItem(array, i);
+ if (!item) {
+ builder.Add(NUdf::TBlockItem{});
+ } else {
+ auto s = item.AsStringRef();
+ size_t len = s.Size() - VARHDRSZ;
+ const char* ptr = s.Data() + VARHDRSZ;
+ builder.Add(NUdf::TBlockItem{NUdf::TStringRef(ptr, len)});
+ }
}
- }
- std::shared_ptr<arrow::Buffer> nulls;
- nulls = nullBuilder.Finish();
- nulls = NUdf::MakeDenseBitmap(nulls->data(), length, arrow::default_memory_pool());
- std::shared_ptr<arrow::Buffer> data = dataBuilder.Finish();
-
- *res = arrow::ArrayData::Make(arrow::uint64(), length ,{ data, nulls});
- return arrow::Status::OK();
+ return arrow::Status::OK();
+ };
};
break;
@@ -116,66 +144,116 @@ Y_UNIT_TEST_SUITE(TPgCodegen) {
kernelCtx.SetState(&state);
FmgrInfo finfo;
Zero(finfo);
- fmgr_info(NPg::LookupProc("date_eq", { 0, 0}).ProcId, &finfo);
+ if (fixed) {
+ fmgr_info(NPg::LookupProc("date_eq", { 0, 0}).ProcId, &finfo);
+ } else {
+ fmgr_info(NPg::LookupProc("textout", { 0} ).ProcId, &finfo);
+ }
+
state.flinfo = &finfo;
state.context = nullptr;
state.resultinfo = nullptr;
state.fncollation = DEFAULT_COLLATION_OID;
- state.IsCStringResult = false;
- state.IsFixedResult = true;
- state.IsFixedArg.push_back(true);
- state.IsFixedArg.push_back(true);
- const size_t N = 10000;
- arrow::UInt64Builder builder;
- ARROW_OK(builder.Reserve(N));
- for (size_t i = 0; i < N; ++i) {
- builder.UnsafeAppend(i);
+ state.IsCStringResult = true;
+ if (fixed) {
+ state.IsFixedResult = true;
+ state.IsFixedArg.push_back(true);
+ state.IsFixedArg.push_back(true);
+ } else {
+ state.IsFixedResult = false;
+ state.IsFixedArg.push_back(false);
}
- std::shared_ptr<arrow::ArrayData> out;
- ARROW_OK(builder.FinishInternal(&out));
- arrow::Datum arg1(out), arg2;
- if (constArg) {
- Cout << "with const arg\n";
- arg2 = NKikimr::NMiniKQL::MakeScalarDatum<ui64>(0);
+ const size_t N = 10000;
+ std::vector<arrow::Datum> batchArgs;
+ if (fixed) {
+ arrow::UInt64Builder builder;
+ ARROW_OK(builder.Reserve(N));
+ for (size_t i = 0; i < N; ++i) {
+ builder.UnsafeAppend(i);
+ }
+
+ std::shared_ptr<arrow::ArrayData> out;
+ ARROW_OK(builder.FinishInternal(&out));
+ arrow::Datum arg1(out), arg2;
+ if (constArg) {
+ Cout << "with const arg\n";
+ arg2 = NKikimr::NMiniKQL::MakeScalarDatum<ui64>(0);
+ } else {
+ arg2 = out;
+ }
+
+ batchArgs.push_back(arg1);
+ batchArgs.push_back(arg2);
} else {
- arg2 = out;
+ arrow::BinaryBuilder builder;
+ ARROW_OK(builder.Reserve(N));
+ for (size_t i = 0; i < N; ++i) {
+ std::string s(VARHDRSZ + 500, 'A' + i % 26);
+ auto t = (text*)s.data();
+ SET_VARSIZE(t, VARHDRSZ + 500);
+ builder.Append(s);
+ }
+
+ std::shared_ptr<arrow::ArrayData> out;
+ ARROW_OK(builder.FinishInternal(&out));
+ arrow::Datum arg1(out);
+ batchArgs.push_back(arg1);
}
+ arrow::compute::ExecBatch batch(std::move(batchArgs), N);
+
{
Cout << "begin...\n";
TSimpleTimer timer;
- for (size_t count = 0; count < 10000; ++count) {
- arrow::compute::ExecBatch batch({ arg1, arg2}, N);
+ for (size_t count = 0; count < (fixed ? 10000 : 1000); ++count) {
arrow::Datum res;
ARROW_OK(execFunc(&kernelCtx, batch, &res));
- Y_ENSURE(res.is_array());
- Y_ENSURE(res.array()->length == N);
+ Y_ENSURE(res.length() == N);
}
Cout << "done, elapsed: " << timer.Get() << "\n";
}
}
- Y_UNIT_TEST(PgFuncIdeal) {
- PgFuncImpl(EKernelFlavor::Ideal, false);
- PgFuncImpl(EKernelFlavor::Ideal, true);
+ Y_UNIT_TEST(PgFixedFuncIdeal) {
+ PgFuncImpl(EKernelFlavor::Ideal, false, true);
+ PgFuncImpl(EKernelFlavor::Ideal, true, true);
+ }
+
+ Y_UNIT_TEST(PgFixedFuncCpp) {
+ PgFuncImpl(EKernelFlavor::Cpp, false, true);
+ PgFuncImpl(EKernelFlavor::Cpp, true, true);
+ }
+
+ Y_UNIT_TEST(PgFixedFuncDefArg) {
+ PgFuncImpl(EKernelFlavor::DefArg, false, true);
+ PgFuncImpl(EKernelFlavor::DefArg, true, true);
}
- Y_UNIT_TEST(PgFuncCpp) {
- PgFuncImpl(EKernelFlavor::Cpp, false);
- PgFuncImpl(EKernelFlavor::Cpp, true);
+#if defined(NDEBUG) && !defined(_asan_enabled_)
+ Y_UNIT_TEST(PgFixedFuncBC) {
+ PgFuncImpl(EKernelFlavor::BitCode, false, true);
+ PgFuncImpl(EKernelFlavor::BitCode, true, true);
}
+#endif
+
+ Y_UNIT_TEST(PgStrFuncIdeal) {
+ PgFuncImpl(EKernelFlavor::DefArg, false, false);
+ }
- Y_UNIT_TEST(PgFuncDefArg) {
- PgFuncImpl(EKernelFlavor::DefArg, false);
- PgFuncImpl(EKernelFlavor::DefArg, true);
+ Y_UNIT_TEST(PgStrFuncCpp) {
+ PgFuncImpl(EKernelFlavor::Cpp, false, false);
+ }
+
+ Y_UNIT_TEST(PgStrFuncDefArg) {
+ PgFuncImpl(EKernelFlavor::DefArg, false, false);
}
#if defined(NDEBUG) && !defined(_asan_enabled_)
- Y_UNIT_TEST(PgFuncBC) {
- PgFuncImpl(EKernelFlavor::BitCode, false);
- PgFuncImpl(EKernelFlavor::BitCode, true);
+ Y_UNIT_TEST(PgStrFuncBC) {
+ PgFuncImpl(EKernelFlavor::BitCode, false, false);
}
#endif
+
}