MCPcopy Create free account
hub / github.com/F-Stack/f-stack / DiB_fileStats

Function DiB_fileStats

freebsd/contrib/zstd/programs/dibio.c:238–255  ·  view source on GitHub ↗

! DiB_fileStats() : * Given a list of files, and a chunkSize (0 == no chunk, whole files) * provides the amount of data to be loaded and the resulting nb of samples. * This is useful primarily for allocation purpose => sample buffer, and sample sizes table. */

Source from the content-addressed store, hash-verified

236 * This is useful primarily for allocation purpose => sample buffer, and sample sizes table.
237 */
238static fileStats DiB_fileStats(const char** fileNamesTable, unsigned nbFiles, size_t chunkSize, unsigned displayLevel)
239{
240 fileStats fs;
241 unsigned n;
242 memset(&fs, 0, sizeof(fs));
243 for (n=0; n<nbFiles; n++) {
244 U64 const fileSize = UTIL_getFileSize(fileNamesTable[n]);
245 U64 const srcSize = (fileSize == UTIL_FILESIZE_UNKNOWN) ? 0 : fileSize;
246 U32 const nbSamples = (U32)(chunkSize ? (srcSize + (chunkSize-1)) / chunkSize : 1);
247 U64 const chunkToLoad = chunkSize ? MIN(chunkSize, srcSize) : srcSize;
248 size_t const cappedChunkSize = (size_t)MIN(chunkToLoad, SAMPLESIZE_MAX);
249 fs.totalSizeToLoad += cappedChunkSize * nbSamples;
250 fs.oneSampleTooLarge |= (chunkSize > 2*SAMPLESIZE_MAX);
251 fs.nbSamples += nbSamples;
252 }
253 DISPLAYLEVEL(4, "Preparing to load : %u KB \n", (unsigned)(fs.totalSizeToLoad >> 10));
254 return fs;
255}
256
257
258/*! ZDICT_trainFromBuffer_unsafe_legacy() :

Callers 1

DiB_trainFromFilesFunction · 0.85

Calls 2

memsetFunction · 0.85
UTIL_getFileSizeFunction · 0.85

Tested by

no test coverage detected