reformat source code
according to code styles, 'AccessModifierOffset' should be -2.
This commit is contained in:
parent
8c4a2f26a6
commit
4a92b6d7df
@ -2,7 +2,7 @@
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
SortIncludes: false
|
||||
AccessModifierOffset: -4
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
|
54
deps/easy/src/packet/easy_tbnet.h
vendored
54
deps/easy/src/packet/easy_tbnet.h
vendored
@ -43,7 +43,7 @@ static uint64_t addrv_to_server_id(easy_addr_t addr)
|
||||
class IServerAdapter;
|
||||
class Transport;
|
||||
class DataBuffer {
|
||||
public:
|
||||
public:
|
||||
DataBuffer(easy_buf_t* pb)
|
||||
{
|
||||
b = pb;
|
||||
@ -180,7 +180,7 @@ class DataBuffer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
easy_pool_t* pool;
|
||||
easy_list_t* l;
|
||||
easy_buf_t* b;
|
||||
@ -188,14 +188,14 @@ class DataBuffer {
|
||||
};
|
||||
|
||||
class PacketHeader {
|
||||
public:
|
||||
public:
|
||||
uint32_t _chid;
|
||||
int _pcode;
|
||||
int _dataLen;
|
||||
};
|
||||
|
||||
class Packet {
|
||||
public:
|
||||
public:
|
||||
Packet()
|
||||
{
|
||||
memset(&_packetHeader, 0, sizeof(PacketHeader));
|
||||
@ -241,13 +241,13 @@ class Packet {
|
||||
virtual bool encode(DataBuffer* output) = 0;
|
||||
virtual bool decode(DataBuffer* input, PacketHeader* header) = 0;
|
||||
|
||||
public:
|
||||
public:
|
||||
PacketHeader _packetHeader;
|
||||
easy_request_t* r;
|
||||
};
|
||||
|
||||
class ControlPacket : public Packet {
|
||||
public:
|
||||
public:
|
||||
enum { CMD_BAD_PACKET = 1, CMD_TIMEOUT_PACKET, CMD_DISCONN_PACKET };
|
||||
ControlPacket(int c) : _command(c)
|
||||
{}
|
||||
@ -268,12 +268,12 @@ class ControlPacket : public Packet {
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int _command;
|
||||
};
|
||||
|
||||
class IOComponent {
|
||||
public:
|
||||
public:
|
||||
IOComponent()
|
||||
{}
|
||||
~IOComponent()
|
||||
@ -283,12 +283,12 @@ class IOComponent {
|
||||
this->l = l;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
easy_listen_t* l;
|
||||
};
|
||||
|
||||
class IPacketFactory {
|
||||
public:
|
||||
public:
|
||||
IPacketFactory()
|
||||
{
|
||||
flag = 0x416e4574;
|
||||
@ -304,7 +304,7 @@ class IPacketFactory {
|
||||
|
||||
class IPacketStreamer {
|
||||
|
||||
public:
|
||||
public:
|
||||
IPacketStreamer()
|
||||
{
|
||||
_factory = NULL;
|
||||
@ -410,12 +410,12 @@ class IPacketStreamer {
|
||||
return EASY_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
IPacketFactory* _factory;
|
||||
};
|
||||
|
||||
class IPacketHandler {
|
||||
public:
|
||||
public:
|
||||
enum HPRetCode {
|
||||
KEEP_CHANNEL = 0, // easy_ok
|
||||
CLOSE_CHANNEL = -1, // easy_error
|
||||
@ -482,13 +482,13 @@ class IPacketHandler {
|
||||
{}
|
||||
virtual HPRetCode handlePacket(Packet* packet, void* args) = 0;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
IPacketStreamer* client_streamer;
|
||||
easy_io_handler_pt client_handler;
|
||||
};
|
||||
|
||||
class PacketQueue {
|
||||
public:
|
||||
public:
|
||||
PacketQueue(easy_message_t* pm)
|
||||
{
|
||||
m = pm;
|
||||
@ -502,7 +502,7 @@ class PacketQueue {
|
||||
|
||||
class Connection {
|
||||
|
||||
public:
|
||||
public:
|
||||
Connection()
|
||||
{}
|
||||
Connection(easy_connection_t* c, easy_request_t* r)
|
||||
@ -565,14 +565,14 @@ class Connection {
|
||||
return htons(((addr.addr >> 32) & 0xffff));
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
easy_addr_t addr;
|
||||
easy_connection_t* c;
|
||||
easy_request_t* r;
|
||||
};
|
||||
|
||||
class IServerAdapter {
|
||||
public:
|
||||
public:
|
||||
IServerAdapter()
|
||||
{
|
||||
memset(&server_handler, 0, sizeof(easy_io_handler_pt));
|
||||
@ -646,14 +646,14 @@ class IServerAdapter {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
IPacketStreamer* server_streamer;
|
||||
easy_io_handler_pt server_handler;
|
||||
};
|
||||
|
||||
class DefaultPacketStreamer : public IPacketStreamer {
|
||||
|
||||
public:
|
||||
public:
|
||||
DefaultPacketStreamer()
|
||||
{}
|
||||
|
||||
@ -673,7 +673,7 @@ class DefaultPacketStreamer : public IPacketStreamer {
|
||||
|
||||
class Transport {
|
||||
|
||||
public:
|
||||
public:
|
||||
Transport()
|
||||
{
|
||||
_eio = easy_eio_create(NULL, 1);
|
||||
@ -742,19 +742,19 @@ class Transport {
|
||||
return _eio;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
easy_io_t* _eio;
|
||||
};
|
||||
|
||||
class IPacketQueueHandler {
|
||||
public:
|
||||
public:
|
||||
virtual ~IPacketQueueHandler()
|
||||
{}
|
||||
virtual bool handlePacketQueue(Packet* packet, void* args) = 0;
|
||||
};
|
||||
|
||||
class PacketQueueThread {
|
||||
public:
|
||||
public:
|
||||
PacketQueueThread()
|
||||
{
|
||||
_threadPool = NULL;
|
||||
@ -794,13 +794,13 @@ class PacketQueueThread {
|
||||
return easy_thread_pool_push_message(_threadPool, queue.m, (int64_t)(long)queue.m);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
IPacketQueueHandler* _handler;
|
||||
easy_thread_pool_t* _threadPool;
|
||||
};
|
||||
|
||||
class ConnectionManager {
|
||||
public:
|
||||
public:
|
||||
ConnectionManager(Transport* transport, IPacketStreamer* streamer, IPacketHandler* packetHandler)
|
||||
{
|
||||
_transport = transport;
|
||||
@ -871,7 +871,7 @@ class ConnectionManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Transport* _transport;
|
||||
IPacketHandler* _packetHandler;
|
||||
easy_client_t* _cl;
|
||||
|
6
deps/oblib/src/common/cell/ob_cell_reader.h
vendored
6
deps/oblib/src/common/cell/ob_cell_reader.h
vendored
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObCellReader {
|
||||
public:
|
||||
public:
|
||||
ObCellReader();
|
||||
virtual ~ObCellReader()
|
||||
{}
|
||||
@ -38,7 +38,7 @@ class ObCellReader {
|
||||
}
|
||||
int read_cell(common::ObObj& obj);
|
||||
|
||||
private:
|
||||
private:
|
||||
inline int read_oracle_timestamp(
|
||||
const ObObjType obj_type, const uint8_t meta_attr, const ObOTimestampMetaAttrType otmat, ObObj& obj);
|
||||
int read_interval_ds(ObObj& obj);
|
||||
@ -49,7 +49,7 @@ class ObCellReader {
|
||||
int read(const T*& ptr);
|
||||
inline int is_es_end_object(const common::ObObj& obj, bool& is_end_obj);
|
||||
|
||||
private:
|
||||
private:
|
||||
const char* buf_;
|
||||
int64_t buf_size_;
|
||||
int64_t pos_;
|
||||
|
8
deps/oblib/src/common/cell/ob_cell_writer.h
vendored
8
deps/oblib/src/common/cell/ob_cell_writer.h
vendored
@ -36,7 +36,7 @@ enum ObCompactStoreType {
|
||||
const uint8_t TEXT_CELL_META_VERSION = 1;
|
||||
|
||||
class ObCellWriter {
|
||||
public:
|
||||
public:
|
||||
struct CellMeta {
|
||||
static const uint64_t SF_BIT_TYPE = 6;
|
||||
static const uint64_t SF_BIT_ATTR = 2;
|
||||
@ -66,7 +66,7 @@ class ObCellWriter {
|
||||
EV_LOCK_ROW = 5
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObCellWriter();
|
||||
virtual ~ObCellWriter()
|
||||
{}
|
||||
@ -111,7 +111,7 @@ class ObCellWriter {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
template <class T>
|
||||
int append(const T& value);
|
||||
inline int write_int(const ObObj& obj, const enum common::ObObjType meta_type, const int64_t value);
|
||||
@ -133,7 +133,7 @@ class ObCellWriter {
|
||||
return old_text_format_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
char* buf_;
|
||||
int64_t buf_size_;
|
||||
int64_t pos_;
|
||||
|
4
deps/oblib/src/common/data_buffer.h
vendored
4
deps/oblib/src/common/data_buffer.h
vendored
@ -21,7 +21,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObDataBuffer : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObDataBuffer() : data_(NULL), capacity_(0), position_(0), limit_(0)
|
||||
{}
|
||||
|
||||
@ -138,7 +138,7 @@ class ObDataBuffer : public ObIAllocator {
|
||||
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
char* data_;
|
||||
int64_t capacity_;
|
||||
int64_t position_;
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObDirectLogReader : public ObSingleLogReader {
|
||||
public:
|
||||
public:
|
||||
ObDirectLogReader();
|
||||
virtual ~ObDirectLogReader();
|
||||
|
||||
|
4
deps/oblib/src/common/log/ob_log_cursor.h
vendored
4
deps/oblib/src/common/log/ob_log_cursor.h
vendored
@ -44,7 +44,7 @@ struct ObLogCursor {
|
||||
|
||||
ObLogCursor& set_cursor(ObLogCursor& cursor, const int64_t file_id, const int64_t log_id, const int64_t offset);
|
||||
class ObAtomicLogCursor {
|
||||
public:
|
||||
public:
|
||||
ObAtomicLogCursor()
|
||||
{}
|
||||
~ObAtomicLogCursor()
|
||||
@ -52,7 +52,7 @@ class ObAtomicLogCursor {
|
||||
int get_cursor(ObLogCursor& cursor) const;
|
||||
int set_cursor(ObLogCursor& cursor);
|
||||
|
||||
private:
|
||||
private:
|
||||
ObLogCursor log_cursor_;
|
||||
mutable common::SpinRWLock cursor_lock_;
|
||||
};
|
||||
|
14
deps/oblib/src/common/log/ob_log_data_writer.h
vendored
14
deps/oblib/src/common/log/ob_log_data_writer.h
vendored
@ -22,7 +22,7 @@ namespace common {
|
||||
int myfallocate(int fd, int mode, off_t offset, off_t len);
|
||||
|
||||
class MinAvailFileIdGetter {
|
||||
public:
|
||||
public:
|
||||
MinAvailFileIdGetter()
|
||||
{}
|
||||
virtual ~MinAvailFileIdGetter()
|
||||
@ -31,12 +31,12 @@ class MinAvailFileIdGetter {
|
||||
};
|
||||
|
||||
class ObLogDataWriter {
|
||||
public:
|
||||
public:
|
||||
static const int OPEN_FLAG = O_WRONLY | O_DIRECT;
|
||||
static const int OPEN_MODE = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
static const int CREATE_FLAG = OPEN_FLAG | O_CREAT;
|
||||
class AppendBuffer {
|
||||
public:
|
||||
public:
|
||||
static const int64_t DEFAULT_BUF_SIZE = 1 << 22;
|
||||
AppendBuffer();
|
||||
~AppendBuffer();
|
||||
@ -44,14 +44,14 @@ class ObLogDataWriter {
|
||||
int flush(int fd);
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t file_pos_;
|
||||
char* buf_;
|
||||
int64_t buf_end_;
|
||||
int64_t buf_limit_;
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObLogDataWriter();
|
||||
~ObLogDataWriter();
|
||||
int init(const char* log_dir, const int64_t file_size, const int64_t du_percent, const int64_t log_sync_type,
|
||||
@ -67,13 +67,13 @@ class ObLogDataWriter {
|
||||
}
|
||||
int64_t to_string(char* buf, const int64_t len) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int check_eof_after_log_cursor(const ObLogCursor& cursor);
|
||||
int prepare_fd(const int64_t file_id);
|
||||
int reuse(const char* pool_file, const char* fname);
|
||||
const char* select_pool_file(char* fname, const int64_t limit);
|
||||
|
||||
private:
|
||||
private:
|
||||
AppendBuffer write_buffer_;
|
||||
const char* log_dir_;
|
||||
int64_t file_size_;
|
||||
|
@ -30,7 +30,7 @@ struct ObSimpleLogFile {
|
||||
};
|
||||
|
||||
class ObLogDirScanner {
|
||||
public:
|
||||
public:
|
||||
ObLogDirScanner();
|
||||
virtual ~ObLogDirScanner();
|
||||
|
||||
@ -66,7 +66,7 @@ class ObLogDirScanner {
|
||||
bool has_ckpt() const;
|
||||
void reset();
|
||||
|
||||
private:
|
||||
private:
|
||||
/**
|
||||
* Find all log files under directory
|
||||
*/
|
||||
@ -90,7 +90,7 @@ class ObLogDirScanner {
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ObLogDirScanner);
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t min_log_id_;
|
||||
uint64_t max_log_id_;
|
||||
uint64_t max_ckpt_id_;
|
||||
|
@ -98,7 +98,7 @@ static int64_t calc_nop_log_len(int64_t pos, int64_t min_log_size)
|
||||
|
||||
char ObLogGenerator::eof_flag_buf_[LOG_FILE_ALIGN_SIZE] __attribute__((aligned(DIO_ALIGN_SIZE)));
|
||||
static class EOF_FLAG_BUF_CONSTRUCTOR {
|
||||
public:
|
||||
public:
|
||||
EOF_FLAG_BUF_CONSTRUCTOR()
|
||||
{
|
||||
const char* mark_str = "end_of_log_file";
|
||||
|
12
deps/oblib/src/common/log/ob_log_generator.h
vendored
12
deps/oblib/src/common/log/ob_log_generator.h
vendored
@ -35,11 +35,11 @@ struct DebugLog {
|
||||
int64_t last_ctime_;
|
||||
};
|
||||
class ObLogGenerator {
|
||||
public:
|
||||
public:
|
||||
static const int64_t LOG_FILE_ALIGN_SIZE = 1 << OB_DIRECT_IO_ALIGN_BITS;
|
||||
static const int64_t LOG_FILE_ALIGN_MASK = LOG_FILE_ALIGN_SIZE - 1;
|
||||
static const int64_t LOG_BUF_RESERVED_SIZE = 3 * LOG_FILE_ALIGN_SIZE; // nop + switch_log + eof
|
||||
public:
|
||||
public:
|
||||
ObLogGenerator();
|
||||
~ObLogGenerator();
|
||||
int init(int64_t log_buf_size, int64_t log_file_max_size, const ObAddr* id = NULL);
|
||||
@ -63,12 +63,12 @@ class ObLogGenerator {
|
||||
int64_t to_string(char* buf, const int64_t len) const;
|
||||
static bool is_eof(const char* buf, int64_t len);
|
||||
|
||||
public:
|
||||
public:
|
||||
int get_start_cursor(ObLogCursor& log_cursor) const;
|
||||
int get_end_cursor(ObLogCursor& log_cursor) const;
|
||||
int dump_for_debug() const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool is_inited() const;
|
||||
int check_state() const;
|
||||
bool has_log() const;
|
||||
@ -78,10 +78,10 @@ class ObLogGenerator {
|
||||
int write_nop(const bool force_write = false);
|
||||
int append_eof();
|
||||
|
||||
public:
|
||||
public:
|
||||
static char eof_flag_buf_[LOG_FILE_ALIGN_SIZE] __attribute__((aligned(DIO_ALIGN_SIZE)));
|
||||
|
||||
private:
|
||||
private:
|
||||
bool is_frozen_;
|
||||
int64_t log_file_max_size_;
|
||||
ObLogCursor start_cursor_;
|
||||
|
8
deps/oblib/src/common/log/ob_log_reader.h
vendored
8
deps/oblib/src/common/log/ob_log_reader.h
vendored
@ -29,11 +29,11 @@ namespace common {
|
||||
* short time before reading the log again
|
||||
*/
|
||||
class ObLogReader {
|
||||
public:
|
||||
public:
|
||||
static const int64_t WAIT_TIME = 1000000; // us
|
||||
static const int FAIL_TIMES = 60;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObLogReader();
|
||||
virtual ~ObLogReader();
|
||||
|
||||
@ -60,12 +60,12 @@ class ObLogReader {
|
||||
inline int get_cursor(common::ObLogCursor& cursor);
|
||||
inline int get_next_cursor(common::ObLogCursor& cursor);
|
||||
|
||||
private:
|
||||
private:
|
||||
int seek(uint64_t log_seq);
|
||||
int open_log_(const uint64_t log_file_id, const uint64_t last_log_seq = 0);
|
||||
int read_log_(LogCommand& cmd, uint64_t& log_seq, char*& log_data, int64_t& data_len);
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t cur_log_file_id_;
|
||||
uint64_t cur_log_seq_id_;
|
||||
uint64_t max_log_file_id_;
|
||||
|
10
deps/oblib/src/common/log/ob_single_log_reader.h
vendored
10
deps/oblib/src/common/log/ob_single_log_reader.h
vendored
@ -23,10 +23,10 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObSingleLogReader {
|
||||
public:
|
||||
public:
|
||||
static const int64_t LOG_BUFFER_MAX_LENGTH;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObSingleLogReader();
|
||||
virtual ~ObSingleLogReader();
|
||||
|
||||
@ -88,18 +88,18 @@ class ObSingleLogReader {
|
||||
dio_ = false;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int read_header(ObLogEntry& entry);
|
||||
int trim_last_zero_padding(int64_t header_size);
|
||||
int open_with_lucky(const uint64_t file_id, const uint64_t last_log_seq);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/**
|
||||
* Read data from the log file to the read buffer
|
||||
*/
|
||||
int read_log_();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool is_inited_; // Initialization tag
|
||||
uint64_t file_id_; // Log file id
|
||||
uint64_t last_log_seq_; // Last log (Mutator) serial number
|
||||
|
8
deps/oblib/src/common/ob_accuracy.h
vendored
8
deps/oblib/src/common/ob_accuracy.h
vendored
@ -73,7 +73,7 @@ inline bool is_oracle_byte_length(const bool is_oracle_mode, const ObLengthSeman
|
||||
}
|
||||
|
||||
class ObAccuracy {
|
||||
public:
|
||||
public:
|
||||
ObAccuracy()
|
||||
{
|
||||
reset();
|
||||
@ -157,7 +157,7 @@ class ObAccuracy {
|
||||
accuracy_ = -1;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
OB_INLINE ObAccuracy& operator=(const ObAccuracy& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
@ -174,7 +174,7 @@ class ObAccuracy {
|
||||
return accuracy_ != other.accuracy_;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
// why we expose this 3 arrays directly?
|
||||
// imagine that we add 'if ... else' statements in ddl_default_accuracy() first,
|
||||
// and 'int ret = OB_SUCCESS' and 'return ret' statements too.
|
||||
@ -188,7 +188,7 @@ class ObAccuracy {
|
||||
static const ObAccuracy DML_DEFAULT_ACCURACY[ObMaxType];
|
||||
static const ObAccuracy MAX_ACCURACY_OLD[ObMaxType];
|
||||
|
||||
public:
|
||||
public:
|
||||
TO_STRING_KV(N_LENGTH, length_, N_PRECISION, precision_, N_SCALE, scale_);
|
||||
NEED_SERIALIZE_AND_DESERIALIZE;
|
||||
|
||||
|
2
deps/oblib/src/common/ob_action_flag.h
vendored
2
deps/oblib/src/common/ob_action_flag.h
vendored
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObActionFlag {
|
||||
public:
|
||||
public:
|
||||
static const int64_t OP_MIN_OBJ = 1;
|
||||
static const int64_t OP_MAX_OBJ = 2;
|
||||
static const int64_t OP_NOP = 3;
|
||||
|
8
deps/oblib/src/common/ob_balance_filter.h
vendored
8
deps/oblib/src/common/ob_balance_filter.h
vendored
@ -31,23 +31,23 @@ class ObBalanceFilter : public lib::ThreadPool {
|
||||
static const int64_t MAX_THREAD_NUM = 4096;
|
||||
static const int64_t REBALANCE_INTERVAL = 3L * 1000000L;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObBalanceFilter();
|
||||
~ObBalanceFilter();
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(const int64_t thread_num, const bool dynamic_rebalance);
|
||||
void destroy();
|
||||
void run1() override;
|
||||
|
||||
public:
|
||||
public:
|
||||
uint64_t filt(const uint64_t input);
|
||||
void migrate(const int64_t bucket_pos, const int64_t thread_pos);
|
||||
void log_info();
|
||||
void add_thread(const int64_t add_num);
|
||||
void sub_thread(const int64_t sub_num);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool inited_;
|
||||
int64_t bucket_node_num_;
|
||||
volatile int64_t thread_node_num_;
|
||||
|
42
deps/oblib/src/common/ob_buffer.h
vendored
42
deps/oblib/src/common/ob_buffer.h
vendored
@ -70,18 +70,18 @@ struct ObAlignedAllocator {
|
||||
|
||||
template <class Alloc = DfltBufferAlloc<> >
|
||||
class base_buffer {
|
||||
public:
|
||||
public:
|
||||
static const int64_t DEFAULT_CAPACITY = BUFSIZ;
|
||||
static const bool USE_EXCEPTION = true;
|
||||
static const bool NO_EXCEPTION = false;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int64_t capacity_;
|
||||
int64_t length_;
|
||||
int64_t base_;
|
||||
Alloc alloc_;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int64_t min(int64_t a, int64_t b) const
|
||||
{
|
||||
return a < b ? a : b;
|
||||
@ -140,7 +140,7 @@ class base_buffer {
|
||||
return len;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
base_buffer() : capacity_(0), length_(0), base_(0)
|
||||
{
|
||||
init_capacity_(DEFAULT_CAPACITY);
|
||||
@ -157,7 +157,7 @@ class base_buffer {
|
||||
length_ = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual char* ptre() = 0;
|
||||
virtual const char* ptre() const = 0;
|
||||
virtual char* ptr() = 0;
|
||||
@ -230,7 +230,7 @@ class base_buffer {
|
||||
return ObDataBuffer(ptr(), capacity());
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
int64_t compare(const char* str, int64_t len) const
|
||||
{
|
||||
int64_t r = MEMCMP(ptr(), str, min(length(), len));
|
||||
@ -252,7 +252,7 @@ class base_buffer {
|
||||
return compare(rbuf.ptr(), rbuf.length());
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
int append(const char* str, int64_t len)
|
||||
{
|
||||
if (0 == str || len < 0) {
|
||||
@ -469,7 +469,7 @@ class base_buffer {
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
int assign(const char* str, int64_t len)
|
||||
{
|
||||
if (0 == str || len < 0) {
|
||||
@ -606,13 +606,13 @@ class base_buffer {
|
||||
return appende(h);
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
template <class charT>
|
||||
class iterator_base {
|
||||
private:
|
||||
private:
|
||||
charT* cur_;
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit iterator_base(charT* p)
|
||||
{
|
||||
cur_ = p;
|
||||
@ -716,13 +716,13 @@ class base_buffer {
|
||||
|
||||
template <class Alloc = DfltBufferAlloc<> >
|
||||
class base_normal_buffer : public base_buffer<Alloc> {
|
||||
protected:
|
||||
protected:
|
||||
char* ptr_;
|
||||
|
||||
public:
|
||||
public:
|
||||
typedef base_buffer<Alloc> Parent;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual int reset_size_(bool exception, int64_t size, bool retain_data)
|
||||
{
|
||||
if (0 == ptr_) {
|
||||
@ -765,7 +765,7 @@ class base_normal_buffer : public base_buffer<Alloc> {
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
base_normal_buffer() : base_buffer<Alloc>()
|
||||
{
|
||||
preset_();
|
||||
@ -784,7 +784,7 @@ class base_normal_buffer : public base_buffer<Alloc> {
|
||||
Parent::length_ = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual char* ptre()
|
||||
{
|
||||
return ptr_ + Parent::base_;
|
||||
@ -805,13 +805,13 @@ class base_normal_buffer : public base_buffer<Alloc> {
|
||||
|
||||
template <int N = 256, class Alloc = DfltBufferAlloc<> >
|
||||
class sbuffer : public base_buffer<Alloc> {
|
||||
protected:
|
||||
protected:
|
||||
char buff_[N];
|
||||
|
||||
public:
|
||||
public:
|
||||
typedef base_buffer<Alloc> Parent;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual int reset_size_(bool exception, int64_t size, bool retain_data)
|
||||
{
|
||||
(void)size;
|
||||
@ -823,13 +823,13 @@ class sbuffer : public base_buffer<Alloc> {
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
sbuffer() : base_buffer<Alloc>(N)
|
||||
{}
|
||||
virtual ~sbuffer()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual char* ptre()
|
||||
{
|
||||
return buff_ + Parent::base_;
|
||||
|
8
deps/oblib/src/common/ob_clock_generator.h
vendored
8
deps/oblib/src/common/ob_clock_generator.h
vendored
@ -26,7 +26,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
class ObClockGenerator : public lib::ThreadPool {
|
||||
private:
|
||||
private:
|
||||
ObClockGenerator() : inited_(false), ready_(false), cur_ts_(0), last_used_time_(0)
|
||||
{}
|
||||
~ObClockGenerator()
|
||||
@ -34,7 +34,7 @@ class ObClockGenerator : public lib::ThreadPool {
|
||||
destroy();
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
static int init();
|
||||
static void destroy();
|
||||
static int64_t getClock();
|
||||
@ -43,11 +43,11 @@ class ObClockGenerator : public lib::ThreadPool {
|
||||
static void msleep(const int64_t ms);
|
||||
static void usleep(const int64_t us);
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t get_us();
|
||||
void run1() final;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool inited_;
|
||||
bool ready_;
|
||||
int64_t cur_ts_;
|
||||
|
4
deps/oblib/src/common/ob_common_utility.h
vendored
4
deps/oblib/src/common/ob_common_utility.h
vendored
@ -46,13 +46,13 @@ inline int check_stack_overflow(void)
|
||||
* The of pointer of the class is maintained on thread local.
|
||||
*/
|
||||
class ObFatalErrExtraInfoGuard {
|
||||
public:
|
||||
public:
|
||||
explicit ObFatalErrExtraInfoGuard();
|
||||
virtual ~ObFatalErrExtraInfoGuard();
|
||||
static const ObFatalErrExtraInfoGuard* get_thd_local_val_ptr();
|
||||
DEFINE_VIRTUAL_TO_STRING();
|
||||
|
||||
private:
|
||||
private:
|
||||
static ObFatalErrExtraInfoGuard*& get_val();
|
||||
ObFatalErrExtraInfoGuard* last_;
|
||||
};
|
||||
|
6
deps/oblib/src/common/ob_field.h
vendored
6
deps/oblib/src/common/ob_field.h
vendored
@ -27,7 +27,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
struct ObParamedSelectItemCtx {
|
||||
public:
|
||||
public:
|
||||
// paramed column for display
|
||||
ObString paramed_cname_;
|
||||
// Record every parameterized? Offset relative to field name
|
||||
@ -69,7 +69,7 @@ struct ObParamedSelectItemCtx {
|
||||
|
||||
// NOTE: ~ObFileld may not called, all memory should be auto free.
|
||||
class ObField {
|
||||
public:
|
||||
public:
|
||||
ObString dname_; // database name for display
|
||||
ObString tname_; // table name for display
|
||||
ObString org_tname_; // original table name
|
||||
@ -119,7 +119,7 @@ class ObField {
|
||||
static int get_field_mb_length(
|
||||
const ObObjType type, const ObAccuracy& accuracy, const ObCollationType charsetnr, int32_t& length);
|
||||
|
||||
private:
|
||||
private:
|
||||
static int32_t my_decimal_precision_to_length_no_truncation(int16_t precision, int16_t scale, bool unsigned_flag)
|
||||
{
|
||||
/*
|
||||
|
4
deps/oblib/src/common/ob_hint.h
vendored
4
deps/oblib/src/common/ob_hint.h
vendored
@ -22,7 +22,7 @@ const char* get_consistency_level_str(ObConsistencyLevel level);
|
||||
/// @retval -1 on error
|
||||
ObConsistencyLevel get_consistency_level_by_str(const ObString& level);
|
||||
struct ObTableScanHint {
|
||||
public:
|
||||
public:
|
||||
int64_t max_parallel_count_;
|
||||
bool enable_parallel_;
|
||||
int64_t timeout_us_;
|
||||
@ -30,7 +30,7 @@ struct ObTableScanHint {
|
||||
ObConsistencyLevel read_consistency_;
|
||||
bool force_refresh_lc_;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObTableScanHint()
|
||||
: max_parallel_count_(OB_DEFAULT_MAX_PARALLEL_COUNT),
|
||||
enable_parallel_(true),
|
||||
|
4
deps/oblib/src/common/ob_i_callback.h
vendored
4
deps/oblib/src/common/ob_i_callback.h
vendored
@ -16,7 +16,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObICallback {
|
||||
public:
|
||||
public:
|
||||
ObICallback()
|
||||
{}
|
||||
virtual ~ObICallback()
|
||||
@ -25,7 +25,7 @@ class ObICallback {
|
||||
};
|
||||
|
||||
class ObICallbackHandler {
|
||||
public:
|
||||
public:
|
||||
ObICallbackHandler()
|
||||
{}
|
||||
virtual ~ObICallbackHandler()
|
||||
|
2
deps/oblib/src/common/ob_i_rs_cb.h
vendored
2
deps/oblib/src/common/ob_i_rs_cb.h
vendored
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObIRSCb {
|
||||
public:
|
||||
public:
|
||||
virtual int submit_pt_update_task(const common::ObPartitionKey& part_key, const int64_t data_version) = 0;
|
||||
};
|
||||
} // namespace common
|
||||
|
12
deps/oblib/src/common/ob_member.h
vendored
12
deps/oblib/src/common/ob_member.h
vendored
@ -23,11 +23,11 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObMember {
|
||||
public:
|
||||
public:
|
||||
ObMember();
|
||||
ObMember(const common::ObAddr& server, const int64_t timestamp);
|
||||
|
||||
public:
|
||||
public:
|
||||
const common::ObAddr& get_server() const;
|
||||
int64_t get_timestamp() const;
|
||||
virtual void reset();
|
||||
@ -42,7 +42,7 @@ class ObMember {
|
||||
TO_YSON_KV(Y_(server), OB_ID(t), timestamp_, Y_(flag));
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
common::ObAddr server_;
|
||||
int64_t timestamp_;
|
||||
int64_t flag_;
|
||||
@ -65,7 +65,7 @@ inline bool operator<(const ObMember& lhs, const ObMember& rhs)
|
||||
}
|
||||
|
||||
class ObReplicaMember : public ObMember {
|
||||
public:
|
||||
public:
|
||||
ObReplicaMember() : ObMember(), replica_type_(REPLICA_TYPE_FULL), region_(DEFAULT_REGION_NAME), memstore_percent_(100)
|
||||
{}
|
||||
ObReplicaMember(const common::ObAddr& server, const int64_t timestamp)
|
||||
@ -93,7 +93,7 @@ class ObReplicaMember : public ObMember {
|
||||
: ObMember(server, timestamp), replica_type_(replica_type), region_(region), memstore_percent_(memstore_percent)
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
common::ObReplicaType get_replica_type() const;
|
||||
int set_replica_type(const common::ObReplicaType replica_type);
|
||||
const common::ObRegion& get_region() const;
|
||||
@ -115,7 +115,7 @@ class ObReplicaMember : public ObMember {
|
||||
TO_STRING_KV(K_(server), K_(timestamp), K_(flag), K_(replica_type), K_(region), K_(memstore_percent));
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
private:
|
||||
private:
|
||||
common::ObReplicaType replica_type_;
|
||||
common::ObRegion region_;
|
||||
int64_t memstore_percent_;
|
||||
|
6
deps/oblib/src/common/ob_member_list.h
vendored
6
deps/oblib/src/common/ob_member_list.h
vendored
@ -22,11 +22,11 @@ template <int64_t MAX_MEMBER_NUM>
|
||||
class ObMemberListBase {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
ObMemberListBase();
|
||||
~ObMemberListBase();
|
||||
|
||||
public:
|
||||
public:
|
||||
void reset();
|
||||
bool is_valid() const;
|
||||
int add_member(const common::ObMember& member);
|
||||
@ -51,7 +51,7 @@ class ObMemberListBase {
|
||||
int64_t to_string(char* buf, const int64_t buf_len) const;
|
||||
TO_YSON_KV(OB_ID(member), common::ObArrayWrap<common::ObMember>(member_, member_number_));
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t member_number_;
|
||||
common::ObMember member_[MAX_MEMBER_NUM];
|
||||
};
|
||||
|
10
deps/oblib/src/common/ob_partition_key.h
vendored
10
deps/oblib/src/common/ob_partition_key.h
vendored
@ -22,7 +22,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
struct ObPartitionKey final {
|
||||
public:
|
||||
public:
|
||||
ObPartitionKey() : table_id_(OB_INVALID_ID), part_id_(OB_INVALID_INDEX), assit_id_(OB_INVALID_INDEX), hash_value_(0)
|
||||
{}
|
||||
|
||||
@ -116,7 +116,7 @@ struct ObPartitionKey final {
|
||||
uint64_t tablegroup_id_;
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
int32_t part_id_; // First level part_id
|
||||
union {
|
||||
int32_t subpart_id_; // Secondary part_id
|
||||
@ -141,14 +141,14 @@ typedef ObSEArray<ObPartitionType, OB_DEFAULT_PARTITION_KEY_COUNT> ObPartitionTy
|
||||
class ObPartitionLeaderArray {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
ObPartitionLeaderArray()
|
||||
{}
|
||||
~ObPartitionLeaderArray()
|
||||
{}
|
||||
void reset();
|
||||
|
||||
public:
|
||||
public:
|
||||
int push(const common::ObPartitionKey& partition, const common::ObAddr& leader,
|
||||
const common::ObPartitionType& type = ObPartitionType::NORMAL_PARTITION);
|
||||
int assign(const ObPartitionLeaderArray& pla);
|
||||
@ -175,7 +175,7 @@ class ObPartitionLeaderArray {
|
||||
|
||||
TO_STRING_KV(K_(partitions), K_(leaders), K_(type_array));
|
||||
|
||||
private:
|
||||
private:
|
||||
common::ObPartitionArray partitions_;
|
||||
common::ObAddrArray leaders_;
|
||||
common::ObPartitionTypeArray type_array_;
|
||||
|
40
deps/oblib/src/common/ob_queue_thread.h
vendored
40
deps/oblib/src/common/ob_queue_thread.h
vendored
@ -35,16 +35,16 @@ class ObCond {
|
||||
static const int64_t SPIN_WAIT_NUM = 0;
|
||||
static const int64_t BUSY_INTERVAL = 1000;
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit ObCond(const int64_t spin_wait_num = SPIN_WAIT_NUM);
|
||||
~ObCond();
|
||||
|
||||
public:
|
||||
public:
|
||||
void signal();
|
||||
int timedwait(const int64_t time_us);
|
||||
int wait();
|
||||
|
||||
private:
|
||||
private:
|
||||
const int64_t spin_wait_num_;
|
||||
volatile bool bcond_;
|
||||
int64_t last_waked_time_;
|
||||
@ -89,14 +89,14 @@ class S2MQueueThread {
|
||||
typedef DRWLock::WRLockGuard WRLockGuard;
|
||||
typedef ObTCCounter Counter;
|
||||
|
||||
public:
|
||||
public:
|
||||
enum { HIGH_PRIO_QUEUE = 0, HOTSPOT_QUEUE = 1, NORMAL_PRIO_QUEUE = 2, LOW_PRIO_QUEUE = 3, QUEUE_COUNT = 4 };
|
||||
|
||||
public:
|
||||
public:
|
||||
S2MQueueThread();
|
||||
virtual ~S2MQueueThread();
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(
|
||||
const int64_t thread_num, const int64_t task_num_limit, const bool queue_rebalance, const bool dynamic_rebalance);
|
||||
int set_prio_quota(v4si& quota);
|
||||
@ -114,7 +114,7 @@ class S2MQueueThread {
|
||||
};
|
||||
int wakeup();
|
||||
|
||||
public:
|
||||
public:
|
||||
int push(void* task, const int64_t prio = NORMAL_PRIV);
|
||||
int push(void* task, const uint64_t task_sign, const int64_t prio);
|
||||
int push_low_prio(void* task);
|
||||
@ -137,12 +137,12 @@ class S2MQueueThread {
|
||||
UNUSED(ptr);
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
void* rebalance_(int64_t& idx, const ThreadConf& cur_thread);
|
||||
int launch_thread_(const int64_t thread_num, const int64_t task_num_limit);
|
||||
static void* thread_func_(void* data);
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t thread_num_;
|
||||
volatile uint64_t thread_conf_iter_;
|
||||
RWLock thread_conf_lock_;
|
||||
@ -157,15 +157,15 @@ typedef S2MCond M2SCond;
|
||||
class M2SQueueThread {
|
||||
static const int64_t QUEUE_WAIT_TIME;
|
||||
|
||||
public:
|
||||
public:
|
||||
M2SQueueThread();
|
||||
virtual ~M2SQueueThread();
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(const int64_t task_num_limit, const int64_t idle_interval);
|
||||
void destroy();
|
||||
|
||||
public:
|
||||
public:
|
||||
int push(void* task);
|
||||
int64_t get_queued_num() const;
|
||||
virtual void handle(void* task, void* pdata) = 0;
|
||||
@ -179,10 +179,10 @@ class M2SQueueThread {
|
||||
};
|
||||
virtual void on_idle(){};
|
||||
|
||||
private:
|
||||
private:
|
||||
static void* thread_func_(void* data);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool inited_;
|
||||
pthread_t pd_;
|
||||
volatile bool run_flag_;
|
||||
@ -195,15 +195,15 @@ class M2SQueueThread {
|
||||
class SeqQueueThread {
|
||||
static const int64_t QUEUE_WAIT_TIME = 10 * 1000;
|
||||
|
||||
public:
|
||||
public:
|
||||
SeqQueueThread();
|
||||
virtual ~SeqQueueThread();
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(const int64_t task_num_limit, const int64_t idle_interval);
|
||||
void destroy();
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual int push(void* task);
|
||||
int64_t get_queued_num() const;
|
||||
virtual void handle(void* task, void* pdata) = 0;
|
||||
@ -222,13 +222,13 @@ class SeqQueueThread {
|
||||
virtual void on_idle(){};
|
||||
virtual int64_t get_seq(void* task) = 0;
|
||||
|
||||
private:
|
||||
private:
|
||||
static void* thread_func_(void* data);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
ObSeqQueue task_queue_;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool inited_;
|
||||
pthread_t pd_;
|
||||
volatile bool run_flag_;
|
||||
|
14
deps/oblib/src/common/ob_range.h
vendored
14
deps/oblib/src/common/ob_range.h
vendored
@ -24,13 +24,13 @@ namespace common {
|
||||
class ObStoreRange;
|
||||
|
||||
class ObBorderFlag {
|
||||
public:
|
||||
public:
|
||||
static const int8_t INCLUSIVE_START = 0x1;
|
||||
static const int8_t INCLUSIVE_END = 0x2;
|
||||
static const int8_t MIN_VALUE = 0x4;
|
||||
static const int8_t MAX_VALUE = 0x8;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObBorderFlag() : data_(0)
|
||||
{}
|
||||
virtual ~ObBorderFlag()
|
||||
@ -103,7 +103,7 @@ class ObBorderFlag {
|
||||
|
||||
TO_STRING_KV(N_FLAG, data_);
|
||||
|
||||
private:
|
||||
private:
|
||||
int8_t data_;
|
||||
};
|
||||
|
||||
@ -291,7 +291,7 @@ struct ObVersion {
|
||||
};
|
||||
|
||||
class ObVersionProvider {
|
||||
public:
|
||||
public:
|
||||
virtual ~ObVersionProvider()
|
||||
{}
|
||||
virtual const ObVersion get_frozen_version() const = 0;
|
||||
@ -310,7 +310,7 @@ class ObVersionProvider {
|
||||
struct ObVersionRange {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t MIN_VERSION = 0;
|
||||
static const int64_t MAX_VERSION = INT64_MAX;
|
||||
|
||||
@ -337,7 +337,7 @@ struct ObVersionRange {
|
||||
struct ObLogTsRange {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t MIN_TS = 0;
|
||||
static const int64_t MAX_TS = INT64_MAX;
|
||||
|
||||
@ -383,7 +383,7 @@ struct ObLogTsRange {
|
||||
|
||||
class ObNewRange {
|
||||
|
||||
public:
|
||||
public:
|
||||
uint64_t table_id_;
|
||||
ObBorderFlag border_flag_;
|
||||
ObRowkey start_key_;
|
||||
|
8
deps/oblib/src/common/ob_role_mgr.h
vendored
8
deps/oblib/src/common/ob_role_mgr.h
vendored
@ -19,7 +19,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
/// @brief ObRoleMgr manages the role and status of the process
|
||||
class ObRoleMgr {
|
||||
public:
|
||||
public:
|
||||
static const int32_t OB_MASTER = 1;
|
||||
static const int32_t OB_SLAVE = 2;
|
||||
enum Role {
|
||||
@ -50,7 +50,7 @@ class ObRoleMgr {
|
||||
BOOTOK = 8,
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObRoleMgr() : role_(SLAVE), state_(INIT)
|
||||
{}
|
||||
|
||||
@ -75,10 +75,10 @@ class ObRoleMgr {
|
||||
|
||||
inline const char* get_state_str() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObRoleMgr);
|
||||
|
||||
private:
|
||||
private:
|
||||
volatile Role role_;
|
||||
volatile State state_;
|
||||
};
|
||||
|
8
deps/oblib/src/common/ob_segmented_buffer.h
vendored
8
deps/oblib/src/common/ob_segmented_buffer.h
vendored
@ -21,7 +21,7 @@ namespace common {
|
||||
class ObSegmentedBufffer {
|
||||
friend class ObSegmentedBuffferIterator;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObSegmentedBufffer(const int block_size, const lib::ObMemAttr attr)
|
||||
: block_size_(block_size), attr_(attr), head_(nullptr), block_(nullptr), pos_(0)
|
||||
{}
|
||||
@ -35,7 +35,7 @@ class ObSegmentedBufffer {
|
||||
void destory();
|
||||
int dump_to_file(const char* file_name);
|
||||
|
||||
private:
|
||||
private:
|
||||
const int block_size_;
|
||||
const lib::ObMemAttr attr_;
|
||||
char* head_;
|
||||
@ -44,12 +44,12 @@ class ObSegmentedBufffer {
|
||||
};
|
||||
|
||||
class ObSegmentedBuffferIterator {
|
||||
public:
|
||||
public:
|
||||
ObSegmentedBuffferIterator(ObSegmentedBufffer& sb) : next_buf_(sb.head_), sb_(sb)
|
||||
{}
|
||||
char* next(int64_t& len);
|
||||
|
||||
private:
|
||||
private:
|
||||
char* next_buf_;
|
||||
const ObSegmentedBufffer& sb_;
|
||||
};
|
||||
|
4
deps/oblib/src/common/ob_server_ext.h
vendored
4
deps/oblib/src/common/ob_server_ext.h
vendored
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObServerExt {
|
||||
public:
|
||||
public:
|
||||
friend class ObOcmInstance;
|
||||
ObServerExt();
|
||||
~ObServerExt();
|
||||
@ -34,7 +34,7 @@ class ObServerExt {
|
||||
ObAddr& get_server();
|
||||
int deep_copy(const ObServerExt& server_ext);
|
||||
|
||||
private:
|
||||
private:
|
||||
char hostname_[OB_MAX_HOST_NAME_LENGTH];
|
||||
ObAddr server_;
|
||||
int64_t magic_num_;
|
||||
|
4
deps/oblib/src/common/ob_simple_iterator.h
vendored
4
deps/oblib/src/common/ob_simple_iterator.h
vendored
@ -24,7 +24,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
template <typename T, const char* LABEL, int64_t LOCAL_ARRAY_SIZE>
|
||||
class ObSimpleIterator {
|
||||
public:
|
||||
public:
|
||||
ObSimpleIterator() : item_arr_(LABEL, OB_MALLOC_NORMAL_BLOCK_SIZE)
|
||||
{
|
||||
reset();
|
||||
@ -40,7 +40,7 @@ class ObSimpleIterator {
|
||||
}
|
||||
int get_next(T& item);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool is_ready_;
|
||||
typename common::ObSEArray<T, LOCAL_ARRAY_SIZE> item_arr_;
|
||||
typename common::ObSEArray<T, LOCAL_ARRAY_SIZE>::iterator it_;
|
||||
|
16
deps/oblib/src/common/ob_simple_tpl.h
vendored
16
deps/oblib/src/common/ob_simple_tpl.h
vendored
@ -63,10 +63,10 @@ struct Pair {
|
||||
|
||||
template <typename Factory>
|
||||
struct TSI {
|
||||
public:
|
||||
public:
|
||||
typedef typename Factory::InstanceType T;
|
||||
|
||||
public:
|
||||
public:
|
||||
TSI(Factory& factory) : create_err_(0), factory_(factory)
|
||||
{
|
||||
create_err_ = pthread_key_create(&key_, destroy);
|
||||
@ -94,7 +94,7 @@ struct TSI {
|
||||
return val;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static void destroy(void* arg)
|
||||
{
|
||||
if (NULL != arg) {
|
||||
@ -109,7 +109,7 @@ struct TSI {
|
||||
// Can not be deleted, regardless of memory
|
||||
template <typename T>
|
||||
class SimpleList {
|
||||
public:
|
||||
public:
|
||||
SimpleList() : tail_((T*)&guard_)
|
||||
{
|
||||
tail_->next_ = tail_;
|
||||
@ -141,23 +141,23 @@ class SimpleList {
|
||||
return tail_->next_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
T* guard_;
|
||||
T* tail_;
|
||||
};
|
||||
|
||||
template <typename Allocator>
|
||||
class ObHandyAllocatorWrapper : public Allocator {
|
||||
public:
|
||||
public:
|
||||
ObHandyAllocatorWrapper() : allocated_(0)
|
||||
{}
|
||||
~ObHandyAllocatorWrapper()
|
||||
{}
|
||||
|
||||
private:
|
||||
private:
|
||||
volatile int64_t allocated_;
|
||||
|
||||
public:
|
||||
public:
|
||||
int64_t get_alloc_size() const
|
||||
{
|
||||
return allocated_;
|
||||
|
18
deps/oblib/src/common/ob_smart_var.h
vendored
18
deps/oblib/src/common/ob_smart_var.h
vendored
@ -50,7 +50,7 @@ extern void* smart_alloc(const int64_t, const char*);
|
||||
extern void smart_free(void*);
|
||||
|
||||
class _SBase {
|
||||
public:
|
||||
public:
|
||||
_SBase(const int ret, const bool from_heap) : ret_(ret), from_heap_(from_heap)
|
||||
{}
|
||||
int ret_;
|
||||
@ -59,7 +59,7 @@ class _SBase {
|
||||
|
||||
template <typename T, bool large, bool direct_heap = false>
|
||||
class _S : public _SBase {
|
||||
public:
|
||||
public:
|
||||
static int precheck(bool& from_heap, bool& by_vla)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -72,7 +72,7 @@ class _S : public _SBase {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
template <typename... Args>
|
||||
_S(const int ret, const bool from_heap, Args&&... args) : _SBase(ret, from_heap), v_(nullptr)
|
||||
{
|
||||
@ -110,7 +110,7 @@ template <typename T, int N, bool direct_heap>
|
||||
class _S<T[N], true, direct_heap> : public _SBase {
|
||||
typedef T Array[N];
|
||||
|
||||
public:
|
||||
public:
|
||||
static int precheck(bool& from_heap, bool& by_vla)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -123,7 +123,7 @@ class _S<T[N], true, direct_heap> : public _SBase {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
_S(const int ret, const bool from_heap) : _SBase(ret, from_heap), v_(nullptr)
|
||||
{
|
||||
if (OB_SUCCESS == ret_) {
|
||||
@ -160,7 +160,7 @@ class _S<T[N], true, direct_heap> : public _SBase {
|
||||
|
||||
template <typename T>
|
||||
class _S<T, false> : public _SBase {
|
||||
public:
|
||||
public:
|
||||
static int precheck(bool& from_heap, bool& by_vla)
|
||||
{
|
||||
from_heap = false;
|
||||
@ -168,7 +168,7 @@ class _S<T, false> : public _SBase {
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
template <typename... Args>
|
||||
_S(const int ret, const bool from_heap, Args&&... args) : _SBase(ret, from_heap), obj_(args...), v_(&obj_)
|
||||
{}
|
||||
@ -184,7 +184,7 @@ template <typename T, int N>
|
||||
class _S<T[N], false> : public _SBase {
|
||||
typedef T Array[N];
|
||||
|
||||
public:
|
||||
public:
|
||||
static int precheck(bool& from_heap, bool& by_vla)
|
||||
{
|
||||
from_heap = false;
|
||||
@ -192,7 +192,7 @@ class _S<T[N], false> : public _SBase {
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
_S(const int ret, const bool from_heap) : _SBase(ret, from_heap), v_(&array_[0])
|
||||
{}
|
||||
Array& get()
|
||||
|
8
deps/oblib/src/common/ob_store_format.h
vendored
8
deps/oblib/src/common/ob_store_format.h
vendored
@ -46,17 +46,17 @@ struct ObStoreFormatItem {
|
||||
};
|
||||
|
||||
class ObStoreFormat {
|
||||
public:
|
||||
public:
|
||||
static const ObStoreFormatType STORE_FORMAT_MYSQL_START = OB_STORE_FORMAT_REDUNDANT_MYSQL;
|
||||
static const ObStoreFormatType STORE_FORMAT_MYSQL_DEFAULT = OB_STORE_FORMAT_COMPACT_MYSQL;
|
||||
static const ObStoreFormatType STORE_FORMAT_ORACLE_START = OB_STORE_FORMAT_NOCOMPRESS_ORACLE;
|
||||
static const ObStoreFormatType STORE_FORMAT_ORACLE_DEFAULT = OB_STORE_FORMAT_OLTP_ORACLE;
|
||||
|
||||
private:
|
||||
private:
|
||||
ObStoreFormat(){};
|
||||
virtual ~ObStoreFormat(){};
|
||||
|
||||
public:
|
||||
public:
|
||||
static inline bool is_row_store_type_valid(const ObRowStoreType type)
|
||||
{
|
||||
return type == FLAT_ROW_STORE || type == SPARSE_ROW_STORE;
|
||||
@ -111,7 +111,7 @@ class ObStoreFormat {
|
||||
static int find_store_format_type(
|
||||
const ObString& store_format, const bool is_oracle_mode, ObStoreFormatType& store_format_type);
|
||||
|
||||
private:
|
||||
private:
|
||||
static const ObStoreFormatItem store_format_items[OB_STORE_FORMAT_MAX];
|
||||
static const char* row_store_name[MAX_ROW_STORE];
|
||||
};
|
||||
|
14
deps/oblib/src/common/ob_store_range.h
vendored
14
deps/oblib/src/common/ob_store_range.h
vendored
@ -27,7 +27,7 @@ namespace common {
|
||||
// because the comparison of the start_key_ and end_key_ of the range requires additional
|
||||
// (column order) information.
|
||||
class ObStoreRange {
|
||||
public:
|
||||
public:
|
||||
ObStoreRange()
|
||||
{
|
||||
reset();
|
||||
@ -158,7 +158,7 @@ class ObStoreRange {
|
||||
|
||||
inline int get_common_store_rowkey(ObStoreRowkey& store_rowkey) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t table_id_;
|
||||
ObBorderFlag border_flag_;
|
||||
ObStoreRowkey start_key_;
|
||||
@ -166,7 +166,7 @@ class ObStoreRange {
|
||||
|
||||
// FIXME-: remove interfaces below after changing code that calls below methods
|
||||
// ObStoreRange should NOT provide compare semantics
|
||||
public:
|
||||
public:
|
||||
inline void set_whole_range();
|
||||
inline bool is_whole_range() const
|
||||
{
|
||||
@ -343,7 +343,7 @@ inline int deep_copy_range(ObIAllocator& allocator, const ObStoreRange& src, ObS
|
||||
* for better performance.
|
||||
*/
|
||||
class ObExtStoreRange {
|
||||
public:
|
||||
public:
|
||||
ObExtStoreRange();
|
||||
explicit ObExtStoreRange(const ObStoreRange& range);
|
||||
|
||||
@ -394,7 +394,7 @@ class ObExtStoreRange {
|
||||
|
||||
TO_STRING_KV(K_(range), K_(ext_start_key), K_(ext_end_key));
|
||||
|
||||
private:
|
||||
private:
|
||||
ObStoreRange range_;
|
||||
// used for search macro block
|
||||
ObExtStoreRowkey ext_start_key_;
|
||||
@ -402,13 +402,13 @@ class ObExtStoreRange {
|
||||
};
|
||||
|
||||
class ObVersionStoreRangeConversionHelper {
|
||||
public:
|
||||
public:
|
||||
static int store_rowkey_to_multi_version_range(const ObExtStoreRowkey& src_rowkey,
|
||||
const ObVersionRange& version_range, ObIAllocator& allocator, ObExtStoreRange& multi_version_range);
|
||||
static int range_to_multi_version_range(const ObExtStoreRange& src_range, const ObVersionRange& version_range,
|
||||
ObIAllocator& allocator, ObExtStoreRange& multi_version_range);
|
||||
|
||||
private:
|
||||
private:
|
||||
static int build_multi_version_store_rowkey(const ObStoreRowkey& rowkey, const int64_t trans_version,
|
||||
ObIAllocator& allocator, ObStoreRowkey& multi_version_rowkey);
|
||||
};
|
||||
|
8
deps/oblib/src/common/ob_string_buf.h
vendored
8
deps/oblib/src/common/ob_string_buf.h
vendored
@ -25,7 +25,7 @@ namespace common {
|
||||
// ObStringBufT is used to store the ObString and ObObj object.
|
||||
template <typename PageAllocatorT = ModulePageAllocator, typename PageArenaT = PageArena<char, PageAllocatorT> >
|
||||
class ObStringBufT {
|
||||
public:
|
||||
public:
|
||||
explicit ObStringBufT(
|
||||
const lib::ObLabel& label = ObModIds::OB_STRING_BUF, const int64_t block_size = DEF_MEM_BLOCK_SIZE);
|
||||
explicit ObStringBufT(PageArenaT& arena);
|
||||
@ -33,7 +33,7 @@ class ObStringBufT {
|
||||
int reset();
|
||||
int reuse();
|
||||
|
||||
public:
|
||||
public:
|
||||
// Writes a string to buf.
|
||||
// @param [in] str the string object to be stored.
|
||||
// @param [out] stored_str records the stored ptr and length of string.
|
||||
@ -80,11 +80,11 @@ class ObStringBufT {
|
||||
arena_.free(static_cast<char*>(ptr));
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static const int64_t DEF_MEM_BLOCK_SIZE;
|
||||
static const int64_t MIN_DEF_MEM_BLOCK_SIZE;
|
||||
|
||||
private:
|
||||
private:
|
||||
PageArenaT local_arena_;
|
||||
PageArenaT& arena_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObStringBufT);
|
||||
|
8
deps/oblib/src/common/ob_timeout_ctx.h
vendored
8
deps/oblib/src/common/ob_timeout_ctx.h
vendored
@ -26,7 +26,7 @@ namespace common {
|
||||
// Pass timeout argument by thread local variable,
|
||||
// to avoid add timeout argument to all functions.
|
||||
class ObTimeoutCtx {
|
||||
public:
|
||||
public:
|
||||
ObTimeoutCtx();
|
||||
virtual ~ObTimeoutCtx();
|
||||
|
||||
@ -52,14 +52,14 @@ class ObTimeoutCtx {
|
||||
|
||||
TO_STRING_KV(K_(abs_timeout_us));
|
||||
|
||||
private:
|
||||
private:
|
||||
explicit ObTimeoutCtx(bool link_self);
|
||||
void do_link_self();
|
||||
|
||||
private:
|
||||
private:
|
||||
static ObTimeoutCtx*& header();
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t abs_timeout_us_; // query_timeout
|
||||
int64_t trx_timeout_us_; // trx_timeout
|
||||
ObTimeoutCtx* next_;
|
||||
|
8
deps/oblib/src/common/ob_trace_profile.h
vendored
8
deps/oblib/src/common/ob_trace_profile.h
vendored
@ -20,12 +20,12 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObTraceProfile {
|
||||
public:
|
||||
public:
|
||||
ObTraceProfile();
|
||||
~ObTraceProfile()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(const char* module, const int64_t warn_timeout, const bool is_tracing);
|
||||
void set_sign(const uint64_t sign);
|
||||
void reset();
|
||||
@ -35,7 +35,7 @@ class ObTraceProfile {
|
||||
int trace(const ObPartitionKey& partition_key, const char* flag, const ObAddr& server);
|
||||
void report_trace();
|
||||
|
||||
private:
|
||||
private:
|
||||
struct TraceEntry {
|
||||
void reset();
|
||||
ObPartitionKey partition_key_;
|
||||
@ -56,7 +56,7 @@ class ObTraceProfile {
|
||||
|
||||
TraceEntry entry_[MAX_TRACE_NUM];
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObTraceProfile);
|
||||
};
|
||||
|
||||
|
14
deps/oblib/src/common/ob_unit_info.h
vendored
14
deps/oblib/src/common/ob_unit_info.h
vendored
@ -24,17 +24,17 @@ namespace share {
|
||||
struct ObUnit {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
enum Status {
|
||||
UNIT_STATUS_ACTIVE = 0,
|
||||
UNIT_STATUS_DELETING,
|
||||
UNIT_STATUS_MAX,
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
static const char* const unit_status_strings[UNIT_STATUS_MAX];
|
||||
|
||||
public:
|
||||
public:
|
||||
ObUnit();
|
||||
~ObUnit()
|
||||
{}
|
||||
@ -73,7 +73,7 @@ typedef common::ObFixedLengthString<common::MAX_UNIT_CONFIG_LENGTH> ObUnitConfig
|
||||
struct ObUnitConfig {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
static constexpr double CPU_EPSILON = 0.00001;
|
||||
ObUnitConfig();
|
||||
~ObUnitConfig()
|
||||
@ -105,7 +105,7 @@ typedef common::ObFixedLengthString<common::MAX_RESOURCE_POOL_LENGTH> ObResource
|
||||
struct ObResourcePool {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t DEFAULT_ZONE_COUNT = 5;
|
||||
|
||||
ObResourcePool();
|
||||
@ -124,7 +124,7 @@ struct ObResourcePool {
|
||||
uint64_t tenant_id_;
|
||||
common::ObReplicaType replica_type_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObResourcePool);
|
||||
};
|
||||
|
||||
@ -151,7 +151,7 @@ struct ObUnitInfo {
|
||||
ObUnitConfig config_;
|
||||
ObResourcePool pool_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObUnitInfo);
|
||||
};
|
||||
|
||||
|
8
deps/oblib/src/common/ob_version_provider.h
vendored
8
deps/oblib/src/common/ob_version_provider.h
vendored
@ -15,18 +15,18 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObVersionProvider {
|
||||
public:
|
||||
public:
|
||||
ObVersionProvider(){};
|
||||
virtual ~ObVersionProvider(){};
|
||||
virtual common::ObVersion get_frozen_version() const = 0;
|
||||
|
||||
private:
|
||||
private:
|
||||
// types and constants
|
||||
private:
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObVersionProvider);
|
||||
|
||||
private:
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
} // end namespace common
|
||||
|
4
deps/oblib/src/common/ob_zerofill_info.h
vendored
4
deps/oblib/src/common/ob_zerofill_info.h
vendored
@ -18,13 +18,13 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
struct ObZerofillInfo {
|
||||
public:
|
||||
public:
|
||||
ObZerofillInfo(const bool zf, const ObLength len) : max_length_(len), need_zerofill_(zf)
|
||||
{}
|
||||
ObZerofillInfo() : max_length_(0), need_zerofill_(false)
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
ObLength max_length_;
|
||||
bool need_zerofill_;
|
||||
};
|
||||
|
10
deps/oblib/src/common/object/ob_obj_compare.h
vendored
10
deps/oblib/src/common/object/ob_obj_compare.h
vendored
@ -42,7 +42,7 @@ OB_INLINE bool ob_is_invalid_cmp_op_bool(ObCmpOp cmp_op)
|
||||
}
|
||||
|
||||
class ObCompareCtx final {
|
||||
public:
|
||||
public:
|
||||
// member functions
|
||||
ObCompareCtx(const ObObjType cmp_type, const ObCollationType cmp_cs_type, const bool is_null_safe,
|
||||
const int64_t tz_off, const ObCmpNullPos null_pos)
|
||||
@ -61,7 +61,7 @@ class ObCompareCtx final {
|
||||
{}
|
||||
TO_STRING_KV(K_(cmp_type), K_(cmp_cs_type), K_(is_null_safe), K_(tz_off));
|
||||
|
||||
public:
|
||||
public:
|
||||
// data members
|
||||
ObObjType cmp_type_; // used by upper functions, not in these compare functions.
|
||||
ObCollationType cmp_cs_type_;
|
||||
@ -84,7 +84,7 @@ typedef int (*obj_cmp_func_nullsafe)(
|
||||
* so actually we can do any compare operations which NEED NOT cast.
|
||||
*/
|
||||
class ObObjCmpFuncs {
|
||||
public:
|
||||
public:
|
||||
static inline bool is_datetime_timestamp_cmp(ObObjType type1, ObObjType type2)
|
||||
{
|
||||
return (ObTimestampType == type1 && ObDateTimeType == type2) ||
|
||||
@ -217,13 +217,13 @@ class ObObjCmpFuncs {
|
||||
template <ObObjTypeClass tc1, ObObjTypeClass tc2>
|
||||
static int cmp_func(const ObObj& Obj1, const ObObj& obj2, const ObCompareCtx& cmp_ctx);
|
||||
|
||||
private:
|
||||
private:
|
||||
OB_INLINE static int INT_TO_CR(int val)
|
||||
{
|
||||
return val < 0 ? CR_LT : val > 0 ? CR_GT : CR_EQ;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static const obj_cmp_func cmp_funcs[ObMaxTC][ObMaxTC][CO_MAX];
|
||||
static const obj_cmp_func_nullsafe cmp_funcs_nullsafe[ObMaxTC][ObMaxTC];
|
||||
static const ObObj cmp_res_objs_bool[CR_BOOL_CNT];
|
||||
|
28
deps/oblib/src/common/object/ob_object.h
vendored
28
deps/oblib/src/common/object/ob_object.h
vendored
@ -47,7 +47,7 @@ inline ObCmpNullPos default_null_pos()
|
||||
struct ObEnumSetInnerValue {
|
||||
OB_UNIS_VERSION_V(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
ObEnumSetInnerValue() : numberic_value_(0), string_value_()
|
||||
{}
|
||||
ObEnumSetInnerValue(uint64_t numberic_value, common::ObString& string_value)
|
||||
@ -111,7 +111,7 @@ struct ObLobScale {
|
||||
};
|
||||
|
||||
class ObObjMeta {
|
||||
public:
|
||||
public:
|
||||
ObObjMeta() : type_(ObNullType), cs_level_(CS_LEVEL_INVALID), cs_type_(CS_TYPE_INVALID), scale_(-1)
|
||||
{}
|
||||
|
||||
@ -855,7 +855,7 @@ class ObObjMeta {
|
||||
return offsetof(ObObjMeta, scale_) * 8;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
uint8_t type_;
|
||||
uint8_t cs_level_; // collation level
|
||||
uint8_t cs_type_; // collation type
|
||||
@ -1081,7 +1081,7 @@ union ObObjValue {
|
||||
|
||||
class ObBatchChecksum;
|
||||
class ObObj {
|
||||
public:
|
||||
public:
|
||||
// min, max extend value
|
||||
static const int64_t MIN_OBJECT_VALUE = UINT64_MAX - 2;
|
||||
static const int64_t MAX_OBJECT_VALUE = UINT64_MAX - 1;
|
||||
@ -1091,7 +1091,7 @@ class ObObj {
|
||||
static const char* MAX_OBJECT_VALUE_STR;
|
||||
static const char* NOP_VALUE_STR;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObObj();
|
||||
ObObj(const ObObj& other);
|
||||
explicit ObObj(bool val);
|
||||
@ -2137,12 +2137,12 @@ class ObObj {
|
||||
int get_char_length(const ObAccuracy accuracy, int32_t& char_len, bool is_oracle_mode) const;
|
||||
int convert_string_value_charset(ObCharsetType charset_type, ObIAllocator& allocator);
|
||||
|
||||
private:
|
||||
private:
|
||||
friend class tests::common::ObjTest;
|
||||
friend class ObCompactCellWriter;
|
||||
friend class ObCompactCellIterator;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObObjMeta meta_; // sizeof = 4
|
||||
union {
|
||||
int32_t val_len_;
|
||||
@ -3773,13 +3773,13 @@ struct ParamFlag {
|
||||
};
|
||||
|
||||
class ObObjParam : public ObObj {
|
||||
public:
|
||||
public:
|
||||
ObObjParam() : ObObj(), accuracy_(), res_flags_(0), raw_text_pos_(-1), raw_text_len_(-1)
|
||||
{}
|
||||
ObObjParam(const ObObj& other) : ObObj(other), accuracy_(), res_flags_(0), raw_text_pos_(-1), raw_text_len_(-1)
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
void reset();
|
||||
// accuracy.
|
||||
OB_INLINE void set_accuracy(const common::ObAccuracy& accuracy)
|
||||
@ -3940,7 +3940,7 @@ class ObObjParam : public ObObj {
|
||||
return offsetof(ObObjParam, flag_) * 8;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObAccuracy accuracy_;
|
||||
uint32_t res_flags_; // BINARY, NUM, NOT_NULL, TIMESTAMP, etc
|
||||
// reference: src/lib/regex/include/mysql_com.h
|
||||
@ -3953,7 +3953,7 @@ class ObObjParam : public ObObj {
|
||||
struct ObDataType {
|
||||
OB_UNIS_VERSION(1);
|
||||
|
||||
public:
|
||||
public:
|
||||
ObDataType() : meta_(), accuracy_(), charset_(CHARSET_UTF8MB4), is_binary_collation_(false), is_zero_fill_(false)
|
||||
{}
|
||||
TO_STRING_KV(K_(meta), K_(accuracy), K_(charset), K_(is_binary_collation), K_(is_zero_fill));
|
||||
@ -4115,7 +4115,7 @@ typedef int64_t (*ob_obj_value_get_serialize_size)(const ObObj& obj);
|
||||
typedef uint64_t (*ob_obj_crc64_v3)(const ObObj& obj, const uint64_t hash);
|
||||
|
||||
class ObObjUtil {
|
||||
public:
|
||||
public:
|
||||
static ob_obj_hash get_murmurhash_v3(ObObjType type);
|
||||
static ob_obj_hash get_murmurhash_v2(ObObjType type);
|
||||
static ob_obj_crc64_v3 get_crc64_v3(ObObjType type);
|
||||
@ -4124,7 +4124,7 @@ class ObObjUtil {
|
||||
};
|
||||
|
||||
class ObHexEscapeSqlStr {
|
||||
public:
|
||||
public:
|
||||
ObHexEscapeSqlStr(const common::ObString& str) : str_(str)
|
||||
{}
|
||||
ObString str() const
|
||||
@ -4134,7 +4134,7 @@ class ObHexEscapeSqlStr {
|
||||
int64_t get_extra_length() const;
|
||||
DECLARE_TO_STRING;
|
||||
|
||||
private:
|
||||
private:
|
||||
ObString str_;
|
||||
};
|
||||
|
||||
|
6
deps/oblib/src/common/row/ob_row.h
vendored
6
deps/oblib/src/common/row/ob_row.h
vendored
@ -27,7 +27,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
class ObColumnInfo {
|
||||
public:
|
||||
public:
|
||||
int64_t index_;
|
||||
common::ObCollationType cs_type_;
|
||||
ObColumnInfo() : index_(common::OB_INVALID_INDEX), cs_type_(common::CS_TYPE_INVALID)
|
||||
@ -42,7 +42,7 @@ class ObColumnInfo {
|
||||
* @brief: wrap row pointer(an ObObj array) and row size
|
||||
*/
|
||||
class ObNewRow final {
|
||||
public:
|
||||
public:
|
||||
ObNewRow() : cells_(NULL), count_(0), projector_size_(0), projector_(NULL)
|
||||
{}
|
||||
ObNewRow(ObObj* cells, int64_t count) : cells_(cells), count_(count), projector_size_(0), projector_(NULL)
|
||||
@ -144,7 +144,7 @@ class ObNewRow final {
|
||||
return pos;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
ObObj* cells_;
|
||||
int64_t count_; // cells count
|
||||
int64_t projector_size_;
|
||||
|
8
deps/oblib/src/common/row/ob_row_desc.h
vendored
8
deps/oblib/src/common/row/ob_row_desc.h
vendored
@ -21,7 +21,7 @@ namespace common {
|
||||
|
||||
/// Line description
|
||||
class ObRowDesc {
|
||||
public:
|
||||
public:
|
||||
struct Desc {
|
||||
uint64_t table_id_;
|
||||
uint64_t column_id_;
|
||||
@ -42,7 +42,7 @@ class ObRowDesc {
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObRowDesc();
|
||||
~ObRowDesc();
|
||||
/**
|
||||
@ -83,13 +83,13 @@ class ObRowDesc {
|
||||
|
||||
int assign(const ObRowDesc& other);
|
||||
|
||||
private:
|
||||
private:
|
||||
struct DescIndex {
|
||||
Desc desc_;
|
||||
int64_t idx_;
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
static const int64_t MAX_COLUMNS_COUNT = common::OB_ROW_MAX_COLUMNS_COUNT; // 512
|
||||
static uint64_t HASH_COLLISIONS_COUNT;
|
||||
// data members
|
||||
|
20
deps/oblib/src/common/row/ob_row_iterator.h
vendored
20
deps/oblib/src/common/row/ob_row_iterator.h
vendored
@ -19,13 +19,13 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
class ObNewRowIterator {
|
||||
public:
|
||||
public:
|
||||
enum IterType {
|
||||
Other = 0,
|
||||
ObTableScanIterator = 1,
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObNewRowIterator() : type_(Other)
|
||||
{}
|
||||
explicit ObNewRowIterator(const IterType type) : type_(type)
|
||||
@ -69,18 +69,18 @@ class ObNewRowIterator {
|
||||
return type_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const IterType type_;
|
||||
};
|
||||
|
||||
class ObNewIterIterator {
|
||||
public:
|
||||
public:
|
||||
enum IterType {
|
||||
Other = 0,
|
||||
ObTableScanIterIterator = 1,
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObNewIterIterator() : type_(Other)
|
||||
{}
|
||||
explicit ObNewIterIterator(const IterType type) : type_(type)
|
||||
@ -95,13 +95,13 @@ class ObNewIterIterator {
|
||||
return type_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const IterType type_;
|
||||
};
|
||||
|
||||
/// wrap one row as an iterator
|
||||
class ObSingleRowIteratorWrapper : public ObNewRowIterator {
|
||||
public:
|
||||
public:
|
||||
ObSingleRowIteratorWrapper();
|
||||
ObSingleRowIteratorWrapper(ObNewRow* row);
|
||||
virtual ~ObSingleRowIteratorWrapper()
|
||||
@ -117,11 +117,11 @@ class ObSingleRowIteratorWrapper : public ObNewRowIterator {
|
||||
iter_end_ = false;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObSingleRowIteratorWrapper);
|
||||
|
||||
private:
|
||||
private:
|
||||
// data members
|
||||
ObNewRow* row_;
|
||||
bool iter_end_;
|
||||
@ -148,7 +148,7 @@ inline int ObSingleRowIteratorWrapper::get_next_row(ObNewRow*& row)
|
||||
}
|
||||
|
||||
class ObOuterRowIterator {
|
||||
public:
|
||||
public:
|
||||
ObOuterRowIterator()
|
||||
{}
|
||||
virtual ~ObOuterRowIterator()
|
||||
|
2
deps/oblib/src/common/row/ob_row_store.cpp
vendored
2
deps/oblib/src/common/row/ob_row_store.cpp
vendored
@ -85,7 +85,7 @@ struct ObRowStore::BlockInfo {
|
||||
const ObIArray<int64_t>& reserved_columns, const ObNewRow& row, int64_t payload, StoredRow*& stored_row);
|
||||
friend class ObRowStore::BlockList;
|
||||
|
||||
private:
|
||||
private:
|
||||
#ifdef __clang__
|
||||
int64_t magic_ [[gnu::unused]];
|
||||
#else
|
||||
|
20
deps/oblib/src/common/row/ob_row_store.h
vendored
20
deps/oblib/src/common/row/ob_row_store.h
vendored
@ -23,7 +23,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObRowStore {
|
||||
public:
|
||||
public:
|
||||
struct BlockInfo;
|
||||
// What is reserved_cells_ for?
|
||||
// In order by c1 and other calculations, not only must all the columns be written to the ObRowStore, but also need to
|
||||
@ -41,7 +41,7 @@ class ObRowStore {
|
||||
TO_STRING_KV(N_PAYLOAD, payload_, N_CELLS, ObArrayWrap<ObObj>(reserved_cells_, reserved_cells_count_));
|
||||
};
|
||||
class Iterator : public ObOuterRowIterator {
|
||||
public:
|
||||
public:
|
||||
friend class ObRowStore;
|
||||
Iterator();
|
||||
/// @param row [in/out] row.size_ is used to verify the data
|
||||
@ -58,17 +58,17 @@ class ObRowStore {
|
||||
// @pre is_valid
|
||||
bool has_next() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
explicit Iterator(const ObRowStore* row_store);
|
||||
int next_iter_pos(const BlockInfo*& iter_block, int64_t& iter_pos);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
const ObRowStore* row_store_;
|
||||
const BlockInfo* cur_iter_block_;
|
||||
int64_t cur_iter_pos_;
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObRowStore(ObIAllocator& alloc, const lib::ObLabel& label = ObModIds::OB_SQL_ROW_STORE,
|
||||
const uint64_t tenant_id = common::OB_SERVER_TENANT_ID, bool use_compact_row = true);
|
||||
ObRowStore(const lib::ObLabel& label = ObModIds::OB_SQL_ROW_STORE,
|
||||
@ -239,7 +239,7 @@ class ObRowStore {
|
||||
TO_STRING_KV(N_BLOCK_SIZE, block_size_, N_DATA_SIZE, data_size_, N_BLOCK_NUM, blocks_.get_block_count(), N_ROW_COUNT,
|
||||
row_count_, N_COLUMN_COUNT, col_count_, N_READ_ONLY, is_read_only_);
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObRowStore);
|
||||
|
||||
static const int64_t BIG_BLOCK_SIZE = OB_MALLOC_BIG_BLOCK_SIZE;
|
||||
@ -247,7 +247,7 @@ class ObRowStore {
|
||||
|
||||
// non-circular doubly linked list
|
||||
class BlockList {
|
||||
public:
|
||||
public:
|
||||
BlockList();
|
||||
void reset();
|
||||
int add_last(BlockInfo* block);
|
||||
@ -281,14 +281,14 @@ class ObRowStore {
|
||||
return 0 == count_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
BlockInfo* first_;
|
||||
BlockInfo* last_;
|
||||
int64_t count_;
|
||||
int64_t used_mem_size_; // bytes of all blocks
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
static int64_t get_reserved_cells_size(const int64_t reserved_columns_count);
|
||||
int add_row_by_projector(const ObNewRow& row, const StoredRow*& stored_row, int64_t payload);
|
||||
int init_pre_project_row(int64_t count);
|
||||
@ -304,7 +304,7 @@ class ObRowStore {
|
||||
void del_block_list(BlockInfo* del_block);
|
||||
int adjust_row_cells_reference();
|
||||
|
||||
private:
|
||||
private:
|
||||
// @TODO: add control for tenant_id
|
||||
DefaultPageAllocator inner_alloc_;
|
||||
ObFixedArray<int64_t, common::ObIAllocator> reserved_columns_;
|
||||
|
2
deps/oblib/src/common/row/ob_row_util.h
vendored
2
deps/oblib/src/common/row/ob_row_util.h
vendored
@ -20,7 +20,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
|
||||
class ObRowUtil {
|
||||
public:
|
||||
public:
|
||||
static int convert(const common::ObString& compact_row, ObNewRow& row);
|
||||
static int convert(const char* compact_row, int64_t buf_len, ObNewRow& row);
|
||||
static int compare_row(const ObNewRow& lrow, const ObNewRow& rrow, int& cmp);
|
||||
|
10
deps/oblib/src/common/rowkey/ob_rowkey.h
vendored
10
deps/oblib/src/common/rowkey/ob_rowkey.h
vendored
@ -30,7 +30,7 @@ class ObRowkeyInfo;
|
||||
class ObStoreRowkey;
|
||||
|
||||
class ObRowkey {
|
||||
public:
|
||||
public:
|
||||
ObRowkey() : obj_ptr_(NULL), obj_cnt_(0)
|
||||
{}
|
||||
ObRowkey(ObObj* ptr, const int64_t cnt) : obj_ptr_(ptr), obj_cnt_(cnt)
|
||||
@ -38,7 +38,7 @@ class ObRowkey {
|
||||
~ObRowkey()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
int to_store_rowkey(ObStoreRowkey& store_rowkey) const;
|
||||
void reset()
|
||||
{
|
||||
@ -164,7 +164,7 @@ class ObRowkey {
|
||||
}
|
||||
static int get_common_prefix_length(const ObRowkey& lhs, const ObRowkey& rhs, int64_t& prefix_len);
|
||||
|
||||
public:
|
||||
public:
|
||||
int equal(const ObRowkey& rhs, bool& is_equal) const;
|
||||
bool simple_equal(const ObRowkey& rhs) const;
|
||||
// FIXME temporarily, rowkey compare with column order use seperate func
|
||||
@ -286,11 +286,11 @@ class ObRowkey {
|
||||
return compare(rhs) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObObj* obj_ptr_;
|
||||
int64_t obj_cnt_;
|
||||
|
||||
public:
|
||||
public:
|
||||
static ObObj MIN_OBJECT;
|
||||
static ObObj MAX_OBJECT;
|
||||
static ObRowkey MIN_ROWKEY;
|
||||
|
@ -52,7 +52,7 @@ struct ObRowkeyColumn {
|
||||
};
|
||||
|
||||
class ObRowkeyInfo {
|
||||
public:
|
||||
public:
|
||||
ObRowkeyInfo();
|
||||
explicit ObRowkeyInfo(ObIAllocator* allocator);
|
||||
~ObRowkeyInfo();
|
||||
@ -107,7 +107,7 @@ class ObRowkeyInfo {
|
||||
int get_column_ids(ObBitSet<>& column_ids) const;
|
||||
NEED_SERIALIZE_AND_DESERIALIZE;
|
||||
|
||||
private:
|
||||
private:
|
||||
int expand(const int64_t size);
|
||||
static const int64_t DEFAULT_ROWKEY_COLUMN_ARRAY_CAPACITY = 8;
|
||||
ObRowkeyColumn* columns_;
|
||||
|
12
deps/oblib/src/common/rowkey/ob_store_rowkey.h
vendored
12
deps/oblib/src/common/rowkey/ob_store_rowkey.h
vendored
@ -26,7 +26,7 @@ namespace common {
|
||||
* FIXME-: reduce some of the log levels once the code stablizes
|
||||
*/
|
||||
class ObStoreRowkey {
|
||||
public:
|
||||
public:
|
||||
ObStoreRowkey() : key_(), hash_(0)
|
||||
{}
|
||||
ObStoreRowkey(ObObj* ptr, const int64_t cnt)
|
||||
@ -224,7 +224,7 @@ class ObStoreRowkey {
|
||||
return key_.compare_prefix(rhs.key_, cmp);
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
inline bool operator==(const ObStoreRowkey& rhs) const
|
||||
{
|
||||
return simple_equal(rhs);
|
||||
@ -274,13 +274,13 @@ class ObStoreRowkey {
|
||||
static ObStoreRowkey MIN_STORE_ROWKEY;
|
||||
static ObStoreRowkey MAX_STORE_ROWKEY;
|
||||
|
||||
private:
|
||||
private:
|
||||
enum MinMaxFlag { MIN, MAX };
|
||||
int set_min_max(const ObIArray<ObOrderType>& column_orders, ObIAllocator& allocator, MinMaxFlag min_or_max);
|
||||
int is_min_max(const ObIArrayWrap<ObOrderType>& column_orders, const int64_t rowkey_cnt, bool& is_min_max,
|
||||
MinMaxFlag min_or_max) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
ObRowkey key_; // only used as a container for ObObjs
|
||||
mutable uint64_t hash_;
|
||||
};
|
||||
@ -289,7 +289,7 @@ class ObStoreRowkey {
|
||||
// (no need to convert to collation_free multiple times)
|
||||
// Only used in the storage layer.
|
||||
class ObExtStoreRowkey {
|
||||
public:
|
||||
public:
|
||||
ObExtStoreRowkey();
|
||||
explicit ObExtStoreRowkey(const ObStoreRowkey& store_rowkey);
|
||||
ObExtStoreRowkey(const ObStoreRowkey& store_rowkey, const ObStoreRowkey& collation_free_store_rowkey);
|
||||
@ -363,7 +363,7 @@ class ObExtStoreRowkey {
|
||||
TO_STRING_KV(
|
||||
K_(store_rowkey), K_(collation_free_store_rowkey), K_(range_cut_pos), K_(range_check_min), K_(range_array_idx));
|
||||
|
||||
private:
|
||||
private:
|
||||
ObStoreRowkey store_rowkey_;
|
||||
ObStoreRowkey collation_free_store_rowkey_;
|
||||
int16_t range_cut_pos_; // cut-off from min/max object
|
||||
|
@ -38,7 +38,7 @@ inline v4si v4si_gt0(v4si x_)
|
||||
return is_gt0;
|
||||
}
|
||||
class ObPriorityScheduler {
|
||||
public:
|
||||
public:
|
||||
ObPriorityScheduler()
|
||||
{
|
||||
v4si quota = {1, 1, 1, 1};
|
||||
@ -50,7 +50,7 @@ class ObPriorityScheduler {
|
||||
~ObPriorityScheduler()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
void set_quota(v4si quota) __attribute__((always_inline))
|
||||
{
|
||||
quota_ = quota;
|
||||
|
6
deps/oblib/src/lib/alloc/abit_set.h
vendored
6
deps/oblib/src/lib/alloc/abit_set.h
vendored
@ -24,7 +24,7 @@ namespace lib {
|
||||
|
||||
// Thread unsafe, three level BitSet
|
||||
class ABitSet {
|
||||
public:
|
||||
public:
|
||||
ABitSet(int nbits, char* buf)
|
||||
: nbits_(nbits),
|
||||
use_zero_level_(nbits_ >= (1 << 6 << 6)),
|
||||
@ -115,13 +115,13 @@ class ABitSet {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int myffsl(uint64_t v, int pos) const
|
||||
{
|
||||
return ffsl(v & ~((1UL << pos) - 1));
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const int nbits_;
|
||||
const bool use_zero_level_;
|
||||
uint64_t zero_level_;
|
||||
|
@ -27,7 +27,7 @@ enum AllocFailedReason {
|
||||
};
|
||||
|
||||
struct AllocFailedCtx {
|
||||
public:
|
||||
public:
|
||||
int reason_;
|
||||
int64_t alloc_size_;
|
||||
union {
|
||||
|
14
deps/oblib/src/lib/alloc/alloc_interface.h
vendored
14
deps/oblib/src/lib/alloc/alloc_interface.h
vendored
@ -24,21 +24,21 @@ namespace oceanbase {
|
||||
namespace lib {
|
||||
class ObTenantCtxAllocator;
|
||||
class IBlockMgr {
|
||||
public:
|
||||
public:
|
||||
virtual ABlock* alloc_block(uint64_t size, const ObMemAttr& attr) = 0;
|
||||
virtual void free_block(ABlock* block) = 0;
|
||||
virtual ObTenantCtxAllocator& get_tenant_ctx_allocator() = 0;
|
||||
}; // end of class IBlockMgr
|
||||
|
||||
class ISetLocker {
|
||||
public:
|
||||
public:
|
||||
virtual void lock() = 0;
|
||||
virtual void unlock() = 0;
|
||||
virtual bool trylock() = 0;
|
||||
};
|
||||
|
||||
class SetDoNothingLocker : public ISetLocker {
|
||||
public:
|
||||
public:
|
||||
void lock() override
|
||||
{}
|
||||
void unlock() override
|
||||
@ -50,7 +50,7 @@ class SetDoNothingLocker : public ISetLocker {
|
||||
};
|
||||
|
||||
class SetLocker : public ISetLocker {
|
||||
public:
|
||||
public:
|
||||
SetLocker(lib::ObMutex& mutex) : mutex_(mutex)
|
||||
{}
|
||||
void lock() override
|
||||
@ -66,12 +66,12 @@ class SetLocker : public ISetLocker {
|
||||
return 0 == mutex_.trylock();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
lib::ObMutex& mutex_;
|
||||
};
|
||||
|
||||
class SetLockerForLogger : public ISetLocker {
|
||||
public:
|
||||
public:
|
||||
SetLockerForLogger(lib::ObMutex& mutex) : mutex_(mutex), is_disable_(false)
|
||||
{}
|
||||
void lock() override
|
||||
@ -95,7 +95,7 @@ class SetLockerForLogger : public ISetLocker {
|
||||
return succ;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
lib::ObMutex& mutex_;
|
||||
bool is_disable_;
|
||||
};
|
||||
|
6
deps/oblib/src/lib/alloc/alloc_struct.h
vendored
6
deps/oblib/src/lib/alloc/alloc_struct.h
vendored
@ -385,7 +385,7 @@ ObLabel AObject::label() const
|
||||
class Label {
|
||||
constexpr static int MAX_LEN = AOBJECT_LABEL_SIZE;
|
||||
|
||||
public:
|
||||
public:
|
||||
Label() : label_(nullptr)
|
||||
{}
|
||||
Label(const char* str) : label_(str)
|
||||
@ -403,11 +403,11 @@ class Label {
|
||||
}
|
||||
const char* label_;
|
||||
|
||||
private:
|
||||
private:
|
||||
static void fmt(char* buf, int64_t buf_len, int64_t& pos, const char* str);
|
||||
static void fmt(char* buf, int64_t buf_len, int64_t& pos, int64_t digit);
|
||||
|
||||
private:
|
||||
private:
|
||||
char buf_[MAX_LEN + 1];
|
||||
};
|
||||
|
||||
|
6
deps/oblib/src/lib/alloc/block_set.h
vendored
6
deps/oblib/src/lib/alloc/block_set.h
vendored
@ -26,7 +26,7 @@ class ISetLocker;
|
||||
class BlockSet {
|
||||
friend class ObTenantCtxAllocator;
|
||||
|
||||
public:
|
||||
public:
|
||||
BlockSet();
|
||||
~BlockSet();
|
||||
|
||||
@ -52,7 +52,7 @@ class BlockSet {
|
||||
locker_ = locker;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(BlockSet);
|
||||
|
||||
void add_free_block(ABlock* block);
|
||||
@ -63,7 +63,7 @@ class BlockSet {
|
||||
void free_chunk(AChunk* const chunk);
|
||||
void check_block(ABlock* block);
|
||||
|
||||
private:
|
||||
private:
|
||||
lib::ObMutex mutex_;
|
||||
// block_list_ can not be initialized, the state is maintained by avail_bm_
|
||||
union {
|
||||
|
16
deps/oblib/src/lib/alloc/memory_dump.h
vendored
16
deps/oblib/src/lib/alloc/memory_dump.h
vendored
@ -36,7 +36,7 @@ namespace common {
|
||||
enum DumpType { DUMP_CONTEXT, DUMP_CHUNK, STAT_LABEL };
|
||||
|
||||
class ObMemoryDumpTask {
|
||||
public:
|
||||
public:
|
||||
TO_STRING_KV(K(type_), K(dump_all_), KP(p_context_), K(slot_idx_), K(dump_tenant_ctx_), K(tenant_id_), K(ctx_id_),
|
||||
KP(p_chunk_));
|
||||
DumpType type_;
|
||||
@ -79,7 +79,7 @@ struct LabelItem {
|
||||
};
|
||||
|
||||
class LabelMap : public common::hash::ObHashMap<ObString, LabelItem*> {
|
||||
public:
|
||||
public:
|
||||
common::ObLocalModSet* mod_set_ = nullptr;
|
||||
};
|
||||
|
||||
@ -87,10 +87,10 @@ using lib::ABlock;
|
||||
using lib::AChunk;
|
||||
using lib::AObject;
|
||||
class ObMemoryDump : public lib::TGRunnable {
|
||||
public:
|
||||
public:
|
||||
static constexpr const char* LOG_FILE = "log/memory_meta";
|
||||
|
||||
private:
|
||||
private:
|
||||
friend class observer::ObAllVirtualMemoryInfo;
|
||||
friend class lib::ObTenantCtxAllocator;
|
||||
|
||||
@ -130,7 +130,7 @@ class ObMemoryDump : public lib::TGRunnable {
|
||||
char log_buf_[LOG_BUF_LEN];
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
ObMemoryDump();
|
||||
~ObMemoryDump();
|
||||
static ObMemoryDump& get_instance();
|
||||
@ -162,14 +162,14 @@ class ObMemoryDump : public lib::TGRunnable {
|
||||
avaliable_task_set_ |= (1 << pos);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void run1() override;
|
||||
void handle(void* task);
|
||||
|
||||
private:
|
||||
private:
|
||||
AChunk* find_chunk(void* ptr);
|
||||
|
||||
private:
|
||||
private:
|
||||
ObLightyQueue queue_;
|
||||
lib::ObMutex task_mutex_;
|
||||
ObMemoryDumpTask tasks_[TASK_NUM];
|
||||
|
@ -28,7 +28,7 @@ class ObMallocAllocator : public common::ObIAllocator {
|
||||
friend class ObMemoryCutter;
|
||||
static const uint64_t PRESERVED_TENANT_COUNT = 10000;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObMallocAllocator();
|
||||
virtual ~ObMallocAllocator();
|
||||
|
||||
@ -67,14 +67,14 @@ class ObMallocAllocator : public common::ObIAllocator {
|
||||
const uint64_t tenant_id, const uint64_t ctx_id, const int64_t size, const bool reserve = false);
|
||||
int get_chunks(AChunk** chunks, int cap, int& cnt);
|
||||
|
||||
private:
|
||||
private:
|
||||
using InvokeFunc = std::function<int(ObTenantMemoryMgr*)>;
|
||||
static int with_resource_handle_invoke(uint64_t tenant_id, InvokeFunc func);
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObMallocAllocator);
|
||||
|
||||
private:
|
||||
private:
|
||||
obsys::CRWLock locks_[PRESERVED_TENANT_COUNT];
|
||||
ObTenantCtxAllocator* allocators_[PRESERVED_TENANT_COUNT][common::ObCtxIds::MAX_CTX_ID];
|
||||
int64_t reserved_;
|
||||
|
@ -45,7 +45,7 @@ class ObTenantCtxAllocator : public common::ObIAllocator, private common::ObLink
|
||||
};
|
||||
using InvokeFunc = std::function<int(const ObTenantMemoryMgr*)>;
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit ObTenantCtxAllocator(uint64_t tenant_id, uint64_t ctx_id = 0)
|
||||
: resource_handle_(),
|
||||
tenant_id_(tenant_id),
|
||||
@ -268,7 +268,7 @@ class ObTenantCtxAllocator : public common::ObIAllocator, private common::ObLink
|
||||
return &w_mod_set_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void print_usage() const;
|
||||
AChunk* pop_chunk();
|
||||
void push_chunk(AChunk* chunk);
|
||||
@ -284,7 +284,7 @@ class ObTenantCtxAllocator : public common::ObIAllocator, private common::ObLink
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObTenantResourceMgrHandle resource_handle_;
|
||||
uint64_t tenant_id_;
|
||||
uint64_t ctx_id_;
|
||||
|
10
deps/oblib/src/lib/alloc/object_mgr.h
vendored
10
deps/oblib/src/lib/alloc/object_mgr.h
vendored
@ -27,7 +27,7 @@ namespace lib {
|
||||
class SubObjectMgr : public IBlockMgr {
|
||||
friend class ObTenantCtxAllocator;
|
||||
|
||||
public:
|
||||
public:
|
||||
SubObjectMgr(const bool for_logger)
|
||||
: mutex_(common::ObLatchIds::ALLOC_OBJECT_LOCK),
|
||||
mod_set_(),
|
||||
@ -85,7 +85,7 @@ class SubObjectMgr : public IBlockMgr {
|
||||
return bs_.get_tenant_ctx_allocator();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
lib::ObMutex mutex_;
|
||||
common::ObLocalModSet mod_set_;
|
||||
SetLocker normal_locker_;
|
||||
@ -97,7 +97,7 @@ class SubObjectMgr : public IBlockMgr {
|
||||
|
||||
template <int N>
|
||||
class ObjectMgr : public IBlockMgr {
|
||||
public:
|
||||
public:
|
||||
ObjectMgr(ObTenantCtxAllocator& allocator, uint64_t tenant_id, uint64_t ctx_id);
|
||||
~ObjectMgr();
|
||||
|
||||
@ -113,11 +113,11 @@ class ObjectMgr : public IBlockMgr {
|
||||
common::ObModItem get_mod_usage(int mod_id) const;
|
||||
void print_usage() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
SubObjectMgr* create_sub_mgr();
|
||||
void destroy_sub_mgr(SubObjectMgr* sub_mgr);
|
||||
|
||||
public:
|
||||
public:
|
||||
ObTenantCtxAllocator& ta_;
|
||||
const ObMemAttr attr_;
|
||||
const int sub_cnt_;
|
||||
|
6
deps/oblib/src/lib/alloc/object_set.h
vendored
6
deps/oblib/src/lib/alloc/object_set.h
vendored
@ -39,7 +39,7 @@ class ObjectSet {
|
||||
typedef AObject* FreeList;
|
||||
typedef ABitSet BitMap;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObjectSet(MemoryContext* mem_context = nullptr, const uint32_t ablock_size = INTACT_NORMAL_AOBJECT_SIZE);
|
||||
~ObjectSet();
|
||||
|
||||
@ -78,7 +78,7 @@ class ObjectSet {
|
||||
inline int64_t get_normal_used() const;
|
||||
inline int64_t get_normal_alloc() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
AObject* alloc_normal_object(const uint32_t cls, const ObMemAttr& attr);
|
||||
AObject* alloc_big_object(const uint64_t size, const ObMemAttr& attr);
|
||||
|
||||
@ -100,7 +100,7 @@ class ObjectSet {
|
||||
void do_free_object(AObject* obj);
|
||||
void do_free_dirty_list();
|
||||
|
||||
private:
|
||||
private:
|
||||
MemoryContext* mem_context_;
|
||||
ISetLocker* locker_;
|
||||
common::ObLocalModSet* mod_set_;
|
||||
|
@ -16,7 +16,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class AdapterAllocator {
|
||||
public:
|
||||
public:
|
||||
AdapterAllocator() : buffer_(NULL), pos_(0)
|
||||
{}
|
||||
~AdapterAllocator()
|
||||
@ -38,7 +38,7 @@ class AdapterAllocator {
|
||||
UNUSED(buf);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
char* buffer_;
|
||||
int64_t pos_;
|
||||
};
|
||||
|
12
deps/oblib/src/lib/allocator/ob_allocator.h
vendored
12
deps/oblib/src/lib/allocator/ob_allocator.h
vendored
@ -25,10 +25,10 @@ namespace common {
|
||||
using lib::ObMemAttr;
|
||||
extern ObMemAttr default_memattr;
|
||||
class ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
virtual ~ObIAllocator(){};
|
||||
|
||||
public:
|
||||
public:
|
||||
/************************************************************************/
|
||||
/* New Interface (Under construction) */
|
||||
/************************************************************************/
|
||||
@ -95,7 +95,7 @@ class ObIAllocator {
|
||||
extern ObIAllocator* global_default_allocator;
|
||||
|
||||
class ObWrapperAllocator : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
explicit ObWrapperAllocator(ObIAllocator* alloc) : alloc_(alloc){};
|
||||
explicit ObWrapperAllocator(const lib::ObLabel& label) : alloc_(NULL)
|
||||
{
|
||||
@ -140,13 +140,13 @@ class ObWrapperAllocator : public ObIAllocator {
|
||||
return offsetof(ObWrapperAllocator, alloc_) * 8;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
// data members
|
||||
ObIAllocator* alloc_;
|
||||
};
|
||||
|
||||
class ObWrapperAllocatorWithAttr : public ObWrapperAllocator {
|
||||
public:
|
||||
public:
|
||||
explicit ObWrapperAllocatorWithAttr(ObIAllocator* alloc, ObMemAttr attr = ObMemAttr())
|
||||
: ObWrapperAllocator(alloc), mem_attr_(attr){};
|
||||
explicit ObWrapperAllocatorWithAttr(const lib::ObLabel& label) : ObWrapperAllocator(NULL), mem_attr_()
|
||||
@ -163,7 +163,7 @@ class ObWrapperAllocatorWithAttr : public ObWrapperAllocator {
|
||||
return ObWrapperAllocator::alloc(sz, mem_attr_);
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
ObMemAttr mem_attr_;
|
||||
};
|
||||
} // namespace common
|
||||
|
12
deps/oblib/src/lib/allocator/ob_allocator_v2.h
vendored
12
deps/oblib/src/lib/allocator/ob_allocator_v2.h
vendored
@ -35,7 +35,7 @@ class ObAllocator : public ObIAllocator {
|
||||
friend class lib::MemoryContext;
|
||||
friend class ObParallelAllocator;
|
||||
|
||||
public:
|
||||
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);
|
||||
void* alloc(const int64_t size) override
|
||||
@ -55,7 +55,7 @@ class ObAllocator : public ObIAllocator {
|
||||
return pm_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int init();
|
||||
void lock()
|
||||
{
|
||||
@ -70,7 +70,7 @@ class ObAllocator : public ObIAllocator {
|
||||
return locker_->trylock();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
MemoryContext* mem_context_;
|
||||
ObMemAttr attr_;
|
||||
const bool use_pm_;
|
||||
@ -140,7 +140,7 @@ class ObParallelAllocator : public ObIAllocator {
|
||||
// Maximum concurrency
|
||||
static const int N = 8;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObParallelAllocator(ObAllocator& root_allocator, MemoryContext* mem_context, const ObMemAttr& attr = default_memattr,
|
||||
const int parallel = 4, const uint32_t ablock_size = lib::INTACT_NORMAL_AOBJECT_SIZE);
|
||||
virtual ~ObParallelAllocator();
|
||||
@ -157,10 +157,10 @@ class ObParallelAllocator : public ObIAllocator {
|
||||
}
|
||||
int64_t used() const override;
|
||||
|
||||
private:
|
||||
private:
|
||||
int init();
|
||||
|
||||
private:
|
||||
private:
|
||||
ObAllocator& root_allocator_;
|
||||
MemoryContext* mem_context_;
|
||||
ObMemAttr attr_;
|
||||
|
@ -21,7 +21,7 @@ class ObBlockAllocMgr;
|
||||
extern ObBlockAllocMgr default_blk_alloc;
|
||||
|
||||
class ObBlockAllocMgr {
|
||||
public:
|
||||
public:
|
||||
ObBlockAllocMgr(int64_t limit = INT64_MAX) : limit_(limit), hold_(0)
|
||||
{}
|
||||
~ObBlockAllocMgr()
|
||||
@ -66,7 +66,7 @@ class ObBlockAllocMgr {
|
||||
return ((limit_ - hold_) > size);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t limit_;
|
||||
int64_t hold_;
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ namespace common {
|
||||
class ObBuddyAllocator : public common::ObIAllocator {
|
||||
friend class ::BuddyAllocatorTest;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObBuddyAllocator(ObIAllocator& alloc);
|
||||
~ObBuddyAllocator();
|
||||
int32_t init(const int64_t min_block_size);
|
||||
@ -30,12 +30,12 @@ class ObBuddyAllocator : public common::ObIAllocator {
|
||||
|
||||
int print_info(char* buf, const int64_t buf_len, int64_t& pos) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int32_t fix_index_array(int32_t order);
|
||||
bool find_buddy(int64_t index, int64_t& buddy_index, int32_t order) const;
|
||||
void* compute_addr_in(int64_t index, int32_t order) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
// uncopyable class
|
||||
ObBuddyAllocator(const ObBuddyAllocator&);
|
||||
ObBuddyAllocator& operator=(const ObBuddyAllocator&);
|
||||
@ -49,7 +49,7 @@ class ObBuddyAllocator : public common::ObIAllocator {
|
||||
int32_t combine_free(int64_t index, int64_t buddy_index, int32_t current_order);
|
||||
int32_t single_free(void*& ptr, int64_t index, int32_t order);
|
||||
|
||||
private:
|
||||
private:
|
||||
static const int MAX_MEMORY_ORDER = 20; // max alloc 1MB memory
|
||||
static const int MAX_AREA_SIZE = MAX_MEMORY_ORDER + 10;
|
||||
bool inited_;
|
||||
|
@ -21,7 +21,7 @@ namespace common {
|
||||
// @note thread-safe
|
||||
template <typename T>
|
||||
class ObCachedAllocator {
|
||||
public:
|
||||
public:
|
||||
ObCachedAllocator();
|
||||
virtual ~ObCachedAllocator();
|
||||
|
||||
@ -36,11 +36,11 @@ class ObCachedAllocator {
|
||||
return cached_count_;
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObCachedAllocator);
|
||||
|
||||
private:
|
||||
private:
|
||||
// data members
|
||||
ObSpinLock lock_;
|
||||
ObPool<> pool_;
|
||||
|
@ -17,11 +17,11 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObConcurrentFIFOAllocator : public common::ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObConcurrentFIFOAllocator();
|
||||
virtual ~ObConcurrentFIFOAllocator();
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(const int64_t total_limit, const int64_t hold_limit, const int64_t page_size);
|
||||
|
||||
int init(const int64_t total_limit, const int64_t hold_limit, const int64_t tenant_id, const lib::ObLabel& label,
|
||||
@ -30,7 +30,7 @@ class ObConcurrentFIFOAllocator : public common::ObIAllocator {
|
||||
int init(const int64_t page_size, const lib::ObLabel& label, const uint64_t tenant_id, const int64_t total_limit);
|
||||
void destroy();
|
||||
|
||||
public:
|
||||
public:
|
||||
void set_label(const lib::ObLabel& label);
|
||||
void* alloc(const int64_t size);
|
||||
void* alloc(const int64_t size, const ObMemAttr& attr);
|
||||
@ -43,13 +43,13 @@ class ObConcurrentFIFOAllocator : public common::ObIAllocator {
|
||||
int set_hold_limit(int64_t hold_limit);
|
||||
void set_total_limit(int64_t total_limit);
|
||||
|
||||
private:
|
||||
private:
|
||||
static const int64_t STORAGE_SIZE_TIMES = 2;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObConcurrentFIFOAllocator);
|
||||
|
||||
private:
|
||||
private:
|
||||
ObLfFIFOAllocator inner_allocator_;
|
||||
};
|
||||
} // namespace common
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
struct ObCtxParallel {
|
||||
public:
|
||||
public:
|
||||
ObCtxParallel()
|
||||
{
|
||||
for (int64_t i = 0; i < ObCtxIds::MAX_CTX_ID; i++) {
|
||||
@ -41,7 +41,7 @@ struct ObCtxParallel {
|
||||
return p;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const static int DEFAULT_CTX_PARALLEL = 8;
|
||||
int parallel_[ObCtxIds::MAX_CTX_ID];
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ namespace common {
|
||||
// obj_count_ sub 1. If the "obj_count_" of a MemBlock become 0 after a free action, this MemBlock
|
||||
// can be recycled. After expire duration time, a recycled MemBlock can be freed.
|
||||
class ObDelayFreeMemBlock : public common::ObDLinkBase<ObDelayFreeMemBlock> {
|
||||
public:
|
||||
public:
|
||||
explicit ObDelayFreeMemBlock(char* end);
|
||||
virtual ~ObDelayFreeMemBlock();
|
||||
inline int64_t remain() const;
|
||||
@ -40,14 +40,14 @@ class ObDelayFreeMemBlock : public common::ObDLinkBase<ObDelayFreeMemBlock> {
|
||||
inline void free(void* ptr);
|
||||
inline void reuse();
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t free_timestamp_;
|
||||
int64_t obj_count_;
|
||||
char* end_;
|
||||
char* current_;
|
||||
char data_[0];
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObDelayFreeMemBlock);
|
||||
};
|
||||
|
||||
@ -58,7 +58,7 @@ class ObDelayFreeMemBlock : public common::ObDLinkBase<ObDelayFreeMemBlock> {
|
||||
// from free list to working list. If the size of free list exceeds MAX_CACHE_MEMORY_SIZE, the expi-
|
||||
// red memblock will be freed.
|
||||
class ObDelayFreeAllocator : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObDelayFreeAllocator();
|
||||
virtual ~ObDelayFreeAllocator();
|
||||
int init(const lib::ObLabel& label, const bool is_thread_safe, const int64_t expire_duration_us);
|
||||
@ -75,7 +75,7 @@ class ObDelayFreeAllocator : public ObIAllocator {
|
||||
inline int64_t get_memory_fragment_size() const;
|
||||
inline int64_t get_total_size() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
struct DataMeta {
|
||||
int64_t data_len_;
|
||||
ObDelayFreeMemBlock* mem_block_;
|
||||
@ -84,12 +84,12 @@ class ObDelayFreeAllocator : public ObIAllocator {
|
||||
static const int64_t MEM_BLOCK_DATA_SIZE = MEM_BLOCK_SIZE - sizeof(ObDelayFreeMemBlock);
|
||||
static const int64_t MAX_CACHE_MEMORY_SIZE = OB_MALLOC_BIG_BLOCK_SIZE * 32;
|
||||
|
||||
private:
|
||||
private:
|
||||
ObDelayFreeMemBlock* alloc_block(const int64_t data_size);
|
||||
void free_block(ObDelayFreeMemBlock* block);
|
||||
void free_list(ObDList<ObDelayFreeMemBlock>& list);
|
||||
|
||||
private:
|
||||
private:
|
||||
ObDList<ObDelayFreeMemBlock> working_list_;
|
||||
ObDList<ObDelayFreeMemBlock> free_list_;
|
||||
int64_t cache_memory_size_;
|
||||
@ -101,7 +101,7 @@ class ObDelayFreeAllocator : public ObIAllocator {
|
||||
lib::ObMutex mutex_;
|
||||
bool inited_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObDelayFreeAllocator);
|
||||
};
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObExternalRef {
|
||||
public:
|
||||
public:
|
||||
enum { REF_LIMIT = OB_MAX_CPU_NUM * 16 };
|
||||
class IERefPtr {
|
||||
public:
|
||||
public:
|
||||
IERefPtr() : next_(NULL)
|
||||
{}
|
||||
virtual ~IERefPtr()
|
||||
@ -104,7 +104,7 @@ class ObExternalRef {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void* load_ptr(void** paddr)
|
||||
{
|
||||
return (void*)(((uint64_t)ATOMIC_LOAD(paddr)) & ~1ULL);
|
||||
@ -143,7 +143,7 @@ class ObExternalRef {
|
||||
return h;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t ref_array_[REF_LIMIT];
|
||||
};
|
||||
}; // end namespace common
|
||||
|
12
deps/oblib/src/lib/allocator/ob_fifo_allocator.h
vendored
12
deps/oblib/src/lib/allocator/ob_fifo_allocator.h
vendored
@ -34,7 +34,7 @@ class ObFIFOAllocator : public common::ObIAllocator {
|
||||
friend class ::ObFIFOAllocatorNormalPageListTest;
|
||||
friend class UsedTotalChecker;
|
||||
|
||||
private:
|
||||
private:
|
||||
static const int32_t PAGE_HEADER = 0xe1fba00c;
|
||||
// Alloc Header Magic Number. f1f0allc for FIFOALLC
|
||||
static const int32_t ALLOC_HEADER = 0xf1f0a11c;
|
||||
@ -42,7 +42,7 @@ class ObFIFOAllocator : public common::ObIAllocator {
|
||||
static const int32_t ALREADY_FREE = 0xf5eebef0;
|
||||
static const int64_t SPECIAL_FLAG = -1;
|
||||
|
||||
public:
|
||||
public:
|
||||
struct BasePageHeader {
|
||||
using LinkedNode = common::ObDLinkNode<BasePageHeader*>;
|
||||
BasePageHeader() : magic_num_(PAGE_HEADER)
|
||||
@ -77,7 +77,7 @@ class ObFIFOAllocator : public common::ObIAllocator {
|
||||
BasePageHeader* page_header_;
|
||||
} __attribute__((aligned(16)));
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit ObFIFOAllocator(const uint64_t tenant_id = OB_SERVER_TENANT_ID);
|
||||
~ObFIFOAllocator();
|
||||
|
||||
@ -122,7 +122,7 @@ class ObFIFOAllocator : public common::ObIAllocator {
|
||||
return normal_total() + special_total_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
BasePageHeader* get_page_header(void* p);
|
||||
bool check_param(const int64_t size, const int64_t align);
|
||||
bool check_magic(void* p, int64_t& size);
|
||||
@ -140,7 +140,7 @@ class ObFIFOAllocator : public common::ObIAllocator {
|
||||
void free_special(SpecialPageHeader* page);
|
||||
int sync_idle(const int64_t idle_size, const int64_t max_size);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool is_inited_;
|
||||
ObIAllocator* allocator_;
|
||||
int64_t page_size_;
|
||||
@ -155,7 +155,7 @@ class ObFIFOAllocator : public common::ObIAllocator {
|
||||
int64_t special_total_;
|
||||
mutable ObSpinLock lock_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObFIFOAllocator);
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ struct ObFixedSizeBufAllocInfo {
|
||||
// caller can acquire and release the pre divided block buffer.
|
||||
template <int64_t SIZE>
|
||||
class ObFixedSizeBlockAllocator {
|
||||
public:
|
||||
public:
|
||||
virtual ~ObFixedSizeBlockAllocator();
|
||||
int init(const int64_t block_num, const lib::ObLabel& label = ObModIds::OB_FIXED_SIZE_BLOCK_ALLOCATOR);
|
||||
void destroy();
|
||||
@ -56,16 +56,16 @@ class ObFixedSizeBlockAllocator {
|
||||
return max_block_num_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObFixedSizeBlockAllocator();
|
||||
int init_max_block_num();
|
||||
int expand(const int64_t block_num);
|
||||
bool contains_internal(void* ptr) const;
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t MAX_MEMORY_ALLOCATION = OB_MAX_SYS_BKGD_THREAD_NUM * 6 * OB_DEFAULT_MACRO_BLOCK_SIZE;
|
||||
|
||||
private:
|
||||
private:
|
||||
static const int64_t MAX_MEMORY_IN_MINI_MODE = 128 * 1024 * 1024; // 128MB
|
||||
|
||||
bool is_inited_;
|
||||
@ -87,7 +87,7 @@ template <int64_t SIZE>
|
||||
class ObFixedSizeBlockMemoryContext {
|
||||
static constexpr int INIT_BLOCK_NUM = 8;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObFixedSizeBlockMemoryContext();
|
||||
virtual ~ObFixedSizeBlockMemoryContext();
|
||||
|
||||
@ -107,7 +107,7 @@ class ObFixedSizeBlockMemoryContext {
|
||||
}
|
||||
int64_t get_used_block_num();
|
||||
|
||||
private:
|
||||
private:
|
||||
bool is_inited_;
|
||||
int64_t used_block_num_;
|
||||
ObFixedSizeBlockAllocator<SIZE>& fsb_allocator_;
|
||||
|
34
deps/oblib/src/lib/allocator/ob_hazard_ref.h
vendored
34
deps/oblib/src/lib/allocator/ob_hazard_ref.h
vendored
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class HazardRef {
|
||||
public:
|
||||
public:
|
||||
enum {
|
||||
MAX_THREAD_NUM = OB_MAX_THREAD_NUM,
|
||||
THREAD_REF_COUNT_LIMIT = 8,
|
||||
@ -26,7 +26,7 @@ class HazardRef {
|
||||
};
|
||||
const static uint64_t INVALID_VERSION = UINT64_MAX;
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit HazardRef(bool debug = false) : cur_ver_(1), debug_(debug)
|
||||
{
|
||||
for (int i = 0; i < TOTAL_REF_COUNT_LIMIT; i++) {
|
||||
@ -54,13 +54,13 @@ class HazardRef {
|
||||
return min_version;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static uint64_t min(uint64_t x, uint64_t y)
|
||||
{
|
||||
return x < y ? x : y;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t cur_ver_ CACHE_ALIGNED;
|
||||
bool debug_;
|
||||
uint64_t ref_array_[TOTAL_REF_COUNT_LIMIT];
|
||||
@ -81,7 +81,7 @@ struct HazardNode {
|
||||
};
|
||||
|
||||
class HazardNodeList {
|
||||
public:
|
||||
public:
|
||||
HazardNodeList() : count_(0), tail_(&head_)
|
||||
{
|
||||
head_.next_ = &head_;
|
||||
@ -137,14 +137,14 @@ class HazardNodeList {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t count_;
|
||||
HazardNode head_;
|
||||
HazardNode* tail_;
|
||||
};
|
||||
|
||||
class RetireList {
|
||||
public:
|
||||
public:
|
||||
enum { MAX_THREAD_NUM = OB_MAX_THREAD_NUM };
|
||||
struct ThreadRetireList {
|
||||
ThreadRetireList()
|
||||
@ -155,9 +155,9 @@ class RetireList {
|
||||
HazardNodeList prepare_list_;
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
class RetireNodeIterator {
|
||||
public:
|
||||
public:
|
||||
explicit RetireNodeIterator(RetireList* host) : thread_offset_(0), host_(host)
|
||||
{}
|
||||
~RetireNodeIterator()
|
||||
@ -178,12 +178,12 @@ class RetireList {
|
||||
return ret_node;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t thread_offset_;
|
||||
RetireList* host_;
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
RetireList() : hazard_version_(0)
|
||||
{}
|
||||
virtual ~RetireList()
|
||||
@ -215,7 +215,7 @@ class RetireList {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
HazardNode* reclaim_node(ThreadRetireList* retire_list)
|
||||
{
|
||||
HazardNode* p = NULL;
|
||||
@ -234,13 +234,13 @@ class RetireList {
|
||||
return get_itid() < MAX_THREAD_NUM ? retire_list_ + get_itid() : NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t hazard_version_ CACHE_ALIGNED;
|
||||
ThreadRetireList retire_list_[MAX_THREAD_NUM];
|
||||
};
|
||||
|
||||
class HazardHandle {
|
||||
public:
|
||||
public:
|
||||
explicit HazardHandle(HazardRef& href) : href_(href), ref_(NULL)
|
||||
{}
|
||||
virtual ~HazardHandle()
|
||||
@ -261,13 +261,13 @@ class HazardHandle {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
HazardRef& href_;
|
||||
uint64_t* ref_;
|
||||
};
|
||||
|
||||
class RetireListHandle {
|
||||
public:
|
||||
public:
|
||||
typedef HazardNode Node;
|
||||
typedef HazardNodeList NodeList;
|
||||
RetireListHandle(HazardRef& href, RetireList& retire_list) : href_(href), retire_list_(retire_list)
|
||||
@ -313,7 +313,7 @@ class RetireListHandle {
|
||||
retire_list_.retire(node);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
HazardRef& href_;
|
||||
RetireList& retire_list_;
|
||||
NodeList alloc_list_;
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObLfFIFOAllocator : public ObIAllocator, public ObVSliceAlloc {
|
||||
public:
|
||||
public:
|
||||
typedef ObBlockAllocMgr BlockAlloc;
|
||||
static const int64_t DEFAULT_CACHE_PAGE_COUNT = 64;
|
||||
ObLfFIFOAllocator()
|
||||
@ -45,7 +45,7 @@ class ObLfFIFOAllocator : public ObIAllocator, public ObVSliceAlloc {
|
||||
ObVSliceAlloc::purge_extra_cached_block(0);
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
void* alloc(const int64_t size)
|
||||
{
|
||||
return ObVSliceAlloc::alloc(size);
|
||||
@ -80,7 +80,7 @@ class ObLfFIFOAllocator : public ObIAllocator, public ObVSliceAlloc {
|
||||
return get_block_using_ratio(ptr) < 0.8;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
BlockAlloc block_alloc_;
|
||||
};
|
||||
}; // namespace common
|
||||
|
22
deps/oblib/src/lib/allocator/ob_malloc.h
vendored
22
deps/oblib/src/lib/allocator/ob_malloc.h
vendored
@ -74,7 +74,7 @@ void* ob_malloc_align(const int64_t alignment, const int64_t nbyte, const lib::O
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
class ObMalloc : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObMalloc(){};
|
||||
explicit ObMalloc(const lib::ObLabel& label)
|
||||
{
|
||||
@ -84,7 +84,7 @@ class ObMalloc : public ObIAllocator {
|
||||
{}
|
||||
virtual ~ObMalloc(){};
|
||||
|
||||
public:
|
||||
public:
|
||||
void set_label(const lib::ObLabel& label)
|
||||
{
|
||||
memattr_.label_ = label;
|
||||
@ -106,13 +106,13 @@ class ObMalloc : public ObIAllocator {
|
||||
ob_free(ptr);
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
ObMemAttr memattr_;
|
||||
};
|
||||
typedef ObMalloc ObTCMalloc;
|
||||
|
||||
class ObMemBuf {
|
||||
public:
|
||||
public:
|
||||
ObMemBuf() : buf_ptr_(NULL), buf_size_(OB_MALLOC_NORMAL_BLOCK_SIZE), label_(ObModIds::OB_MOD_DO_NOT_USE_ME)
|
||||
{}
|
||||
|
||||
@ -140,18 +140,18 @@ class ObMemBuf {
|
||||
|
||||
int ensure_space(const int64_t size, const lib::ObLabel& label = nullptr);
|
||||
|
||||
private:
|
||||
private:
|
||||
char* buf_ptr_;
|
||||
int64_t buf_size_;
|
||||
lib::ObLabel label_;
|
||||
};
|
||||
|
||||
class ObMemBufAllocatorWrapper : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObMemBufAllocatorWrapper(ObMemBuf& mem_buf, const lib::ObLabel& label = nullptr) : mem_buf_(mem_buf), label_(label)
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual void* alloc(int64_t sz)
|
||||
{
|
||||
char* ptr = NULL;
|
||||
@ -170,17 +170,17 @@ class ObMemBufAllocatorWrapper : public ObIAllocator {
|
||||
UNUSED(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObMemBuf& mem_buf_;
|
||||
lib::ObLabel label_;
|
||||
};
|
||||
|
||||
class ObRawBufAllocatorWrapper : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObRawBufAllocatorWrapper(char* mem_buf, int64_t mem_buf_len) : mem_buf_(mem_buf), mem_buf_len_(mem_buf_len)
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual void* alloc(int64_t sz)
|
||||
{
|
||||
char* ptr = NULL;
|
||||
@ -199,7 +199,7 @@ class ObRawBufAllocatorWrapper : public ObIAllocator {
|
||||
UNUSED(ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
char* mem_buf_;
|
||||
int64_t mem_buf_len_;
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ class ObMemLeakChecker {
|
||||
|
||||
typedef hash::ObHashMap<PtrKey, Info> mod_alloc_info_t;
|
||||
|
||||
public:
|
||||
public:
|
||||
typedef hash::ObHashMap<Info, std::pair<int64_t, int64_t>> mod_info_map_t;
|
||||
using TCharArray = char[lib::AOBJECT_LABEL_SIZE + 1];
|
||||
|
||||
@ -254,7 +254,7 @@ class ObMemLeakChecker {
|
||||
return 0 == MEMCMP(&obj.label_[0], label_, len_);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
// Limit the memory used by hashmap
|
||||
static constexpr int MEMORY_LIMIT = 128L << 20;
|
||||
static constexpr int MAP_SIZE_LIMIT = MEMORY_LIMIT / sizeof(Info);
|
||||
@ -264,7 +264,7 @@ class ObMemLeakChecker {
|
||||
CONTEXT_CHECK,
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
TCharArray origin_str_;
|
||||
union {
|
||||
struct {
|
||||
@ -282,7 +282,7 @@ class ObMemLeakChecker {
|
||||
int len_;
|
||||
mod_alloc_info_t malloc_info_;
|
||||
|
||||
private:
|
||||
private:
|
||||
static lib::ObSimpleRateLimiter rl_;
|
||||
};
|
||||
}; // end namespace common
|
||||
|
@ -23,7 +23,7 @@ namespace common {
|
||||
// The interface of rewritable classes, which provides rewrite_switch methods to rewrite itself to
|
||||
// new memory.
|
||||
class ObIRewritable {
|
||||
public:
|
||||
public:
|
||||
ObIRewritable();
|
||||
|
||||
virtual ~ObIRewritable();
|
||||
@ -50,7 +50,7 @@ class ObIRewritable {
|
||||
// registered rewritable object to rewrite itself to current working allocator, at last free memory of
|
||||
// standby allocator after expire duration time.
|
||||
class ObMemfragRecycleAllocator : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObMemfragRecycleAllocator();
|
||||
virtual ~ObMemfragRecycleAllocator();
|
||||
|
||||
@ -106,7 +106,7 @@ class ObMemfragRecycleAllocator : public ObIAllocator {
|
||||
int64_t get_all_alloc_size() const;
|
||||
int64_t get_cur_alloc_size() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
enum ObMemfragRecycleAllocatorState { INIT, SWITCHING_PREPARE, SWITCHING, SWITCHING_OVER };
|
||||
|
||||
static const int64_t META_MAGIC_NUM = 0x4D455441;
|
||||
@ -125,7 +125,7 @@ class ObMemfragRecycleAllocator : public ObIAllocator {
|
||||
|
||||
bool need_switch(ObDelayFreeAllocator& allocator);
|
||||
|
||||
private:
|
||||
private:
|
||||
ObDelayFreeAllocator allocator_[2];
|
||||
int64_t cur_allocator_pos_;
|
||||
enum ObMemfragRecycleAllocatorState state_;
|
||||
@ -136,33 +136,33 @@ class ObMemfragRecycleAllocator : public ObIAllocator {
|
||||
lib::ObMutex mutex_;
|
||||
bool inited_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObMemfragRecycleAllocator);
|
||||
};
|
||||
|
||||
// A singleton which is used for recycling memory of all ObMemfragRecycleAllocator periodically.
|
||||
class ObMRAllocatorRecycler {
|
||||
public:
|
||||
public:
|
||||
static ObMRAllocatorRecycler& get_instance();
|
||||
int register_allocator(ObMemfragRecycleAllocator* allocator);
|
||||
int deregister_allocator(ObMemfragRecycleAllocator* allocator);
|
||||
void recycle();
|
||||
void set_schedule_interval_us(const int64_t interval_us);
|
||||
|
||||
private:
|
||||
private:
|
||||
class SelfCreator {
|
||||
public:
|
||||
public:
|
||||
SelfCreator();
|
||||
virtual ~SelfCreator();
|
||||
};
|
||||
class ObMRAllocatorRecycleTask : public ObTimerTask {
|
||||
public:
|
||||
public:
|
||||
ObMRAllocatorRecycleTask();
|
||||
virtual ~ObMRAllocatorRecycleTask();
|
||||
void runTimerTask();
|
||||
};
|
||||
|
||||
private:
|
||||
private:
|
||||
ObMRAllocatorRecycler();
|
||||
virtual ~ObMRAllocatorRecycler();
|
||||
static const int64_t MAX_META_MEMORY_ALLOCATOR_COUNT = 8;
|
||||
@ -174,7 +174,7 @@ class ObMRAllocatorRecycler {
|
||||
ObMemfragRecycleAllocator* allocators_[MAX_META_MEMORY_ALLOCATOR_COUNT];
|
||||
bool is_scheduled_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObMRAllocatorRecycler);
|
||||
};
|
||||
|
||||
|
16
deps/oblib/src/lib/allocator/ob_mod_define.h
vendored
16
deps/oblib/src/lib/allocator/ob_mod_define.h
vendored
@ -1248,7 +1248,7 @@ struct ObModItem {
|
||||
class ObLocalModSet {
|
||||
enum { MOD_COUNT_LIMIT = ObNewModIds::OB_MOD_END };
|
||||
|
||||
public:
|
||||
public:
|
||||
ObLocalModSet()
|
||||
{
|
||||
reset();
|
||||
@ -1286,7 +1286,7 @@ class ObLocalModSet {
|
||||
mods_[(mod_id >= 0 && mod_id < MOD_COUNT_LIMIT) ? mod_id : 0].update(hold, used);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObModItem mods_[MOD_COUNT_LIMIT];
|
||||
};
|
||||
|
||||
@ -1299,7 +1299,7 @@ struct ObCtxIds {
|
||||
};
|
||||
|
||||
class ObCtxInfo {
|
||||
public:
|
||||
public:
|
||||
enum { CTX_COUNT_LIMIT = ObCtxIds::MAX_CTX_ID };
|
||||
|
||||
ObCtxInfo() : ctx_names_()
|
||||
@ -1314,7 +1314,7 @@ class ObCtxInfo {
|
||||
return ctx_id < ObCtxIds::MAX_CTX_ID ? ctx_names_[ctx_id] : name;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void set_ctx_name(uint64_t ctx_id, const char* ctx_name)
|
||||
{
|
||||
if (ctx_id < ObCtxIds::MAX_CTX_ID) {
|
||||
@ -1322,7 +1322,7 @@ class ObCtxInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const char* ctx_names_[CTX_COUNT_LIMIT];
|
||||
};
|
||||
|
||||
@ -1332,7 +1332,7 @@ inline bool is_valid_mod_id(int64_t mod_id)
|
||||
}
|
||||
|
||||
class ObModSet {
|
||||
public:
|
||||
public:
|
||||
enum { MOD_COUNT_LIMIT = ObNewModIds::OB_MOD_END };
|
||||
// You can pass the string uniformly where mod_id is used
|
||||
// No need to modify the ob_mod_define.h file
|
||||
@ -1361,7 +1361,7 @@ class ObModSet {
|
||||
return t;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void set_mod_name(int64_t mod_id, const char* name)
|
||||
{
|
||||
if (mod_id >= 0 && mod_id < ObModSet::MOD_COUNT_LIMIT) {
|
||||
@ -1369,7 +1369,7 @@ class ObModSet {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const char* mod_names_[MOD_COUNT_LIMIT];
|
||||
};
|
||||
|
||||
|
16
deps/oblib/src/lib/allocator/ob_page_manager.h
vendored
16
deps/oblib/src/lib/allocator/ob_page_manager.h
vendored
@ -32,7 +32,7 @@ using lib::ObTenantCtxAllocator;
|
||||
using oceanbase::common::default_memattr;
|
||||
|
||||
class ObPageManager : public lib::IBlockMgr {
|
||||
public:
|
||||
public:
|
||||
constexpr static int DEFAULT_CHUNK_CACHE_CNT = 2;
|
||||
constexpr static int MINI_MODE_CHUNK_CACHE_CNT = 0;
|
||||
RBNODE(ObPageManager, rblink);
|
||||
@ -46,11 +46,11 @@ class ObPageManager : public lib::IBlockMgr {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
friend class ObPageManagerCenter;
|
||||
friend class Thread;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObPageManager();
|
||||
~ObPageManager();
|
||||
static ObPageManager* thread_local_instance()
|
||||
@ -97,12 +97,12 @@ class ObPageManager : public lib::IBlockMgr {
|
||||
tl_instance_ = &instance;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int init();
|
||||
static __thread ObPageManager* tl_instance_;
|
||||
static int64_t global_id_;
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t id_;
|
||||
lib::ObMemAttr attr_;
|
||||
lib::BlockSet bs_;
|
||||
@ -114,18 +114,18 @@ class ObPageManager : public lib::IBlockMgr {
|
||||
};
|
||||
|
||||
class ObPageManagerCenter {
|
||||
public:
|
||||
public:
|
||||
static ObPageManagerCenter& get_instance();
|
||||
int register_pm(ObPageManager& pm);
|
||||
void unregister_pm(ObPageManager& pm);
|
||||
bool has_register(ObPageManager& pm) const;
|
||||
int print_tenant_stat(int64_t tenant_id, char* buf, int64_t len, int64_t& pos);
|
||||
|
||||
private:
|
||||
private:
|
||||
ObPageManagerCenter();
|
||||
int print_tenant_stat(int64_t tenant_id, int64_t& sum_used, int64_t& sum_hold, char* buf, int64_t len, int64_t& pos);
|
||||
|
||||
private:
|
||||
private:
|
||||
lib::ObMutex mutex_;
|
||||
container::ObRbTree<ObPageManager, container::ObDummyCompHelper<ObPageManager>> rb_tree_;
|
||||
};
|
||||
|
20
deps/oblib/src/lib/allocator/ob_pcounter.h
vendored
20
deps/oblib/src/lib/allocator/ob_pcounter.h
vendored
@ -60,7 +60,7 @@ inline int64_t get_cpu_num()
|
||||
}
|
||||
|
||||
class PthreadSpinLock {
|
||||
public:
|
||||
public:
|
||||
PthreadSpinLock()
|
||||
{
|
||||
IGNORE_RETURN pthread_spin_init(&lock_, false);
|
||||
@ -82,7 +82,7 @@ class PthreadSpinLock {
|
||||
IGNORE_RETURN pthread_spin_unlock(&lock_);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
pthread_spinlock_t lock_;
|
||||
};
|
||||
|
||||
@ -101,7 +101,7 @@ inline const PCounterDesc* get_pcounter_desc(int mod)
|
||||
}
|
||||
|
||||
class PCounterSet {
|
||||
public:
|
||||
public:
|
||||
PCounterSet()
|
||||
{
|
||||
memset(counters_, 0, sizeof(counters_));
|
||||
@ -109,7 +109,7 @@ class PCounterSet {
|
||||
~PCounterSet()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
void set(int mod, int64_t val)
|
||||
{
|
||||
counters_[mod].set(val);
|
||||
@ -123,12 +123,12 @@ class PCounterSet {
|
||||
return counters_[mod].value();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
::oceanbase::common::ObPCCounter counters_[PCOUNTER_COUNT];
|
||||
};
|
||||
|
||||
class Printer {
|
||||
public:
|
||||
public:
|
||||
enum { MAX_BUF_SIZE = 4096 };
|
||||
Printer() : limit_(MAX_BUF_SIZE), pos_(0)
|
||||
{
|
||||
@ -177,14 +177,14 @@ class Printer {
|
||||
return src;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
char buf_[MAX_BUF_SIZE];
|
||||
int64_t limit_;
|
||||
int64_t pos_;
|
||||
};
|
||||
|
||||
class PCounterMonitor {
|
||||
public:
|
||||
public:
|
||||
typedef PthreadSpinLock Lock;
|
||||
PCounterMonitor(PCounterSet& set, int64_t interval)
|
||||
: pcounter_set_(set), report_interval_(interval), last_report_time_(0), report_seq_(1)
|
||||
@ -194,7 +194,7 @@ class PCounterMonitor {
|
||||
~PCounterMonitor()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
void report()
|
||||
{
|
||||
int64_t cur_time = get_us();
|
||||
@ -226,7 +226,7 @@ class PCounterMonitor {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
PCounterSet& pcounter_set_;
|
||||
Lock lock_;
|
||||
int64_t report_interval_;
|
||||
|
@ -20,7 +20,7 @@ namespace common {
|
||||
// @note thread-safe depends on LockT
|
||||
template <typename T, typename BlockAllocatorT = ObMalloc, typename LockT = ObNullLock>
|
||||
class ObPooledAllocator {
|
||||
public:
|
||||
public:
|
||||
ObPooledAllocator(int64_t block_size = common::OB_MALLOC_NORMAL_BLOCK_SIZE,
|
||||
const BlockAllocatorT& alloc = BlockAllocatorT(ObModIds::OB_POOL));
|
||||
virtual ~ObPooledAllocator();
|
||||
@ -35,11 +35,11 @@ class ObPooledAllocator {
|
||||
void inc_ref(){};
|
||||
void dec_ref(){};
|
||||
|
||||
private:
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObPooledAllocator);
|
||||
|
||||
private:
|
||||
private:
|
||||
// data members
|
||||
ObPool<BlockAllocatorT, LockT> the_pool_;
|
||||
};
|
||||
|
6
deps/oblib/src/lib/allocator/ob_qsync.h
vendored
6
deps/oblib/src/lib/allocator/ob_qsync.h
vendored
@ -21,7 +21,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObQSync {
|
||||
public:
|
||||
public:
|
||||
enum { MAX_REF_CNT = 256 };
|
||||
struct Ref {
|
||||
Ref() : ref_(0)
|
||||
@ -79,7 +79,7 @@ class ObQSync {
|
||||
return bool_ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t add_ref(int64_t idx, int64_t x)
|
||||
{
|
||||
int64_t ret = 0;
|
||||
@ -92,7 +92,7 @@ class ObQSync {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Ref ref_array_[MAX_REF_CNT];
|
||||
};
|
||||
|
||||
|
26
deps/oblib/src/lib/allocator/ob_retire_station.h
vendored
26
deps/oblib/src/lib/allocator/ob_retire_station.h
vendored
@ -21,7 +21,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class QClock {
|
||||
public:
|
||||
public:
|
||||
enum { MAX_QCLOCK_SLOT_NUM = OB_MAX_CPU_NUM * 32 };
|
||||
struct ClockSlot {
|
||||
ClockSlot() : clock_(UINT64_MAX)
|
||||
@ -90,14 +90,14 @@ class QClock {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
bool is_quiescent(uint64_t clock)
|
||||
{
|
||||
uint64_t cur_clock = get_clock();
|
||||
return clock < cur_clock && (clock < get_qclock() || clock < update_qclock(calc_quiescent_clock(cur_clock)));
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t get_slot_id()
|
||||
{
|
||||
return get_itid();
|
||||
@ -135,7 +135,7 @@ class QClock {
|
||||
return qclock;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t clock_ CACHE_ALIGNED;
|
||||
uint64_t qclock_ CACHE_ALIGNED;
|
||||
ClockSlot clock_array_[MAX_QCLOCK_SLOT_NUM] CACHE_ALIGNED;
|
||||
@ -148,14 +148,14 @@ inline QClock& get_global_qclock()
|
||||
}
|
||||
|
||||
class HazardList {
|
||||
public:
|
||||
public:
|
||||
typedef ObLink Link;
|
||||
HazardList() : size_(0), head_(NULL), tail_(NULL)
|
||||
{}
|
||||
virtual ~HazardList()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
int64_t size()
|
||||
{
|
||||
return size_;
|
||||
@ -196,7 +196,7 @@ class HazardList {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Link* get_head()
|
||||
{
|
||||
return head_;
|
||||
@ -225,14 +225,14 @@ class HazardList {
|
||||
tail_ = NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t size_;
|
||||
Link* head_;
|
||||
Link* tail_;
|
||||
};
|
||||
|
||||
class RetireStation {
|
||||
public:
|
||||
public:
|
||||
typedef HazardList List;
|
||||
enum { MAX_RETIRE_SLOT_NUM = OB_MAX_CPU_NUM * 32 };
|
||||
|
||||
@ -301,20 +301,20 @@ class RetireStation {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
RetireList& get_retire_list()
|
||||
{
|
||||
return retire_list_[get_itid() % MAX_RETIRE_SLOT_NUM];
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t retire_limit_;
|
||||
QClock& qclock_;
|
||||
RetireList retire_list_[MAX_RETIRE_SLOT_NUM];
|
||||
};
|
||||
|
||||
class QClockGuard {
|
||||
public:
|
||||
public:
|
||||
explicit QClockGuard(QClock& qclock = get_global_qclock()) : qclock_(qclock), slot_id_(qclock_.enter_critical())
|
||||
{}
|
||||
~QClockGuard()
|
||||
@ -322,7 +322,7 @@ class QClockGuard {
|
||||
qclock_.leave_critical(slot_id_);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
QClock& qclock_;
|
||||
uint64_t slot_id_;
|
||||
};
|
||||
|
8
deps/oblib/src/lib/allocator/ob_safe_arena.h
vendored
8
deps/oblib/src/lib/allocator/ob_safe_arena.h
vendored
@ -19,7 +19,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObSafeArena : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObSafeArena(const lib::ObLabel& label, const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE)
|
||||
: arena_alloc_(label, page_size), lock_()
|
||||
{}
|
||||
@ -27,7 +27,7 @@ class ObSafeArena : public ObIAllocator {
|
||||
virtual ~ObSafeArena()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
virtual void* alloc(const int64_t sz) override
|
||||
{
|
||||
return alloc(sz, default_memattr);
|
||||
@ -78,11 +78,11 @@ class ObSafeArena : public ObIAllocator {
|
||||
return arena_alloc_.get_arena();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObArenaAllocator arena_alloc_;
|
||||
ObSpinLock lock_;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObSafeArena);
|
||||
};
|
||||
} // namespace common
|
||||
|
@ -22,7 +22,7 @@ namespace common {
|
||||
extern ObBlockAllocMgr default_blk_alloc;
|
||||
|
||||
class ObFifoBlock : public common::ObDLink {
|
||||
public:
|
||||
public:
|
||||
typedef ObFifoBlock Host;
|
||||
struct Item {
|
||||
Item(Host* host, int64_t size) : host_(host), size_(size)
|
||||
@ -72,7 +72,7 @@ class ObFifoBlock : public common::ObDLink {
|
||||
return 0 == ATOMIC_AAF(&ref_, val);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t blk_size_ CACHE_ALIGNED;
|
||||
int64_t bytes_alloc_ CACHE_ALIGNED;
|
||||
int64_t ref_ CACHE_ALIGNED;
|
||||
@ -85,13 +85,13 @@ class ObSimpleFifoAlloc {
|
||||
typedef common::SpinRLockGuard RLockGuard;
|
||||
typedef common::SpinWLockGuard WLockGuard;
|
||||
|
||||
public:
|
||||
public:
|
||||
enum { MAX_ARENA_NUM = 32, BLOCK_SIZE = OB_MALLOC_BIG_BLOCK_SIZE };
|
||||
typedef ObBlockAllocMgr BlockAlloc;
|
||||
typedef ObFifoBlock Block;
|
||||
typedef ObSimpleSync Sync;
|
||||
class Arena : public Sync {
|
||||
public:
|
||||
public:
|
||||
Arena() : blk_(NULL)
|
||||
{}
|
||||
Block* blk()
|
||||
@ -107,11 +107,11 @@ class ObSimpleFifoAlloc {
|
||||
return ATOMIC_TAS(&blk_, NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Block* blk_;
|
||||
} CACHE_ALIGNED;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObSimpleFifoAlloc(const ObMemAttr& attr, int block_size = BLOCK_SIZE, BlockAlloc& blk_alloc = default_blk_alloc)
|
||||
: nway_(1), bsize_(block_size), bytes_alloc_(0), mattr_(attr), blk_alloc_(blk_alloc)
|
||||
{
|
||||
@ -218,7 +218,7 @@ class ObSimpleFifoAlloc {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Block* prepare_block(int64_t blk_size)
|
||||
{
|
||||
Block* blk = NULL;
|
||||
@ -253,7 +253,7 @@ class ObSimpleFifoAlloc {
|
||||
return has_reach_limit;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int nway_ CACHE_ALIGNED;
|
||||
int64_t bsize_;
|
||||
int64_t bytes_alloc_;
|
||||
|
42
deps/oblib/src/lib/allocator/ob_slice_alloc.h
vendored
42
deps/oblib/src/lib/allocator/ob_slice_alloc.h
vendored
@ -24,7 +24,7 @@ namespace common {
|
||||
extern ObBlockAllocMgr default_blk_alloc;
|
||||
|
||||
class ObSimpleSync {
|
||||
public:
|
||||
public:
|
||||
ObSimpleSync() : ref_(0)
|
||||
{}
|
||||
int32_t ref(int32_t x)
|
||||
@ -38,12 +38,12 @@ class ObSimpleSync {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int32_t ref_;
|
||||
};
|
||||
|
||||
class ObDListWithLock {
|
||||
public:
|
||||
public:
|
||||
typedef ObDLink DLink;
|
||||
ObDListWithLock() : lock_()
|
||||
{
|
||||
@ -68,7 +68,7 @@ class ObDListWithLock {
|
||||
return &head_ == p ? NULL : p;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void add_(DLink* p)
|
||||
{
|
||||
DLink* prev = head_.prev_;
|
||||
@ -86,13 +86,13 @@ class ObDListWithLock {
|
||||
next->prev_ = prev;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
mutable common::ObSpinLock lock_;
|
||||
DLink head_ CACHE_ALIGNED;
|
||||
};
|
||||
|
||||
class ObEmbedFixedQueue {
|
||||
public:
|
||||
public:
|
||||
ObEmbedFixedQueue() : push_(0), pop_(0), capacity_(0)
|
||||
{}
|
||||
~ObEmbedFixedQueue()
|
||||
@ -119,7 +119,7 @@ class ObEmbedFixedQueue {
|
||||
return p;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
uint32_t push_ CACHE_ALIGNED;
|
||||
uint32_t pop_ CACHE_ALIGNED;
|
||||
uint32_t capacity_ CACHE_ALIGNED;
|
||||
@ -135,7 +135,7 @@ class ObEmbedFixedQueue {
|
||||
list.
|
||||
*/
|
||||
class ObStockCtrl {
|
||||
public:
|
||||
public:
|
||||
enum { K = INT32_MAX / 2 };
|
||||
ObStockCtrl() : total_(0), stock_(0)
|
||||
{}
|
||||
@ -147,7 +147,7 @@ class ObStockCtrl {
|
||||
stock_ = n;
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
uint32_t total()
|
||||
{
|
||||
return total_;
|
||||
@ -175,7 +175,7 @@ class ObStockCtrl {
|
||||
return ov == K + total_ - 1;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int32_t faa(int32_t x)
|
||||
{
|
||||
return ATOMIC_FAA(&stock_, x);
|
||||
@ -213,17 +213,17 @@ class ObStockCtrl {
|
||||
return ov;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int32_t total_ CACHE_ALIGNED;
|
||||
int32_t stock_ CACHE_ALIGNED;
|
||||
};
|
||||
|
||||
class ObBlockSlicer : public ObStockCtrl {
|
||||
public:
|
||||
public:
|
||||
typedef ObEmbedFixedQueue FList;
|
||||
typedef ObBlockSlicer Host;
|
||||
struct Item {
|
||||
public:
|
||||
public:
|
||||
Item(Host* host) : host_(host)
|
||||
{}
|
||||
~Item()
|
||||
@ -232,10 +232,10 @@ class ObBlockSlicer : public ObStockCtrl {
|
||||
} __attribute__((aligned(16)));
|
||||
;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObDLink dlink_ CACHE_ALIGNED;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObBlockSlicer(int32_t limit, int32_t slice_size, void* tmallocator = NULL) : tmallocator_(tmallocator)
|
||||
{
|
||||
int64_t isize = lib::align_up2((int32_t)sizeof(Item) + slice_size, 16);
|
||||
@ -282,21 +282,21 @@ class ObBlockSlicer : public ObStockCtrl {
|
||||
return tmallocator_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
uint64_t hash_;
|
||||
void* tmallocator_;
|
||||
FList flist_ CACHE_ALIGNED;
|
||||
};
|
||||
|
||||
class ObSliceAlloc {
|
||||
public:
|
||||
public:
|
||||
enum { MAX_ARENA_NUM = 32, MAX_REF_NUM = 4096, DEFAULT_BLOCK_SIZE = OB_MALLOC_NORMAL_BLOCK_SIZE };
|
||||
typedef ObSimpleSync Sync;
|
||||
typedef ObBlockSlicer Block;
|
||||
typedef ObBlockAllocMgr BlockAlloc;
|
||||
typedef ObDListWithLock BlockList;
|
||||
class Arena {
|
||||
public:
|
||||
public:
|
||||
Arena() : blk_(NULL)
|
||||
{}
|
||||
Block* blk()
|
||||
@ -312,7 +312,7 @@ class ObSliceAlloc {
|
||||
return ATOMIC_TAS(&blk_, NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Block* blk_;
|
||||
} CACHE_ALIGNED;
|
||||
ObSliceAlloc() : nway_(0), bsize_(0), isize_(0), slice_limit_(0), blk_alloc_(default_blk_alloc), tmallocator_(NULL)
|
||||
@ -439,7 +439,7 @@ class ObSliceAlloc {
|
||||
to_cstring(attr_));
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
void release_block(Block* blk)
|
||||
{
|
||||
if (blk->release()) {
|
||||
@ -491,7 +491,7 @@ class ObSliceAlloc {
|
||||
// try_purge();
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int nway_ CACHE_ALIGNED;
|
||||
int32_t bsize_;
|
||||
int32_t isize_;
|
||||
|
@ -17,7 +17,7 @@
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
class ObSmallAllocator : public ObSliceAlloc {
|
||||
public:
|
||||
public:
|
||||
typedef ObBlockAllocMgr BlockAlloc;
|
||||
static const int64_t DEFAULT_MIN_OBJ_COUNT_ON_BLOCK = 1;
|
||||
ObSmallAllocator()
|
||||
@ -50,7 +50,7 @@ class ObSmallAllocator : public ObSliceAlloc {
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
BlockAlloc block_alloc_;
|
||||
};
|
||||
}; // end namespace common
|
||||
|
@ -24,7 +24,7 @@ using common::ObArenaAllocator;
|
||||
class ObSQLArenaAllocator : public ObIAllocator {
|
||||
const static int THRESHOLD_SIZE_ONCE = 1 << 20; // 1M
|
||||
const static int DEFAULT_THRESHOLD_SIZE_TOTAL = 10 << 20; // 10M
|
||||
public:
|
||||
public:
|
||||
ObSQLArenaAllocator(const int64_t tenant_id = common::OB_SERVER_TENANT_ID);
|
||||
virtual ~ObSQLArenaAllocator();
|
||||
void set_tenant_id(const uint64_t tenant_id);
|
||||
@ -38,7 +38,7 @@ class ObSQLArenaAllocator : public ObIAllocator {
|
||||
bool revert_tracer();
|
||||
void reset_remain_one_page();
|
||||
|
||||
private:
|
||||
private:
|
||||
// Use normal_application when the single and total size does not exceed the threshold
|
||||
// Apply for the rest with large_
|
||||
ObArenaAllocator normal_;
|
||||
|
16
deps/oblib/src/lib/allocator/ob_thread_mempool.h
vendored
16
deps/oblib/src/lib/allocator/ob_thread_mempool.h
vendored
@ -42,18 +42,18 @@ class ObMemList {
|
||||
MemBlock* next;
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit ObMemList(const int32_t fixed_size);
|
||||
~ObMemList();
|
||||
|
||||
public:
|
||||
public:
|
||||
void* get();
|
||||
void put(void* ptr, const int32_t max_free_num);
|
||||
int64_t inc_ref_cnt();
|
||||
int64_t dec_ref_cnt();
|
||||
int64_t get_ref_cnt();
|
||||
|
||||
private:
|
||||
private:
|
||||
MemAllocator alloc_;
|
||||
MemBlock* header_;
|
||||
int32_t size_;
|
||||
@ -64,24 +64,24 @@ class ObMemList {
|
||||
class ObThreadMempool {
|
||||
static const pthread_key_t INVALID_THREAD_KEY = INT32_MAX;
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int32_t DEFAULT_MAX_FREE_NUM = 0;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObThreadMempool();
|
||||
~ObThreadMempool();
|
||||
|
||||
public:
|
||||
public:
|
||||
int init(const int32_t fixed_size, const int32_t max_free_num);
|
||||
int destroy();
|
||||
void* alloc();
|
||||
void free(void* ptr);
|
||||
void set_max_free_num(const int32_t max_free_num);
|
||||
|
||||
private:
|
||||
private:
|
||||
static void destroy_thread_data_(void* ptr);
|
||||
|
||||
private:
|
||||
private:
|
||||
pthread_key_t key_;
|
||||
int32_t fixed_size_;
|
||||
int32_t max_free_num_;
|
||||
|
16
deps/oblib/src/lib/allocator/ob_vslice_alloc.h
vendored
16
deps/oblib/src/lib/allocator/ob_vslice_alloc.h
vendored
@ -23,7 +23,7 @@ namespace common {
|
||||
extern ObBlockAllocMgr default_blk_alloc;
|
||||
|
||||
class ObBlockVSlicer {
|
||||
public:
|
||||
public:
|
||||
typedef ObBlockVSlicer Host;
|
||||
struct Item {
|
||||
Item(Host* host, int64_t size) : host_(host), size_(size)
|
||||
@ -73,7 +73,7 @@ class ObBlockVSlicer {
|
||||
return 0 == ATOMIC_AAF(&ref_, val);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int64_t blk_size_ CACHE_ALIGNED;
|
||||
int64_t ref_ CACHE_ALIGNED;
|
||||
int64_t pos_ CACHE_ALIGNED;
|
||||
@ -81,13 +81,13 @@ class ObBlockVSlicer {
|
||||
};
|
||||
|
||||
class ObVSliceAlloc {
|
||||
public:
|
||||
public:
|
||||
enum { MAX_ARENA_NUM = 32, DEFAULT_BLOCK_SIZE = OB_MALLOC_NORMAL_BLOCK_SIZE };
|
||||
typedef ObBlockAllocMgr BlockAlloc;
|
||||
typedef ObBlockVSlicer Block;
|
||||
typedef ObSimpleSync Sync;
|
||||
class Arena : public Sync {
|
||||
public:
|
||||
public:
|
||||
Arena() : blk_(NULL)
|
||||
{}
|
||||
Block* blk()
|
||||
@ -103,11 +103,11 @@ class ObVSliceAlloc {
|
||||
return ATOMIC_TAS(&blk_, NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Block* blk_;
|
||||
} CACHE_ALIGNED;
|
||||
|
||||
public:
|
||||
public:
|
||||
ObVSliceAlloc() : nway_(0), bsize_(0), blk_alloc_(default_blk_alloc)
|
||||
{}
|
||||
ObVSliceAlloc(const ObMemAttr& attr, int block_size = DEFAULT_BLOCK_SIZE, BlockAlloc& blk_alloc = default_blk_alloc)
|
||||
@ -241,7 +241,7 @@ class ObVSliceAlloc {
|
||||
return ratio;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Block* prepare_block()
|
||||
{
|
||||
Block* blk = NULL;
|
||||
@ -256,7 +256,7 @@ class ObVSliceAlloc {
|
||||
blk_alloc_.free_block(blk, blk->get_blk_size());
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
int nway_ CACHE_ALIGNED;
|
||||
int64_t bsize_;
|
||||
ObMemAttr mattr_;
|
||||
|
129
deps/oblib/src/lib/allocator/page_arena.h
vendored
129
deps/oblib/src/lib/allocator/page_arena.h
vendored
@ -90,7 +90,7 @@ struct DefaultPageAllocator : public ObIAllocator {
|
||||
return ob_malloc(sz, malloc_attr);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
lib::ObLabel label_;
|
||||
uint64_t tenant_id_;
|
||||
int64_t ctx_id_;
|
||||
@ -155,7 +155,7 @@ struct ModulePageAllocator : public ObIAllocator {
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
ObIAllocator* allocator_;
|
||||
lib::ObLabel label_;
|
||||
uint64_t tenant_id_;
|
||||
@ -169,7 +169,7 @@ struct ModulePageAllocator : public ObIAllocator {
|
||||
*/
|
||||
template <typename CharT = char, class PageAllocatorT = DefaultPageAllocator>
|
||||
class PageArena {
|
||||
private: // types
|
||||
private: // types
|
||||
typedef PageArena<CharT, PageAllocatorT> Self;
|
||||
|
||||
struct Page {
|
||||
@ -293,11 +293,11 @@ class PageArena {
|
||||
int64_t total_;
|
||||
};
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t DEFAULT_PAGE_SIZE = OB_MALLOC_NORMAL_BLOCK_SIZE - sizeof(Page); // default 8KB
|
||||
static const int64_t DEFAULT_BIG_PAGE_SIZE = OB_MALLOC_BIG_BLOCK_SIZE; // default 2M
|
||||
|
||||
private: // data
|
||||
private: // data
|
||||
Page* cur_page_;
|
||||
Page* header_;
|
||||
Page* tailer_;
|
||||
@ -309,7 +309,7 @@ class PageArena {
|
||||
PageAllocatorT page_allocator_;
|
||||
TracerContext* tc_;
|
||||
|
||||
private: // helpers
|
||||
private: // helpers
|
||||
Page* insert_head(Page* page)
|
||||
{
|
||||
if (OB_ISNULL(page)) {
|
||||
@ -488,7 +488,7 @@ class PageArena {
|
||||
return *this;
|
||||
}
|
||||
|
||||
public: // API
|
||||
public: // API
|
||||
/** constructor */
|
||||
PageArena(const int64_t page_size = DEFAULT_PAGE_SIZE, const PageAllocatorT& alloc = PageAllocatorT())
|
||||
: cur_page_(NULL),
|
||||
@ -972,7 +972,7 @@ class PageArena {
|
||||
return total_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(PageArena);
|
||||
};
|
||||
|
||||
@ -980,41 +980,88 @@ typedef PageArena<> CharArena;
|
||||
typedef PageArena<unsigned char> ByteArena;
|
||||
typedef PageArena<char, ModulePageAllocator> ModuleArena;
|
||||
|
||||
class ObArenaAllocator final : public ObIAllocator
|
||||
{
|
||||
class ObArenaAllocator final : public ObIAllocator {
|
||||
public:
|
||||
ObArenaAllocator(const lib::ObLabel &label = ObModIds::OB_MODULE_PAGE_ALLOCATOR,
|
||||
const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE,
|
||||
int64_t tenant_id = OB_SERVER_TENANT_ID,
|
||||
int64_t ctx_id = 0)
|
||||
: arena_(page_size, ModulePageAllocator(label, tenant_id, ctx_id)) {};
|
||||
ObArenaAllocator(ObIAllocator &allocator, const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE)
|
||||
: arena_(page_size, ModulePageAllocator(allocator)) {};
|
||||
virtual ~ObArenaAllocator() {};
|
||||
ObArenaAllocator(const lib::ObLabel& label = ObModIds::OB_MODULE_PAGE_ALLOCATOR,
|
||||
const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE, int64_t tenant_id = OB_SERVER_TENANT_ID,
|
||||
int64_t ctx_id = 0)
|
||||
: arena_(page_size, ModulePageAllocator(label, tenant_id, ctx_id)){};
|
||||
ObArenaAllocator(ObIAllocator& allocator, const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE)
|
||||
: arena_(page_size, ModulePageAllocator(allocator)){};
|
||||
virtual ~ObArenaAllocator(){};
|
||||
|
||||
public:
|
||||
virtual void *alloc(const int64_t sz) override{ return arena_.alloc_aligned(sz); }
|
||||
void *alloc(const int64_t size, const ObMemAttr &attr) override
|
||||
virtual void* alloc(const int64_t sz) override
|
||||
{
|
||||
return arena_.alloc_aligned(sz);
|
||||
}
|
||||
void* alloc(const int64_t size, const ObMemAttr& attr) override
|
||||
{
|
||||
UNUSED(attr);
|
||||
return alloc(size);
|
||||
}
|
||||
virtual void *alloc_aligned(const int64_t sz, const int64_t align)
|
||||
{ return arena_.alloc_aligned(sz, align); }
|
||||
virtual void *realloc(void *ptr, const int64_t oldsz, const int64_t newsz) override { return arena_.realloc(reinterpret_cast<char*>(ptr), oldsz, newsz); }
|
||||
virtual void free(void *ptr) override { arena_.free(reinterpret_cast<char *>(ptr)); ptr = NULL; }
|
||||
virtual void clear() { arena_.free(); }
|
||||
int64_t used() const override { return arena_.used(); }
|
||||
int64_t total() const override { return arena_.total(); }
|
||||
void reset() override { arena_.free(); }
|
||||
void reset_remain_one_page() { arena_.free_remain_one_page(); }
|
||||
void reuse() override { arena_.reuse(); }
|
||||
virtual void set_label(const lib::ObLabel &label) { arena_.set_label(label); }
|
||||
virtual lib::ObLabel get_label() const { return arena_.get_label(); }
|
||||
virtual void set_tenant_id(uint64_t tenant_id) { arena_.set_tenant_id(tenant_id); }
|
||||
bool set_tracer() { return arena_.set_tracer(); }
|
||||
bool revert_tracer() { return arena_.revert_tracer(); }
|
||||
void set_ctx_id(int64_t ctx_id) { arena_.set_ctx_id(ctx_id); }
|
||||
void set_attr(const ObMemAttr &attr) override
|
||||
virtual void* alloc_aligned(const int64_t sz, const int64_t align)
|
||||
{
|
||||
return arena_.alloc_aligned(sz, align);
|
||||
}
|
||||
virtual void* realloc(void* ptr, const int64_t oldsz, const int64_t newsz) override
|
||||
{
|
||||
return arena_.realloc(reinterpret_cast<char*>(ptr), oldsz, newsz);
|
||||
}
|
||||
virtual void free(void* ptr) override
|
||||
{
|
||||
arena_.free(reinterpret_cast<char*>(ptr));
|
||||
ptr = NULL;
|
||||
}
|
||||
virtual void clear()
|
||||
{
|
||||
arena_.free();
|
||||
}
|
||||
int64_t used() const override
|
||||
{
|
||||
return arena_.used();
|
||||
}
|
||||
int64_t total() const override
|
||||
{
|
||||
return arena_.total();
|
||||
}
|
||||
void reset() override
|
||||
{
|
||||
arena_.free();
|
||||
}
|
||||
void reset_remain_one_page()
|
||||
{
|
||||
arena_.free_remain_one_page();
|
||||
}
|
||||
void reuse() override
|
||||
{
|
||||
arena_.reuse();
|
||||
}
|
||||
virtual void set_label(const lib::ObLabel& label)
|
||||
{
|
||||
arena_.set_label(label);
|
||||
}
|
||||
virtual lib::ObLabel get_label() const
|
||||
{
|
||||
return arena_.get_label();
|
||||
}
|
||||
virtual void set_tenant_id(uint64_t tenant_id)
|
||||
{
|
||||
arena_.set_tenant_id(tenant_id);
|
||||
}
|
||||
bool set_tracer()
|
||||
{
|
||||
return arena_.set_tracer();
|
||||
}
|
||||
bool revert_tracer()
|
||||
{
|
||||
return arena_.revert_tracer();
|
||||
}
|
||||
void set_ctx_id(int64_t ctx_id)
|
||||
{
|
||||
arena_.set_ctx_id(ctx_id);
|
||||
}
|
||||
void set_attr(const ObMemAttr& attr) override
|
||||
{
|
||||
arena_.set_tenant_id(attr.tenant_id_);
|
||||
arena_.set_ctx_id(attr.ctx_id_);
|
||||
@ -1035,18 +1082,18 @@ public:
|
||||
return arena_.mprotect_page_arena(prot);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ModuleArena arena_;
|
||||
};
|
||||
|
||||
class ObSafeArenaAllocator : public ObIAllocator {
|
||||
public:
|
||||
public:
|
||||
ObSafeArenaAllocator(ObArenaAllocator& arena) : arena_(arena), lock_()
|
||||
{}
|
||||
virtual ~ObSafeArenaAllocator()
|
||||
{}
|
||||
|
||||
public:
|
||||
public:
|
||||
void* alloc(const int64_t sz) override
|
||||
{
|
||||
return alloc(sz, default_memattr);
|
||||
@ -1080,7 +1127,7 @@ class ObSafeArenaAllocator : public ObIAllocator {
|
||||
return arena_.used();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
ObArenaAllocator& arena_;
|
||||
ObSpinLock lock_;
|
||||
};
|
||||
|
6
deps/oblib/src/lib/async/event_base.h
vendored
6
deps/oblib/src/lib/async/event_base.h
vendored
@ -20,18 +20,18 @@ namespace oceanbase {
|
||||
namespace lib {
|
||||
|
||||
class EventBase {
|
||||
public:
|
||||
public:
|
||||
EventBase();
|
||||
virtual ~EventBase();
|
||||
|
||||
int init();
|
||||
void destroy();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void signal();
|
||||
void wait4event(int64_t maxwait = 0);
|
||||
|
||||
private:
|
||||
private:
|
||||
std::thread th_;
|
||||
struct ev_loop* loop_;
|
||||
ev_async sched_watcher_;
|
||||
|
@ -30,7 +30,7 @@ union AtomicInt64 {
|
||||
};
|
||||
|
||||
class ObAtomicReference final {
|
||||
public:
|
||||
public:
|
||||
ObAtomicReference();
|
||||
~ObAtomicReference();
|
||||
void reset();
|
||||
@ -49,7 +49,7 @@ class ObAtomicReference final {
|
||||
return atomic_num_.ref;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
AtomicInt64 atomic_num_;
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace oceanbase {
|
||||
namespace common {
|
||||
template <class T, class HashFunc>
|
||||
class ObBloomFilter {
|
||||
public:
|
||||
public:
|
||||
ObBloomFilter();
|
||||
~ObBloomFilter();
|
||||
int init(int64_t element_count, double false_positive_prob = BLOOM_FILTER_FALSE_POSITIVE_PROB);
|
||||
@ -66,7 +66,7 @@ class ObBloomFilter {
|
||||
TO_STRING_KV(K_(nhash), K_(nbit), KP_(bits));
|
||||
INLINE_NEED_SERIALIZE_AND_DESERIALIZE;
|
||||
|
||||
private:
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObBloomFilter);
|
||||
static constexpr double BLOOM_FILTER_FALSE_POSITIVE_PROB = 0.01;
|
||||
mutable HashFunc hash_func_;
|
||||
|
38
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
38
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
@ -936,7 +936,7 @@ size_t ObCharset::strlen_char(const ObCollationType collation_type, const char*
|
||||
size_t ret = 0;
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
if (OB_ISNULL(cs->cset)) {
|
||||
@ -1092,8 +1092,7 @@ int ObCharset::mb_wc(ObCollationType collation_type, const ObString& mb, int32_t
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
ob_wc_t res_wc;
|
||||
@ -1122,8 +1121,7 @@ int ObCharset::mb_wc(
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
ob_wc_t res_wc;
|
||||
@ -1152,8 +1150,7 @@ int ObCharset::display_len(ObCollationType collation_type, const ObString& mb, i
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
if (OB_ISNULL(cs->cset)) {
|
||||
@ -1197,8 +1194,7 @@ int ObCharset::max_display_width_charpos(ObCollationType collation_type, const c
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
if (OB_ISNULL(cs->cset)) {
|
||||
@ -1673,8 +1669,7 @@ bool ObCharset::is_bin_sort(ObCollationType collation_type)
|
||||
bool ret = false;
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
ret = (0 != (cs->state & OB_CS_BINSORT));
|
||||
@ -1801,8 +1796,7 @@ int ObCharset::first_valid_char(
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else if (OB_UNLIKELY(NULL == buf)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_ERROR("Null buffer passed in", K(ret), K(buf));
|
||||
@ -1992,8 +1986,7 @@ bool ObCharset::is_space(const ObCollationType collation_type, char c)
|
||||
bool ret = false;
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
ret = (' ' == c);
|
||||
@ -2006,8 +1999,7 @@ bool ObCharset::is_graph(const ObCollationType collation_type, char c)
|
||||
bool ret = false;
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
ret = !!(((cs)->ctype + 1)[(unsigned char)(c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR));
|
||||
@ -2020,8 +2012,7 @@ bool ObCharset::usemb(const ObCollationType collation_type)
|
||||
bool ret = false;
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
ret = (NULL != cs->cset->ismbchar);
|
||||
@ -2034,8 +2025,7 @@ int ObCharset::is_mbchar(const ObCollationType collation_type, const char* str,
|
||||
bool ret = false;
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
if (NULL != cs->cset->ismbchar) {
|
||||
@ -2062,8 +2052,7 @@ int ObCharset::get_mbmaxlen_by_coll(const ObCollationType collation_type, int64_
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
mbmaxlen = cs->mbmaxlen;
|
||||
@ -2077,8 +2066,7 @@ int ObCharset::get_mbminlen_by_coll(const ObCollationType collation_type, int64_
|
||||
if (OB_UNLIKELY(collation_type <= CS_TYPE_INVALID || collation_type >= CS_TYPE_MAX) ||
|
||||
OB_ISNULL(ObCharset::charset_arr[collation_type])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR(
|
||||
"unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
LOG_ERROR("unexpected error. invalid argument(s)", K(ret), K(collation_type));
|
||||
} else {
|
||||
ObCharsetInfo* cs = static_cast<ObCharsetInfo*>(ObCharset::charset_arr[collation_type]);
|
||||
mbminlen = cs->mbminlen;
|
||||
|
24
deps/oblib/src/lib/charset/ob_charset.h
vendored
24
deps/oblib/src/lib/charset/ob_charset.h
vendored
@ -88,11 +88,11 @@ struct ObCollationWrapper {
|
||||
const char* ob_collation_type_str(ObCollationType collation_type);
|
||||
|
||||
class ObCharset {
|
||||
private:
|
||||
private:
|
||||
ObCharset(){};
|
||||
virtual ~ObCharset(){};
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t CHARSET_WRAPPER_COUNT = 2;
|
||||
static const int64_t COLLATION_WRAPPER_COUNT = 3;
|
||||
|
||||
@ -243,19 +243,19 @@ class ObCharset {
|
||||
static bool is_cjk_charset(ObCollationType collation_type);
|
||||
static bool is_valid_connection_collation(ObCollationType collation_type);
|
||||
|
||||
public:
|
||||
public:
|
||||
static const int64_t VALID_COLLATION_TYPES = 3;
|
||||
|
||||
private:
|
||||
private:
|
||||
static bool is_argument_valid(const ObCharsetInfo* charset_info, const char* str, int64_t str_len);
|
||||
static bool is_argument_valid(
|
||||
const ObCollationType collation_type, const char* str1, int64_t str_len1, const char* str2, int64_t str_len2);
|
||||
|
||||
private:
|
||||
private:
|
||||
// disallow copy
|
||||
DISALLOW_COPY_AND_ASSIGN(ObCharset);
|
||||
|
||||
private:
|
||||
private:
|
||||
static const ObCharsetWrapper charset_wrap_arr_[CHARSET_WRAPPER_COUNT];
|
||||
static const ObCollationWrapper collation_wrap_arr_[COLLATION_WRAPPER_COUNT];
|
||||
static void* charset_arr[CS_TYPE_MAX]; // CHARSET_INFO *
|
||||
@ -264,7 +264,7 @@ class ObCharset {
|
||||
};
|
||||
|
||||
class ObCharsetUtils {
|
||||
public:
|
||||
public:
|
||||
static int init(ObIAllocator& allocator);
|
||||
static ObString get_const_str(ObCollationType coll_type, int ascii)
|
||||
{
|
||||
@ -297,25 +297,25 @@ class ObCharsetUtils {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static ObString const_str_for_ascii_[CHARSET_MAX][INT8_MAX + 1];
|
||||
};
|
||||
|
||||
class ObStringScanner {
|
||||
public:
|
||||
public:
|
||||
ObStringScanner(const ObString& str, common::ObCollationType collation_type)
|
||||
: str_(str), collation_type_(collation_type)
|
||||
{}
|
||||
int next_character(ObString& encoding, int32_t& wchar);
|
||||
TO_STRING_KV(K_(str), K_(collation_type));
|
||||
|
||||
private:
|
||||
private:
|
||||
const ObString& str_;
|
||||
common::ObCollationType collation_type_;
|
||||
};
|
||||
|
||||
class ObCharSetString {
|
||||
public:
|
||||
public:
|
||||
ObCharSetString(ObString str, ObCollationType cs_type) : str_(str), cs_type_(cs_type)
|
||||
{}
|
||||
ObString& get_string()
|
||||
@ -327,7 +327,7 @@ class ObCharSetString {
|
||||
return ObCharset::charset_convert(allocator, str_, cs_type_, target_cs_type, str_);
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
ObString str_;
|
||||
ObCollationType cs_type_;
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user