123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #pragma once
- #include <yt/cpp/mapreduce/interface/fwd.h>
- #include <yt/cpp/mapreduce/interface/config.h>
- #include <yt/cpp/mapreduce/interface/operation.h>
- #include <yt/cpp/mapreduce/common/fwd.h>
- #include <yt/cpp/mapreduce/http/context.h>
- #include <yt/cpp/mapreduce/http/requests.h>
- #include <utility>
- namespace NYT {
- ////////////////////////////////////////////////////////////////////////////////
- TMaybe<TNode> GetCommonTableFormat(
- const TVector<TMaybe<TNode>>& formats);
- TMaybe<TNode> GetTableFormat(
- const IClientRetryPolicyPtr& clientRetryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TRichYPath& path);
- TMaybe<TNode> GetTableFormats(
- const IClientRetryPolicyPtr& clientRetryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TVector<TRichYPath>& paths);
- ////////////////////////////////////////////////////////////////////////////////
- namespace NDetail {
- ////////////////////////////////////////////////////////////////////////////////
- enum class EIODirection
- {
- Input,
- Output,
- };
- ////////////////////////////////////////////////////////////////////////////////
- struct TSmallJobFile
- {
- TString FileName;
- TString Data;
- };
- ////////////////////////////////////////////////////////////////////////////////
- // Table that is used while preparing operation formats. Can be real table or intermediate
- struct TStructuredJobTable
- {
- TTableStructure Description;
- // Might be null for intermediate tables in MapReduce operation
- TMaybe<TRichYPath> RichYPath;
- static TStructuredJobTable Intermediate(TTableStructure description)
- {
- return TStructuredJobTable{std::move(description), Nothing()};
- }
- };
- using TStructuredJobTableList = TVector<TStructuredJobTable>;
- TString JobTablePathString(const TStructuredJobTable& jobTable);
- TStructuredJobTableList ToStructuredJobTableList(const TVector<TStructuredTablePath>& tableList);
- TStructuredJobTableList CanonizeStructuredTableList(const TClientContext& context, const TVector<TStructuredTablePath>& tableList);
- TVector<TRichYPath> GetPathList(
- const TStructuredJobTableList& tableList,
- const TMaybe<TVector<TTableSchema>>& schemaInferenceResult,
- bool inferSchema);
- ////////////////////////////////////////////////////////////////////////////////
- class TFormatBuilder
- {
- private:
- struct TFormatSwitcher;
- public:
- TFormatBuilder(
- IClientRetryPolicyPtr clientRetryPolicy,
- TClientContext context,
- TTransactionId transactionId,
- TOperationOptions operationOptions);
- std::pair<TFormat, TMaybe<TSmallJobFile>> CreateFormat(
- const IStructuredJob& job,
- const EIODirection& direction,
- const TStructuredJobTableList& structuredTableList,
- const TMaybe<TFormatHints>& formatHints,
- ENodeReaderFormat nodeReaderFormat,
- bool allowFormatFromTableAttribute);
- std::pair<TFormat, TMaybe<TSmallJobFile>> CreateVoidFormat(
- const IStructuredJob& job,
- const EIODirection& direction,
- const TStructuredJobTableList& structuredTableList,
- const TMaybe<TFormatHints>& formatHints,
- ENodeReaderFormat nodeReaderFormat,
- bool allowFormatFromTableAttribute);
- std::pair<TFormat, TMaybe<TSmallJobFile>> CreateYamrFormat(
- const IStructuredJob& job,
- const EIODirection& direction,
- const TStructuredJobTableList& structuredTableList,
- const TMaybe<TFormatHints>& formatHints,
- ENodeReaderFormat nodeReaderFormat,
- bool allowFormatFromTableAttribute);
- std::pair<TFormat, TMaybe<TSmallJobFile>> CreateNodeFormat(
- const IStructuredJob& job,
- const EIODirection& direction,
- const TStructuredJobTableList& structuredTableList,
- const TMaybe<TFormatHints>& formatHints,
- ENodeReaderFormat nodeReaderFormat,
- bool allowFormatFromTableAttribute);
- std::pair<TFormat, TMaybe<TSmallJobFile>> CreateProtobufFormat(
- const IStructuredJob& job,
- const EIODirection& direction,
- const TStructuredJobTableList& structuredTableList,
- const TMaybe<TFormatHints>& formatHints,
- ENodeReaderFormat nodeReaderFormat,
- bool allowFormatFromTableAttribute);
- private:
- const IClientRetryPolicyPtr ClientRetryPolicy_;
- const TClientContext Context_;
- const TTransactionId TransactionId_;
- const TOperationOptions OperationOptions_;
- };
- ////////////////////////////////////////////////////////////////////////////////
- TMaybe<TTableSchema> GetTableSchema(const TTableStructure& tableStructure);
- ////////////////////////////////////////////////////////////////////////////////
- } // namespace NDetail
- } // namespace NYT
|