blob: aab5caced961abaa3dc9a2b778b0654fa4e8869e (
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
36
37
38
39
40
41
42
43
|
#include "mkql_now.h"
#include <yql/essentials/minikql/computation/mkql_computation_node_holders.h>
#include <yql/essentials/minikql/mkql_node_cast.h>
namespace NKikimr {
namespace NMiniKQL {
namespace {
class TNowWrapper : public TMutableComputationNode<TNowWrapper> {
typedef TMutableComputationNode<TNowWrapper> TBaseComputation;
public:
TNowWrapper(TComputationMutables& mutables, TComputationNodePtrVector&& dependentNodes)
: TBaseComputation(mutables)
, DependentNodes(dependentNodes)
{
}
NUdf::TUnboxedValuePod DoCalculate(TComputationContext& ctx) const {
return NUdf::TUnboxedValuePod(ctx.TimeProvider.Now().MicroSeconds());
}
private:
void RegisterDependencies() const final {
std::for_each(DependentNodes.cbegin(), DependentNodes.cend(), std::bind(&TNowWrapper::DependsOn, this, std::placeholders::_1));
}
const TComputationNodePtrVector DependentNodes;
};
}
IComputationNode* WrapNow(TCallable& callable, const TComputationNodeFactoryContext& ctx) {
TComputationNodePtrVector dependentNodes(callable.GetInputsCount());
for (ui32 i = 0; i < callable.GetInputsCount(); ++i) {
dependentNodes[i] = LocateNode(ctx.NodeLocator, callable, i);
}
return new TNowWrapper(ctx.Mutables, std::move(dependentNodes));
}
}
}
|