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

Method Measure

library/cpp/containers/comptrie/writeable_node.cpp:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 size_t TWriteableNode::Measure() const {
31 size_t len = 2 + LeafLength;
32 size_t fwdLen = 0;
33 size_t lastLen = 0;
34 size_t lastFwdLen = 0;
35 // Now, increase all the offsets by the length and recalculate everything, until it converges
36 do {
37 lastLen = len;
38 lastFwdLen = fwdLen;
39
40 len = 2 + LeafLength;
41 len += MeasureOffset(LeftOffset != NPOS ? LeftOffset + lastLen : 0);
42 len += MeasureOffset(RightOffset != NPOS ? RightOffset + lastLen : 0);
43
44 // Relative forward offset of 0 means we don't need extra length for an epsilon link.
45 // But an epsilon link means we need an extra 1 for the flags and the forward offset is measured
46 // from the start of the epsilon link, not from the start of our node.
47 if (ForwardOffset != NPOS && ForwardOffset != 0) {
48 fwdLen = MeasureOffset(ForwardOffset + lastFwdLen) + 1;
49 len += fwdLen;
50 }
51
52 } while (lastLen != len || lastFwdLen != fwdLen);
53
54 return len;
55 }
56
57 size_t TWriteableNode::Pack(char* buffer) const {
58 const size_t length = Measure();

Callers 1

RecreateNodeMethod · 0.45

Calls 1

MeasureOffsetFunction · 0.85

Tested by

no test coverage detected