MCPcopy Create free account
hub / github.com/catboost/catboost / SaveAsCompressedArray

Function SaveAsCompressedArray

catboost/libs/data/objects.cpp:1186–1208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1184
1185template <class T>
1186static void SaveAsCompressedArray(TConstArrayRef<T> values, IBinSaver* binSaver) {
1187 constexpr ui8 paddingBuffer[sizeof(ui64)-1] = {0};
1188
1189 const ui32 objectCount = values.size();
1190 const ui32 bytesPerKey = sizeof(T);
1191 const ui32 bitsPerKey = bytesPerKey * CHAR_BIT;
1192
1193 TIndexHelper<ui64> indexHelper(bitsPerKey);
1194
1195 // save values to be deserialiable as a TVector<ui64>
1196
1197 const IBinSaver::TStoredSize compressedStorageVectorSize = indexHelper.CompressedSize(objectCount);
1198 SaveMulti(binSaver, objectCount, bitsPerKey, compressedStorageVectorSize);
1199
1200 // pad to ui64-alignment to make it deserializable as CompressedArray storage
1201 const size_t paddingSize =
1202 size_t(compressedStorageVectorSize)*sizeof(ui64) - size_t(bytesPerKey)*objectCount;
1203
1204 SaveArrayData(values, binSaver);
1205 if (paddingSize) {
1206 SaveArrayData(TConstArrayRef<ui8>(paddingBuffer, paddingSize), binSaver);
1207 }
1208}
1209
1210template <class TColumn>
1211static void SaveColumnData(

Callers

nothing calls this directly

Calls 4

SaveMultiFunction · 0.85
SaveArrayDataFunction · 0.85
CompressedSizeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected