diff options
author | max42 <max42@yandex-team.com> | 2023-07-29 00:02:16 +0300 |
---|---|---|
committer | max42 <max42@yandex-team.com> | 2023-07-29 00:02:16 +0300 |
commit | 73b89de71748a21e102d27b9f3ed1bf658766cb5 (patch) | |
tree | 188bbd2d622fa91cdcbb1b6d6d77fbc84a0646f5 /yt/cpp/mapreduce/interface/batch_request.h | |
parent | 528e321bcc2a2b67b53aeba58c3bd88305a141ee (diff) | |
download | ydb-73b89de71748a21e102d27b9f3ed1bf658766cb5.tar.gz |
YT-19210: expose YQL shared library for YT.
After this, a new target libyqlplugin.so appears. in open-source cmake build.
Diff in open-source YDB repo looks like the following: https://paste.yandex-team.ru/f302bdb4-7ef2-4362-91c7-6ca45f329264
Diffstat (limited to 'yt/cpp/mapreduce/interface/batch_request.h')
-rw-r--r-- | yt/cpp/mapreduce/interface/batch_request.h | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/interface/batch_request.h b/yt/cpp/mapreduce/interface/batch_request.h new file mode 100644 index 0000000000..3ea28f76fd --- /dev/null +++ b/yt/cpp/mapreduce/interface/batch_request.h @@ -0,0 +1,222 @@ +#pragma once + +#include "fwd.h" + +#include "client_method_options.h" + +#include <library/cpp/threading/future/future.h> +#include <util/generic/ptr.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////// + +/// Helper base of @ref NYT::IBatchRequest holding most of useful methods. +class IBatchRequestBase + : public TThrRefBase +{ +public: + virtual ~IBatchRequestBase() = default; + + /// + /// @brief Create cypress node. + /// + /// @see NYT::ICypressClient::Create + virtual ::NThreading::TFuture<TNodeId> Create( + const TYPath& path, + ENodeType type, + const TCreateOptions& options = TCreateOptions()) = 0; + + /// + /// @brief Remove cypress node. + /// + /// @see NYT::ICypressClient::Remove + virtual ::NThreading::TFuture<void> Remove( + const TYPath& path, + const TRemoveOptions& options = TRemoveOptions()) = 0; + + /// + /// @brief Check wether cypress node exists. + /// + /// @see NYT::ICypressClient::Exists + virtual ::NThreading::TFuture<bool> Exists( + const TYPath& path, + const TExistsOptions& options = TExistsOptions()) = 0; + + /// + /// @brief Get cypress node. + /// + /// @see NYT::ICypressClient::Get + virtual ::NThreading::TFuture<TNode> Get( + const TYPath& path, + const TGetOptions& options = TGetOptions()) = 0; + + /// + /// @brief Set cypress node. + /// + /// @see NYT::ICypressClient::Set + virtual ::NThreading::TFuture<void> Set( + const TYPath& path, + const TNode& node, + const TSetOptions& options = TSetOptions()) = 0; + + /// + /// @brief List cypress directory. + /// + /// @see NYT::ICypressClient::List + virtual ::NThreading::TFuture<TNode::TListType> List( + const TYPath& path, + const TListOptions& options = TListOptions()) = 0; + + /// + /// @brief Copy cypress node. + /// + /// @see NYT::ICypressClient::Copy + virtual ::NThreading::TFuture<TNodeId> Copy( + const TYPath& sourcePath, + const TYPath& destinationPath, + const TCopyOptions& options = TCopyOptions()) = 0; + + /// + /// @brief Move cypress node. + /// + /// @see NYT::ICypressClient::Move + virtual ::NThreading::TFuture<TNodeId> Move( + const TYPath& sourcePath, + const TYPath& destinationPath, + const TMoveOptions& options = TMoveOptions()) = 0; + + /// + /// @brief Create symbolic link. + /// + /// @see NYT::ICypressClient::Link. + virtual ::NThreading::TFuture<TNodeId> Link( + const TYPath& targetPath, + const TYPath& linkPath, + const TLinkOptions& options = TLinkOptions()) = 0; + + /// + /// @brief Lock cypress node. + /// + /// @see NYT::ICypressClient::Lock + virtual ::NThreading::TFuture<ILockPtr> Lock( + const TYPath& path, + ELockMode mode, + const TLockOptions& options = TLockOptions()) = 0; + + /// + /// @brief Unlock cypress node. + /// + /// @see NYT::ICypressClient::Unlock + virtual ::NThreading::TFuture<void> Unlock( + const TYPath& path, + const TUnlockOptions& options = TUnlockOptions()) = 0; + + /// + /// @brief Abort operation. + /// + /// @see NYT::IClient::AbortOperation + virtual ::NThreading::TFuture<void> AbortOperation(const TOperationId& operationId) = 0; + + /// + /// @brief Force complete operation. + /// + /// @see NYT::IClient::CompleteOperation + virtual ::NThreading::TFuture<void> CompleteOperation(const TOperationId& operationId) = 0; + + /// + /// @brief Suspend operation. + /// + /// @see NYT::IClient::SuspendOperation + virtual ::NThreading::TFuture<void> SuspendOperation( + const TOperationId& operationId, + const TSuspendOperationOptions& options = TSuspendOperationOptions()) = 0; + + /// + /// @brief Resume operation. + /// + /// @see NYT::IClient::ResumeOperation + virtual ::NThreading::TFuture<void> ResumeOperation( + const TOperationId& operationId, + const TResumeOperationOptions& options = TResumeOperationOptions()) = 0; + + /// + /// @brief Update parameters of running operation. + /// + /// @see NYT::IClient::UpdateOperationParameters + virtual ::NThreading::TFuture<void> UpdateOperationParameters( + const TOperationId& operationId, + const TUpdateOperationParametersOptions& options = TUpdateOperationParametersOptions()) = 0; + + /// + /// @brief Canonize cypress path + /// + /// @see NYT::ICypressClient::CanonizeYPath + virtual ::NThreading::TFuture<TRichYPath> CanonizeYPath(const TRichYPath& path) = 0; + + /// + /// @brief Get table columnar statistic + /// + /// @see NYT::ICypressClient::GetTableColumnarStatistics + virtual ::NThreading::TFuture<TVector<TTableColumnarStatistics>> GetTableColumnarStatistics( + const TVector<TRichYPath>& paths, + const TGetTableColumnarStatisticsOptions& options = {}) = 0; + + /// + /// @brief Check permission for given path. + /// + /// @see NYT::IClient::CheckPermission + virtual ::NThreading::TFuture<TCheckPermissionResponse> CheckPermission( + const TString& user, + EPermission permission, + const TYPath& path, + const TCheckPermissionOptions& options = TCheckPermissionOptions()) = 0; +}; + +/// +/// @brief Batch request object. +/// +/// Allows to send multiple lightweight requests at once significantly +/// reducing time of their execution. +/// +/// Methods of this class accept same arguments as @ref NYT::IClient methods but +/// return TFuture that is set after execution of @ref NYT::IBatchRequest::ExecuteBatch +/// +/// @see [Example of usage](https://a.yandex-team.ru/arc/trunk/arcadia/yt/cpp/mapreduce/examples/tutorial/batch_request/main.cpp) +class IBatchRequest + : public IBatchRequestBase +{ +public: + /// + /// @brief Temporary override current transaction. + /// + /// Using WithTransaction user can temporary override default transaction. + /// Example of usage: + /// TBatchRequest batchRequest; + /// auto noTxResult = batchRequest.Get("//some/path"); + /// auto txResult = batchRequest.WithTransaction(tx).Get("//some/path"); + virtual IBatchRequestBase& WithTransaction(const TTransactionId& transactionId) = 0; + IBatchRequestBase& WithTransaction(const ITransactionPtr& transaction); + + /// + /// @brief Executes all subrequests of batch request. + /// + /// After execution of this method all TFuture objects returned by subrequests will + /// be filled with either result or error. + /// + /// @note It is undefined in which order these requests are executed. + /// + /// @note This method doesn't throw if subrequest emits error. + /// Instead corresponding future is set with exception. + /// So it is always important to check TFuture status. + /// + /// Single TBatchRequest instance may be executed only once + /// and cannot be modified (filled with additional requests) after execution. + /// Exception is thrown on attempt to modify executed batch request + /// or execute it again. + virtual void ExecuteBatch(const TExecuteBatchOptions& options = TExecuteBatchOptions()) = 0; +}; + +//////////////////////////////////////////////////////////////////// + +} // namespace NYT |