aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers/comptrie/node.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/containers/comptrie/node.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers/comptrie/node.cpp')
-rw-r--r--library/cpp/containers/comptrie/node.cpp124
1 files changed, 62 insertions, 62 deletions
diff --git a/library/cpp/containers/comptrie/node.cpp b/library/cpp/containers/comptrie/node.cpp
index 5fd22f15ec..cd98e6b4d6 100644
--- a/library/cpp/containers/comptrie/node.cpp
+++ b/library/cpp/containers/comptrie/node.cpp
@@ -6,74 +6,74 @@
#include <util/generic/yexception.h>
namespace NCompactTrie {
- TNode::TNode()
- : Offset(0)
- , LeafLength(0)
- , CoreLength(0)
- , Label(0)
- {
- for (auto& offset : Offsets) {
- offset = 0;
- }
+ TNode::TNode()
+ : Offset(0)
+ , LeafLength(0)
+ , CoreLength(0)
+ , Label(0)
+ {
+ for (auto& offset : Offsets) {
+ offset = 0;
+ }
}
- // We believe that epsilon links are found only on the forward-position and that afer jumping an epsilon link you come to an ordinary node.
+ // We believe that epsilon links are found only on the forward-position and that afer jumping an epsilon link you come to an ordinary node.
+
+ TNode::TNode(const char* data, size_t offset, const ILeafSkipper& skipFunction)
+ : Offset(offset)
+ , LeafLength(0)
+ , CoreLength(0)
+ , Label(0)
+ {
+ for (auto& anOffset : Offsets) {
+ anOffset = 0;
+ }
+ if (!data)
+ return; // empty constructor
+
+ const char* datapos = data + offset;
+ char flags = *(datapos++);
+ Y_ASSERT(!IsEpsilonLink(flags));
+ Label = *(datapos++);
- TNode::TNode(const char* data, size_t offset, const ILeafSkipper& skipFunction)
- : Offset(offset)
- , LeafLength(0)
- , CoreLength(0)
- , Label(0)
- {
- for (auto& anOffset : Offsets) {
- anOffset = 0;
- }
- if (!data)
- return; // empty constructor
+ size_t leftsize = LeftOffsetLen(flags);
+ size_t& leftOffset = Offsets[D_LEFT];
+ leftOffset = UnpackOffset(datapos, leftsize);
+ if (leftOffset) {
+ leftOffset += Offset;
+ }
+ datapos += leftsize;
- const char* datapos = data + offset;
- char flags = *(datapos++);
- Y_ASSERT(!IsEpsilonLink(flags));
- Label = *(datapos++);
+ size_t rightsize = RightOffsetLen(flags);
+ size_t& rightOffset = Offsets[D_RIGHT];
+ rightOffset = UnpackOffset(datapos, rightsize);
+ if (rightOffset) {
+ rightOffset += Offset;
+ }
+ datapos += rightsize;
+
+ if (flags & MT_FINAL) {
+ Offsets[D_FINAL] = datapos - data;
+ LeafLength = skipFunction.SkipLeaf(datapos);
+ }
- size_t leftsize = LeftOffsetLen(flags);
- size_t& leftOffset = Offsets[D_LEFT];
- leftOffset = UnpackOffset(datapos, leftsize);
- if (leftOffset) {
- leftOffset += Offset;
- }
- datapos += leftsize;
-
- size_t rightsize = RightOffsetLen(flags);
- size_t& rightOffset = Offsets[D_RIGHT];
- rightOffset = UnpackOffset(datapos, rightsize);
- if (rightOffset) {
- rightOffset += Offset;
- }
- datapos += rightsize;
-
- if (flags & MT_FINAL) {
- Offsets[D_FINAL] = datapos - data;
- LeafLength = skipFunction.SkipLeaf(datapos);
- }
-
- CoreLength = 2 + leftsize + rightsize + LeafLength;
- if (flags & MT_NEXT) {
- size_t& forwardOffset = Offsets[D_NEXT];
- forwardOffset = Offset + CoreLength;
- // There might be an epsilon link at the forward position.
- // If so, set the ForwardOffset to the value that points to the link's end.
- const char* forwardPos = data + forwardOffset;
- const char forwardFlags = *forwardPos;
- if (IsEpsilonLink(forwardFlags)) {
- // Jump through the epsilon link.
- size_t epsilonOffset = UnpackOffset(forwardPos + 1, forwardFlags & MT_SIZEMASK);
- if (!epsilonOffset) {
- ythrow yexception() << "Corrupted epsilon link";
- }
- forwardOffset += epsilonOffset;
+ CoreLength = 2 + leftsize + rightsize + LeafLength;
+ if (flags & MT_NEXT) {
+ size_t& forwardOffset = Offsets[D_NEXT];
+ forwardOffset = Offset + CoreLength;
+ // There might be an epsilon link at the forward position.
+ // If so, set the ForwardOffset to the value that points to the link's end.
+ const char* forwardPos = data + forwardOffset;
+ const char forwardFlags = *forwardPos;
+ if (IsEpsilonLink(forwardFlags)) {
+ // Jump through the epsilon link.
+ size_t epsilonOffset = UnpackOffset(forwardPos + 1, forwardFlags & MT_SIZEMASK);
+ if (!epsilonOffset) {
+ ythrow yexception() << "Corrupted epsilon link";
+ }
+ forwardOffset += epsilonOffset;
}
}
}
-
+
}