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

Code before:
}

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));
    auto read_buff = executeQuery(lock_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;
}

String YTsaurusClient::getNodeIdFromLock(const String & lock_id)
{

    String lock_metadata_path = fmt::format("{}/{}/@node_id", LOCKS_STORAGE_CYPRESS_PATH, lock_id);

Review comment (suggestion):
```suggestion
    // But... for start_tx query the result always double quoted string.
```

Code after:
}

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));
    executeQuery(commit_tx_query);
}

String YTsaurusClient::lock(const String & cypress_path, const String & transaction_id)
{
    YTsaurusQueryPtr lock_query(new YTsaurusLockQuery(cypress_path, transaction_id));
    auto read_buff = executeQuery(lock_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;