Skip to content

Commit 2d1b76f

Browse files
committed
Address review comments
1 parent bdbaed2 commit 2d1b76f

File tree

9 files changed

+56
-41
lines changed

9 files changed

+56
-41
lines changed

components/core/src/clp_s/ArchiveReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void ArchiveReader::open(string_view archives_dir, string_view archive_id) {
2727
m_schema_tree = ReaderUtils::read_schema_tree(archive_path_str);
2828
m_schema_map = ReaderUtils::read_schemas(archive_path_str);
2929

30-
m_log_event_idx_column_id = m_schema_tree->get_internal_field_id(constants::cLogEventIdxName);
30+
m_log_event_idx_column_id = m_schema_tree->get_metadata_field_id(constants::cLogEventIdxName);
3131

3232
m_table_metadata_file_reader.open(archive_path_str + constants::cArchiveTableMetadataFile);
3333
m_stream_reader.open_packed_streams(archive_path_str + constants::cArchiveTablesFile);

components/core/src/clp_s/JsonParser.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ bool JsonParser::parse() {
467467
return false;
468468
}
469469

470-
// Add internal log_event_idx field to record
471-
auto log_event_idx = add_internal_field(constants::cLogEventIdxName, NodeType::Integer);
470+
// Add log_event_idx field to metadata for record
471+
auto log_event_idx = add_metadata_field(constants::cLogEventIdxName, NodeType::Integer);
472472
m_current_parsed_message.add_value(
473473
log_event_idx,
474474
m_archive_writer->get_next_log_event_id()
@@ -534,13 +534,13 @@ bool JsonParser::parse() {
534534
return true;
535535
}
536536

537-
int32_t JsonParser::add_internal_field(std::string_view const field_name, NodeType type) {
538-
auto internal_subtree_id = m_archive_writer->add_node(
537+
int32_t JsonParser::add_metadata_field(std::string_view const field_name, NodeType type) {
538+
auto metadata_subtree_id = m_archive_writer->add_node(
539539
constants::cRootNodeId,
540-
NodeType::Internal,
541-
constants::cInternalSubtreeName
540+
NodeType::Metadata,
541+
constants::cMetadataSubtreeName
542542
);
543-
return m_archive_writer->add_node(internal_subtree_id, type, field_name);
543+
return m_archive_writer->add_node(metadata_subtree_id, type, field_name);
544544
}
545545

546546
void JsonParser::store() {

components/core/src/clp_s/JsonParser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class JsonParser {
101101
* Note: this method should be called before parsing a record so that internal fields come first
102102
* in each table. This isn't strictly necessary, but it is a nice convention.
103103
*/
104-
int32_t add_internal_field(std::string_view const field_name, NodeType type);
104+
int32_t add_metadata_field(std::string_view const field_name, NodeType type);
105105

106106
int m_num_messages;
107107
std::vector<std::string> m_file_paths;

components/core/src/clp_s/SchemaTree.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ int32_t SchemaTree::add_node(int32_t parent_node_id, NodeType type, std::string_
1919
if (constants::cRootNodeId == parent_node_id) {
2020
if (NodeType::Object == type) {
2121
m_object_subtree_id = node_id;
22-
} else if (NodeType::Internal == type) {
23-
m_internal_subtree_id = node_id;
22+
} else if (NodeType::Metadata == type) {
23+
m_metadata_subtree_id = node_id;
2424
}
2525
}
2626

@@ -34,13 +34,13 @@ int32_t SchemaTree::add_node(int32_t parent_node_id, NodeType type, std::string_
3434
return node_id;
3535
}
3636

37-
int32_t SchemaTree::get_internal_field_id(std::string_view const field_name) {
38-
if (m_internal_subtree_id < 0) {
37+
int32_t SchemaTree::get_metadata_field_id(std::string_view const field_name) {
38+
if (m_metadata_subtree_id < 0) {
3939
return -1;
4040
}
4141

42-
auto& internal_subtree_node = m_nodes[m_internal_subtree_id];
43-
for (auto child_id : internal_subtree_node.get_children_ids()) {
42+
auto& metadata_subtree_node = m_nodes[m_metadata_subtree_id];
43+
for (auto child_id : metadata_subtree_node.get_children_ids()) {
4444
auto& child_node = m_nodes[child_id];
4545
if (child_node.get_key_name() == field_name) {
4646
return child_id;

components/core/src/clp_s/SchemaTree.hpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
#include <absl/container/flat_hash_map.h>
1212

1313
namespace 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+
*/
1427
enum 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

components/core/src/clp_s/archive_constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ constexpr char cArchiveVarDictFile[] = "/var.dict";
2121
// Schema tree constants
2222
constexpr char cRootNodeName[] = "";
2323
constexpr int32_t cRootNodeId = -1;
24-
constexpr char cInternalSubtreeName[] = "";
24+
constexpr char cMetadataSubtreeName[] = "";
2525
constexpr char cLogEventIdxName[] = "log_event_idx";
2626

2727
namespace results_cache::decompression {

components/core/src/clp_s/search/Output.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ void Output::init(
138138

139139
for (auto column_reader : column_readers) {
140140
auto column_id = column_reader->get_id();
141-
if (((0
142-
!= (m_wildcard_type_mask
143-
& node_to_literal_type(m_schema_tree->get_node(column_id).get_type())))
144-
|| m_match.schema_searches_against_column(schema_id, column_id))
145-
&& 0 == m_internal_columns.count(column_id))
141+
if ((0
142+
!= (m_wildcard_type_mask
143+
& node_to_literal_type(m_schema_tree->get_node(column_id).get_type())))
144+
|| m_match.schema_searches_against_column(schema_id, column_id))
146145
{
146+
if (0 != m_metadata_columns.count(column_id)) {
147+
continue;
148+
}
147149
ClpStringColumnReader* clp_reader = dynamic_cast<ClpStringColumnReader*>(column_reader);
148150
VariableStringColumnReader* var_reader
149151
= dynamic_cast<VariableStringColumnReader*>(column_reader);
@@ -963,15 +965,15 @@ void Output::populate_string_queries(std::shared_ptr<Expression> const& expr) {
963965
}
964966

965967
void Output::populate_internal_columns() {
966-
int32_t internal_subtree_root_node_id = m_schema_tree->get_internal_subtree_node_id();
967-
if (-1 == internal_subtree_root_node_id) {
968+
int32_t metadata_subtree_root_node_id = m_schema_tree->get_metadata_subtree_node_id();
969+
if (-1 == metadata_subtree_root_node_id) {
968970
return;
969971
}
970972

971-
// This code assumes that the internal subtree contains no nested structures
972-
auto& internal_node = m_schema_tree->get_node(internal_subtree_root_node_id);
973-
for (auto child_id : internal_node.get_children_ids()) {
974-
m_internal_columns.insert(child_id);
973+
// This code assumes that the metadata subtree contains no nested structures
974+
auto& metadata_node = m_schema_tree->get_node(metadata_subtree_root_node_id);
975+
for (auto child_id : metadata_node.get_children_ids()) {
976+
m_metadata_columns.insert(child_id);
975977
}
976978
}
977979

@@ -991,7 +993,7 @@ void Output::populate_searched_wildcard_columns(std::shared_ptr<Expression> cons
991993
if (Schema::schema_entry_is_unordered_object(node)) {
992994
continue;
993995
}
994-
if (0 != m_internal_columns.count(node)) {
996+
if (0 != m_metadata_columns.count(node)) {
995997
continue;
996998
}
997999
auto tree_node_type = m_schema_tree->get_node(node).get_type();

components/core/src/clp_s/search/Output.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Output : public FilterClass {
8989
std::vector<ColumnDescriptor*> m_wildcard_columns;
9090
std::map<ColumnDescriptor*, std::set<int32_t>> m_wildcard_to_searched_basic_columns;
9191
LiteralTypeBitmask m_wildcard_type_mask{0};
92-
std::unordered_set<int32_t> m_internal_columns;
92+
std::unordered_set<int32_t> m_metadata_columns;
9393

9494
std::stack<
9595
std::pair<ExpressionType, OpList::iterator>,

components/core/src/clp_s/search/SearchUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LiteralType node_to_literal_type(NodeType type) {
3434
return LiteralType::NullT;
3535
case NodeType::DateString:
3636
return LiteralType::EpochDateT;
37-
case NodeType::Internal:
37+
case NodeType::Metadata:
3838
case NodeType::Unknown:
3939
default:
4040
return LiteralType::UnknownT;

0 commit comments

Comments
 (0)