123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- #pragma once
- #include "raw_batch_request.h"
- #include <yt/cpp/mapreduce/common/fwd.h>
- #include <yt/cpp/mapreduce/http/context.h>
- #include <yt/cpp/mapreduce/interface/client_method_options.h>
- #include <yt/cpp/mapreduce/interface/operation.h>
- namespace NYT {
- ////////////////////////////////////////////////////////////////////////////////
- class IRequestRetryPolicy;
- struct TClientContext;
- struct TExecuteBatchOptions;
- ////////////////////////////////////////////////////////////////////////////////
- namespace NDetail::NRawClient {
- ////////////////////////////////////////////////////////////////////////////////
- TOperationAttributes ParseOperationAttributes(const TNode& node);
- TCheckPermissionResponse ParseCheckPermissionResponse(const TNode& node);
- ////////////////////////////////////////////////////////////////////////////////
- //
- // marks `batchRequest' as executed
- void ExecuteBatch(
- IRequestRetryPolicyPtr retryPolicy,
- const TClientContext& context,
- TRawBatchRequest& batchRequest,
- const TExecuteBatchOptions& options = TExecuteBatchOptions());
- //
- // Cypress
- //
- TNode Get(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TGetOptions& options = TGetOptions());
- TNode TryGet(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TGetOptions& options);
- void Set(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TNode& value,
- const TSetOptions& options = TSetOptions());
- void MultisetAttributes(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TNode::TMapType& value,
- const TMultisetAttributesOptions& options = TMultisetAttributesOptions());
- bool Exists(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TExistsOptions& options = TExistsOptions());
- TNodeId Create(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const ENodeType& type,
- const TCreateOptions& options = TCreateOptions());
- TNodeId CopyWithoutRetries(
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& sourcePath,
- const TYPath& destinationPath,
- const TCopyOptions& options = TCopyOptions());
- TNodeId CopyInsideMasterCell(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& sourcePath,
- const TYPath& destinationPath,
- const TCopyOptions& options = TCopyOptions());
- TNodeId MoveWithoutRetries(
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& sourcePath,
- const TYPath& destinationPath,
- const TMoveOptions& options = TMoveOptions());
- TNodeId MoveInsideMasterCell(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& sourcePath,
- const TYPath& destinationPath,
- const TMoveOptions& options = TMoveOptions());
- void Remove(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TRemoveOptions& options = TRemoveOptions());
- TNode::TListType List(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TListOptions& options = TListOptions());
- TNodeId Link(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& targetPath,
- const TYPath& linkPath,
- const TLinkOptions& options = TLinkOptions());
- TLockId Lock(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- ELockMode mode,
- const TLockOptions& options = TLockOptions());
- void Unlock(
- IRequestRetryPolicyPtr retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TUnlockOptions& options = TUnlockOptions());
- void Concatenate(
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TVector<TRichYPath>& sourcePaths,
- const TRichYPath& destinationPath,
- const TConcatenateOptions& options = TConcatenateOptions());
- //
- // Transactions
- //
- void PingTx(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId);
- //
- // Operations
- //
- TOperationAttributes GetOperation(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TGetOperationOptions& options = TGetOperationOptions());
- TOperationAttributes GetOperation(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TString& operationId,
- const TGetOperationOptions& options = TGetOperationOptions());
- void AbortOperation(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId);
- void CompleteOperation(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId);
- void SuspendOperation(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TSuspendOperationOptions& options = TSuspendOperationOptions());
- void ResumeOperation(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TResumeOperationOptions& options = TResumeOperationOptions());
- TListOperationsResult ListOperations(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TListOperationsOptions& options = TListOperationsOptions());
- void UpdateOperationParameters(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TUpdateOperationParametersOptions& options = TUpdateOperationParametersOptions());
- //
- // Jobs
- //
- TJobAttributes GetJob(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TJobId& jobId,
- const TGetJobOptions& options = TGetJobOptions());
- TListJobsResult ListJobs(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TListJobsOptions& options = TListJobsOptions());
- ::TIntrusivePtr<IFileReader> GetJobInput(
- const TClientContext& context,
- const TJobId& jobId,
- const TGetJobInputOptions& options = TGetJobInputOptions());
- ::TIntrusivePtr<IFileReader> GetJobFailContext(
- const TClientContext& context,
- const TOperationId& operationId,
- const TJobId& jobId,
- const TGetJobFailContextOptions& options = TGetJobFailContextOptions());
- TString GetJobStderrWithRetries(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TOperationId& operationId,
- const TJobId& jobId,
- const TGetJobStderrOptions& /* options */ = TGetJobStderrOptions());
- ::TIntrusivePtr<IFileReader> GetJobStderr(
- const TClientContext& context,
- const TOperationId& operationId,
- const TJobId& jobId,
- const TGetJobStderrOptions& options = TGetJobStderrOptions());
- //
- // File cache
- //
- TMaybe<TYPath> GetFileFromCache(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TString& md5Signature,
- const TYPath& cachePath,
- const TGetFileFromCacheOptions& options = TGetFileFromCacheOptions());
- TYPath PutFileToCache(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& filePath,
- const TString& md5Signature,
- const TYPath& cachePath,
- const TPutFileToCacheOptions& options = TPutFileToCacheOptions());
- //
- // SkyShare
- //
- TNode::TListType SkyShareTable(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const std::vector<TYPath>& tablePaths,
- const TSkyShareTableOptions& options);
- //
- // Misc
- //
- TCheckPermissionResponse CheckPermission(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TString& user,
- EPermission permission,
- const TYPath& path,
- const TCheckPermissionOptions& options = TCheckPermissionOptions());
- TVector<TTabletInfo> GetTabletInfos(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TYPath& path,
- const TVector<int>& tabletIndexes,
- const TGetTabletInfosOptions& options);
- TVector<TTableColumnarStatistics> GetTableColumnarStatistics(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TVector<TRichYPath>& paths,
- const TGetTableColumnarStatisticsOptions& options);
- TMultiTablePartitions GetTablePartitions(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TVector<TRichYPath>& paths,
- const TGetTablePartitionsOptions& options);
- TRichYPath CanonizeYPath(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TRichYPath& path);
- TVector<TRichYPath> CanonizeYPaths(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TVector<TRichYPath>& paths);
- //
- // Tables
- //
- void AlterTable(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId,
- const TYPath& path,
- const TAlterTableOptions& options);
- void AlterTableReplica(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TReplicaId& replicaId,
- const TAlterTableReplicaOptions& options);
- void DeleteRows(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TYPath& path,
- const TNode::TListType& keys,
- const TDeleteRowsOptions& options);
- void FreezeTable(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TYPath& path,
- const TFreezeTableOptions& options);
- void UnfreezeTable(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TYPath& path,
- const TUnfreezeTableOptions& options);
- // Transactions
- void AbortTransaction(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId);
- void CommitTransaction(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& transactionId);
- TTransactionId StartTransaction(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TTransactionId& parentId,
- const TStartTransactionOptions& options);
- ////////////////////////////////////////////////////////////////////////////////
- template<typename TSrc, typename TBatchAdder>
- auto BatchTransform(
- const IRequestRetryPolicyPtr& retryPolicy,
- const TClientContext& context,
- const TSrc& src,
- TBatchAdder batchAdder,
- const TExecuteBatchOptions& executeBatchOptions = {})
- {
- TRawBatchRequest batch(context.Config);
- using TFuture = decltype(batchAdder(batch, *std::begin(src)));
- TVector<TFuture> futures;
- for (const auto& el : src) {
- futures.push_back(batchAdder(batch, el));
- }
- ExecuteBatch(retryPolicy, context, batch, executeBatchOptions);
- using TDst = decltype(futures[0].ExtractValueSync());
- TVector<TDst> result;
- result.reserve(std::size(src));
- for (auto& future : futures) {
- result.push_back(future.ExtractValueSync());
- }
- return result;
- }
- ////////////////////////////////////////////////////////////////////////////////
- } // namespace NDetail::NRawClient
- } // namespace NYT
|