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