aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/mkql_function_metadata.cpp
blob: 0d9e821b9512cb03a577710086e844e92143cddc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "mkql_function_metadata.h"

namespace NKikimr {

namespace NMiniKQL {

TKernelFamilyBase::TKernelFamilyBase(const arrow::compute::FunctionOptions* functionOptions)
    : TKernelFamily(functionOptions)
{}

const TKernel* TKernelFamilyBase::FindKernel(const NUdf::TDataTypeId* argTypes, size_t argTypesCount, NUdf::TDataTypeId returnType) const {
    std::vector<NUdf::TDataTypeId> args(argTypes, argTypes + argTypesCount);
    auto it = KernelMap.find({ args, returnType });
    if (it == KernelMap.end()) {
        return nullptr;
    }

    return it->second.get();
}

TVector<const TKernel*> TKernelFamilyBase::GetAllKernels() const {
    TVector<const TKernel*> ret;
    for (const auto& k : KernelMap) {
        ret.emplace_back(k.second.get());
    }

    return ret;
}

void TKernelFamilyBase::Adopt(const std::vector<NUdf::TDataTypeId>& argTypes, NUdf::TDataTypeId returnType, std::unique_ptr<TKernel>&& kernel) {
    KernelMap.emplace(std::make_pair(argTypes, returnType), std::move(kernel));
}

}
}