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

Function ProcessFile

tools/triecompiler/lib/main.cpp:294–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292
293template <class TRecord, class TPacker>
294static int ProcessFile(IInputStream& in, const TOptions& o, const TPacker& packer) {
295 TFixedBufferFileOutput out(o.Triefile);
296 typedef typename TRecord::TKeyChar TKeyChar;
297 typedef typename TRecord::TValue TValue;
298
299 THolder< TCompactTrieBuilder<TKeyChar, TValue, TPacker> > builder(new TCompactTrieBuilder<TKeyChar, TValue, TPacker>(o.Flags, packer));
300
301 TRecord r;
302 while (r.Load(in, o.AllowEmptyKey, o.NoValues)) {
303 builder->Add(r.Key.data(), r.Key.size(), r.Value);
304 }
305
306 if (o.Flags & CTBF_VERBOSE) {
307 Cerr << Endl;
308 Cerr << "Entries: " << builder->GetEntryCount() << Endl;
309 Cerr << "Tree nodes: " << builder->GetNodeCount() << Endl;
310 }
311 TBufferOutput inputForFastLayout;
312 IOutputStream* currentOutput = &out;
313 if (o.FastLayout) {
314 currentOutput = &inputForFastLayout;
315 }
316 if (o.Minimized) {
317 TBufferOutput raw;
318 size_t datalength = builder->Save(raw);
319 if (o.Flags & CTBF_VERBOSE)
320 Cerr << "Data length (before compression): " << datalength << Endl;
321 builder.Destroy();
322
323 datalength = CompactTrieMinimize(*currentOutput, raw.Buffer().Data(), raw.Buffer().Size(), o.Flags & CTBF_VERBOSE, packer);
324 if (o.Flags & CTBF_VERBOSE)
325 Cerr << "Data length (minimized): " << datalength << Endl;
326 } else {
327 size_t datalength = builder->Save(*currentOutput);
328 if (o.Flags & CTBF_VERBOSE)
329 Cerr << "Data length: " << datalength << Endl;
330 }
331 if (o.FastLayout) {
332 builder.Destroy();
333 size_t datalength = CompactTrieMakeFastLayout(out, inputForFastLayout.Buffer().Data(),
334 inputForFastLayout.Buffer().Size(), o.Flags & CTBF_VERBOSE, packer);
335 if (o.Flags & CTBF_VERBOSE)
336 Cerr << "Data length (fast layout): " << datalength << Endl;
337 }
338
339 return 0;
340}
341
342template <class TRecord, class TPacker>
343static int VerifyFile(const TOptions& o, const TPacker& packer) {

Callers

nothing calls this directly

Calls 10

GetEntryCountMethod · 0.80
GetNodeCountMethod · 0.80
LoadMethod · 0.45
AddMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
SaveMethod · 0.45
DestroyMethod · 0.45
DataMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected