Repository: ClickHouse/ClickHouse
File: src/Core/YTsaurus/YTsaurusClient.cpp (C++)

Code before:

#include <memory>
#include <utility>


namespace DB
{
namespace ErrorCodes
{
    extern const int INCORRECT_DATA;
    extern const int ALL_CONNECTION_TRIES_FAILED;
    extern const int LOGICAL_ERROR;
}

namespace Setting
{
    extern const SettingsUInt64 max_http_get_redirects;
}

YTsaurusClient::YTsaurusClient(ContextPtr context_, const ConnectionInfo & connection_info_)
    : context(context_), connection_info(connection_info_), log(getLogger("YTsaurusClient"))
{
}


ReadBufferPtr YTsaurusClient::readTable(const String & cypress_path, const std::pair<size_t, size_t>& rows_range)
{
    YTsaurusQueryPtr read_table_query(new YTsaurusReadTableQuery(cypress_path, rows_range));
    return executeQuery(read_table_query);
}

String YTsaurusClient::startTx(size_t timeout_ms)
{
    YTsaurusQueryPtr start_tx_query(new YTsaurusStartTxQuery(timeout_ms));
    auto read_buff = executeQuery(start_tx_query);
    String res;
    // Generally the result of each YTsaurus query should be json.
    // But... for start_tx query the result always doble quoted string.
    readDoubleQuotedString(res, *read_buff);
    return res;
}

void YTsaurusClient::commitTx(const String& transaction_id)
{
    YTsaurusQueryPtr commit_tx_query(new YTsaurusCommitTxQuery(transaction_id));
    executeQuery(commit_tx_query);
}

String YTsaurusClient::lock(const String& cypress_path, const String& transaction_id)
{
    YTsaurusQueryPtr lock_query(new YTsaurusLockQuery(cypress_path, transaction_id));

Review comment (suggestion):
```suggestion
ReadBufferPtr YTsaurusClient::readTable(const String & cypress_path, const std::pair<size_t, size_t> & rows_range)
```

Code after:

#include <memory>
#include <utility>


namespace DB
{
namespace ErrorCodes
{
    extern const int INCORRECT_DATA;
    extern const int ALL_CONNECTION_TRIES_FAILED;
    extern const int LOGICAL_ERROR;
}

namespace Setting
{
    extern const SettingsUInt64 max_http_get_redirects;
}

YTsaurusClient::YTsaurusClient(ContextPtr context_, const ConnectionInfo & connection_info_)
    : context(context_), connection_info(connection_info_), log(getLogger("YTsaurusClient"))
{
}

YTsaurusClient::YTsaurusClient(const YTsaurusClient & other)
    : context(other.context)
    , connection_info(other.connection_info)
    , log(getLogger("YTsaurusClient"))
{
}

ReadBufferPtr YTsaurusClient::readTable(const String & cypress_path, const std::pair<size_t, size_t> & rows_range)
{
    YTsaurusQueryPtr read_table_query(new YTsaurusReadTableQuery(cypress_path, rows_range));
    return executeQuery(read_table_query);
}

String YTsaurusClient::startTx(size_t timeout_ms)
{
    YTsaurusQueryPtr start_tx_query(new YTsaurusStartTxQuery(timeout_ms));
    auto read_buff = executeQuery(start_tx_query);
    String res;
    // Generally the result of each YTsaurus query should be json.
    // But... for start_tx query the result always double quoted string.
    readDoubleQuotedString(res, *read_buff);
    return res;
}

void YTsaurusClient::commitTx(const String & transaction_id)
{
    YTsaurusQueryPtr commit_tx_query(new YTsaurusCommitTxQuery(transaction_id));