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

Method MeasureSubtrie

library/cpp/containers/comptrie/make_fast_layout.cpp:251–281  ·  view source on GitHub ↗

A chain of nodes linked by forward links is considered one node with many left and right children for depth measuring here and in TVanEmdeBoasReverseNodeEnumerator::FindDescendants.

Source from the content-addressed store, hash-verified

249 // for depth measuring here and in
250 // TVanEmdeBoasReverseNodeEnumerator::FindDescendants.
251 size_t TTrieMeasurer::MeasureSubtrie(size_t rootOffset, bool isNewPath) {
252 Y_ASSERT(rootOffset < Trie.Length);
253 TNode node(Trie.Data, rootOffset, Trie.SkipFunction);
254 size_t depth = 0;
255 for (;;) {
256 ++UnminimizedNodeCount;
257 if (Verbose) {
258 ShowProgress(UnminimizedNodeCount);
259 }
260 if (isNewPath) {
261 if (ParentCounts.Get(node.GetOffset()) > 0) {
262 isNewPath = false;
263 } else {
264 ++NodeCount;
265 }
266 ParentCounts.Inc(node.GetOffset());
267 }
268 if (node.GetLeftOffset()) {
269 depth = Max(depth, 1 + MeasureSubtrie(node.GetLeftOffset(), isNewPath));
270 }
271 if (node.GetRightOffset()) {
272 depth = Max(depth, 1 + MeasureSubtrie(node.GetRightOffset(), isNewPath));
273 }
274 if (node.GetForwardOffset()) {
275 node = TNode(Trie.Data, node.GetForwardOffset(), Trie.SkipFunction);
276 } else {
277 break;
278 }
279 }
280 return depth;
281 }
282
283 //--------------------------------------------------------------------------------------
284

Callers

nothing calls this directly

Calls 9

ShowProgressFunction · 0.85
GetLeftOffsetMethod · 0.80
GetRightOffsetMethod · 0.80
GetForwardOffsetMethod · 0.80
TNodeClass · 0.70
MaxFunction · 0.50
GetMethod · 0.45
GetOffsetMethod · 0.45
IncMethod · 0.45

Tested by

no test coverage detected