aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/client/prepare_operation.h
blob: 3b64aa285653bf3860ccb9c3ddcab6a1c009cf41 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once

#include "structured_table_formats.h"

#include <yt/cpp/mapreduce/interface/operation.h>

namespace NYT::NDetail {

////////////////////////////////////////////////////////////////////////////////

class TOperationPreparationContext
    : public IOperationPreparationContext
{
public:
    TOperationPreparationContext(
        const TStructuredJobTableList& structuredInputs,
        const TStructuredJobTableList& structuredOutputs,
        const TClientContext& context,
        const IClientRetryPolicyPtr& retryPolicy,
        TTransactionId transactionId);

    TOperationPreparationContext(
        TVector<TRichYPath> inputs,
        TVector<TRichYPath> outputs,
        const TClientContext& context,
        const IClientRetryPolicyPtr& retryPolicy,
        TTransactionId transactionId);

    int GetInputCount() const override;
    int GetOutputCount() const override;

    const TVector<TTableSchema>& GetInputSchemas() const override;
    const TTableSchema& GetInputSchema(int index) const override;

    TMaybe<TYPath> GetInputPath(int index) const override;
    TMaybe<TYPath> GetOutputPath(int index) const override;

private:
    TVector<TMaybe<TRichYPath>> Inputs_;
    TVector<TMaybe<TRichYPath>> Outputs_;
    const TClientContext& Context_;
    const IClientRetryPolicyPtr RetryPolicy_;
    TTransactionId TransactionId_;

    mutable TVector<TTableSchema> InputSchemas_;
    mutable TVector<bool> InputSchemasLoaded_;
};

////////////////////////////////////////////////////////////////////////////////

class TSpeculativeOperationPreparationContext
    : public IOperationPreparationContext
{
public:
    TSpeculativeOperationPreparationContext(
        const TVector<TTableSchema>& previousResult,
        TStructuredJobTableList inputs,
        TStructuredJobTableList outputs);

    int GetInputCount() const override;
    int GetOutputCount() const override;

    const TVector<TTableSchema>& GetInputSchemas() const override;
    const TTableSchema& GetInputSchema(int index) const override;

    TMaybe<TYPath> GetInputPath(int index) const override;
    TMaybe<TYPath> GetOutputPath(int index) const override;

private:
    TVector<TTableSchema> InputSchemas_;
    TStructuredJobTableList Inputs_;
    TStructuredJobTableList Outputs_;
};

////////////////////////////////////////////////////////////////////////////////

template <typename TTables>
TVector<TTableSchema> PrepareOperation(
    const IJob& job,
    const IOperationPreparationContext& context,
    TTables* inputsPtr,
    TTables* outputsPtr,
    TUserJobFormatHints& hints);

////////////////////////////////////////////////////////////////////////////////

TJobOperationPreparer GetOperationPreparer(
    const IJob& job,
    const IOperationPreparationContext& context);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT::NDetail