-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,384 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "ydb/core/scheme/scheme_tablecell.h" | ||
#include "ydb/core/tx/datashard/upload_stats.h" | ||
#include "ydb/core/tx/tx_proxy/upload_rows.h" | ||
|
||
namespace NKikimr::NDataShard { | ||
|
||
using TTypes = NTxProxy::TUploadTypes; | ||
using TRows = NTxProxy::TUploadRows; | ||
|
||
class TBufferData: public IStatHolder, public TNonCopyable { | ||
public: | ||
TBufferData() | ||
: Rows{std::make_shared<TRows>()} | ||
{ | ||
} | ||
|
||
ui64 GetRows() const override final { | ||
return Rows->size(); | ||
} | ||
|
||
std::shared_ptr<TRows> GetRowsData() const { | ||
return Rows; | ||
} | ||
|
||
ui64 GetBytes() const override final { | ||
return ByteSize; | ||
} | ||
|
||
void FlushTo(TBufferData& other) { | ||
Y_ABORT_UNLESS(this != &other); | ||
Y_ABORT_UNLESS(other.IsEmpty()); | ||
other.Rows.swap(Rows); | ||
other.ByteSize = std::exchange(ByteSize, 0); | ||
other.LastKey = std::exchange(LastKey, {}); | ||
} | ||
|
||
void Clear() { | ||
Rows->clear(); | ||
ByteSize = 0; | ||
LastKey = {}; | ||
} | ||
|
||
void AddRow(TSerializedCellVec&& key, TSerializedCellVec&& targetPk, TString&& targetValue) { | ||
Rows->emplace_back(std::move(targetPk), std::move(targetValue)); | ||
ByteSize += Rows->back().first.GetBuffer().size() + Rows->back().second.size(); | ||
LastKey = std::move(key); | ||
} | ||
|
||
bool IsEmpty() const { | ||
return Rows->empty(); | ||
} | ||
|
||
size_t Size() const { | ||
return Rows->size(); | ||
} | ||
|
||
bool IsReachLimits(const TUploadLimits& Limits) { | ||
// TODO(mbkkt) why [0..BatchRowsLimit) but [0..BatchBytesLimit] | ||
return Rows->size() >= Limits.BatchRowsLimit || ByteSize > Limits.BatchBytesLimit; | ||
} | ||
|
||
auto&& ExtractLastKey() { | ||
return std::move(LastKey); | ||
} | ||
|
||
const auto& GetLastKey() const { | ||
return LastKey; | ||
} | ||
|
||
private: | ||
std::shared_ptr<TRows> Rows; | ||
ui64 ByteSize = 0; | ||
TSerializedCellVec LastKey; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.