Adjust mem attr for load data

This commit is contained in:
wjhh2008
2023-06-08 10:47:46 +00:00
committed by ob-robot
parent a587fa8e2e
commit 9a4cf24b71
4 changed files with 33 additions and 16 deletions

View File

@ -51,14 +51,14 @@ public:
ObArrayHashMap(): lock_(common::ObLatchIds::HASH_MAP_LOCK), size_(0), capacity_(0), items_(NULL) {}
~ObArrayHashMap() { destroy(); }
int init(const lib::ObLabel &label, int64_t capacity)
int init(const lib::ObMemAttr attr, int64_t capacity)
{
int ret = OB_SUCCESS;
if (!label.is_valid() || capacity <= 0) {
if (capacity <= 0) {
ret = OB_INVALID_ARGUMENT;
} else if (is_inited()) {
ret = OB_INIT_TWICE;
} else if (NULL == (items_ = static_cast<Item *>(ob_malloc(capacity * sizeof(Item), label)))) {
} else if (NULL == (items_ = static_cast<Item *>(ob_malloc(capacity * sizeof(Item), attr)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
capacity_ = capacity;
@ -67,6 +67,13 @@ public:
return ret;
}
int init(const lib::ObLabel label, int64_t capacity)
{
ObMemAttr attr;
attr.label_ = label;
return init(attr, capacity);
}
void destroy()
{
if (NULL != items_) {
@ -129,7 +136,7 @@ public:
}
}
}
int64_t to_string(char *buf, int64_t buf_len) const
{
int64_t pos = 0;

View File

@ -37,7 +37,13 @@ public:
virtual ~ObSqlString();
bool is_valid() const;
void set_label(const lib::ObLabel &label) { allocator_.set_label(label); }
void set_attr(const lib::ObMemAttr &attr) { allocator_.set_attr(attr); }
void set_label(const lib::ObLabel &label)
{
lib::ObMemAttr attr;
attr.label_ = label;
allocator_.set_attr(attr);
}
void reset();
void reuse();
int reserve(const int64_t size);