diff options
| author | vvvv <[email protected]> | 2025-10-09 12:25:18 +0300 |
|---|---|---|
| committer | vvvv <[email protected]> | 2025-10-09 12:57:17 +0300 |
| commit | cb77d014972b2cdb27d2e6d979fc3a2772b27ad4 (patch) | |
| tree | 7f3bcd8ce71c6bd0f3ccc11e31b9f665475b819e /yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp | |
| parent | d58a8990d353b051c27e1069141117fdfde64358 (diff) | |
YQL-20086 minikql
commit_hash:e96f7390db5fcbe7e9f64f898141a263ad522daa
Diffstat (limited to 'yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp')
| -rw-r--r-- | yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp b/yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp index e8ac91d3d76..b1692985279 100644 --- a/yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp +++ b/yql/essentials/minikql/comp_nodes/mkql_block_logical.cpp @@ -15,7 +15,6 @@ #include <arrow/array/array_primitive.h> #include <arrow/array/util.h> - namespace NKikimr { namespace NMiniKQL { @@ -143,19 +142,18 @@ private: } // scalar is null -> result is valid _only_ if arr[i] == false - //bitmap = bitmap and not data[i] + // bitmap = bitmap and not data[i] std::shared_ptr<arrow::Buffer> bitmap = ARROW_RESULT(arrow::AllocateBitmap(arr->length, pool)); CompressSparseBitmapNegate(bitmap->mutable_data(), arr->GetValues<ui8>(1), arr->length); if (arr->buffers[0]) { bitmap = ARROW_RESULT(arrow::internal::BitmapAnd(pool, arr->GetValues<ui8>(0, 0), arr->offset, bitmap->data(), 0, arr->length, 0)); } std::shared_ptr<arrow::Buffer> data = CopySparseBitmap(pool, arr->buffers[1], arr->offset, arr->length); - return arrow::ArrayData::Make(arr->type, arr->length, { bitmap, data }); + return arrow::ArrayData::Make(arr->type, arr->length, {bitmap, data}); } arrow::Datum CalcArrayArray(arrow::MemoryPool* pool, const std::shared_ptr<arrow::ArrayData>& arr1, - const std::shared_ptr<arrow::ArrayData>& arr2) const - { + const std::shared_ptr<arrow::ArrayData>& arr2) const { Y_ABORT_UNLESS(arr1->length == arr2->length); auto buf1 = arr1->buffers[0]; auto buf2 = arr2->buffers[0]; @@ -165,10 +163,10 @@ private: std::shared_ptr<arrow::Buffer> bitmap; if (buf1 || buf2) { - bitmap = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); - auto first = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); + bitmap = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); + auto first = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); auto second = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); - CompressSparseBitmap(first->mutable_data(), arr1->GetValues<ui8>(1), length); + CompressSparseBitmap(first->mutable_data(), arr1->GetValues<ui8>(1), length); CompressSparseBitmap(second->mutable_data(), arr2->GetValues<ui8>(1), length); Bitmap v1(first, 0, length); @@ -177,8 +175,8 @@ private: Bitmap b(bitmap, 0, length); std::array<Bitmap, 1> out{b}; - //bitmap = first_false | second_false | (first_true & second_true); - //bitmap = (b1 & ~v1) | (b2 & ~v2) | (b1 & v1 & b2 & v2) + // bitmap = first_false | second_false | (first_true & second_true); + // bitmap = (b1 & ~v1) | (b2 & ~v2) | (b1 & v1 & b2 & v2) if (buf1 && buf2) { Bitmap b1(buf1, offset1, length); Bitmap b2(buf2, offset2, length); @@ -215,7 +213,7 @@ private: } std::shared_ptr<arrow::Buffer> data = ARROW_RESULT(arrow::AllocateBuffer(length, pool)); AndSparseBitmaps(data->mutable_data(), arr1->GetValues<ui8>(1), arr2->GetValues<ui8>(1), length); - return arrow::ArrayData::Make(arr1->type, length, { bitmap, data }); + return arrow::ArrayData::Make(arr1->type, length, {bitmap, data}); } }; @@ -304,20 +302,18 @@ private: } // scalar is null -> result is valid _only_ if arr[i] == true - //bitmap = bitmap and data[i] + // bitmap = bitmap and data[i] std::shared_ptr<arrow::Buffer> bitmap = ARROW_RESULT(arrow::AllocateBitmap(arr->length, pool)); CompressSparseBitmap(bitmap->mutable_data(), arr->GetValues<ui8>(1), arr->length); if (arr->buffers[0]) { bitmap = ARROW_RESULT(arrow::internal::BitmapAnd(pool, arr->GetValues<ui8>(0, 0), arr->offset, bitmap->data(), 0, arr->length, 0)); } std::shared_ptr<arrow::Buffer> data = CopySparseBitmap(pool, arr->buffers[1], arr->offset, arr->length); - return arrow::ArrayData::Make(arr->type, arr->length, { bitmap, data }); + return arrow::ArrayData::Make(arr->type, arr->length, {bitmap, data}); } - arrow::Datum CalcArrayArray(arrow::MemoryPool* pool, const std::shared_ptr<arrow::ArrayData>& arr1, - const std::shared_ptr<arrow::ArrayData>& arr2) const - { + const std::shared_ptr<arrow::ArrayData>& arr2) const { Y_ABORT_UNLESS(arr1->length == arr2->length); auto buf1 = arr1->buffers[0]; auto buf2 = arr2->buffers[0]; @@ -330,7 +326,7 @@ private: bitmap = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); auto first = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); auto second = ARROW_RESULT(arrow::AllocateBitmap(length, pool)); - CompressSparseBitmap(first->mutable_data(), arr1->GetValues<ui8>(1), length); + CompressSparseBitmap(first->mutable_data(), arr1->GetValues<ui8>(1), length); CompressSparseBitmap(second->mutable_data(), arr2->GetValues<ui8>(1), length); Bitmap v1(first, 0, length); @@ -339,8 +335,8 @@ private: Bitmap b(bitmap, 0, length); std::array<Bitmap, 1> out{b}; - //bitmap = first_true | second_true | (first_false & second_false); - //bitmap = (b1 & v1) | (b2 & v2) | (b1 & ~v1 & b2 & ~v2) + // bitmap = first_true | second_true | (first_false & second_false); + // bitmap = (b1 & v1) | (b2 & v2) | (b1 & ~v1 & b2 & ~v2) if (buf1 && buf2) { Bitmap b1(buf1, offset1, length); Bitmap b2(buf2, offset2, length); @@ -377,7 +373,7 @@ private: } std::shared_ptr<arrow::Buffer> data = ARROW_RESULT(arrow::AllocateBuffer(length, pool)); OrSparseBitmaps(data->mutable_data(), arr1->GetValues<ui8>(1), arr2->GetValues<ui8>(1), length); - return arrow::ArrayData::Make(arr1->type, length, { bitmap, data }); + return arrow::ArrayData::Make(arr1->type, length, {bitmap, data}); } }; @@ -440,12 +436,11 @@ private: std::shared_ptr<arrow::Buffer> bitmap = CopyBitmap(pool, arr->buffers[0], arr->offset, arr->length); std::shared_ptr<arrow::Buffer> data = ARROW_RESULT(arrow::AllocateBuffer(arr->length, pool)); XorSparseBitmapScalar(data->mutable_data(), value, arr->GetValues<ui8>(1), arr->length); - return arrow::ArrayData::Make(arr->type, arr->length, { bitmap, data }); + return arrow::ArrayData::Make(arr->type, arr->length, {bitmap, data}); } arrow::Datum CalcArrayArray(arrow::MemoryPool* pool, const std::shared_ptr<arrow::ArrayData>& arr1, - const std::shared_ptr<arrow::ArrayData>& arr2) const - { + const std::shared_ptr<arrow::ArrayData>& arr2) const { Y_ABORT_UNLESS(arr1->length == arr2->length); auto b1 = arr1->buffers[0]; auto b2 = arr2->buffers[0]; @@ -461,7 +456,7 @@ private: } std::shared_ptr<arrow::Buffer> data = ARROW_RESULT(arrow::AllocateBuffer(length, pool)); XorSparseBitmaps(data->mutable_data(), arr1->GetValues<ui8>(1), arr2->GetValues<ui8>(1), length); - return arrow::ArrayData::Make(arr1->type, length, { bitmap, data }); + return arrow::ArrayData::Make(arr1->type, length, {bitmap, data}); } }; @@ -480,9 +475,10 @@ public: *res = input; } else { auto bitmap = CopyBitmap(ctx->memory_pool(), arr.buffers[0], arr.offset, arr.length); - std::shared_ptr<arrow::Buffer> data = ARROW_RESULT(arrow::AllocateBuffer(arr.length, ctx->memory_pool()));; + std::shared_ptr<arrow::Buffer> data = ARROW_RESULT(arrow::AllocateBuffer(arr.length, ctx->memory_pool())); + ; NegateSparseBitmap(data->mutable_data(), arr.GetValues<ui8>(1), arr.length); - *res = arrow::ArrayData::Make(arr.type, arr.length, { bitmap, data }); + *res = arrow::ArrayData::Make(arr.type, arr.length, {bitmap, data}); } return arrow::Status::OK(); @@ -495,9 +491,9 @@ std::shared_ptr<arrow::compute::ScalarKernel> MakeKernel(const TVector<TType*>& MKQL_ENSURE(ConvertArrowType(AS_TYPE(TBlockType, resultType)->GetItemType(), returnArrowType), "Unsupported arrow type"); auto exec = std::make_shared<TExec>(); auto kernel = std::make_shared<arrow::compute::ScalarKernel>(ConvertToInputTypes(argTypes), ConvertToOutputType(resultType), - [exec](arrow::compute::KernelContext* ctx, const arrow::compute::ExecBatch& batch, arrow::Datum* res) { - return exec->Exec(ctx, batch, res); - }); + [exec](arrow::compute::KernelContext* ctx, const arrow::compute::ExecBatch& batch, arrow::Datum* res) { + return exec->Exec(ctx, batch, res); + }); kernel->null_handling = arrow::compute::NullHandling::COMPUTED_NO_PREALLOCATE; return kernel; @@ -517,8 +513,8 @@ IComputationNode* WrapBlockLogical(std::string_view name, TCallable& callable, c auto compute1 = LocateNode(ctx.NodeLocator, callable, 0); auto compute2 = LocateNode(ctx.NodeLocator, callable, 1); - TComputationNodePtrVector argsNodes = { compute1, compute2 }; - TVector<TType*> argsTypes = { callable.GetInput(0).GetStaticType(), callable.GetInput(1).GetStaticType() }; + TComputationNodePtrVector argsNodes = {compute1, compute2}; + TVector<TType*> argsTypes = {callable.GetInput(0).GetStaticType(), callable.GetInput(1).GetStaticType()}; std::shared_ptr<arrow::compute::ScalarKernel> kernel; if (name == "And") { @@ -555,13 +551,12 @@ IComputationNode* WrapBlockNot(TCallable& callable, const TComputationNodeFactor "Requires boolean args."); auto compute = LocateNode(ctx.NodeLocator, callable, 0); - TComputationNodePtrVector argsNodes = { compute }; - TVector<TType*> argsTypes = { callable.GetInput(0).GetStaticType() }; + TComputationNodePtrVector argsNodes = {compute}; + TVector<TType*> argsTypes = {callable.GetInput(0).GetStaticType()}; auto kernel = MakeKernel<TNotBlockExec>(argsTypes, argsTypes[0]); return new TBlockFuncNode(ctx.Mutables, ToDatumValidateMode(ctx.ValidateMode), "Not", std::move(argsNodes), argsTypes, callable.GetType()->GetReturnType(), *kernel, kernel); } - -} -} +} // namespace NMiniKQL +} // namespace NKikimr |
