@@ -69,49 +69,60 @@ class TSimpleSerializationStat {
69
69
70
70
class TBatchSerializationStat {
71
71
protected:
72
- double SerializedBytesPerRecord = 0 ;
73
- double RawBytesPerRecord = 0 ;
72
+ ui64 RecordCount = 0 ;
73
+ double SerializedBytes = 0 ;
74
+ double RawBytes = 0 ;
75
+ protected:
76
+ double GetSerializedBytesPerRecord () const {
77
+ return SerializedBytes / RecordCount;
78
+ }
79
+ double GetRawBytesPerRecord () const {
80
+ return RawBytes / RecordCount;
81
+ }
74
82
public:
75
83
TBatchSerializationStat () = default ;
76
84
TBatchSerializationStat (const ui64 bytes, const ui64 recordsCount, const ui64 rawBytes) {
77
85
Y_ABORT_UNLESS (recordsCount);
78
- SerializedBytesPerRecord = 1.0 * bytes / recordsCount;
79
- RawBytesPerRecord = 1.0 * rawBytes / recordsCount;
86
+ RecordCount = recordsCount;
87
+ SerializedBytes = bytes;
88
+ RawBytes = rawBytes;
80
89
}
81
90
82
91
TString DebugString () const {
83
- return TStringBuilder () << " {sbpr=" << SerializedBytesPerRecord << " ;rbpr=" << RawBytesPerRecord << " }" ;
92
+ return TStringBuilder () << " {sbpr=" << GetSerializedBytesPerRecord () << " ;rbpr=" << GetRawBytesPerRecord () << " }" ;
84
93
}
85
94
86
95
TBatchSerializationStat (const TSimpleSerializationStat& simple) {
87
- SerializedBytesPerRecord = simple.GetSerializedBytesPerRecord ();
88
- RawBytesPerRecord = simple.GetRawBytesPerRecord ();
96
+ RecordCount = simple.GetRecordsCount ();
97
+ SerializedBytes = simple.GetSerializedBytes ();
98
+ RawBytes = simple.GetRawBytes ();
89
99
}
90
100
91
101
void Merge (const TSimpleSerializationStat& item) {
92
- SerializedBytesPerRecord += item.GetSerializedBytesPerRecord ();
93
- RawBytesPerRecord += item.GetRawBytesPerRecord ();
102
+ RecordCount += item.GetRecordsCount ();
103
+ SerializedBytes += item.GetSerializedBytes ();
104
+ RawBytes += item.GetRawBytes ();
94
105
}
95
106
96
107
std::vector<i64 > SplitRecordsForBlobSize (const i64 recordsCount, const ui64 blobSize) const ;
97
108
98
- std::optional<ui64> PredictOptimalPackRecordsCount (const ui64 recordsCount, const ui64 blobSize) const {
99
- if (!SerializedBytesPerRecord ) {
109
+ std::optional<ui64> PredictOptimalPackRecordsCount (const ui64 recordsCount, const ui64 blobSize) const {
110
+ if (!SerializedBytes ) {
100
111
return {};
101
112
}
102
- const ui64 fullSize = 1.0 * recordsCount * SerializedBytesPerRecord ;
113
+ const ui64 fullSize = recordsCount * GetSerializedBytesPerRecord () ;
103
114
if (fullSize < blobSize) {
104
115
return recordsCount;
105
116
} else {
106
- return std::floor (1.0 * blobSize / SerializedBytesPerRecord );
117
+ return std::floor (blobSize / GetSerializedBytesPerRecord () );
107
118
}
108
119
}
109
120
110
121
std::optional<ui64> PredictOptimalSplitFactor (const ui64 recordsCount, const ui64 blobSize) const {
111
- if (!SerializedBytesPerRecord ) {
122
+ if (!SerializedBytes ) {
112
123
return {};
113
124
}
114
- const ui64 fullSize = 1.0 * recordsCount * SerializedBytesPerRecord ;
125
+ const ui64 fullSize = recordsCount * GetSerializedBytesPerRecord () ;
115
126
if (fullSize < blobSize) {
116
127
return 1 ;
117
128
} else {
0 commit comments