! 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. */
| 236 | * This is useful primarily for allocation purpose => sample buffer, and sample sizes table. |
| 237 | */ |
| 238 | static 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() : |
no test coverage detected