-
Notifications
You must be signed in to change notification settings - Fork 607
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
18 changed files
with
1,934 additions
and
149 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,72 @@ | ||
#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 { | ||
|
||
class TBufferData: public IStatHolder, public TNonCopyable { | ||
public: | ||
TBufferData() | ||
: Rows{std::make_shared<NTxProxy::TUploadRows>()} { | ||
} | ||
|
||
ui64 GetRows() const override final { | ||
return Rows->size(); | ||
} | ||
|
||
auto 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<NTxProxy::TUploadRows> Rows; | ||
ui64 ByteSize = 0; | ||
TSerializedCellVec LastKey; | ||
}; | ||
|
||
} |
Oops, something went wrong.