Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions be/src/olap/rowset/segment_v2/stream_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ struct SubstreamIterator {
};

// path -> StreamReader
using SubstreamReaderTree = vectorized::SubcolumnsTree<SubstreamIterator>;
using SubstreamReaderTree = vectorized::SubcolumnsTree<SubstreamIterator, false>;

// Reader for the storage layer, the file_column_type indicates the read type of the column in segment file
struct SubcolumnReader {
std::unique_ptr<ColumnReader> reader;
std::shared_ptr<const vectorized::IDataType> file_column_type;
};
using SubcolumnColumnReaders = vectorized::SubcolumnsTree<SubcolumnReader>;
using SubcolumnColumnReaders = vectorized::SubcolumnsTree<SubcolumnReader, true>;

} // namespace doris::segment_v2
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ColumnObject final : public COWHelper<IColumn, ColumnObject> {
// the root Node should be JSONB type when finalize
bool is_root = false;
};
using Subcolumns = SubcolumnsTree<Subcolumn>;
using Subcolumns = SubcolumnsTree<Subcolumn, false>;

private:
/// If true then all subcolumns are nullable.
Expand Down
35 changes: 23 additions & 12 deletions be/src/vec/columns/subcolumn_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
#include "vec/columns/column.h"
#include "vec/common/arena.h"
#include "vec/common/string_ref.h"
#include "vec/data_types/data_type.h"
#include "vec/json/path_in_data.h"
namespace doris::vectorized {
/// Tree that represents paths in document
/// with additional data in nodes.

template <typename NodeData>
// Tree that represents paths in document with additional data in nodes.
// IsShared mean this object shared above multiple tasks, need swtich to subcolumns_tree_tracker
template <typename NodeData, bool IsShared>
class SubcolumnsTree {
public:
struct Node {
Expand Down Expand Up @@ -75,10 +73,12 @@ class SubcolumnsTree {
void add_child(std::string_view key, std::shared_ptr<Node> next_node, Arena& strings_pool) {
next_node->parent = this;
StringRef key_ref;
{
if constexpr (IsShared) {
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(
ExecEnv::GetInstance()->subcolumns_tree_tracker());
key_ref = {strings_pool.insert(key.data(), key.length()), key.length()};
} else {
key_ref = {strings_pool.insert(key.data(), key.length()), key.length()};
}
children[key_ref] = std::move(next_node);
}
Expand Down Expand Up @@ -256,7 +256,7 @@ class SubcolumnsTree {
/// for the last rows.
/// If there are no leaves, skip current node and find
/// the next node up to the current.
leaf = SubcolumnsTree<NodeData>::find_leaf(node_nested, pred);
leaf = SubcolumnsTree<NodeData, IsShared>::find_leaf(node_nested, pred);

if (leaf) {
break;
Expand Down Expand Up @@ -308,14 +308,25 @@ class SubcolumnsTree {
const_iterator end() const { return leaves.end(); }

~SubcolumnsTree() {
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(ExecEnv::GetInstance()->subcolumns_tree_tracker());
strings_pool.reset();
if constexpr (IsShared) {
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(
ExecEnv::GetInstance()->subcolumns_tree_tracker());
strings_pool.reset();
} else {
strings_pool.reset();
}
}

SubcolumnsTree() {
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(ExecEnv::GetInstance()->subcolumns_tree_tracker());
SCOPED_SKIP_MEMORY_CHECK();
strings_pool = std::make_shared<Arena>();
if constexpr (IsShared) {
SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(
ExecEnv::GetInstance()->subcolumns_tree_tracker());
SCOPED_SKIP_MEMORY_CHECK();
strings_pool = std::make_shared<Arena>();
} else {
SCOPED_SKIP_MEMORY_CHECK();
strings_pool = std::make_shared<Arena>();
}
}

private:
Expand Down
6 changes: 6 additions & 0 deletions be/src/vec/common/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ void Allocator<clear_memory_, mmap_populate, use_mmap, MemoryAllocator>::add_add
return;
}
#endif
if (!doris::config::crash_in_memory_tracker_inaccurate) {
return;
}
doris::thread_context()->thread_mem_tracker_mgr->limiter_mem_tracker()->add_address_sanitizers(
buf, size);
}
Expand All @@ -301,6 +304,9 @@ void Allocator<clear_memory_, mmap_populate, use_mmap, MemoryAllocator>::remove_
return;
}
#endif
if (!doris::config::crash_in_memory_tracker_inaccurate) {
return;
}
doris::thread_context()
->thread_mem_tracker_mgr->limiter_mem_tracker()
->remove_address_sanitizers(buf, size);
Expand Down
Loading