MCPcopy Create free account
hub / github.com/antirez/ds4 / raxNode

Class raxNode

rax.h:101–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 * compressed paths are still represented by chaining multiple nodes. */
100#define RAX_NODE_MAX_SIZE ((1<<16)-1)
101typedef struct raxNode {
102 uint32_t iskey:1; /* Does this node contain a key? */
103 uint32_t isnull:1; /* Associated value is NULL (don't store it). */
104 uint32_t iscompr:1; /* Node is compressed. */
105 uint32_t leafbitmap:13; /* Bit N set = child N is an inline value, not
106 a pointer to a child node. This allows us to
107 avoid allocating leaf nodes that only hold a
108 value. Only bits 0-12 are available, so children
109 at index >= 13 can't be inlined. For compressed
110 nodes only bit 0 is meaningful. */
111 uint32_t size:16; /* Number of children, or compressed string len. */
112 /* Data layout is as follows:
113 *
114 * If node is not compressed we have 'size' bytes, one for each children
115 * character, and 'size' raxNode pointers, point to each child node.
116 * Note how the character is not stored in the children but in the
117 * edge of the parents:
118 *
119 * [header iscompr=0][abc][a-ptr][b-ptr][c-ptr](value-ptr?)
120 *
121 * if node is compressed (iscompr bit is 1) the node has 1 child.
122 * In that case the 'size' bytes of the string stored immediately at
123 * the start of the data section, represent a sequence of successive
124 * nodes linked one after the other, for which only the last one in
125 * the sequence is actually represented as a node, and pointed to by
126 * the current compressed node.
127 *
128 * [header iscompr=1][xyz][z-ptr](value-ptr?)
129 *
130 * Both compressed and not compressed nodes can represent a key
131 * with associated data in the radix tree at any level (not just terminal
132 * nodes).
133 *
134 * If the node has an associated key (iskey=1) and is not NULL
135 * (isnull=0), then after the raxNode pointers pointing to the
136 * children, an additional value pointer is present (as you can see
137 * in the representation above as "value-ptr" field).
138 */
139 unsigned char data[];
140} raxNode;
141
142typedef struct rax {
143 raxNode *head;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected