disable construct of ObIAllocator
This commit is contained in:
parent
17b0f303d7
commit
9007c77b10
8
deps/oblib/src/common/data_buffer.h
vendored
8
deps/oblib/src/common/data_buffer.h
vendored
@ -28,7 +28,7 @@ public:
|
||||
ObDataBuffer(char* data, const int64_t capacity) : data_(data), capacity_(capacity), position_(0), limit_(0)
|
||||
{}
|
||||
|
||||
~ObDataBuffer()
|
||||
virtual ~ObDataBuffer()
|
||||
{}
|
||||
|
||||
inline bool set_data(char* data, const int64_t capacity)
|
||||
@ -55,7 +55,7 @@ public:
|
||||
limit_ = 0;
|
||||
}
|
||||
|
||||
inline void* alloc(const int64_t sz)
|
||||
inline virtual void* alloc(const int64_t sz)
|
||||
{
|
||||
void* ret = NULL;
|
||||
if (OB_LIKELY(sz > 0 && capacity_ - position_ >= sz)) {
|
||||
@ -64,13 +64,13 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
inline void* alloc(const int64_t sz, const lib::ObMemAttr& attr)
|
||||
inline virtual void* alloc(const int64_t sz, const lib::ObMemAttr& attr)
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(sz);
|
||||
}
|
||||
|
||||
inline void free()
|
||||
inline virtual void free()
|
||||
{
|
||||
position_ = 0;
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ public:
|
||||
attr.tenant_id_ = tenant_id;
|
||||
attr.ctx_id_ = ctx_id;
|
||||
}
|
||||
virtual ~ObTenantCtxAllocator()
|
||||
{}
|
||||
int set_tenant_memory_mgr()
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
|
31
deps/oblib/src/lib/allocator/ob_allocator.h
vendored
31
deps/oblib/src/lib/allocator/ob_allocator.h
vendored
@ -17,41 +17,23 @@
|
||||
#include "lib/alloc/alloc_struct.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace lib {
|
||||
struct ObMemAttr;
|
||||
} // end of namespace lib
|
||||
|
||||
namespace common {
|
||||
using lib::ObMemAttr;
|
||||
extern ObMemAttr default_memattr;
|
||||
class ObIAllocator {
|
||||
public:
|
||||
virtual ~ObIAllocator(){};
|
||||
|
||||
public:
|
||||
/************************************************************************/
|
||||
/* New Interface (Under construction) */
|
||||
/************************************************************************/
|
||||
// Use attr passed in by set_attr().
|
||||
virtual void* alloc(const int64_t size)
|
||||
{
|
||||
UNUSED(size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual void* alloc(const int64_t size, const ObMemAttr& attr)
|
||||
{
|
||||
UNUSED(size);
|
||||
UNUSED(attr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual void* alloc(const int64_t size) = 0;
|
||||
virtual void* alloc(const int64_t size, const ObMemAttr& attr) = 0;
|
||||
virtual void* realloc(const void* ptr, const int64_t size, const ObMemAttr& attr)
|
||||
{
|
||||
UNUSED(ptr);
|
||||
UNUSED(size);
|
||||
UNUSED(attr);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void* realloc(void* ptr, const int64_t oldsz, const int64_t newsz)
|
||||
@ -59,13 +41,10 @@ public:
|
||||
UNUSED(ptr);
|
||||
UNUSED(oldsz);
|
||||
UNUSED(newsz);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void free(void* ptr)
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
virtual void free(void* ptr) = 0;
|
||||
|
||||
virtual int64_t total() const
|
||||
{
|
||||
|
@ -38,12 +38,14 @@ class ObAllocator : public ObIAllocator {
|
||||
public:
|
||||
ObAllocator(__MemoryContext__* mem_context, const ObMemAttr& attr = default_memattr, const bool use_pm = false,
|
||||
const uint32_t ablock_size = lib::INTACT_NORMAL_AOBJECT_SIZE);
|
||||
virtual ~ObAllocator()
|
||||
{}
|
||||
void* alloc(const int64_t size) override
|
||||
{
|
||||
return alloc(size, attr_);
|
||||
}
|
||||
void* alloc(const int64_t size, const ObMemAttr& attr) override;
|
||||
void free(void* ptr) override;
|
||||
virtual void* alloc(const int64_t size, const ObMemAttr& attr) override;
|
||||
virtual void free(void* ptr) override;
|
||||
int64_t hold() const;
|
||||
int64_t total() const override
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
|
||||
public:
|
||||
explicit ObFIFOAllocator(const uint64_t tenant_id = OB_SERVER_TENANT_ID);
|
||||
~ObFIFOAllocator();
|
||||
virtual ~ObFIFOAllocator();
|
||||
|
||||
int init(ObIAllocator* allocator, const int64_t page_size, const ObMemAttr& attr = default_memattr,
|
||||
const int64_t init_size = 0, const int64_t idle_size = 256L << 10, const int64_t max_size = INT64_MAX);
|
||||
|
12
deps/oblib/src/lib/allocator/ob_malloc.h
vendored
12
deps/oblib/src/lib/allocator/ob_malloc.h
vendored
@ -156,7 +156,7 @@ public:
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual void* alloc(int64_t sz)
|
||||
virtual void* alloc(int64_t sz) override
|
||||
{
|
||||
char* ptr = NULL;
|
||||
if (OB_SUCCESS == mem_buf_.ensure_space(sz, label_)) {
|
||||
@ -164,12 +164,12 @@ public:
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
virtual void* alloc(int64_t sz, const ObMemAttr& attr)
|
||||
virtual void* alloc(int64_t sz, const ObMemAttr& attr) override
|
||||
{
|
||||
UNUSEDx(attr);
|
||||
return alloc(sz);
|
||||
}
|
||||
virtual void free(char* ptr)
|
||||
virtual void free(void* ptr) override
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
@ -185,7 +185,7 @@ public:
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual void* alloc(int64_t sz)
|
||||
virtual void* alloc(int64_t sz) override
|
||||
{
|
||||
char* ptr = NULL;
|
||||
if (mem_buf_len_ >= sz) {
|
||||
@ -193,12 +193,12 @@ public:
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
virtual void* alloc(int64_t sz, const ObMemAttr& attr)
|
||||
virtual void* alloc(int64_t sz, const ObMemAttr& attr) override
|
||||
{
|
||||
UNUSEDx(attr);
|
||||
return alloc(sz);
|
||||
}
|
||||
virtual void free(char* ptr)
|
||||
virtual void free(void* ptr) override
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
|
14
deps/oblib/src/lib/container/ob_se_array.h
vendored
14
deps/oblib/src/lib/container/ob_se_array.h
vendored
@ -49,6 +49,11 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void free(void *p) override
|
||||
{
|
||||
UNUSED(p);
|
||||
}
|
||||
|
||||
virtual ~ObNullAllocator(){};
|
||||
};
|
||||
|
||||
@ -61,6 +66,13 @@ static inline void init_block_allocator(lib::MemoryContext& mem_entity, ModulePa
|
||||
{
|
||||
block_allocator = ModulePageAllocator(mem_entity->get_allocator(), block_allocator.get_label());
|
||||
}
|
||||
static inline void init_block_allocator(lib::MemoryContext &mem_context, ObIAllocator &block_allocator)
|
||||
{
|
||||
// this implement is invalid, just for compilation.
|
||||
// protected by static_assert.
|
||||
UNUSED(mem_context);
|
||||
UNUSED(block_allocator);
|
||||
}
|
||||
|
||||
// ObSEArrayImpl is a high performant array for OceanBase developers,
|
||||
// to guarantee performance, it should be used in this way
|
||||
@ -69,6 +81,8 @@ static inline void init_block_allocator(lib::MemoryContext& mem_entity, ModulePa
|
||||
static const int64_t OB_DEFAULT_SE_ARRAY_COUNT = 64;
|
||||
template <typename T, int64_t LOCAL_ARRAY_SIZE, typename BlockAllocatorT = ModulePageAllocator, bool auto_free = false>
|
||||
class ObSEArrayImpl : public ObIArray<T> {
|
||||
static_assert(std::is_constructible<BlockAllocatorT>::value || !auto_free, "BlockAllocatorT can not be constructed.");
|
||||
|
||||
public:
|
||||
using ObIArray<T>::count;
|
||||
using ObIArray<T>::at;
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
{
|
||||
(void)set_data(buf_, MAX_MSGBUF_SIZE);
|
||||
}
|
||||
~ObElectionMsgBuffer()
|
||||
virtual ~ObElectionMsgBuffer()
|
||||
{}
|
||||
|
||||
TO_STRING_KV(K_(capacity), K_(position), K_(limit));
|
||||
|
@ -57,12 +57,16 @@ public:
|
||||
ObSmallArena();
|
||||
~ObSmallArena();
|
||||
void *alloc_aligned(const int64_t size, const int64_t align);
|
||||
void *alloc(const int64_t size, const common::ObMemAttr &attr)
|
||||
virtual void *alloc(const int64_t size, const common::ObMemAttr &attr) override
|
||||
{
|
||||
UNUSEDx(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
void *alloc(const int64_t size);
|
||||
virtual void *alloc(const int64_t size) override;
|
||||
virtual void free(void *ptr) override
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
void reset();
|
||||
int64_t get_small_alloc_count() const;
|
||||
int64_t get_large_alloc_count() const;
|
||||
|
@ -2173,12 +2173,12 @@ public:
|
||||
ObSchemaAllocator(common::ObIAllocator &allocator) : allocator_(&allocator)
|
||||
{}
|
||||
|
||||
virtual void *alloc(const int64_t sz)
|
||||
virtual void* alloc(const int64_t sz) override
|
||||
{
|
||||
return alloc(sz, common::default_memattr);
|
||||
}
|
||||
|
||||
virtual void *alloc(const int64_t sz, const common::ObMemAttr &attr)
|
||||
virtual void* alloc(const int64_t sz, const common::ObMemAttr& attr) override
|
||||
{
|
||||
void *ret = NULL;
|
||||
if (allocator_) {
|
||||
@ -2187,6 +2187,10 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual void free(void *p) override
|
||||
{
|
||||
allocator_->free(p);
|
||||
}
|
||||
virtual ~ObSchemaAllocator(){};
|
||||
|
||||
private:
|
||||
|
@ -344,6 +344,15 @@ public:
|
||||
{}
|
||||
|
||||
void* alloc(const int64_t size) override;
|
||||
void* alloc(const int64_t size, const common::ObMemAttr& attr) override
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
void free(void* ptr) override
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t off_;
|
||||
|
@ -41,6 +41,15 @@ public:
|
||||
}
|
||||
|
||||
virtual void* alloc(const int64_t size) override;
|
||||
virtual void* alloc(const int64_t size, const common::ObMemAttr& attr) override
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
virtual void free(void* ptr) override
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
common::ObIAllocator* alloc_;
|
||||
|
@ -31,11 +31,16 @@ public:
|
||||
|
||||
int init(const int64_t obj_size, const char* label, uint64_t tenant_id_);
|
||||
|
||||
void* alloc(int64_t sz)
|
||||
void* alloc(const int64_t sz) override
|
||||
{
|
||||
return alloc_(sz);
|
||||
}
|
||||
void free(void* ptr)
|
||||
void* alloc(const int64_t size, const common::ObMemAttr& attr) override
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
void free(void* ptr) override
|
||||
{
|
||||
free_(ptr);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public:
|
||||
ATOMIC_STORE(&free_count_, 0);
|
||||
ATOMIC_STORE(&alloc_size_, 0);
|
||||
}
|
||||
void* alloc(const int64_t size)
|
||||
void* alloc(const int64_t size) override
|
||||
{
|
||||
void* ret = nullptr;
|
||||
if (OB_ISNULL(ret = allocator_.alloc(size))) {
|
||||
@ -179,7 +179,12 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
void free(void* ptr)
|
||||
void* alloc(const int64_t size, const ObMemAttr& attr) override
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
void free(void* ptr) override
|
||||
{
|
||||
if (OB_ISNULL(ptr)) {
|
||||
// do nothing
|
||||
@ -244,7 +249,7 @@ public:
|
||||
ATOMIC_STORE(&free_count_, 0);
|
||||
ATOMIC_STORE(&alloc_size_, 0);
|
||||
}
|
||||
void* alloc(const int64_t size)
|
||||
void* alloc(const int64_t size) override
|
||||
{
|
||||
void* ret = nullptr;
|
||||
if (OB_ISNULL(ret = allocator_.alloc(size))) {
|
||||
@ -255,7 +260,12 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
void free(void* ptr)
|
||||
void* alloc(const int64_t size, const ObMemAttr& attr) override
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
void free(void* ptr) override
|
||||
{
|
||||
if (OB_ISNULL(ptr)) {
|
||||
// do nothing
|
||||
|
@ -76,6 +76,10 @@ class ObEmptyAlloc : public ObIAllocator {
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
void free(void *ptr) override
|
||||
{
|
||||
UNUSED(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(RARowStore, alloc_project_fail)
|
||||
|
Loading…
x
Reference in New Issue
Block a user