forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_plan_cache_callback.cpp
More file actions
61 lines (56 loc) · 1.81 KB
/
ob_plan_cache_callback.cpp
File metadata and controls
61 lines (56 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_PC
#include "ob_plan_cache_callback.h"
#include "sql/plan_cache/ob_plan_cache_value.h"
#include "sql/plan_cache/ob_plan_cache.h"
using namespace oceanbase;
using namespace oceanbase::sql;
using namespace oceanbase::common;
void ObPlanCacheAtomicOp::operator()(PlanCacheKV& entry)
{
if (NULL != entry.second) {
entry.second->inc_ref_count(ref_handle_);
pcv_set_ = entry.second;
SQL_PC_LOG(DEBUG, "succ to get pcv_set", "ref_count", pcv_set_->get_ref_count());
} else {
// if no pcv set found, no need to do anything now
}
}
// get pcvs and lock
int ObPlanCacheAtomicOp::get_value(ObPCVSet*& pcvs)
{
int ret = OB_SUCCESS;
pcvs = NULL;
if (OB_ISNULL(pcv_set_)) {
ret = OB_NOT_INIT;
SQL_PC_LOG(WARN, "invalid argument", K(pcv_set_));
} else if (OB_SUCC(lock(*pcv_set_))) {
pcvs = pcv_set_;
} else {
if (NULL != pcv_set_) {
pcv_set_->dec_ref_count(ref_handle_);
}
SQL_PC_LOG(DEBUG, "failed to get read lock of plan cache value", K(ret));
}
return ret;
}
void ObCacheObjAtomicOp::operator()(ObjKV& entry)
{
if (NULL != entry.second) {
cache_obj_ = entry.second;
cache_obj_->inc_ref_count(ref_handle_);
SQL_PC_LOG(DEBUG, "succ to get plan", "ref_count", cache_obj_->get_ref_count());
} else {
// do nothing
}
}