1111#include < absl/container/flat_hash_map.h>
1212
1313namespace clp_s {
14+ /* *
15+ * This enum defines the valid MPT node types as well as the 8-bit number used to encode them.
16+ *
17+ * The number used to represent each node type can not change. That means that elements in this
18+ * enum can never be reordered and that new node types always need to be added to the end of the
19+ * enum (but before Unknown).
20+ *
21+ * Node types are used to help record the structure of a log record, with the exception of the
22+ * "Metadata" node type. The "Metadata" type is a special type used by the implementation to
23+ * demarcate data needed by the implementation that is not part of the log record. In particular,
24+ * the implementation may create a special subtree of the MPT which contains fields used to record
25+ * things like original log order.
26+ */
1427enum class NodeType : uint8_t {
1528 Integer,
1629 Float,
@@ -22,7 +35,7 @@ enum class NodeType : uint8_t {
2235 NullValue,
2336 DateString,
2437 StructuredArray,
25- Internal ,
38+ Metadata ,
2639 Unknown = std::underlying_type<NodeType>::type(~0ULL )
2740};
2841
@@ -46,12 +59,12 @@ class SchemaNode {
4659 )
4760 : m_parent_id(parent_id),
4861 m_id (id),
49- m_key_buf (std::make_unique<char []>(key_name.size())),
50- m_key_name(m_key_buf .get(), key_name.size()),
62+ m_key_name_buf (std::make_unique<char []>(key_name.size())),
63+ m_key_name(m_key_name_buf .get(), key_name.size()),
5164 m_type(type),
5265 m_count(0 ),
5366 m_depth(depth) {
54- memcpy (m_key_buf .get (), key_name.begin (), key_name.size ());
67+ memcpy (m_key_name_buf .get (), key_name.begin (), key_name.size ());
5568 }
5669
5770 /* *
@@ -120,18 +133,18 @@ class SchemaTree {
120133 int32_t get_object_subtree_node_id () const { return m_object_subtree_id; }
121134
122135 /* *
123- * Get the field Id for a specified field within the Internal subtree.
136+ * Get the field Id for a specified field within the Metadata subtree.
124137 * @param field_name
125138 *
126- * @return the field Id if the field exists within the Internal sub-tree, -1 otherwise.
139+ * @return the field Id if the field exists within the Metadata sub-tree, -1 otherwise.
127140 */
128- int32_t get_internal_field_id (std::string_view const field_name);
141+ int32_t get_metadata_field_id (std::string_view const field_name);
129142
130143 /* *
131- * @return the Id of the root of the Internal sub-tree.
132- * @return -1 if the Internal sub-tree does not exist.
144+ * @return the Id of the root of the Metadata sub-tree.
145+ * @return -1 if the Metadata sub-tree does not exist.
133146 */
134- int32_t get_internal_subtree_node_id () { return m_internal_subtree_id ; }
147+ int32_t get_metadata_subtree_node_id () { return m_metadata_subtree_id ; }
135148
136149 std::vector<SchemaNode> const & get_nodes () const { return m_nodes; }
137150
@@ -169,7 +182,7 @@ class SchemaTree {
169182 std::vector<SchemaNode> m_nodes;
170183 absl::flat_hash_map<std::tuple<int32_t , std::string_view const , NodeType>, int32_t > m_node_map;
171184 int32_t m_object_subtree_id{-1 };
172- int32_t m_internal_subtree_id {-1 };
185+ int32_t m_metadata_subtree_id {-1 };
173186};
174187} // namespace clp_s
175188
0 commit comments