aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaksim Kita <kitaetoya@gmail.com>2023-07-11 14:10:58 +0000
committermaksim-kita <maksim-kita@yandex-team.com>2023-07-11 17:10:58 +0300
commitfa87beed76de6d492f8e7ce5dd00e1ae460de3b9 (patch)
tree5056e19807241404c8b4f4d1908b2bd732a6ab6f
parent341dec40451fa14efd03d41ae055e96d8490761d (diff)
downloadydb-fa87beed76de6d492f8e7ce5dd00e1ae460de3b9.tar.gz
SerializedCellVec improve serialize peformance
SerializedCellVec improve serialize peformance Pull Request resolved: #305
-rw-r--r--ydb/core/scheme/scheme_tablecell.cpp4
-rw-r--r--ydb/core/scheme/scheme_tablecell.h20
2 files changed, 22 insertions, 2 deletions
diff --git a/ydb/core/scheme/scheme_tablecell.cpp b/ydb/core/scheme/scheme_tablecell.cpp
index 3d30ca1d80..80ef260d73 100644
--- a/ydb/core/scheme/scheme_tablecell.cpp
+++ b/ydb/core/scheme/scheme_tablecell.cpp
@@ -97,7 +97,7 @@ namespace {
size += sizeof(TCellHeader) + cell.Size();
}
- resultBuffer.resize(size);
+ resultBuffer.ReserveAndResize(size);
char* resultBufferData = resultBuffer.Detach();
ui16 cellsSize = cells.size();
@@ -115,7 +115,7 @@ namespace {
const auto & cell = cells[i];
if (cell.Size() > 0) {
- memcpy(resultBufferData, cell.Data(), cell.Size());
+ cell.CopyDataInto(resultBufferData);
}
if (resultCells) {
diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h
index de70c17afa..e0f67f1394 100644
--- a/ydb/core/scheme/scheme_tablecell.h
+++ b/ydb/core/scheme/scheme_tablecell.h
@@ -121,6 +121,26 @@ public:
const char* InlineData() const { Y_VERIFY_DEBUG(!IsInline_); return Ptr; }
const char* Data() const { Y_VERIFY_DEBUG(!IsInline_); return Ptr; }
#endif
+
+ void CopyDataInto(char * dst) const {
+ if (IsInline_) {
+ switch (DataSize_) {
+ case 8: memcpy(dst, &IntVal, 8); break;
+ case 7: memcpy(dst, &IntVal, 7); break;
+ case 6: memcpy(dst, &IntVal, 6); break;
+ case 5: memcpy(dst, &IntVal, 5); break;
+ case 4: memcpy(dst, &IntVal, 4); break;
+ case 3: memcpy(dst, &IntVal, 3); break;
+ case 2: memcpy(dst, &IntVal, 2); break;
+ case 1: memcpy(dst, &IntVal, 1); break;
+ }
+ return;
+ }
+
+ if (Ptr) {
+ memcpy(dst, Ptr, DataSize_);
+ }
+ }
};
#pragma pack(pop)