aboutsummaryrefslogtreecommitdiffstats
path: root/ydb/library/yql/dq/runtime/dq_output.h
blob: e793ff5231b4f27c3fb65dfee7141b1a4ce49a04 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once

#include <ydb/library/yql/minikql/mkql_node.h>

#include <util/datetime/base.h>
#include <util/generic/ptr.h>

namespace NYql {
namespace NDqProto {

class TCheckpoint;
class TTaskInput;
} // namespace NDqProto

namespace NUdf {
class TUnboxedValue;
} // namespace NUdf

namespace NDq {

struct TDqOutputStats {
    // basic stats
    ui64 Chunks = 0;
    ui64 Bytes = 0;
    ui64 RowsIn = 0;
    ui64 RowsOut = 0;
    TInstant FirstRowIn;

    // profile stats
    ui64 MaxMemoryUsage = 0;
    ui64 MaxRowsInMemory = 0;
};

class IDqOutput : public TSimpleRefCount<IDqOutput> {
public:
    using TPtr = TIntrusivePtr<IDqOutput>;

    virtual ~IDqOutput() = default;

    // <| producer methods
    [[nodiscard]]
    virtual bool IsFull() const = 0;
    // can throw TDqChannelStorageException
    virtual void Push(NUdf::TUnboxedValue&& value) = 0;
    // Push checkpoint. Checkpoints may be pushed to channel even after it is finished.
    virtual void Push(NDqProto::TCheckpoint&& checkpoint) = 0;
    virtual void Finish() = 0;

    // <| consumer methods
    [[nodiscard]]
    virtual bool HasData() const = 0;
    virtual bool IsFinished() const = 0;

    virtual NKikimr::NMiniKQL::TType* GetOutputType() const = 0;

    virtual const TDqOutputStats* GetStats() const = 0;
};

} // namespace NDq
} // namespace NYql