dataroaring commented on a change in pull request #8476:
URL: https://github.com/apache/incubator-doris/pull/8476#discussion_r829001314
##########
File path: be/src/runtime/thread_context.h
##########
@@ -50,27 +56,65 @@ class ThreadContext {
};
public:
- ThreadContext() : _thread_id(std::this_thread::get_id()),
_type(TaskType::UNKNOWN) {}
+ ThreadContext() : _thread_id(std::this_thread::get_id()),
_type(TaskType::UNKNOWN) {
+ _thread_mem_tracker_mgr.reset(new ThreadMemTrackerMgr());
+ }
void attach(const TaskType& type, const std::string& task_id,
- const TUniqueId& fragment_instance_id) {
+ const TUniqueId& fragment_instance_id,
+ const std::shared_ptr<MemTracker>& mem_tracker) {
DCHECK(_type == TaskType::UNKNOWN && _task_id == "");
_type = type;
_task_id = task_id;
_fragment_instance_id = fragment_instance_id;
+ _thread_mem_tracker_mgr->attach_task(task_type_string(_type), task_id,
fragment_instance_id,
+ mem_tracker);
}
void detach() {
_type = TaskType::UNKNOWN;
_task_id = "";
_fragment_instance_id = TUniqueId();
+ _thread_mem_tracker_mgr->detach_task();
}
- const std::string type() const;
const std::string& task_id() const { return _task_id; }
const std::thread::id& thread_id() const { return _thread_id; }
const TUniqueId& fragment_instance_id() const { return
_fragment_instance_id; }
+ inline static const std::string task_type_string(ThreadContext::TaskType
type) {
+ switch (type) {
+ case ThreadContext::TaskType::QUERY:
+ return "QUERY";
+ case ThreadContext::TaskType::LOAD:
+ return "LOAD";
+ case ThreadContext::TaskType::COMPACTION:
+ return "COMPACTION";
+ default:
+ return "UNKNOWN";
+ }
Review comment:
I means array not map. e.g. const char * xx_desc[TYPE_NUM]. But maybe
compiler translates such switch case to code like array?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]