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

Function VerifyFile

tools/triecompiler/lib/main.cpp:343–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341
342template <class TRecord, class TPacker>
343static int VerifyFile(const TOptions& o, const TPacker& packer) {
344 TMappedFile filemap(o.Triefile);
345 typedef typename TRecord::TKeyChar TKeyChar;
346 typedef typename TRecord::TValue TValue;
347 TCompactTrie<TKeyChar, TValue, TPacker> trie((const char*)filemap.getData(), filemap.getSize(), packer);
348
349 TFileInput in(o.Infile);
350 size_t entrycount = 0;
351 int retcode = 0;
352 TRecord r;
353 while (r.Load(in, o.AllowEmptyKey, o.NoValues)) {
354 entrycount++;
355 TValue trievalue;
356
357 if (!trie.Find(r.Key.data(), r.Key.size(), &trievalue)) {
358 Cerr << "Trie check failed on key #" << entrycount << "\"" << r.Key << "\": no key present" << Endl;
359 retcode = 1;
360 } else if (!o.NoValues && trievalue != r.Value) {
361 Cerr << "Trie check failed on key #" << entrycount << "\"" << r.Key << "\": value mismatch" << Endl;
362 retcode = 1;
363 }
364 }
365
366 for (typename TCompactTrie<TKeyChar, TValue, TPacker>::TConstIterator iter = trie.Begin(); iter != trie.End(); ++iter) {
367 entrycount--;
368 }
369
370 if (entrycount) {
371 Cerr << "Broken iteration: entry count mismatch" << Endl;
372 retcode = 1;
373 }
374
375 if ((o.Flags & CTBF_VERBOSE) && !retcode) {
376 Cerr << "Trie check successful" << Endl;
377 }
378 return retcode;
379}
380
381template <class TRecord, class TPacker>
382static int SelectInput(const TOptions& o, const TPacker& packer) {

Callers

nothing calls this directly

Calls 8

getDataMethod · 0.80
getSizeMethod · 0.80
LoadMethod · 0.45
FindMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45

Tested by

no test coverage detected