From c965cc6b5f631c4a5680e2abe13f215bfc5420c1 Mon Sep 17 00:00:00 2001 From: ColinLee Date: Fri, 19 Dec 2025 14:37:55 +0800 Subject: [PATCH] update fmt. --- cpp/examples/cpp_examples/demo_read.cpp | 12 +- cpp/examples/cpp_examples/demo_write.cpp | 2 - cpp/src/common/allocator/alloc_base.h | 18 +- cpp/src/common/allocator/byte_stream.h | 262 +++++----- cpp/src/common/allocator/mem_alloc.cc | 44 +- cpp/src/common/allocator/page_arena.cc | 18 +- cpp/src/common/allocator/page_arena.h | 24 +- cpp/src/common/container/array.h | 24 +- cpp/src/common/container/bit_map.h | 10 +- cpp/src/common/container/blocking_queue.cc | 6 +- cpp/src/common/container/byte_buffer.h | 22 +- cpp/src/common/container/hash_func.h | 12 +- cpp/src/common/container/hash_node.h | 12 +- cpp/src/common/container/list.h | 38 +- cpp/src/common/container/murmur_hash3.h | 14 +- cpp/src/common/container/slice.h | 26 +- cpp/src/common/container/sorted_array.h | 22 +- cpp/src/common/datatype/value.h | 60 +-- cpp/src/common/global.h | 6 +- cpp/src/common/mutex/mutex.h | 4 +- cpp/src/common/path.h | 6 +- cpp/src/common/record.h | 28 +- cpp/src/common/row_record.h | 66 +-- cpp/src/common/seq_tvlist.h | 10 +- cpp/src/common/statistic.h | 478 +++++++++--------- cpp/src/common/tablet_iterator.h | 20 +- cpp/src/common/tsblock/tsblock.cc | 52 +- cpp/src/common/tsblock/tuple_desc.cc | 2 +- cpp/src/common/tsblock/tuple_desc.h | 14 +- .../tsblock/vector/fixed_length_vector.h | 12 +- .../tsblock/vector/variable_length_vector.h | 12 +- cpp/src/common/tsfile_common.cc | 48 +- cpp/src/common/tsfile_mgr.cc | 24 +- cpp/src/common/tsfile_mgr.h | 26 +- cpp/src/compress/compressor.h | 16 +- cpp/src/compress/compressor_factory.h | 8 +- cpp/src/compress/gzip_compressor.cc | 40 +- cpp/src/compress/gzip_compressor.h | 34 +- cpp/src/compress/lz4_compressor.cc | 30 +- cpp/src/compress/lz4_compressor.h | 22 +- cpp/src/compress/lzo_compressor.cc | 37 +- cpp/src/compress/lzo_compressor.h | 18 +- cpp/src/compress/snappy_compressor.cc | 26 +- cpp/src/compress/snappy_compressor.h | 18 +- cpp/src/compress/uncompressed_compressor.h | 12 +- cpp/src/encoding/decoder.h | 16 +- cpp/src/encoding/dictionary_encoder.h | 22 +- cpp/src/encoding/encoder.h | 14 +- cpp/src/encoding/encoder_factory.h | 12 +- cpp/src/encoding/float_sprintz_decoder.h | 24 +- cpp/src/encoding/gorilla_encoder.h | 126 ++--- cpp/src/encoding/int32_rle_encoder.h | 20 +- cpp/src/encoding/int32_sprintz_decoder.h | 26 +- cpp/src/encoding/int64_rle_decoder.h | 34 +- cpp/src/encoding/int64_rle_encoder.h | 20 +- cpp/src/encoding/plain_encoder.h | 14 +- cpp/src/encoding/ts2diff_decoder.h | 144 +++--- cpp/src/encoding/ts2diff_encoder.h | 118 ++--- cpp/src/encoding/zigzag_decoder.h | 32 +- cpp/src/encoding/zigzag_encoder.h | 28 +- cpp/src/file/open_file.cc | 18 +- cpp/src/file/open_file.h | 28 +- cpp/src/file/read_file.cc | 12 +- cpp/src/file/read_file.h | 10 +- cpp/src/file/tsfile_io_reader.h | 82 +-- cpp/src/file/tsfile_io_writer.cc | 120 ++--- cpp/src/file/tsfile_io_writer.h | 90 ++-- cpp/src/file/write_file.cc | 6 +- cpp/src/file/write_file.h | 6 +- cpp/src/parser/generated/PathParser.cpp | 214 ++++---- cpp/src/parser/generated/PathParser.h | 138 ++--- .../parser/generated/PathParserBaseVisitor.h | 16 +- cpp/src/parser/generated/PathParserListener.h | 32 +- cpp/src/parser/generated/PathParserVisitor.h | 16 +- .../block/device_ordered_tsblock_reader.cc | 6 +- .../block/device_ordered_tsblock_reader.h | 20 +- cpp/src/reader/block/tsblock_reader.h | 8 +- cpp/src/reader/bloom_filter.cc | 35 +- cpp/src/reader/bloom_filter.h | 26 +- cpp/src/reader/chunk_reader.cc | 76 +-- cpp/src/reader/chunk_reader.h | 60 +-- cpp/src/reader/column_mapping.h | 16 +- cpp/src/reader/expression.cc | 74 +-- cpp/src/reader/expression.h | 66 +-- cpp/src/reader/filter/and_filter.h | 18 +- cpp/src/reader/filter/between.h | 18 +- cpp/src/reader/filter/binary_filter.h | 10 +- cpp/src/reader/filter/eq.h | 2 +- cpp/src/reader/filter/gt.h | 2 +- cpp/src/reader/filter/gt_eq.h | 2 +- cpp/src/reader/filter/in.h | 4 +- cpp/src/reader/filter/lt.h | 2 +- cpp/src/reader/filter/lt_eq.h | 2 +- cpp/src/reader/filter/not_eq.h | 2 +- cpp/src/reader/filter/object.h | 60 +-- cpp/src/reader/filter/or_filter.h | 26 +- cpp/src/reader/filter/time_operator.cc | 50 +- cpp/src/reader/filter/time_operator.h | 34 +- cpp/src/reader/filter/unary_filter.h | 2 +- cpp/src/reader/ichunk_reader.h | 16 +- cpp/src/reader/qds_with_timegenerator.h | 42 +- cpp/src/reader/qds_without_timegenerator.h | 20 +- cpp/src/reader/scan_iterator.cc | 50 +- cpp/src/reader/scan_iterator.h | 68 +-- cpp/src/reader/task/device_query_task.cc | 10 +- cpp/src/reader/task/device_query_task.h | 16 +- cpp/src/reader/task/device_task_iterator.cc | 4 +- cpp/src/reader/task/device_task_iterator.h | 14 +- cpp/src/reader/tsfile_executor.cc | 24 +- cpp/src/reader/tsfile_executor.h | 28 +- cpp/src/reader/tsfile_series_scan_iterator.h | 30 +- cpp/src/reader/tsfile_tree_reader.cc | 16 +- cpp/src/reader/tsfile_tree_reader.h | 12 +- cpp/src/utils/db_utils.h | 56 +- cpp/src/utils/storage_utils.h | 20 +- cpp/src/writer/chunk_writer.cc | 8 +- cpp/src/writer/chunk_writer.h | 16 +- cpp/src/writer/page_writer.cc | 8 +- cpp/src/writer/page_writer.h | 30 +- cpp/src/writer/time_chunk_writer.cc | 8 +- cpp/src/writer/time_chunk_writer.h | 16 +- cpp/src/writer/time_page_writer.cc | 6 +- cpp/src/writer/time_page_writer.h | 24 +- cpp/src/writer/tsfile_writer.cc | 306 +++++------ cpp/src/writer/tsfile_writer.h | 172 +++---- cpp/src/writer/value_chunk_writer.cc | 8 +- cpp/src/writer/value_chunk_writer.h | 16 +- cpp/src/writer/value_page_writer.cc | 8 +- cpp/src/writer/value_page_writer.h | 28 +- cpp/test/common/allocator/alloc_base_test.cc | 24 +- cpp/test/common/tsblock/tslock_test.cc | 18 +- cpp/test/common/tsfile_common_test.cc | 20 +- cpp/test/compress/gzip_compressor_test.cc | 8 +- cpp/test/compress/lz4_compressor_test.cc | 8 +- cpp/test/compress/lzo_compressor_test.cc | 8 +- cpp/test/compress/snappy_compressor_test.cc | 8 +- cpp/test/file/write_file_test.cc | 6 +- cpp/test/writer/tsfile_writer_test.cc | 104 ++-- cpp/test_all.sh | 18 - 139 files changed, 2519 insertions(+), 2537 deletions(-) mode change 100755 => 100644 cpp/test/compress/snappy_compressor_test.cc delete mode 100644 cpp/test_all.sh diff --git a/cpp/examples/cpp_examples/demo_read.cpp b/cpp/examples/cpp_examples/demo_read.cpp index f90efe350..91eb7c461 100644 --- a/cpp/examples/cpp_examples/demo_read.cpp +++ b/cpp/examples/cpp_examples/demo_read.cpp @@ -41,11 +41,15 @@ int demo_read() { columns.emplace_back("s1"); auto table_schema = reader.get_table_schema(table_name); - storage::Filter* tag_filter1 = storage::TagFilterBuilder(table_schema.get()).eq("id1", "id1_filed_1"); - storage::Filter* tag_filter2 = storage::TagFilterBuilder(table_schema.get()).eq("id2", "id1_filed_2"); - storage::Filter* tag_filter = storage::TagFilterBuilder(table_schema.get()).and_filter(tag_filter1, tag_filter2); + storage::Filter* tag_filter1 = + storage::TagFilterBuilder(table_schema.get()).eq("id1", "id1_filed_1"); + storage::Filter* tag_filter2 = + storage::TagFilterBuilder(table_schema.get()).eq("id2", "id1_filed_2"); + storage::Filter* tag_filter = storage::TagFilterBuilder(table_schema.get()) + .and_filter(tag_filter1, tag_filter2); // Column vector contains the columns you want to select. - HANDLE_ERROR(reader.query(table_name, columns, 0, 100, temp_ret, tag_filter)); + HANDLE_ERROR( + reader.query(table_name, columns, 0, 100, temp_ret, tag_filter)); // Get query handler. auto ret = dynamic_cast(temp_ret); diff --git a/cpp/examples/cpp_examples/demo_write.cpp b/cpp/examples/cpp_examples/demo_write.cpp index a9403666d..98f4dfcee 100644 --- a/cpp/examples/cpp_examples/demo_write.cpp +++ b/cpp/examples/cpp_examples/demo_write.cpp @@ -24,7 +24,6 @@ #include "cpp_examples.h" int demo_write() { - storage::libtsfile_init(); std::string table_name = "table1"; @@ -61,7 +60,6 @@ int demo_write() { common::ColumnCategory::FIELD}, 10); - for (int row = 0; row < 5; row++) { long timestamp = row; tablet.add_timestamp(row, timestamp); diff --git a/cpp/src/common/allocator/alloc_base.h b/cpp/src/common/allocator/alloc_base.h index e9824b11e..effe267d0 100644 --- a/cpp/src/common/allocator/alloc_base.h +++ b/cpp/src/common/allocator/alloc_base.h @@ -72,18 +72,18 @@ enum AllocModID { __MAX_MOD_ID = 127, // leave 1 bit to detect header size }; -extern const char *g_mod_names[__LAST_MOD_ID]; +extern const char* g_mod_names[__LAST_MOD_ID]; /* very basic alloc/free interface in C style */ -void *mem_alloc(uint32_t size, AllocModID mid); -void mem_free(void *ptr); -void *mem_realloc(void *ptr, uint32_t size); +void* mem_alloc(uint32_t size, AllocModID mid); +void mem_free(void* ptr); +void* mem_realloc(void* ptr, uint32_t size); class ModStat { public: ModStat() : stat_arr_(NULL) {} - static ModStat &get_instance() { + static ModStat& get_instance() { /* * This is the singleton of Mod Memory Statistic. * gms is short for Global Mod Statistic @@ -108,14 +108,14 @@ class ModStat { #endif private: - INLINE int32_t *get_item(int8_t mid) { + INLINE int32_t* get_item(int8_t mid) { return &(stat_arr_[mid * (ITEM_SIZE / sizeof(int32_t))]); } private: static const int32_t ITEM_SIZE = CACHE_LINE_SIZE; static const int32_t ITEM_COUNT = __LAST_MOD_ID; - int32_t *stat_arr_; + int32_t* stat_arr_; STATIC_ASSERT((ITEM_SIZE % sizeof(int32_t) == 0), ModStat_ITEM_SIZE_ERROR); }; @@ -123,8 +123,8 @@ class ModStat { /* base allocator */ class BaseAllocator { public: - void *alloc(uint32_t size, AllocModID mid) { return mem_alloc(size, mid); } - void free(void *ptr) { mem_free(ptr); } + void* alloc(uint32_t size, AllocModID mid) { return mem_alloc(size, mid); } + void free(void* ptr) { mem_free(ptr); } }; extern BaseAllocator g_base_allocator; diff --git a/cpp/src/common/allocator/byte_stream.h b/cpp/src/common/allocator/byte_stream.h index 65c4b80a8..570aa1c13 100644 --- a/cpp/src/common/allocator/byte_stream.h +++ b/cpp/src/common/allocator/byte_stream.h @@ -235,12 +235,12 @@ FORCE_INLINE double bytes_to_double(uint8_t bytes[8]) { class ByteStream { private: struct Page { - OptionalAtomic next_; // 9 bytes - uint8_t *buf_; // 8 bytes + OptionalAtomic next_; // 9 bytes + uint8_t* buf_; // 8 bytes explicit Page(bool enable_atomic) : next_(nullptr, enable_atomic) { - buf_ = (uint8_t - *)(this + + buf_ = + (uint8_t*)(this + 1); // I think it should add 17, because the Page // class is 9+8=17 bytes. No, adding one to a // pointer is not adding a byte, but adding the @@ -248,13 +248,13 @@ class ByteStream { // pointed to by the pointer, and adding one // here is actually adding 17 bytes. No problem. } - Page(bool enable_atomic, uint8_t *wrapped_buf) + Page(bool enable_atomic, uint8_t* wrapped_buf) : next_(nullptr, enable_atomic), buf_(wrapped_buf) {} }; public: ByteStream(uint32_t page_size, AllocModID mid, bool enable_atomic = false, - BaseAllocator &allocator = g_base_allocator) + BaseAllocator& allocator = g_base_allocator) : allocator_(allocator), head_(nullptr, enable_atomic), tail_(nullptr, enable_atomic), @@ -287,9 +287,9 @@ class ByteStream { /* ================ Part 0: wrap from outside buffer ================ */ // if you wrap a buffer as a ByteStream, you should // manage the outside buffer yourself. - void wrap_from(const char *buf, int32_t buf_len) { + void wrap_from(const char* buf, int32_t buf_len) { wrapped_page_.next_.store(nullptr); - wrapped_page_.buf_ = (uint8_t *)buf; + wrapped_page_.buf_ = (uint8_t*)buf; page_size_ = buf_len; head_.store(&wrapped_page_); @@ -302,7 +302,7 @@ class ByteStream { FORCE_INLINE bool is_wrapped() const { return head_.load() == &wrapped_page_; } - char *get_wrapped_buf() { return (char *)wrapped_page_.buf_; } + char* get_wrapped_buf() { return (char*)wrapped_page_.buf_; } void clear_wrapped_buf() { wrapped_page_.buf_ = nullptr; } /* ================ Part 1: basic ================ */ @@ -323,7 +323,7 @@ class ByteStream { // if this ByteStream is wrapped from a plain buffer // do not free the outside buffer. if (!is_wrapped()) { - Page *p = head_.load(); + Page* p = head_.load(); while (p) { p = head_.load()->next_.load(); allocator_.free(head_.load()); @@ -338,7 +338,7 @@ class ByteStream { } // never used TODO - void shallow_clone_from(ByteStream &other) { + void shallow_clone_from(ByteStream& other) { this->page_size_ = other.page_size_; this->mid_ = other.mid_; this->head_.store(other.head_.load()); @@ -358,7 +358,7 @@ class ByteStream { /* ================ Part 2: write_xxx and read_xxx ================ */ // writer @buf with length @len into this bytestream - int write_buf(const uint8_t *buf, const uint32_t len) { + int write_buf(const uint8_t* buf, const uint32_t len) { int ret = common::E_OK; uint32_t write_len = 0; while (write_len < len) { @@ -380,7 +380,7 @@ class ByteStream { // reader @want_len bytes to @buf, @read_len indicates real len we reader. // if ByteStream do not have so many bytes, it will return E_PARTIAL_READ if // no other error occure. - int read_buf(uint8_t *buf, const uint32_t want_len, uint32_t &read_len) { + int read_buf(uint8_t* buf, const uint32_t want_len, uint32_t& read_len) { int ret = common::E_OK; bool partial_read = (read_pos_ + want_len > total_size_.load()); uint32_t want_len_limited = @@ -402,23 +402,23 @@ class ByteStream { return partial_read ? common::E_PARTIAL_READ : common::E_OK; } - FORCE_INLINE int write_buf(const char *buf, const uint32_t len) { - return write_buf((const uint8_t *)buf, len); + FORCE_INLINE int write_buf(const char* buf, const uint32_t len) { + return write_buf((const uint8_t*)buf, len); } - FORCE_INLINE int read_buf(char *buf, const uint32_t want_len, - uint32_t &read_len) { - return read_buf((uint8_t *)buf, want_len, read_len); + FORCE_INLINE int read_buf(char* buf, const uint32_t want_len, + uint32_t& read_len) { + return read_buf((uint8_t*)buf, want_len, read_len); } - FORCE_INLINE int read_buf(char *buf, const int32_t want_len, - int32_t &read_len) { - return read_buf((uint8_t *)buf, (uint32_t &)want_len, - (uint32_t &)read_len); + FORCE_INLINE int read_buf(char* buf, const int32_t want_len, + int32_t& read_len) { + return read_buf((uint8_t*)buf, (uint32_t&)want_len, + (uint32_t&)read_len); } void purge_prev_pages(int purge_page_count = INT32_MAX) { - Page *cur = head_.load(); + Page* cur = head_.load(); while (cur != tail_.load() && purge_page_count-- > 0) { - Page *next = cur->next_.load(); + Page* next = cur->next_.load(); allocator_.free(cur); cur = next; } @@ -434,7 +434,7 @@ class ByteStream { * Note: it should be used in single thread. */ struct Buffer { - char *buf_; + char* buf_; uint32_t len_; Buffer() : buf_(nullptr), len_(0) {} @@ -446,7 +446,7 @@ class ByteStream { return b; } b.buf_ = - (char *)(tail_.load()->buf_ + (total_size_.load() % page_size_)); + (char*)(tail_.load()->buf_ + (total_size_.load() % page_size_)); b.len_ = page_size_ - (total_size_.load() % page_size_); return b; } @@ -465,11 +465,11 @@ class ByteStream { * Do not use it if the host_ is still writing */ struct BufferIterator { - const ByteStream &host_; - Page *cur_; - Page *end_; + const ByteStream& host_; + Page* cur_; + Page* end_; int64_t total_size_; - BufferIterator(const ByteStream &bs) : host_(bs) { + BufferIterator(const ByteStream& bs) : host_(bs) { cur_ = bs.head_.load(); end_ = bs.tail_.load(); total_size_ = bs.total_size_.load(); @@ -478,7 +478,7 @@ class ByteStream { Buffer get_next_buf() { Buffer b; if (cur_ != nullptr) { - b.buf_ = (char *)cur_->buf_; + b.buf_ = (char*)cur_->buf_; if (cur_ == end_ && host_.total_size_.load() % host_.page_size_ != 0) { b.len_ = host_.total_size_.load() % host_.page_size_; @@ -501,19 +501,19 @@ class ByteStream { * the host ByteStream should be configured as atomically. */ struct Consumer { - const ByteStream &host_; - Page *cur_; + const ByteStream& host_; + Page* cur_; uint32_t read_offset_within_cur_page_; int64_t total_end_offset_; // for DEBUG - Consumer(const ByteStream &bs) : host_(bs) { + Consumer(const ByteStream& bs) : host_(bs) { ASSERT(bs.head_.enable_atomic()); cur_ = nullptr; read_offset_within_cur_page_ = 0; total_end_offset_ = 0; } - Buffer get_next_buf(ByteStream &host) { + Buffer get_next_buf(ByteStream& host) { Buffer b; if (UNLIKELY(host.head_.load() == nullptr)) { // host is empty, return empty buffer. @@ -526,7 +526,7 @@ class ByteStream { } // get tail position atomically - Page *host_end = nullptr; + Page* host_end = nullptr; uint32_t host_total_size = 0; while (true) { host_end = host_.tail_.load(); @@ -542,7 +542,7 @@ class ByteStream { if (read_offset_within_cur_page_ == host_.page_size_) { return b; } else { - b.buf_ = ((char *)(cur_->buf_)) + + b.buf_ = ((char*)(cur_->buf_)) + read_offset_within_cur_page_; b.len_ = host_.page_size_ - read_offset_within_cur_page_; @@ -555,7 +555,7 @@ class ByteStream { (host_total_size % host_.page_size_)) { return b; } else { - b.buf_ = ((char *)(cur_->buf_)) + + b.buf_ = ((char*)(cur_->buf_)) + read_offset_within_cur_page_; b.len_ = (host_total_size % host_.page_size_) - read_offset_within_cur_page_; @@ -570,7 +570,7 @@ class ByteStream { cur_ = cur_->next_.load(); read_offset_within_cur_page_ = 0; } else { - b.buf_ = ((char *)(cur_->buf_)) + + b.buf_ = ((char*)(cur_->buf_)) + read_offset_within_cur_page_; b.len_ = host_.page_size_ - read_offset_within_cur_page_; @@ -591,7 +591,7 @@ class ByteStream { int ret = common::E_OK; if (UNLIKELY(tail_.load() == nullptr || total_size_.load() % page_size_ == 0)) { - Page *p = nullptr; + Page* p = nullptr; if (RET_FAIL(alloc_page(p))) { return ret; } @@ -616,9 +616,9 @@ class ByteStream { return common::E_OK; } - FORCE_INLINE int alloc_page(Page *&p) { + FORCE_INLINE int alloc_page(Page*& p) { int ret = common::E_OK; - char *buf = (char *)allocator_.alloc(page_size_ + sizeof(Page), mid_); + char* buf = (char*)allocator_.alloc(page_size_ + sizeof(Page), mid_); if (UNLIKELY(buf == nullptr)) { ret = common::E_OOM; } else { @@ -639,10 +639,10 @@ class ByteStream { DISALLOW_COPY_AND_ASSIGN(ByteStream); private: - BaseAllocator &allocator_; - OptionalAtomic head_; - OptionalAtomic tail_; - Page *read_page_; // only one thread is allow to reader this ByteStream + BaseAllocator& allocator_; + OptionalAtomic head_; + OptionalAtomic tail_; + Page* read_page_; // only one thread is allow to reader this ByteStream OptionalAtomic total_size_; // total size in byte uint32_t read_pos_; // current reader position uint32_t marked_read_pos_; // current reader position @@ -651,7 +651,7 @@ class ByteStream { Page wrapped_page_; }; -FORCE_INLINE int merge_byte_stream(ByteStream &sea, ByteStream &river, +FORCE_INLINE int merge_byte_stream(ByteStream& sea, ByteStream& river, bool purge_river = false) { int ret = common::E_OK; ByteStream::BufferIterator buf_iter = river.init_buffer_iterator(); @@ -671,7 +671,7 @@ FORCE_INLINE int merge_byte_stream(ByteStream &sea, ByteStream &river, return ret; } -FORCE_INLINE int copy_bs_to_buf(ByteStream &bs, char *src_buf, +FORCE_INLINE int copy_bs_to_buf(ByteStream& bs, char* src_buf, uint32_t src_buf_len) { ByteStream::BufferIterator buf_iter = bs.init_buffer_iterator(); uint32_t copyed_len = 0; @@ -703,8 +703,8 @@ FORCE_INLINE uint32_t get_var_uint_size( } #if DEBUG_SE -FORCE_INLINE void DEBUG_print_byte_stream(const char *print_tag, - ByteStream &b) { +FORCE_INLINE void DEBUG_print_byte_stream(const char* print_tag, + ByteStream& b) { const int32_t WRAP_COUNT = 16; int32_t print_char_count = 0; ByteStream::BufferIterator buf_iter = b.init_buffer_iterator(); @@ -728,7 +728,7 @@ FORCE_INLINE void DEBUG_print_byte_stream(const char *print_tag, printf("\n\n"); } -FORCE_INLINE void DEBUG_hex_dump_buf(const char *print_tag, const char *buf, +FORCE_INLINE void DEBUG_hex_dump_buf(const char* print_tag, const char* buf, int32_t len) { const int32_t WRAP_COUNT = 16; for (int i = 0; i < len; i++) { @@ -743,16 +743,16 @@ FORCE_INLINE void DEBUG_hex_dump_buf(const char *print_tag, const char *buf, class SerializationUtil { public: - FORCE_INLINE static int write_ui8(uint8_t ui8, ByteStream &out) { + FORCE_INLINE static int write_ui8(uint8_t ui8, ByteStream& out) { return out.write_buf(&ui8, 1); } - FORCE_INLINE static int write_ui16(uint16_t ui16, ByteStream &out) { + FORCE_INLINE static int write_ui16(uint16_t ui16, ByteStream& out) { uint8_t buf[2]; buf[0] = (uint8_t)((ui16 >> 8) & 0xFF); buf[1] = (uint8_t)((ui16) & 0xFF); return out.write_buf(buf, 2); } - FORCE_INLINE static int write_ui32(uint32_t ui32, ByteStream &out) { + FORCE_INLINE static int write_ui32(uint32_t ui32, ByteStream& out) { uint8_t buf[4]; buf[0] = (uint8_t)((ui32 >> 24) & 0xFF); buf[1] = (uint8_t)((ui32 >> 16) & 0xFF); @@ -760,7 +760,7 @@ class SerializationUtil { buf[3] = (uint8_t)((ui32) & 0xFF); return out.write_buf(buf, 4); } - FORCE_INLINE static int write_ui64(uint64_t ui64, ByteStream &out) { + FORCE_INLINE static int write_ui64(uint64_t ui64, ByteStream& out) { // big-endian: most signification byte at smaller address // refer to tsfile.utils.BytesUtil uint8_t buf[8]; @@ -775,7 +775,7 @@ class SerializationUtil { return out.write_buf(buf, 8); } - FORCE_INLINE static int read_ui8(uint8_t &ui8, ByteStream &in) { + FORCE_INLINE static int read_ui8(uint8_t& ui8, ByteStream& in) { int ret = common::E_OK; char buf[1]; uint32_t read_len = 0; @@ -783,7 +783,7 @@ class SerializationUtil { ui8 = (uint8_t)buf[0]; return ret; } - FORCE_INLINE static int read_ui16(uint16_t &ui16, ByteStream &in) { + FORCE_INLINE static int read_ui16(uint16_t& ui16, ByteStream& in) { int ret = common::E_OK; uint8_t buf[2]; uint32_t read_len = 0; @@ -794,7 +794,7 @@ class SerializationUtil { ui16 = (ui16 << 8) | buf[1]; return ret; } - FORCE_INLINE static int read_ui32(uint32_t &ui32, ByteStream &in) { + FORCE_INLINE static int read_ui32(uint32_t& ui32, ByteStream& in) { int ret = common::E_OK; uint8_t buf[4]; uint32_t read_len = 0; @@ -807,7 +807,7 @@ class SerializationUtil { ui32 = (ui32 << 8) | (buf[3] & 0xFF); return ret; } - FORCE_INLINE static int read_ui64(uint64_t &ui64, ByteStream &in) { + FORCE_INLINE static int read_ui64(uint64_t& ui64, ByteStream& in) { int ret = common::E_OK; uint8_t buf[8]; uint32_t read_len = 0; @@ -826,7 +826,7 @@ class SerializationUtil { } FORCE_INLINE static int write_int_little_endian_padded_on_bit_width( - int32_t value, ByteStream &out, int bitWidth) { + int32_t value, ByteStream& out, int bitWidth) { int paddedByteNum = (bitWidth + 7) / 8; if (paddedByteNum > 4) { return E_TSFILE_CORRUPTED; @@ -840,7 +840,7 @@ class SerializationUtil { } FORCE_INLINE static int write_int64_little_endian_padded_on_bit_width( - int64_t value, ByteStream &out, int bit_width) { + int64_t value, ByteStream& out, int bit_width) { int padded_byte_num = (bit_width + 7) / 8; if (padded_byte_num > 8) { return E_TSFILE_CORRUPTED; @@ -854,7 +854,7 @@ class SerializationUtil { } FORCE_INLINE static int read_int_little_endian_padded_on_bit_width( - ByteStream &in, int bitWidth, int32_t &out_val) { + ByteStream& in, int bitWidth, int32_t& out_val) { int padded_byte_num = (bitWidth + 7) / 8; if (padded_byte_num > 4) { return E_TSFILE_CORRUPTED; @@ -873,9 +873,9 @@ class SerializationUtil { return E_OK; } - FORCE_INLINE static int chunk_read_all_data(ByteStream &in, ByteStream &out, + FORCE_INLINE static int chunk_read_all_data(ByteStream& in, ByteStream& out, size_t chunk_size = 4096) { - char *buffer = new char[chunk_size]; + char* buffer = new char[chunk_size]; int ret = common::E_OK; while (in.remaining_size() > 0) { // Adjust read size based on remaining input size @@ -897,20 +897,20 @@ class SerializationUtil { } // caller guarantee buffer has at least 1 byte - FORCE_INLINE static uint8_t read_ui8(char *buffer) { - return *(uint8_t *)buffer; + FORCE_INLINE static uint8_t read_ui8(char* buffer) { + return *(uint8_t*)buffer; } // caller guarantee buffer has at least 2 bytes - FORCE_INLINE static uint16_t read_ui16(char *buffer) { - uint8_t *buf = (uint8_t *)buffer; + FORCE_INLINE static uint16_t read_ui16(char* buffer) { + uint8_t* buf = (uint8_t*)buffer; uint16_t ui16 = buf[0]; ui16 = (ui16 << 8) | (buf[1] & 0xFF); return ui16; } // caller guarantee buffer has at least 4 bytes - FORCE_INLINE static uint32_t read_ui32(char *buffer) { - uint8_t *buf = (uint8_t *)buffer; + FORCE_INLINE static uint32_t read_ui32(char* buffer) { + uint8_t* buf = (uint8_t*)buffer; uint32_t ui32 = buf[0]; ui32 = (ui32 << 8) | (buf[1] & 0xFF); ui32 = (ui32 << 8) | (buf[2] & 0xFF); @@ -918,8 +918,8 @@ class SerializationUtil { return ui32; } // caller guarantee buffer has at least 8 bytes - FORCE_INLINE static uint64_t read_ui64(char *buffer) { - uint8_t *buf = (uint8_t *)buffer; + FORCE_INLINE static uint64_t read_ui64(char* buffer) { + uint8_t* buf = (uint8_t*)buffer; uint64_t ui64 = buf[0]; ui64 = (ui64 << 8) | (buf[1] & 0xFF); ui64 = (ui64 << 8) | (buf[2] & 0xFF); @@ -931,12 +931,12 @@ class SerializationUtil { return ui64; } - FORCE_INLINE static int write_float(float f, ByteStream &out) { + FORCE_INLINE static int write_float(float f, ByteStream& out) { uint8_t bytes[4]; float_to_bytes(f, bytes); return out.write_buf(bytes, 4); } - FORCE_INLINE static int read_float(float &f, ByteStream &in) { + FORCE_INLINE static int read_float(float& f, ByteStream& in) { int ret = common::E_OK; uint8_t bytes[4]; uint32_t read_len = 0; @@ -948,16 +948,16 @@ class SerializationUtil { } return ret; } - FORCE_INLINE static float read_float(char *buffer) { - uint8_t *buf = (uint8_t *)buffer; + FORCE_INLINE static float read_float(char* buffer) { + uint8_t* buf = (uint8_t*)buffer; return bytes_to_float(buf); } - FORCE_INLINE static int write_double(double d, ByteStream &out) { + FORCE_INLINE static int write_double(double d, ByteStream& out) { uint8_t bytes[8]; double_to_bytes(d, bytes); return out.write_buf(bytes, 8); } - FORCE_INLINE static int read_double(double &d, ByteStream &in) { + FORCE_INLINE static int read_double(double& d, ByteStream& in) { int ret = common::E_OK; uint32_t read_len = 0; uint8_t bytes[8]; @@ -969,39 +969,39 @@ class SerializationUtil { } return ret; } - FORCE_INLINE static double read_double(char *buffer) { - uint8_t *buf = (uint8_t *)buffer; + FORCE_INLINE static double read_double(char* buffer) { + uint8_t* buf = (uint8_t*)buffer; return bytes_to_double(buf); } - FORCE_INLINE static int write_i8(int8_t i8, ByteStream &out) { + FORCE_INLINE static int write_i8(int8_t i8, ByteStream& out) { return write_ui8((uint8_t)i8, out); } - FORCE_INLINE static int write_i16(int16_t i16, ByteStream &out) { + FORCE_INLINE static int write_i16(int16_t i16, ByteStream& out) { return write_ui16((uint16_t)i16, out); } - FORCE_INLINE static int write_i32(int32_t i32, ByteStream &out) { + FORCE_INLINE static int write_i32(int32_t i32, ByteStream& out) { return write_ui32((uint32_t)i32, out); } - FORCE_INLINE static int write_i64(int64_t i64, ByteStream &out) { + FORCE_INLINE static int write_i64(int64_t i64, ByteStream& out) { return write_ui64((uint64_t)i64, out); } - FORCE_INLINE static int read_i8(int8_t &i8, ByteStream &in) { - return read_ui8((uint8_t &)i8, in); + FORCE_INLINE static int read_i8(int8_t& i8, ByteStream& in) { + return read_ui8((uint8_t&)i8, in); } - FORCE_INLINE static int read_i16(int16_t &i16, ByteStream &in) { - return read_ui16((uint16_t &)i16, in); + FORCE_INLINE static int read_i16(int16_t& i16, ByteStream& in) { + return read_ui16((uint16_t&)i16, in); } - FORCE_INLINE static int read_i32(int32_t &i32, ByteStream &in) { - return read_ui32((uint32_t &)i32, in); + FORCE_INLINE static int read_i32(int32_t& i32, ByteStream& in) { + return read_ui32((uint32_t&)i32, in); } - FORCE_INLINE static int read_i64(int64_t &i64, ByteStream &in) { - return read_ui64((uint64_t &)i64, in); + FORCE_INLINE static int read_i64(int64_t& i64, ByteStream& in) { + return read_ui64((uint64_t&)i64, in); } // TODO more test on var_xxx - FORCE_INLINE static int do_write_var_uint(uint32_t ui32, ByteStream &out) { + FORCE_INLINE static int do_write_var_uint(uint32_t ui32, ByteStream& out) { int ret = common::E_OK; while ((ui32 & 0xFFFFFF80) != 0) { if (RET_FAIL(write_ui8((ui32 & 0x7F) | 0x80, out))) { @@ -1011,7 +1011,7 @@ class SerializationUtil { } return write_ui8(ui32 & 0x7F, out); } - FORCE_INLINE static int do_write_var_uint(uint32_t ui32, char *out_buf, + FORCE_INLINE static int do_write_var_uint(uint32_t ui32, char* out_buf, const uint32_t out_buf_len) { uint32_t offset = 0; while ((ui32 & 0xFFFFFF80) != 0) { @@ -1028,7 +1028,7 @@ class SerializationUtil { *(out_buf + offset) = (ui32 & 0x7F); return common::E_OK; } - FORCE_INLINE static int do_read_var_uint(uint32_t &ui32, ByteStream &in) { + FORCE_INLINE static int do_read_var_uint(uint32_t& ui32, ByteStream& in) { // Follow readUnsignedVarInt in ReadWriteForEncodingUtils.java int ret = common::E_OK; ui32 = 0; @@ -1047,14 +1047,14 @@ class SerializationUtil { ui32 = ui32 | (ui8 << i); return ret; } - FORCE_INLINE static int do_read_var_uint(uint32_t &ui32, char *in_buf, - int in_buf_len, int *ret_offset) { + FORCE_INLINE static int do_read_var_uint(uint32_t& ui32, char* in_buf, + int in_buf_len, int* ret_offset) { ui32 = 0; int i = 0; uint8_t ui8 = 0; int offset = 0; if (offset < in_buf_len) { - ui8 = *(uint8_t *)(in_buf + offset); + ui8 = *(uint8_t*)(in_buf + offset); offset++; } else { return common::E_BUF_NOT_ENOUGH; @@ -1063,7 +1063,7 @@ class SerializationUtil { ui32 = ui32 | ((ui8 & 0x7F) << i); i = i + 7; if (offset < in_buf_len) { - ui8 = *(uint8_t *)(in_buf + offset); + ui8 = *(uint8_t*)(in_buf + offset); offset++; } else { return common::E_BUF_NOT_ENOUGH; @@ -1075,7 +1075,7 @@ class SerializationUtil { } return common::E_OK; } - FORCE_INLINE static int write_var_int(int32_t i32, ByteStream &out) { + FORCE_INLINE static int write_var_int(int32_t i32, ByteStream& out) { uint32_t ui32 = static_cast(i32) << 1; if (i32 < 0) { ui32 = ~ui32; @@ -1083,7 +1083,7 @@ class SerializationUtil { return do_write_var_uint(ui32, out); } - FORCE_INLINE static int read_var_int(int32_t &i32, ByteStream &in) { + FORCE_INLINE static int read_var_int(int32_t& i32, ByteStream& in) { int ret = common::E_OK; uint32_t ui32; if (RET_FAIL(do_read_var_uint(ui32, in))) { @@ -1095,24 +1095,24 @@ class SerializationUtil { } return ret; } - FORCE_INLINE static int write_var_uint(uint32_t ui32, ByteStream &out) { + FORCE_INLINE static int write_var_uint(uint32_t ui32, ByteStream& out) { return do_write_var_uint(ui32, out); } - FORCE_INLINE static int write_var_uint(uint32_t ui32, char *out_buf, + FORCE_INLINE static int write_var_uint(uint32_t ui32, char* out_buf, const uint32_t out_buf_len) { return do_write_var_uint(ui32, out_buf, out_buf_len); } - FORCE_INLINE static int read_var_uint(uint32_t &ui32, ByteStream &in) { + FORCE_INLINE static int read_var_uint(uint32_t& ui32, ByteStream& in) { return do_read_var_uint(ui32, in); } - FORCE_INLINE static int read_var_uint(uint32_t &ui32, char *in_buf, + FORCE_INLINE static int read_var_uint(uint32_t& ui32, char* in_buf, int in_buf_len, - int *ret_offset = nullptr) { + int* ret_offset = nullptr) { return do_read_var_uint(ui32, in_buf, in_buf_len, ret_offset); } - FORCE_INLINE static int write_var_str(const std::string &str, - ByteStream &out) { + FORCE_INLINE static int write_var_str(const std::string& str, + ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(write_var_int(((int32_t)str.size()), out))) { } else if (RET_FAIL(out.write_buf(str.c_str(), str.size()))) { @@ -1121,8 +1121,8 @@ class SerializationUtil { } // If the str is nullptr, NO_STR_TO_READ will be added instead. - FORCE_INLINE static int write_var_char_ptr(const std::string *str, - ByteStream &out) { + FORCE_INLINE static int write_var_char_ptr(const std::string* str, + ByteStream& out) { int ret = common::E_OK; if (str == nullptr) { write_var_int(storage::NO_STR_TO_READ, out); @@ -1139,8 +1139,8 @@ class SerializationUtil { // If `str` is not a nullptr after calling `read_var_char_ptr`, it // indicates that memory has been allocated and must be freed. - FORCE_INLINE static int read_var_char_ptr(std::string *&str, - ByteStream &in) { + FORCE_INLINE static int read_var_char_ptr(std::string*& str, + ByteStream& in) { int ret = common::E_OK; int32_t len = 0; int32_t read_len = 0; @@ -1151,7 +1151,7 @@ class SerializationUtil { str = nullptr; return ret; } else { - char *tmp_buf = static_cast(malloc(len)); + char* tmp_buf = static_cast(malloc(len)); if (RET_FAIL(in.read_buf(tmp_buf, len, read_len))) { free(tmp_buf); return ret; @@ -1167,13 +1167,13 @@ class SerializationUtil { return ret; } - FORCE_INLINE static int read_var_str(std::string &str, ByteStream &in) { + FORCE_INLINE static int read_var_str(std::string& str, ByteStream& in) { int ret = common::E_OK; int32_t len = 0; int32_t read_len = 0; if (RET_FAIL(read_var_int(len, in))) { } else { - char *tmp_buf = (char *)malloc(len + 1); + char* tmp_buf = (char*)malloc(len + 1); tmp_buf[len] = '\0'; if (RET_FAIL(in.read_buf(tmp_buf, len, read_len))) { } else if (len != read_len) { @@ -1186,20 +1186,20 @@ class SerializationUtil { return ret; } - FORCE_INLINE static int write_str(const std::string &str, ByteStream &out) { + FORCE_INLINE static int write_str(const std::string& str, ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(write_i32((static_cast(str.size())), out))) { } else if (RET_FAIL(out.write_buf(str.c_str(), str.size()))) { } return ret; } - FORCE_INLINE static int read_str(std::string &str, ByteStream &in) { + FORCE_INLINE static int read_str(std::string& str, ByteStream& in) { int ret = common::E_OK; int32_t len = 0; if (RET_FAIL(read_i32(len, in))) { } else { int32_t read_len = 0; - char *tmp_buf = static_cast(malloc(len + 1)); + char* tmp_buf = static_cast(malloc(len + 1)); tmp_buf[len] = '\0'; if (RET_FAIL(in.read_buf(tmp_buf, len, read_len))) { } else if (len != read_len) { @@ -1212,21 +1212,21 @@ class SerializationUtil { return ret; } - FORCE_INLINE static int write_str(const String &str, ByteStream &out) { + FORCE_INLINE static int write_str(const String& str, ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(write_i32((static_cast(str.len_)), out))) { } else if (RET_FAIL(out.write_buf(str.buf_, str.len_))) { } return ret; } - FORCE_INLINE static int read_str(String &str, common::PageArena *pa, - ByteStream &in) { + FORCE_INLINE static int read_str(String& str, common::PageArena* pa, + ByteStream& in) { int ret = common::E_OK; int32_t len = 0; int32_t read_len = 0; if (RET_FAIL(read_i32(len, in))) { } else { - char *buf = (char *)pa->alloc(len); + char* buf = (char*)pa->alloc(len); if (IS_NULL(buf)) { ret = common::E_OOM; } else { @@ -1242,21 +1242,21 @@ class SerializationUtil { return ret; } - FORCE_INLINE static int write_mystring(const String &str, ByteStream &out) { + FORCE_INLINE static int write_mystring(const String& str, ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(write_var_int(str.len_, out))) { } else if (RET_FAIL(out.write_buf(str.buf_, str.len_))) { } return ret; } - FORCE_INLINE static int read_mystring(String &str, common::PageArena *pa, - ByteStream &in) { + FORCE_INLINE static int read_mystring(String& str, common::PageArena* pa, + ByteStream& in) { int ret = common::E_OK; int32_t len = 0; int32_t read_len = 0; if (RET_FAIL(read_var_int(len, in))) { } else { - char *buf = (char *)pa->alloc(len); + char* buf = (char*)pa->alloc(len); if (IS_NULL(buf)) { ret = common::E_OOM; } else { @@ -1271,23 +1271,23 @@ class SerializationUtil { } return ret; } - FORCE_INLINE static int write_char(char ch, ByteStream &out) { + FORCE_INLINE static int write_char(char ch, ByteStream& out) { return write_ui8(ch, out); } - FORCE_INLINE static int read_char(char &ch, ByteStream &in) { - return read_ui8((uint8_t &)ch, in); + FORCE_INLINE static int read_char(char& ch, ByteStream& in) { + return read_ui8((uint8_t&)ch, in); } }; FORCE_INLINE bool deserialize_buf_not_enough(int ret) { return ret == E_OUT_OF_RANGE || ret == E_PARTIAL_READ; } -FORCE_INLINE char *get_bytes_from_bytestream(ByteStream &bs) { +FORCE_INLINE char* get_bytes_from_bytestream(ByteStream& bs) { if (bs.total_size() == 0) { return nullptr; } uint32_t size = bs.total_size(); - char *ret_buf = (char *)malloc(size); + char* ret_buf = (char*)malloc(size); if (ret_buf == nullptr) { return nullptr; } diff --git a/cpp/src/common/allocator/mem_alloc.cc b/cpp/src/common/allocator/mem_alloc.cc index 0cc78c8fb..c79e78858 100644 --- a/cpp/src/common/allocator/mem_alloc.cc +++ b/cpp/src/common/allocator/mem_alloc.cc @@ -32,7 +32,7 @@ namespace common { -const char *g_mod_names[__LAST_MOD_ID] = { +const char* g_mod_names[__LAST_MOD_ID] = { /* 0 */ "DEFAULT", /* 1 */ "MEMTABLE", /* 2 */ "SCHEMA", @@ -80,14 +80,14 @@ constexpr size_t HEADER_PTR_SIZE = 8; // constexpr size_t ALIGNMENT = alignof(std::max_align_t); constexpr size_t ALIGNMENT = 8; -void *mem_alloc(uint32_t size, AllocModID mid) { +void* mem_alloc(uint32_t size, AllocModID mid) { // use 7bit at most ASSERT(mid <= 127); static_assert(HEADER_PTR_SIZE <= ALIGNMENT, "Header must fit within alignment"); constexpr size_t header_size = ALIGNMENT; const size_t total_size = size + header_size; - auto raw = static_cast(malloc(total_size)); + auto raw = static_cast(malloc(total_size)); if (UNLIKELY(raw == nullptr)) { return nullptr; } @@ -95,19 +95,19 @@ void *mem_alloc(uint32_t size, AllocModID mid) { uint64_t header = (data_size << 8) | static_cast(mid); auto low4b = static_cast(header & 0xFFFFFFFF); auto high4b = static_cast(header >> 32); - *reinterpret_cast(raw) = high4b; - *reinterpret_cast(raw + 4) = low4b; + *reinterpret_cast(raw) = high4b; + *reinterpret_cast(raw + 4) = low4b; return raw + header_size; } #ifndef _WIN32 void printCallers() { int layers = 0, i = 0; - char **symbols = NULL; + char** symbols = NULL; const int64_t MAX_FRAMES = 32; - void *frames[MAX_FRAMES]; + void* frames[MAX_FRAMES]; memset(frames, 0, sizeof(frames)); layers = backtrace(frames, MAX_FRAMES); for (i = 0; i < layers; i++) { @@ -127,27 +127,27 @@ void printCallers() { } #endif -void mem_free(void *ptr) { - char *p = static_cast(ptr); - char *raw_ptr = p - ALIGNMENT; +void mem_free(void* ptr) { + char* p = static_cast(ptr); + char* raw_ptr = p - ALIGNMENT; uint64_t header = - static_cast(*reinterpret_cast(raw_ptr + 4)) | - (static_cast(*reinterpret_cast(raw_ptr)) << 32); + static_cast(*reinterpret_cast(raw_ptr + 4)) | + (static_cast(*reinterpret_cast(raw_ptr)) << 32); auto mid = static_cast(header & 0x7F); auto size = static_cast(header >> 8); ModStat::get_instance().update_free(mid, size); ::free(raw_ptr); } -void *mem_realloc(void *ptr, uint32_t size) { - char *p = static_cast(ptr); - char *raw_ptr = p - ALIGNMENT; +void* mem_realloc(void* ptr, uint32_t size) { + char* p = static_cast(ptr); + char* raw_ptr = p - ALIGNMENT; const uint64_t header = - static_cast(*reinterpret_cast(raw_ptr + 4)) | - (static_cast(*reinterpret_cast(raw_ptr)) << 32); + static_cast(*reinterpret_cast(raw_ptr + 4)) | + (static_cast(*reinterpret_cast(raw_ptr)) << 32); auto mid = static_cast(header & 0x7F); auto original_size = static_cast(header >> 8); - p = static_cast(realloc(raw_ptr, size + ALIGNMENT)); + p = static_cast(realloc(raw_ptr, size + ALIGNMENT)); if (UNLIKELY(p == nullptr)) { return nullptr; } @@ -156,17 +156,17 @@ void *mem_realloc(void *ptr, uint32_t size) { uint64_t header_new = (data_size << 8) | static_cast(mid); auto low4b = static_cast(header_new & 0xFFFFFFFF); auto high4b = static_cast(header_new >> 32); - *reinterpret_cast(p) = high4b; - *reinterpret_cast(p + 4) = low4b; + *reinterpret_cast(p) = high4b; + *reinterpret_cast(p + 4) = low4b; ModStat::get_instance().update_alloc( mid, int32_t(size) - int32_t(original_size)); return p + ALIGNMENT; } void ModStat::init() { - stat_arr_ = (int32_t *)(::malloc(ITEM_SIZE * ITEM_COUNT)); + stat_arr_ = (int32_t*)(::malloc(ITEM_SIZE * ITEM_COUNT)); for (int8_t i = 0; i < __LAST_MOD_ID; i++) { - int32_t *item = get_item(i); + int32_t* item = get_item(i); *item = 0; } } diff --git a/cpp/src/common/allocator/page_arena.cc b/cpp/src/common/allocator/page_arena.cc index 9cc9cc009..8abfd9d0e 100644 --- a/cpp/src/common/allocator/page_arena.cc +++ b/cpp/src/common/allocator/page_arena.cc @@ -22,11 +22,11 @@ namespace common { -char *PageArena::alloc(uint32_t size) { +char* PageArena::alloc(uint32_t size) { if (LIKELY(size <= page_size_)) { - Page *cur_page = dummy_head_.next_; + Page* cur_page = dummy_head_.next_; if (LIKELY(cur_page != nullptr)) { - char *ret_ptr = cur_page->alloc(size); + char* ret_ptr = cur_page->alloc(size); if (LIKELY(ret_ptr != nullptr)) { return ret_ptr; } @@ -36,23 +36,23 @@ char *PageArena::alloc(uint32_t size) { * cur_page is null OR can not alloc @size from cur_page, * then alloc new page */ - void *ptr = base_allocator_.alloc(page_size_ + sizeof(Page), mid_); + void* ptr = base_allocator_.alloc(page_size_ + sizeof(Page), mid_); if (UNLIKELY(ptr == nullptr)) { return nullptr; } - Page *new_page = new (ptr) Page(page_size_, cur_page); + Page* new_page = new (ptr) Page(page_size_, cur_page); dummy_head_.next_ = new_page; return new_page->alloc(size); } else { - void *ptr = base_allocator_.alloc(size + sizeof(Page), mid_); - Page *new_page = new (ptr) Page(dummy_head_.next_); + void* ptr = base_allocator_.alloc(size + sizeof(Page), mid_); + Page* new_page = new (ptr) Page(dummy_head_.next_); dummy_head_.next_ = new_page; - return reinterpret_cast(new_page) + sizeof(Page); + return reinterpret_cast(new_page) + sizeof(Page); } } void PageArena::reset() { - Page *p = dummy_head_.next_; + Page* p = dummy_head_.next_; while (p) { dummy_head_.next_ = p->next_; base_allocator_.free(p); diff --git a/cpp/src/common/allocator/page_arena.h b/cpp/src/common/allocator/page_arena.h index 938cac1af..71c11988d 100644 --- a/cpp/src/common/allocator/page_arena.h +++ b/cpp/src/common/allocator/page_arena.h @@ -31,7 +31,7 @@ namespace common { */ class PageArena { public: - explicit PageArena(BaseAllocator &base_allocator = g_base_allocator) + explicit PageArena(BaseAllocator& base_allocator = g_base_allocator) : page_size_(0), mid_(__FIRST_MOD_ID), base_allocator_(base_allocator), @@ -42,14 +42,14 @@ class PageArena { mid_ = mid; } - char *alloc(uint32_t size); + char* alloc(uint32_t size); FORCE_INLINE void destroy() { reset(); } void reset(); #ifdef ENABLE_TEST int TEST_get_page_count() const { int count = 0; - Page *p = dummy_head_.next_; + Page* p = dummy_head_.next_; while (p) { p = p->next_; count++; @@ -62,19 +62,19 @@ class PageArena { class Page { public: Page() : next_(nullptr), page_end_(nullptr), cur_alloc_(nullptr) {} - explicit Page(Page *next_page) + explicit Page(Page* next_page) : next_(next_page), page_end_(nullptr), cur_alloc_(nullptr) {} - Page(uint32_t page_size, Page *next_page) { + Page(uint32_t page_size, Page* next_page) { next_ = next_page; cur_alloc_ = - (char *)this + sizeof(Page); // equals to (char*)(this+1) + (char*)this + sizeof(Page); // equals to (char*)(this+1) page_end_ = cur_alloc_ + page_size; } - INLINE char *alloc(uint32_t size, + INLINE char* alloc(uint32_t size, size_t alignment = alignof(std::max_align_t)) { auto current = reinterpret_cast(cur_alloc_); uintptr_t aligned = (current + alignment - 1) & ~(alignment - 1); - char *ret = reinterpret_cast(aligned); + char* ret = reinterpret_cast(aligned); if (ret + size > page_end_) { return nullptr; } @@ -84,15 +84,15 @@ class PageArena { } public: - Page *next_; - char *page_end_; - char *cur_alloc_; // buf_'s current offset + Page* next_; + char* page_end_; + char* cur_alloc_; // buf_'s current offset }; private: uint32_t page_size_; AllocModID mid_; - BaseAllocator &base_allocator_; + BaseAllocator& base_allocator_; Page dummy_head_; }; diff --git a/cpp/src/common/container/array.h b/cpp/src/common/container/array.h index 96bc34643..7a055808f 100644 --- a/cpp/src/common/container/array.h +++ b/cpp/src/common/container/array.h @@ -41,7 +41,7 @@ template class Array { public: #ifndef NDEBUG - friend std::ostream &operator<<(std::ostream &out, Array &sa) { + friend std::ostream& operator<<(std::ostream& out, Array& sa) { for (size_t idx = 0; idx < sa.size(); idx++) { if (idx > 0) { out << ' '; @@ -92,7 +92,7 @@ class Array { ASSERT(!is_inited_); } array_ = - (ValueType *)mem_alloc(capacity_ * sizeof(*(array_)), MOD_ARRAY); + (ValueType*)mem_alloc(capacity_ * sizeof(*(array_)), MOD_ARRAY); if (UNLIKELY(nullptr == array_)) { is_inited_ = false; // log_err("malloc failed."); @@ -137,7 +137,7 @@ class Array { size_t new_capacity = (size_t)tmp; array_ = - (ValueType *)mem_realloc(array_, new_capacity * sizeof(*(array_))); + (ValueType*)mem_realloc(array_, new_capacity * sizeof(*(array_))); if (UNLIKELY(nullptr == array_)) { // log_err("realloc failed."); return E_OOM; @@ -151,7 +151,7 @@ class Array { // if the size passed to realloc is smaller than before, OS will // automatically release the rest memory array_ = - (ValueType *)mem_realloc(array_, new_capacity * sizeof(*(array_))); + (ValueType*)mem_realloc(array_, new_capacity * sizeof(*(array_))); if (UNLIKELY(nullptr == array_)) { // log_err("malloc failed."); return E_OOM; @@ -160,7 +160,7 @@ class Array { return E_OK; } - int insert(size_t idx, const ValueType &value) { + int insert(size_t idx, const ValueType& value) { if (idx > size_) { // log_err("index %lu is out of range, because size is %lu.", idx, // size_); @@ -197,7 +197,7 @@ class Array { // return E_OK; // } - int append(const ValueType &value) { + int append(const ValueType& value) { if (size_ >= capacity_) { int ret = extend(); if (ret != E_OK) { @@ -209,7 +209,7 @@ class Array { return E_OK; } - FORCE_INLINE ValueType &at(size_t idx) { + FORCE_INLINE ValueType& at(size_t idx) { if (idx >= size_) { // log_err("index %lu is out of range, because size is %lu.", idx, // size_); @@ -219,7 +219,7 @@ class Array { return array_[idx]; } - FORCE_INLINE ValueType &operator[](size_t idx) { + FORCE_INLINE ValueType& operator[](size_t idx) { if (idx >= size_) { // log_err("index %lu is out of range, because size is %lu.", idx, // size_); @@ -229,7 +229,7 @@ class Array { return array_[idx]; } - bool contain(const ValueType &value) { + bool contain(const ValueType& value) { for (size_t i = 0; i < size_; i++) { if (array_[i] == value) { return true; @@ -241,7 +241,7 @@ class Array { /* * if the value is not found, then set 'found' is false. */ - size_t find(const ValueType &target_val, bool &found) { + size_t find(const ValueType& target_val, bool& found) { for (size_t i = 0; i < size_; i++) { if (array_[i] == target_val) { found = true; @@ -270,7 +270,7 @@ class Array { return ret; } - int remove_value(const ValueType &value) { + int remove_value(const ValueType& value) { bool found = false; size_t pos = find(value, found); if (!found) { @@ -296,7 +296,7 @@ class Array { private: size_t capacity_; size_t size_; - ValueType *array_; + ValueType* array_; ValueType dummy_; bool is_inited_; }; diff --git a/cpp/src/common/container/bit_map.h b/cpp/src/common/container/bit_map.h index 9d0367449..356932d14 100644 --- a/cpp/src/common/container/bit_map.h +++ b/cpp/src/common/container/bit_map.h @@ -41,7 +41,7 @@ class BitMap { uint32_t offset = index >> 3; ASSERT(offset < size_); - char *start_addr = bitmap_ + offset; + char* start_addr = bitmap_ + offset; uint8_t bit_mask = get_bit_mask(index); *start_addr = (*start_addr) | (bit_mask); } @@ -50,7 +50,7 @@ class BitMap { uint32_t offset = index >> 3; ASSERT(offset < size_); - char *start_addr = bitmap_ + offset; + char* start_addr = bitmap_ + offset; uint8_t bit_mask = get_bit_mask(index); *start_addr = (*start_addr) & (~bit_mask); } @@ -59,14 +59,14 @@ class BitMap { uint32_t offset = index >> 3; ASSERT(offset < size_); - char *start_addr = bitmap_ + offset; + char* start_addr = bitmap_ + offset; uint8_t bit_mask = get_bit_mask(index); return (*start_addr & bit_mask); } FORCE_INLINE uint32_t get_size() { return size_; } - FORCE_INLINE char *get_bitmap() { return bitmap_; } // for debug + FORCE_INLINE char* get_bitmap() { return bitmap_; } // for debug private: FORCE_INLINE uint8_t get_bit_mask(uint32_t index) { @@ -74,7 +74,7 @@ class BitMap { } private: - char *bitmap_; + char* bitmap_; uint32_t size_; bool init_as_zero_; }; diff --git a/cpp/src/common/container/blocking_queue.cc b/cpp/src/common/container/blocking_queue.cc index f5123d323..c843cd283 100644 --- a/cpp/src/common/container/blocking_queue.cc +++ b/cpp/src/common/container/blocking_queue.cc @@ -31,7 +31,7 @@ BlockingQueue::~BlockingQueue() { pthread_cond_destroy(&cond_); } -void BlockingQueue::push(void *data) { +void BlockingQueue::push(void* data) { pthread_mutex_lock(&mutex_); queue_.push(data); pthread_mutex_unlock(&mutex_); @@ -42,8 +42,8 @@ void BlockingQueue::push(void *data) { pthread_cond_signal(&cond_); } -void *BlockingQueue::pop() { - void *ret_data = NULL; +void* BlockingQueue::pop() { + void* ret_data = NULL; pthread_mutex_lock(&mutex_); while (queue_.empty()) { pthread_cond_wait(&cond_, &mutex_); diff --git a/cpp/src/common/container/byte_buffer.h b/cpp/src/common/container/byte_buffer.h index becf4a4dd..922013496 100644 --- a/cpp/src/common/container/byte_buffer.h +++ b/cpp/src/common/container/byte_buffer.h @@ -46,7 +46,7 @@ class ByteBuffer { } FORCE_INLINE void init(uint32_t size) { - data_ = static_cast(mem_alloc(size, MOD_TSBLOCK)); + data_ = static_cast(mem_alloc(size, MOD_TSBLOCK)); reserved_size_ = size; } @@ -54,11 +54,11 @@ class ByteBuffer { FORCE_INLINE void extend_memory(uint32_t new_size) { ASSERT(new_size > reserved_size_); - data_ = static_cast(mem_realloc(data_, new_size)); + data_ = static_cast(mem_realloc(data_, new_size)); reserved_size_ = new_size; } - FORCE_INLINE void append_variable_value(const char *value, uint32_t len) { + FORCE_INLINE void append_variable_value(const char* value, uint32_t len) { // dynamic growth if (UNLIKELY((real_data_size_ + len + variable_type_len_) > reserved_size_)) { @@ -72,7 +72,7 @@ class ByteBuffer { ASSERT(data_); // append len - memcpy(&data_[real_data_size_], reinterpret_cast(&len), + memcpy(&data_[real_data_size_], reinterpret_cast(&len), variable_type_len_); real_data_size_ += variable_type_len_; if (len > 0) { @@ -82,7 +82,7 @@ class ByteBuffer { } } - FORCE_INLINE void append_fixed_value(const char *value, uint32_t len) { + FORCE_INLINE void append_fixed_value(const char* value, uint32_t len) { // dynamic growth if (UNLIKELY(real_data_size_ + len > reserved_size_)) { // extreme scenarios, when encountering very long string @@ -99,27 +99,27 @@ class ByteBuffer { } // for fixed len value - FORCE_INLINE char *read(uint32_t offset, uint32_t len) { + FORCE_INLINE char* read(uint32_t offset, uint32_t len) { ASSERT((offset + len) <= real_data_size_); - char *p = &data_[offset]; + char* p = &data_[offset]; return p; } // for variable len value - FORCE_INLINE char *read(uint32_t offset, uint32_t *len) { + FORCE_INLINE char* read(uint32_t offset, uint32_t* len) { uint32_t tmp; // Directly memcpy to avoid potential alignment issues when casting // int32_t array pointer std::memcpy(&tmp, data_ + offset, sizeof(tmp)); *len = tmp; - char *p = &data_[offset + variable_type_len_]; + char* p = &data_[offset + variable_type_len_]; return p; } - FORCE_INLINE char *get_data() { return data_; } + FORCE_INLINE char* get_data() { return data_; } private: - char *data_; + char* data_; uint8_t variable_type_len_; uint32_t real_data_size_; uint32_t reserved_size_; // malloc memory size from system diff --git a/cpp/src/common/container/hash_func.h b/cpp/src/common/container/hash_func.h index 8bac3170c..d415fa9c6 100644 --- a/cpp/src/common/container/hash_func.h +++ b/cpp/src/common/container/hash_func.h @@ -42,9 +42,9 @@ struct StringHashFunc { return h; } - uint32_t operator()(const void *data) { + uint32_t operator()(const void* data) { uint32_t hash_ = (const uint32_t)5381; - const char *str = (const char *)data; + const char* str = (const char*)data; char c; while ((c = *str++)) { hash_ = ((hash_ << 5) + hash_) + c; @@ -64,9 +64,9 @@ struct SliceHashFunc { return h; } - uint32_t operator()(const Slice &slice) { + uint32_t operator()(const Slice& slice) { uint32_t hash_ = (const uint32_t)5381; - const char *str = (const char *)slice.data(); + const char* str = (const char*)slice.data(); char c; while ((c = *str++)) { hash_ = ((hash_ << 5) + hash_) + c; @@ -86,7 +86,7 @@ struct TsIDHashFunc { return h; } - uint32_t operator()(const TsID &data) { + uint32_t operator()(const TsID& data) { int32_t tmp = data.db_nid_ * 10000 + data.device_nid_ * 100 + data.measurement_nid_; return Murmur128Hash::hash(tmp, 0); @@ -97,7 +97,7 @@ struct TsIDHashFunc { * using murmur_hash hash algorithm */ struct NodeIDHashFunc { - uint32_t operator()(const NodeID &data) { + uint32_t operator()(const NodeID& data) { return Murmur128Hash::hash(static_cast(data), 0); } }; diff --git a/cpp/src/common/container/hash_node.h b/cpp/src/common/container/hash_node.h index b51d01137..303300b9c 100644 --- a/cpp/src/common/container/hash_node.h +++ b/cpp/src/common/container/hash_node.h @@ -32,7 +32,7 @@ class HashNode { next_ = nullptr; } - HashNode(const KeyType &key, const ValueType &value) + HashNode(const KeyType& key, const ValueType& value) : key_(key), value_(value), is_valid_(true), @@ -45,13 +45,13 @@ class HashNode { FORCE_INLINE ValueType get_value() const { return value_; } - FORCE_INLINE void set_key(const KeyType &key) { key_ = key; } + FORCE_INLINE void set_key(const KeyType& key) { key_ = key; } - FORCE_INLINE void set_value(const ValueType &value) { value_ = value; } + FORCE_INLINE void set_value(const ValueType& value) { value_ = value; } - FORCE_INLINE HashNode *get_next() const { return next_; } + FORCE_INLINE HashNode* get_next() const { return next_; } - FORCE_INLINE void set_next(HashNode *next) { next_ = next; } + FORCE_INLINE void set_next(HashNode* next) { next_ = next; } FORCE_INLINE bool get_valid() const { return is_valid_; } @@ -66,7 +66,7 @@ class HashNode { uint64_t rehash_; KeyType key_; ValueType value_; - HashNode *next_; // pointer to the next node (same bucket) + HashNode* next_; // pointer to the next node (same bucket) }; } // end namespace common diff --git a/cpp/src/common/container/list.h b/cpp/src/common/container/list.h index ea4f23c37..819dfcb2a 100644 --- a/cpp/src/common/container/list.h +++ b/cpp/src/common/container/list.h @@ -25,7 +25,7 @@ namespace common { -#define INVALID_NODE_PTR ((SimpleListNode *)0xABCDEF) +#define INVALID_NODE_PTR ((SimpleListNode*)0xABCDEF) /* * A very simple list. @@ -45,34 +45,34 @@ class SimpleList { private: struct SimpleListNode { T data_; - SimpleListNode *next_; + SimpleListNode* next_; SimpleListNode() : next_(nullptr) {} - SimpleListNode(const T &data) : data_(data), next_(nullptr) {} + SimpleListNode(const T& data) : data_(data), next_(nullptr) {} }; public: class Iterator { public: - Iterator(SimpleListNode *node) : cur_(node) {} + Iterator(SimpleListNode* node) : cur_(node) {} Iterator() : cur_(INVALID_NODE_PTR) {} - T &get() { return cur_->data_; } + T& get() { return cur_->data_; } FORCE_INLINE bool is_inited() const { return cur_ != INVALID_NODE_PTR; } - FORCE_INLINE Iterator &operator++(int n) { + FORCE_INLINE Iterator& operator++(int n) { if (LIKELY(cur_ != nullptr)) { cur_ = cur_->next_; } return *this; } - FORCE_INLINE bool operator!=(const Iterator &other) const { + FORCE_INLINE bool operator!=(const Iterator& other) const { return this->cur_ != other.cur_; } - FORCE_INLINE bool operator==(const Iterator &other) const { + FORCE_INLINE bool operator==(const Iterator& other) const { return this->cur_ == other.cur_; } private: - SimpleListNode *cur_; + SimpleListNode* cur_; }; public: @@ -82,17 +82,17 @@ class SimpleList { page_arena_ = &own_page_arena_; } - SimpleList(PageArena *page_arena) + SimpleList(PageArena* page_arena) : page_arena_(page_arena), head_(nullptr), tail_(nullptr), size_(0) { // page_arena_ should be destroy outside by caller } - int push_back(const T &data) { - void *buf = page_arena_->alloc(sizeof(SimpleListNode)); + int push_back(const T& data) { + void* buf = page_arena_->alloc(sizeof(SimpleListNode)); if (UNLIKELY(buf == nullptr)) { return common::E_OOM; } - SimpleListNode *node = new (buf) SimpleListNode(data); + SimpleListNode* node = new (buf) SimpleListNode(data); if (head_ == nullptr) { head_ = node; tail_ = node; @@ -105,7 +105,7 @@ class SimpleList { return common::E_OK; } - FORCE_INLINE T &front() { + FORCE_INLINE T& front() { ASSERT(size_ > 0 && head_ != nullptr); return head_->data_; } @@ -114,8 +114,8 @@ class SimpleList { if (head_ == nullptr) { return common::E_NOT_EXIST; } - SimpleListNode *prev = head_; - SimpleListNode *cur = head_->next_; + SimpleListNode* prev = head_; + SimpleListNode* cur = head_->next_; while (cur && cur->data_ != target) { cur = cur->next_; } @@ -140,10 +140,10 @@ class SimpleList { } private: - PageArena *page_arena_; + PageArena* page_arena_; PageArena own_page_arena_; - SimpleListNode *head_; - SimpleListNode *tail_; + SimpleListNode* head_; + SimpleListNode* tail_; uint32_t size_; }; diff --git a/cpp/src/common/container/murmur_hash3.h b/cpp/src/common/container/murmur_hash3.h index 1e2bf44ba..da89ac3ce 100644 --- a/cpp/src/common/container/murmur_hash3.h +++ b/cpp/src/common/container/murmur_hash3.h @@ -33,23 +33,23 @@ namespace common { class Murmur128Hash { public: FORCE_INLINE static int32_t hash(int32_t value, uint32_t seed) { - return inner_hash(reinterpret_cast(&value), 4, seed); + return inner_hash(reinterpret_cast(&value), 4, seed); } FORCE_INLINE static int32_t hash(int64_t value, uint32_t seed) { - return inner_hash(reinterpret_cast(&value), 8, seed); + return inner_hash(reinterpret_cast(&value), 8, seed); } FORCE_INLINE static int32_t hash(double value, uint32_t seed) { - return inner_hash(reinterpret_cast(&value), 8, seed); + return inner_hash(reinterpret_cast(&value), 8, seed); } - FORCE_INLINE static int32_t hash(std::string &value, uint32_t seed) { + FORCE_INLINE static int32_t hash(std::string& value, uint32_t seed) { return inner_hash(value.data(), static_cast(value.size()), seed); } - FORCE_INLINE static int32_t hash(const common::String &buf, int32_t seed) { + FORCE_INLINE static int32_t hash(const common::String& buf, int32_t seed) { return inner_hash(buf.buf_, buf.len_ - 1, seed); } @@ -67,8 +67,8 @@ class Murmur128Hash { uk ^= uk >> 33; return (int64_t)uk; } - static int64_t get_block(const char *buf, int32_t index); - static int64_t inner_hash(const char *buf, int32_t len, int64_t seed); + static int64_t get_block(const char* buf, int32_t index); + static int64_t inner_hash(const char* buf, int32_t len, int64_t seed); }; } // end namespace common diff --git a/cpp/src/common/container/slice.h b/cpp/src/common/container/slice.h index 4f678d782..c9e104038 100644 --- a/cpp/src/common/container/slice.h +++ b/cpp/src/common/container/slice.h @@ -42,9 +42,9 @@ class Slice { // Create a slice that refers to the contents of "s" // Slice(const std::string& s) : data_(s.data()), size_(s.size()) {} - Slice(const std::string &s) { + Slice(const std::string& s) { int len = s.size(); - data_ = (char *)malloc(len + 1); // TODO: user ourself's mem_alloc() + data_ = (char*)malloc(len + 1); // TODO: user ourself's mem_alloc() if (UNLIKELY(nullptr == data_)) { // log_err("malloc() failed."); } @@ -54,9 +54,9 @@ class Slice { // Create a slice that refers to s[0,strlen(s)-1] // Slice(const char* s) : data_(s), size_(strlen(s)) {} - Slice(const char *s) { + Slice(const char* s) { int len = strlen(s); - data_ = (char *)malloc(len + 1); // TODO: user ourself's mem_alloc() + data_ = (char*)malloc(len + 1); // TODO: user ourself's mem_alloc() if (UNLIKELY(nullptr == data_)) { // log_err("malloc() failed."); } @@ -73,23 +73,23 @@ class Slice { // Intentionally copyable. // Slice(const Slice&) = default; // Slice& operator=(const Slice&) = default; - Slice(const Slice &other) { + Slice(const Slice& other) { int len = other.size_; - data_ = (char *)malloc(len + 1); // TODO: user ourself's mem_alloc() + data_ = (char*)malloc(len + 1); // TODO: user ourself's mem_alloc() if (UNLIKELY(nullptr == data_)) { // log_err("malloc() failed."); } strcpy(data_, other.data_); size_ = len; } - Slice &operator=(const Slice &other) { + Slice& operator=(const Slice& other) { if (this->data_ != nullptr) { free(data_); // TODO: user ourself's mem_free() data_ = nullptr; } int len = other.size_; this->data_ = - (char *)malloc(len + 1); // TODO: user ourself's mem_alloc() + (char*)malloc(len + 1); // TODO: user ourself's mem_alloc() if (UNLIKELY(nullptr == data_)) { // log_err("malloc() failed."); } @@ -99,7 +99,7 @@ class Slice { } // Return a pointer to the beginning of the referenced data - char *data() const { return data_; } + char* data() const { return data_; } // Return the length (in bytes) of the referenced data size_t size() const { return size_; } @@ -116,18 +116,18 @@ class Slice { // Return a string that contains the copy of the referenced data. std::string to_string() const { return std::string(data_, size_); } - friend bool operator==(const Slice &x, const Slice &y) { + friend bool operator==(const Slice& x, const Slice& y) { return ((x.size() == y.size()) && (memcmp(x.data(), y.data(), x.size()) == 0)); } - friend bool operator!=(const Slice &x, const Slice &y) { return !(x == y); } + friend bool operator!=(const Slice& x, const Slice& y) { return !(x == y); } // Three-way comparison. Returns value: // < 0 iff "*this" < "b", // == 0 iff "*this" == "b", // > 0 iff "*this" > "b" - int compare(const Slice &b) const { + int compare(const Slice& b) const { const size_t min_len = (size_ < b.size_) ? size_ : b.size_; int r = memcmp(data_, b.data_, min_len); if (r == 0) { @@ -140,7 +140,7 @@ class Slice { } private: - char *data_; + char* data_; size_t size_; }; diff --git a/cpp/src/common/container/sorted_array.h b/cpp/src/common/container/sorted_array.h index 0ee3dc2cc..0713449dd 100644 --- a/cpp/src/common/container/sorted_array.h +++ b/cpp/src/common/container/sorted_array.h @@ -44,8 +44,8 @@ template class SortedArray { public: #ifndef NDEBUG - friend std::ostream &operator<<(std::ostream &out, - SortedArray &sa) { + friend std::ostream& operator<<(std::ostream& out, + SortedArray& sa) { for (size_t idx = 0; idx < sa.size(); idx++) { if (idx > 0) { out << ' '; @@ -96,7 +96,7 @@ class SortedArray { ASSERT(!is_inited_); } array_ = - (ValueType *)mem_alloc(capacity_ * sizeof(*(array_)), MOD_ARRAY); + (ValueType*)mem_alloc(capacity_ * sizeof(*(array_)), MOD_ARRAY); if (UNLIKELY(nullptr == array_)) { is_inited_ = false; // log_err("malloc failed."); @@ -140,7 +140,7 @@ class SortedArray { size_t new_capacity = (size_t)tmp; array_ = - (ValueType *)mem_realloc(array_, new_capacity * sizeof(*(array_))); + (ValueType*)mem_realloc(array_, new_capacity * sizeof(*(array_))); if (UNLIKELY(nullptr == array_)) { // log_err("realloc failed."); return E_OOM; @@ -153,7 +153,7 @@ class SortedArray { size_t new_capacity = (size_t)(capacity_ / 2); // if the size passed to realloc is smaller than before, OS will // automatically release the rest memory - array_ = (ValueType *)mem_realloc( + array_ = (ValueType*)mem_realloc( array_, new_capacity * sizeof(*(array_))); // TODO: user ourself's mem_alloc() @@ -166,7 +166,7 @@ class SortedArray { } public: - int insert(const ValueType &value) { + int insert(const ValueType& value) { if (size_ >= capacity_) { int ret = extend(); if (ret != E_OK) { @@ -214,7 +214,7 @@ class SortedArray { return array_[idx]; } - bool contain(const ValueType &target_val) { + bool contain(const ValueType& target_val) { if (size_ == 0) { return false; } @@ -238,7 +238,7 @@ class SortedArray { * if the value is not found, then set 'found' is false ant return the first * bigger one's location */ - size_t find(const ValueType &target_val, bool &found) { + size_t find(const ValueType& target_val, bool& found) { if (size_ == 0) { found = false; return 0; @@ -279,7 +279,7 @@ class SortedArray { return ret; } - int remove_value(const ValueType &value) { + int remove_value(const ValueType& value) { bool found = false; size_t pos = find(value, found); if (found) { @@ -302,7 +302,7 @@ class SortedArray { return array_[0]; } - ValueType &get_max() { + ValueType& get_max() { if (size_ == 0) { // log_warn("The array is empty now."); ASSERT(size_ > 0); @@ -320,7 +320,7 @@ class SortedArray { private: size_t capacity_; size_t size_; - ValueType *array_; + ValueType* array_; ValueType dummy_; bool is_inited_; }; diff --git a/cpp/src/common/datatype/value.h b/cpp/src/common/datatype/value.h index 8fb77a1e6..310f561ba 100644 --- a/cpp/src/common/datatype/value.h +++ b/cpp/src/common/datatype/value.h @@ -85,30 +85,30 @@ struct Value { type_ = type; switch (type) { case common::BOOLEAN: { - value_.bval_ = *(bool *)val; + value_.bval_ = *(bool*)val; break; } case common::DATE: case common::INT32: { - value_.ival_ = *(int32_t *)val; + value_.ival_ = *(int32_t*)val; break; } case common::INT64: { - value_.lval_ = *(int64_t *)val; + value_.lval_ = *(int64_t*)val; break; } case common::FLOAT: { - value_.fval_ = *(float *)val; + value_.fval_ = *(float*)val; break; } case common::DOUBLE: { - value_.dval_ = *(double *)val; + value_.dval_ = *(double*)val; break; } case common::BLOB: case common::STRING: case common::TEXT: { - value_.sval_ = strdup((const char *)val); + value_.sval_ = strdup((const char*)val); break; } default: { @@ -126,45 +126,45 @@ struct Value { int32_t ival_; float fval_; double dval_; - char *sval_; + char* sval_; } value_; }; -FORCE_INLINE Value *make(TSDataType type) { - Value *value = new Value(type); +FORCE_INLINE Value* make(TSDataType type) { + Value* value = new Value(type); return value; } -FORCE_INLINE Value *make_literal(int64_t val) { - Value *value = new Value(INT64); +FORCE_INLINE Value* make_literal(int64_t val) { + Value* value = new Value(INT64); value->value_.lval_ = val; return value; } -FORCE_INLINE Value *make_literal(double val) { - Value *value = new Value(DOUBLE); +FORCE_INLINE Value* make_literal(double val) { + Value* value = new Value(DOUBLE); value->value_.dval_ = val; return value; } -FORCE_INLINE Value *make_literal(char *string) { - Value *value = new Value(TEXT); +FORCE_INLINE Value* make_literal(char* string) { + Value* value = new Value(TEXT); value->value_.sval_ = strdup(string); return value; } -FORCE_INLINE Value *make_literal(bool val) { - Value *value = new Value(BOOLEAN); +FORCE_INLINE Value* make_literal(bool val) { + Value* value = new Value(BOOLEAN); value->value_.bval_ = val; return value; } -FORCE_INLINE Value *make_null_literal() { - Value *value = new Value(NULL_TYPE); +FORCE_INLINE Value* make_null_literal() { + Value* value = new Value(NULL_TYPE); return value; } -FORCE_INLINE std::string value_to_string(Value *value) { +FORCE_INLINE std::string value_to_string(Value* value) { if (value->type_ == common::TEXT) { return std::string(value->value_.sval_); } else { @@ -194,19 +194,19 @@ FORCE_INLINE std::string value_to_string(Value *value) { // return true if cast succ. template -FORCE_INLINE int get_typed_data_from_value(Value *value, T &ret_data) { +FORCE_INLINE int get_typed_data_from_value(Value* value, T& ret_data) { return E_OK; } template <> -FORCE_INLINE int get_typed_data_from_value(Value *value, bool &ret_data) { +FORCE_INLINE int get_typed_data_from_value(Value* value, bool& ret_data) { ret_data = value->value_.bval_; return (value->type_ == BOOLEAN) ? E_OK : E_TYPE_NOT_MATCH; } template <> -FORCE_INLINE int get_typed_data_from_value(Value *value, - int32_t &ret_data) { +FORCE_INLINE int get_typed_data_from_value(Value* value, + int32_t& ret_data) { if (value->value_.lval_ > INT32_MAX || value->value_.lval_ < INT32_MIN) { return E_OVERFLOW; } @@ -216,15 +216,15 @@ FORCE_INLINE int get_typed_data_from_value(Value *value, } template <> -FORCE_INLINE int get_typed_data_from_value(Value *value, - int64_t &ret_data) { +FORCE_INLINE int get_typed_data_from_value(Value* value, + int64_t& ret_data) { ret_data = value->value_.lval_; return (value->type_ == INT64) ? E_OK : E_TYPE_NOT_MATCH; } template <> -FORCE_INLINE int get_typed_data_from_value(Value *value, - float &ret_data) { +FORCE_INLINE int get_typed_data_from_value(Value* value, + float& ret_data) { if (value->value_.dval_ > FLT_MAX || value->value_.dval_ < FLT_MIN) { return E_OVERFLOW; } @@ -233,8 +233,8 @@ FORCE_INLINE int get_typed_data_from_value(Value *value, } template <> -FORCE_INLINE int get_typed_data_from_value(Value *value, - double &ret_data) { +FORCE_INLINE int get_typed_data_from_value(Value* value, + double& ret_data) { ret_data = value->value_.dval_; return (value->type_ == DOUBLE) ? E_OK : E_TYPE_NOT_MATCH; } diff --git a/cpp/src/common/global.h b/cpp/src/common/global.h index 564f30c66..7937e9203 100644 --- a/cpp/src/common/global.h +++ b/cpp/src/common/global.h @@ -164,9 +164,9 @@ FORCE_INLINE uint8_t get_global_compression() { } extern int init_common(); -extern bool is_timestamp_column_name(const char *time_col_name); -extern void cols_to_json(ByteStream *byte_stream, - std::vector &ret_ts_list); +extern bool is_timestamp_column_name(const char* time_col_name); +extern void cols_to_json(ByteStream* byte_stream, + std::vector& ret_ts_list); extern void print_backtrace(); } // namespace common diff --git a/cpp/src/common/mutex/mutex.h b/cpp/src/common/mutex/mutex.h index 8409e1596..726288cd9 100644 --- a/cpp/src/common/mutex/mutex.h +++ b/cpp/src/common/mutex/mutex.h @@ -64,11 +64,11 @@ class Mutex { class MutexGuard { public: - MutexGuard(Mutex &m) : m_(m) { m_.lock(); } + MutexGuard(Mutex& m) : m_(m) { m_.lock(); } ~MutexGuard() { m_.unlock(); } private: - Mutex &m_; + Mutex& m_; }; } // end namespace common diff --git a/cpp/src/common/path.h b/cpp/src/common/path.h index a780b4436..55abf810d 100644 --- a/cpp/src/common/path.h +++ b/cpp/src/common/path.h @@ -37,13 +37,13 @@ struct Path { Path() {} - Path(std::string &device, std::string &measurement) + Path(std::string& device, std::string& measurement) : measurement_(measurement), device_id_(std::make_shared(device)) { full_path_ = device + "." + measurement; } - Path(const std::string &path_sc, bool if_split = true) { + Path(const std::string& path_sc, bool if_split = true) { if (!path_sc.empty()) { if (!if_split) { full_path_ = path_sc; @@ -76,7 +76,7 @@ struct Path { } } - bool operator==(const Path &path) { + bool operator==(const Path& path) { if (measurement_.compare(path.measurement_) == 0 && device_id_->get_device_name().compare( path.device_id_->get_device_name()) == 0) { diff --git a/cpp/src/common/record.h b/cpp/src/common/record.h index a8449c658..4b66cae7a 100644 --- a/cpp/src/common/record.h +++ b/cpp/src/common/record.h @@ -35,7 +35,7 @@ namespace storage { // TODO use common/allocator/my_string.h struct TextType { - char *buf_; + char* buf_; int32_t len_; TextType() : buf_(nullptr), len_(0) {} @@ -56,38 +56,38 @@ struct DataPoint { } u_; common::String text_val_; - DataPoint(const std::string &measurement_name, bool b) + DataPoint(const std::string& measurement_name, bool b) : measurement_name_(measurement_name), text_val_() { u_.bool_val_ = b; } - DataPoint(const std::string &measurement_name, int32_t i32) + DataPoint(const std::string& measurement_name, int32_t i32) : measurement_name_(measurement_name), text_val_() { u_.i32_val_ = i32; } - DataPoint(const std::string &measurement_name, int64_t i64) + DataPoint(const std::string& measurement_name, int64_t i64) : measurement_name_(measurement_name), text_val_() { u_.i64_val_ = i64; } - DataPoint(const std::string &measurement_name, float f) + DataPoint(const std::string& measurement_name, float f) : measurement_name_(measurement_name), text_val_() { u_.float_val_ = f; } - DataPoint(const std::string &measurement_name, double d) + DataPoint(const std::string& measurement_name, double d) : measurement_name_(measurement_name), text_val_() { u_.double_val_ = d; } - DataPoint(const std::string &measurement_name, common::String str) + DataPoint(const std::string& measurement_name, common::String str) : measurement_name_(measurement_name), text_val_() { text_val_.buf_ = str.buf_; text_val_.len_ = str.len_; } - DataPoint(const std::string &measurement_name) + DataPoint(const std::string& measurement_name) : isnull(true), measurement_name_(measurement_name) {} void set_i32(int32_t i32) { u_.i32_val_ = i32; @@ -113,16 +113,16 @@ struct TsRecord { std::vector points_; common::PageArena pa; - TsRecord(const std::string &device_name) : device_id_(device_name) { + TsRecord(const std::string& device_name) : device_id_(device_name) { pa.init(512, common::MOD_TSFILE_READER); } - TsRecord(const std::string &device_name, const int64_t ×tamp) + TsRecord(const std::string& device_name, const int64_t& timestamp) : timestamp_(timestamp), device_id_(device_name) { pa.init(512, common::MOD_TSFILE_READER); } - TsRecord(int64_t timestamp, const std::string &device_name, + TsRecord(int64_t timestamp, const std::string& device_name, int32_t point_count_in_row = 0) : timestamp_(timestamp), device_id_(device_name), points_() { if (point_count_in_row > 0) { @@ -131,7 +131,7 @@ struct TsRecord { } template - int add_point(const std::string &measurement_name, T val) { + int add_point(const std::string& measurement_name, T val) { int ret = common::E_OK; points_.emplace_back(DataPoint(measurement_name, val)); return ret; @@ -139,7 +139,7 @@ struct TsRecord { }; template <> -inline int TsRecord::add_point(const std::string &measurement_name, +inline int TsRecord::add_point(const std::string& measurement_name, common::String val) { int ret = common::E_OK; points_.emplace_back(DataPoint(measurement_name, val)); @@ -147,7 +147,7 @@ inline int TsRecord::add_point(const std::string &measurement_name, } template <> -inline int TsRecord::add_point(const std::string &measurement_name, +inline int TsRecord::add_point(const std::string& measurement_name, std::tm val) { int ret = common::E_OK; int data_int; diff --git a/cpp/src/common/row_record.h b/cpp/src/common/row_record.h index 713cabc83..d6da63efd 100644 --- a/cpp/src/common/row_record.h +++ b/cpp/src/common/row_record.h @@ -53,8 +53,8 @@ struct Field { is_type(common::NULL_TYPE); } - void set_value(common::TSDataType type, void *val, size_t len, - common::PageArena &pa) { + void set_value(common::TSDataType type, void* val, size_t len, + common::PageArena& pa) { if (val == nullptr) { type_ = common::NULL_TYPE; return; @@ -62,25 +62,25 @@ struct Field { type_ = type; switch (type) { case common::BOOLEAN: { - value_.bval_ = *(bool *)val; + value_.bval_ = *(bool*)val; break; } case common::DATE: case common::INT32: { - value_.ival_ = *(int32_t *)val; + value_.ival_ = *(int32_t*)val; break; } case common::TIMESTAMP: case common::INT64: { - value_.lval_ = *(int64_t *)val; + value_.lval_ = *(int64_t*)val; break; } case common::FLOAT: { - value_.fval_ = *(float *)val; + value_.fval_ = *(float*)val; break; } case common::DOUBLE: { - value_.dval_ = *(double *)val; + value_.dval_ = *(double*)val; break; } case common::TEXT: @@ -88,7 +88,7 @@ struct Field { case common::STRING: { value_.strval_ = new common::String(); value_.strval_->dup_from( - std::string(static_cast(val), len), pa); + std::string(static_cast(val), len), pa); break; } default: { @@ -129,7 +129,7 @@ struct Field { return date_value; } - FORCE_INLINE common::String *get_string_value() { + FORCE_INLINE common::String* get_string_value() { if (type_ == common::STRING || type_ == common::TEXT || type_ == common::BLOB) { return value_.strval_; @@ -147,61 +147,61 @@ struct Field { int32_t ival_; float fval_; double dval_; - common::String *strval_; - char *sval_; + common::String* strval_; + char* sval_; } value_; }; -FORCE_INLINE Field *make(common::TSDataType type) { - Field *value = new Field(type); +FORCE_INLINE Field* make(common::TSDataType type) { + Field* value = new Field(type); return value; } -FORCE_INLINE Field *make_literal(int64_t val) { - Field *value = new Field(common::INT64); +FORCE_INLINE Field* make_literal(int64_t val) { + Field* value = new Field(common::INT64); value->value_.lval_ = val; return value; } -FORCE_INLINE Field *make_literal(double val) { - Field *value = new Field(common::DOUBLE); +FORCE_INLINE Field* make_literal(double val) { + Field* value = new Field(common::DOUBLE); value->value_.dval_ = val; return value; } -FORCE_INLINE Field *make_literal(char *string) { - Field *value = new Field(common::TEXT); +FORCE_INLINE Field* make_literal(char* string) { + Field* value = new Field(common::TEXT); value->value_.sval_ = string; return value; } -FORCE_INLINE Field *make_literal(bool val) { - Field *value = new Field(common::BOOLEAN); +FORCE_INLINE Field* make_literal(bool val) { + Field* value = new Field(common::BOOLEAN); value->value_.bval_ = val; return value; } -FORCE_INLINE Field *make_null_literal() { - Field *value = new Field(common::NULL_TYPE); +FORCE_INLINE Field* make_null_literal() { + Field* value = new Field(common::NULL_TYPE); return value; } class RowRecord { public: explicit RowRecord(uint32_t col_num) : col_num_(col_num) { - fields_ = new std::vector(); + fields_ = new std::vector(); fields_->reserve(col_num); for (uint32_t i = 0; i < col_num; ++i) { - Field *val = make_null_literal(); + Field* val = make_null_literal(); fields_->push_back(val); } } RowRecord(int64_t time, uint32_t col_num) : time_(time), col_num_(col_num) { - fields_ = new std::vector(); + fields_ = new std::vector(); fields_->reserve(col_num_); for (uint32_t i = 0; i < col_num_; ++i) { - Field *val = make_null_literal(); + Field* val = make_null_literal(); fields_->push_back(val); } } @@ -227,22 +227,22 @@ class RowRecord { } } - FORCE_INLINE void add_field(Field *field) { fields_->push_back(field); } + FORCE_INLINE void add_field(Field* field) { fields_->push_back(field); } FORCE_INLINE void set_timestamp(int64_t time) { time_ = time; } FORCE_INLINE int64_t get_timestamp() { return time_; } - FORCE_INLINE Field *get_field(uint32_t index) { return (*fields_)[index]; } + FORCE_INLINE Field* get_field(uint32_t index) { return (*fields_)[index]; } - FORCE_INLINE std::vector *get_fields() { return fields_; } + FORCE_INLINE std::vector* get_fields() { return fields_; } FORCE_INLINE uint32_t get_col_num() { return col_num_; } private: - int64_t time_; // time value - uint32_t col_num_; // measurement num - std::vector *fields_; // measurement value + int64_t time_; // time value + uint32_t col_num_; // measurement num + std::vector* fields_; // measurement value }; } // namespace storage diff --git a/cpp/src/common/seq_tvlist.h b/cpp/src/common/seq_tvlist.h index 57f637601..24805ac5d 100644 --- a/cpp/src/common/seq_tvlist.h +++ b/cpp/src/common/seq_tvlist.h @@ -78,19 +78,19 @@ class SeqTVList : public SeqTVListBase { } TV; struct Iterator { - SeqTVList *host_list_; + SeqTVList* host_list_; int32_t read_idx_; int32_t end_idx_; Iterator() : host_list_(nullptr), read_idx_(UINT32_MAX), end_idx_(0) {} - INLINE void init(SeqTVList *host, int32_t start_idx, int32_t end_idx) { + INLINE void init(SeqTVList* host, int32_t start_idx, int32_t end_idx) { host_list_ = host; read_idx_ = start_idx; end_idx_ = end_idx; } - int next(TV &tv) { + int next(TV& tv) { if (read_idx_ >= end_idx_) { return common::E_NO_MORE_DATA; } @@ -147,7 +147,7 @@ class SeqTVList : public SeqTVListBase { #endif private: - FORCE_INLINE void *alloc(uint32_t size) { + FORCE_INLINE void* alloc(uint32_t size) { if (use_page_arena_) { return page_arena_.alloc(size); } else { @@ -161,7 +161,7 @@ class SeqTVList : public SeqTVListBase { int32_t binary_search_lower(int64_t time); private: - TV **tv_array_list_; + TV** tv_array_list_; int64_t last_time_; }; diff --git a/cpp/src/common/statistic.h b/cpp/src/common/statistic.h index d4d31b965..f6d53c206 100644 --- a/cpp/src/common/statistic.h +++ b/cpp/src/common/statistic.h @@ -176,7 +176,7 @@ class Statistic { } virtual FORCE_INLINE void update(int64_t time) { ASSERT(false); } - virtual int serialize_to(common::ByteStream &out) { + virtual int serialize_to(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_var_uint(count_, out))) { } else if (RET_FAIL(common::SerializationUtil::write_ui64(start_time_, @@ -187,7 +187,7 @@ class Statistic { } return ret; } - virtual int serialize_typed_stat(common::ByteStream &out) { + virtual int serialize_typed_stat(common::ByteStream& out) { ASSERT(false); return 0; } @@ -196,27 +196,27 @@ class Statistic { int64_t get_end_time() const { return end_time_; } - virtual int deserialize_from(common::ByteStream &in) { + virtual int deserialize_from(common::ByteStream& in) { int ret = common::E_OK; - if (RET_FAIL(common::SerializationUtil::read_var_uint( - (uint32_t &)count_, in))) { + if (RET_FAIL(common::SerializationUtil::read_var_uint((uint32_t&)count_, + in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)start_time_, in))) { + (uint64_t&)start_time_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)end_time_, in))) { + (uint64_t&)end_time_, in))) { } else if (RET_FAIL(deserialize_typed_stat(in))) { } return ret; } - virtual int deserialize_typed_stat(common::ByteStream &in) { + virtual int deserialize_typed_stat(common::ByteStream& in) { ASSERT(false); return 0; } - virtual int merge_with(Statistic *that) { + virtual int merge_with(Statistic* that) { ASSERT(false); return 0; } - virtual int deep_copy_from(Statistic *stat) { + virtual int deep_copy_from(Statistic* stat) { ASSERT(false); return 0; } @@ -234,38 +234,38 @@ class Statistic { int64_t end_time_; }; -#define MERGE_BOOL_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - if (UNLIKELY(typed_stat->count_ == 0)) { \ - return common::E_OK; \ - } \ - if (count_ == 0) { \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - sum_value_ = typed_stat->sum_value_; \ - first_value_ = typed_stat->first_value_; \ - last_value_ = typed_stat->last_value_; \ - } else { \ - count_ += typed_stat->count_; \ - if (typed_stat->start_time_ < start_time_) { \ - start_time_ = typed_stat->start_time_; \ - first_value_ = typed_stat->first_value_; \ - } \ - if (typed_stat->end_time_ > end_time_) { \ - end_time_ = typed_stat->end_time_; \ - last_value_ = typed_stat->last_value_; \ - } \ - sum_value_ += typed_stat->sum_value_; \ - } \ - return common::E_OK; \ +#define MERGE_BOOL_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + if (UNLIKELY(typed_stat->count_ == 0)) { \ + return common::E_OK; \ + } \ + if (count_ == 0) { \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + sum_value_ = typed_stat->sum_value_; \ + first_value_ = typed_stat->first_value_; \ + last_value_ = typed_stat->last_value_; \ + } else { \ + count_ += typed_stat->count_; \ + if (typed_stat->start_time_ < start_time_) { \ + start_time_ = typed_stat->start_time_; \ + first_value_ = typed_stat->first_value_; \ + } \ + if (typed_stat->end_time_ > end_time_) { \ + end_time_ = typed_stat->end_time_; \ + last_value_ = typed_stat->last_value_; \ + } \ + sum_value_ += typed_stat->sum_value_; \ + } \ + return common::E_OK; \ } while (false) #define MERGE_NUM_STAT_FROM(StatType, untyped_stat) \ @@ -273,7 +273,7 @@ class Statistic { if (UNLIKELY(untyped_stat == nullptr)) { \ return common::E_INVALID_ARG; \ } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ + StatType* typed_stat = (StatType*)(untyped_stat); \ if (UNLIKELY(typed_stat == nullptr)) { \ return common::E_TYPE_NOT_MATCH; \ } \ @@ -311,7 +311,7 @@ class Statistic { if (UNLIKELY(untyped_stat == nullptr)) { \ return common::E_INVALID_ARG; \ } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ + StatType* typed_stat = (StatType*)(untyped_stat); \ if (UNLIKELY(typed_stat == nullptr)) { \ return common::E_TYPE_NOT_MATCH; \ } \ @@ -347,7 +347,7 @@ class Statistic { if (UNLIKELY(untyped_stat == nullptr)) { \ return common::E_INVALID_ARG; \ } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ + StatType* typed_stat = (StatType*)(untyped_stat); \ if (UNLIKELY(typed_stat == nullptr)) { \ return common::E_TYPE_NOT_MATCH; \ } \ @@ -374,98 +374,98 @@ class Statistic { return common::E_OK; \ } while (false) -#define MERGE_BLOB_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - if (UNLIKELY(typed_stat->count_ == 0)) { \ - return common::E_OK; \ - } \ - if (count_ == 0) { \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - } else { \ - count_ += typed_stat->count_; \ - if (typed_stat->start_time_ < start_time_) { \ - start_time_ = typed_stat->start_time_; \ - } \ - if (typed_stat->end_time_ > end_time_) { \ - end_time_ = typed_stat->end_time_; \ - } \ - } \ - return common::E_OK; \ +#define MERGE_BLOB_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + if (UNLIKELY(typed_stat->count_ == 0)) { \ + return common::E_OK; \ + } \ + if (count_ == 0) { \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + } else { \ + count_ += typed_stat->count_; \ + if (typed_stat->start_time_ < start_time_) { \ + start_time_ = typed_stat->start_time_; \ + } \ + if (typed_stat->end_time_ > end_time_) { \ + end_time_ = typed_stat->end_time_; \ + } \ + } \ + return common::E_OK; \ } while (false) -#define MERGE_TIME_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - if (UNLIKELY(typed_stat->count_ == 0)) { \ - return common::E_OK; \ - } \ - if (count_ == 0) { \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - } else { \ - count_ += typed_stat->count_; \ - if (typed_stat->start_time_ < start_time_) { \ - start_time_ = typed_stat->start_time_; \ - } \ - if (typed_stat->end_time_ > end_time_) { \ - end_time_ = typed_stat->end_time_; \ - } \ - } \ - return common::E_OK; \ +#define MERGE_TIME_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + if (UNLIKELY(typed_stat->count_ == 0)) { \ + return common::E_OK; \ + } \ + if (count_ == 0) { \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + } else { \ + count_ += typed_stat->count_; \ + if (typed_stat->start_time_ < start_time_) { \ + start_time_ = typed_stat->start_time_; \ + } \ + if (typed_stat->end_time_ > end_time_) { \ + end_time_ = typed_stat->end_time_; \ + } \ + } \ + return common::E_OK; \ } while (false) -#define DEEP_COPY_BOOL_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - sum_value_ = typed_stat->sum_value_; \ - first_value_ = typed_stat->first_value_; \ - last_value_ = typed_stat->last_value_; \ - return common::E_OK; \ +#define DEEP_COPY_BOOL_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + sum_value_ = typed_stat->sum_value_; \ + first_value_ = typed_stat->first_value_; \ + last_value_ = typed_stat->last_value_; \ + return common::E_OK; \ } while (false) -#define DEEP_COPY_NUM_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - sum_value_ = typed_stat->sum_value_; \ - first_value_ = typed_stat->first_value_; \ - last_value_ = typed_stat->last_value_; \ - min_value_ = typed_stat->min_value_; \ - max_value_ = typed_stat->max_value_; \ - return common::E_OK; \ +#define DEEP_COPY_NUM_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + sum_value_ = typed_stat->sum_value_; \ + first_value_ = typed_stat->first_value_; \ + last_value_ = typed_stat->last_value_; \ + min_value_ = typed_stat->min_value_; \ + max_value_ = typed_stat->max_value_; \ + return common::E_OK; \ } while (false) #define DEEP_COPY_STRING_STAT_FROM(StatType, untyped_stat) \ @@ -473,7 +473,7 @@ class Statistic { if (UNLIKELY(untyped_stat == nullptr)) { \ return common::E_INVALID_ARG; \ } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ + StatType* typed_stat = (StatType*)(untyped_stat); \ if (UNLIKELY(typed_stat == nullptr)) { \ return common::E_TYPE_NOT_MATCH; \ } \ @@ -492,7 +492,7 @@ class Statistic { if (UNLIKELY(untyped_stat == nullptr)) { \ return common::E_INVALID_ARG; \ } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ + StatType* typed_stat = (StatType*)(untyped_stat); \ if (UNLIKELY(typed_stat == nullptr)) { \ return common::E_TYPE_NOT_MATCH; \ } \ @@ -504,34 +504,34 @@ class Statistic { return common::E_OK; \ } while (false) -#define DEEP_COPY_BLOB_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - return common::E_OK; \ +#define DEEP_COPY_BLOB_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + return common::E_OK; \ } while (false) -#define DEEP_COPY_TIME_STAT_FROM(StatType, untyped_stat) \ - do { \ - if (UNLIKELY(untyped_stat == nullptr)) { \ - return common::E_INVALID_ARG; \ - } \ - StatType *typed_stat = (StatType *)(untyped_stat); \ - if (UNLIKELY(typed_stat == nullptr)) { \ - return common::E_TYPE_NOT_MATCH; \ - } \ - count_ = typed_stat->count_; \ - start_time_ = typed_stat->start_time_; \ - end_time_ = typed_stat->end_time_; \ - return common::E_OK; \ +#define DEEP_COPY_TIME_STAT_FROM(StatType, untyped_stat) \ + do { \ + if (UNLIKELY(untyped_stat == nullptr)) { \ + return common::E_INVALID_ARG; \ + } \ + StatType* typed_stat = (StatType*)(untyped_stat); \ + if (UNLIKELY(typed_stat == nullptr)) { \ + return common::E_TYPE_NOT_MATCH; \ + } \ + count_ = typed_stat->count_; \ + start_time_ = typed_stat->start_time_; \ + end_time_ = typed_stat->end_time_; \ + return common::E_OK; \ } while (false) /* ================ Typed Statistics ================*/ @@ -544,7 +544,7 @@ class BooleanStatistic : public Statistic { BooleanStatistic() : sum_value_(0), first_value_(false), last_value_(false) {} - void clone_from(const BooleanStatistic &that) { + void clone_from(const BooleanStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -564,7 +564,7 @@ class BooleanStatistic : public Statistic { FORCE_INLINE void update(int64_t time, bool value) { BOOL_STAT_UPDATE(time, value); } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_ui8(first_value_ ? 1 : 0, out))) { @@ -575,25 +575,25 @@ class BooleanStatistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; - if (RET_FAIL(common::SerializationUtil::read_ui8( - (uint8_t &)first_value_, in))) { + if (RET_FAIL(common::SerializationUtil::read_ui8((uint8_t&)first_value_, + in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui8( - (uint8_t &)last_value_, in))) { + (uint8_t&)last_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)sum_value_, in))) { + (uint64_t&)sum_value_, in))) { } return ret; } FORCE_INLINE common::TSDataType get_type() { return common::BOOLEAN; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_BOOL_STAT_FROM(BooleanStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_BOOL_STAT_FROM(BooleanStatistic, stat); } }; @@ -613,7 +613,7 @@ class Int32Statistic : public Statistic { first_value_(0), last_value_(0) {} - void clone_from(const Int32Statistic &that) { + void clone_from(const Int32Statistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -640,7 +640,7 @@ class Int32Statistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::INT32; } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_ui32(min_value_, out))) { } else if (RET_FAIL(common::SerializationUtil::write_ui32(max_value_, @@ -654,18 +654,18 @@ class Int32Statistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; - if (RET_FAIL(common::SerializationUtil::read_ui32( - (uint32_t &)min_value_, in))) { + if (RET_FAIL(common::SerializationUtil::read_ui32((uint32_t&)min_value_, + in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui32( - (uint32_t &)max_value_, in))) { + (uint32_t&)max_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui32( - (uint32_t &)first_value_, in))) { + (uint32_t&)first_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui32( - (uint32_t &)last_value_, in))) { + (uint32_t&)last_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)sum_value_, in))) { + (uint64_t&)sum_value_, in))) { } // std::cout << "deserialize_typed_stat. ret=" << ret // << ", min_value_= " << min_value_ @@ -676,11 +676,11 @@ class Int32Statistic : public Statistic { // << std::endl; return ret; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_NUM_STAT_FROM(Int32Statistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_NUM_STAT_FROM(Int32Statistic, stat); } @@ -714,7 +714,7 @@ class Int64Statistic : public Statistic { first_value_(0), last_value_(0) {} - void clone_from(const Int64Statistic &that) { + void clone_from(const Int64Statistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -740,7 +740,7 @@ class Int64Statistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::INT64; } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_ui64(min_value_, out))) { } else if (RET_FAIL(common::SerializationUtil::write_ui64(max_value_, @@ -754,26 +754,26 @@ class Int64Statistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; - if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)min_value_, in))) { + if (RET_FAIL(common::SerializationUtil::read_ui64((uint64_t&)min_value_, + in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)max_value_, in))) { + (uint64_t&)max_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)first_value_, in))) { + (uint64_t&)first_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_ui64( - (uint64_t &)last_value_, in))) { + (uint64_t&)last_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_double(sum_value_, in))) { } return ret; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_NUM_STAT_FROM(Int64Statistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_NUM_STAT_FROM(Int64Statistic, stat); } @@ -803,7 +803,7 @@ class FloatStatistic : public Statistic { first_value_(0), last_value_(0) {} - void clone_from(const FloatStatistic &that) { + void clone_from(const FloatStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -829,7 +829,7 @@ class FloatStatistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::FLOAT; } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_float(min_value_, out))) { } else if (RET_FAIL(common::SerializationUtil::write_float(max_value_, @@ -843,7 +843,7 @@ class FloatStatistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::read_float(min_value_, in))) { } else if (RET_FAIL( @@ -857,10 +857,10 @@ class FloatStatistic : public Statistic { } return ret; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_NUM_STAT_FROM(FloatStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_NUM_STAT_FROM(FloatStatistic, stat); } }; @@ -880,7 +880,7 @@ class DoubleStatistic : public Statistic { first_value_(0), last_value_(0) {} - void clone_from(const DoubleStatistic &that) { + void clone_from(const DoubleStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -906,7 +906,7 @@ class DoubleStatistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::DOUBLE; } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL( common::SerializationUtil::write_double(min_value_, out))) { @@ -921,7 +921,7 @@ class DoubleStatistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::read_double(min_value_, in))) { } else if (RET_FAIL(common::SerializationUtil::read_double(max_value_, @@ -935,10 +935,10 @@ class DoubleStatistic : public Statistic { } return ret; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_NUM_STAT_FROM(DoubleStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_NUM_STAT_FROM(DoubleStatistic, stat); } }; @@ -954,7 +954,7 @@ class TimeStatistic : public Statistic { public: TimeStatistic() {} - void clone_from(const TimeStatistic &that) { + void clone_from(const TimeStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -973,13 +973,13 @@ class TimeStatistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::VECTOR; } - int serialize_typed_stat(common::ByteStream &out) { return common::E_OK; } - int deserialize_typed_stat(common::ByteStream &in) { return common::E_OK; } - int merge_with(Statistic *stat) { + int serialize_typed_stat(common::ByteStream& out) { return common::E_OK; } + int deserialize_typed_stat(common::ByteStream& in) { return common::E_OK; } + int merge_with(Statistic* stat) { MERGE_TIME_STAT_FROM(TimeStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_TIME_STAT_FROM(TimeStatistic, stat); } @@ -1007,7 +1007,7 @@ class StringStatistic : public Statistic { pa_->init(512, common::MOD_STATISTIC_OBJ); } - StringStatistic(common::PageArena *pa) + StringStatistic(common::PageArena* pa) : min_value_(), max_value_(), first_value_(), last_value_(), pa_(pa) {} ~StringStatistic() { destroy(); } @@ -1028,7 +1028,7 @@ class StringStatistic : public Statistic { first_value_ = common::String(); last_value_ = common::String(); } - void clone_from(const StringStatistic &that) { + void clone_from(const StringStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -1045,7 +1045,7 @@ class StringStatistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::STRING; } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_str(first_value_, out))) { } else if (RET_FAIL(common::SerializationUtil::write_str(last_value_, @@ -1057,7 +1057,7 @@ class StringStatistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; if (RET_FAIL( common::SerializationUtil::read_str(first_value_, pa_, in))) { @@ -1070,15 +1070,15 @@ class StringStatistic : public Statistic { } return ret; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_STRING_STAT_FROM(StringStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_STRING_STAT_FROM(StringStatistic, stat); } private: - common::PageArena *pa_; + common::PageArena* pa_; }; class TextStatistic : public Statistic { @@ -1090,7 +1090,7 @@ class TextStatistic : public Statistic { pa_->init(512, common::MOD_STATISTIC_OBJ); } - TextStatistic(common::PageArena *pa) + TextStatistic(common::PageArena* pa) : first_value_(), last_value_(), pa_(pa) {} ~TextStatistic() { destroy(); } @@ -1109,7 +1109,7 @@ class TextStatistic : public Statistic { first_value_ = common::String(); last_value_ = common::String(); } - void clone_from(const TextStatistic &that) { + void clone_from(const TextStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -1124,7 +1124,7 @@ class TextStatistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::TEXT; } - int serialize_typed_stat(common::ByteStream &out) { + int serialize_typed_stat(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_str(first_value_, out))) { } else if (RET_FAIL(common::SerializationUtil::write_str(last_value_, @@ -1132,7 +1132,7 @@ class TextStatistic : public Statistic { } return ret; } - int deserialize_typed_stat(common::ByteStream &in) { + int deserialize_typed_stat(common::ByteStream& in) { int ret = common::E_OK; if (RET_FAIL( common::SerializationUtil::read_str(first_value_, pa_, in))) { @@ -1141,15 +1141,15 @@ class TextStatistic : public Statistic { } return ret; } - int merge_with(Statistic *stat) { + int merge_with(Statistic* stat) { MERGE_TEXT_STAT_FROM(TextStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_TEXT_STAT_FROM(TextStatistic, stat); } private: - common::PageArena *pa_; + common::PageArena* pa_; }; class BlobStatistic : public Statistic { @@ -1159,7 +1159,7 @@ class BlobStatistic : public Statistic { pa_->init(512, common::MOD_STATISTIC_OBJ); } - BlobStatistic(common::PageArena *pa) {} + BlobStatistic(common::PageArena* pa) {} ~BlobStatistic() { destroy(); } @@ -1175,7 +1175,7 @@ class BlobStatistic : public Statistic { start_time_ = 0; end_time_ = 0; } - void clone_from(const BlobStatistic &that) { + void clone_from(const BlobStatistic& that) { count_ = that.count_; start_time_ = that.start_time_; end_time_ = that.end_time_; @@ -1187,17 +1187,17 @@ class BlobStatistic : public Statistic { FORCE_INLINE common::TSDataType get_type() { return common::BLOB; } - int serialize_typed_stat(common::ByteStream &out) { return common::E_OK; } - int deserialize_typed_stat(common::ByteStream &in) { return common::E_OK; } - int merge_with(Statistic *stat) { + int serialize_typed_stat(common::ByteStream& out) { return common::E_OK; } + int deserialize_typed_stat(common::ByteStream& in) { return common::E_OK; } + int merge_with(Statistic* stat) { MERGE_BLOB_STAT_FROM(BlobStatistic, stat); } - int deep_copy_from(Statistic *stat) { + int deep_copy_from(Statistic* stat) { DEEP_COPY_BLOB_STAT_FROM(BlobStatistic, stat); } private: - common::PageArena *pa_; + common::PageArena* pa_; }; FORCE_INLINE uint32_t get_typed_statistic_sizeof(common::TSDataType type) { @@ -1243,9 +1243,9 @@ FORCE_INLINE uint32_t get_typed_statistic_sizeof(common::TSDataType type) { return ret_size; } -FORCE_INLINE Statistic *placement_new_statistic(common::TSDataType type, - void *buf) { - Statistic *s = nullptr; +FORCE_INLINE Statistic* placement_new_statistic(common::TSDataType type, + void* buf) { + Statistic* s = nullptr; switch (type) { case common::BOOLEAN: s = new (buf) BooleanStatistic; @@ -1288,10 +1288,10 @@ FORCE_INLINE Statistic *placement_new_statistic(common::TSDataType type, } #define TYPED_CLONE_STATISTIC(StatType) \ - (static_cast(to)) \ - ->clone_from(*(static_cast(from))) + (static_cast(to)) \ + ->clone_from(*(static_cast(from))) -FORCE_INLINE void clone_statistic(Statistic *from, Statistic *to, +FORCE_INLINE void clone_statistic(Statistic* from, Statistic* to, common::TSDataType type) { ASSERT(from != nullptr); ASSERT(to != nullptr); @@ -1365,9 +1365,9 @@ FORCE_INLINE void clone_statistic(Statistic *from, Statistic *to, class StatisticFactory { public: - static Statistic *alloc_statistic(common::TSDataType data_type) { - void *buf = nullptr; - Statistic *stat = nullptr; + static Statistic* alloc_statistic(common::TSDataType data_type) { + void* buf = nullptr; + Statistic* stat = nullptr; switch (data_type) { case common::BOOLEAN: ALLOC_STATISTIC(BooleanStatistic); @@ -1408,10 +1408,10 @@ class StatisticFactory { } return stat; } - static Statistic *alloc_statistic_with_pa(common::TSDataType data_type, - common::PageArena *pa) { - void *buf = nullptr; - Statistic *stat = nullptr; + static Statistic* alloc_statistic_with_pa(common::TSDataType data_type, + common::PageArena* pa) { + void* buf = nullptr; + Statistic* stat = nullptr; switch (data_type) { case common::BOOLEAN: ALLOC_STATISTIC_WITH_PA(BooleanStatistic); @@ -1451,7 +1451,7 @@ class StatisticFactory { } return stat; } - static void free(Statistic *stat) { + static void free(Statistic* stat) { stat->destroy(); common::mem_free(stat); } diff --git a/cpp/src/common/tablet_iterator.h b/cpp/src/common/tablet_iterator.h index 930a42afb..53163f7e6 100644 --- a/cpp/src/common/tablet_iterator.h +++ b/cpp/src/common/tablet_iterator.h @@ -31,44 +31,44 @@ namespace storage { return E_DATA_TYPE_NOT_MATCH; \ } \ timestamp = tablet_.timestamps_[row_iter_]; \ - void *value_arr = value_matrix_[col_idx_]; \ + void* value_arr = value_matrix_[col_idx_]; \ if (data_type_ == TsType) { \ - value = ((CppType *)value_arr) + row_iter_; \ + value = ((CppType*)value_arr) + row_iter_; \ } \ return E_OK; \ } while (false) class TabletColIterator { public: - TabletColIterator(const Tablet &tablet, int col_idx) + TabletColIterator(const Tablet& tablet, int col_idx) : tablet_(tablet), col_idx_(col_idx) { ASSERT(col_idx <= tablet.schema_vec_->size()); data_type = get_data_type_size(tablet.schema_vec_->at(i).data_type_); row_iter_ = 0; } - const MeasurementSchema &get_measurement_schema() const { + const MeasurementSchema& get_measurement_schema() const { return schema_vec_->at(col_idx_); } - int get_next(int64_t ×tamp, bool &value) { + int get_next(int64_t& timestamp, bool& value) { GET_TYPED_NEXT(timestamp, bool, BOOLEAN, value); } - int get_next(int64_t ×tamp, int32_t &value) { + int get_next(int64_t& timestamp, int32_t& value) { GET_TYPED_NEXT(timestamp, int32_t, INT32, value); } - int get_next(int64_t ×tamp, int64_t &value) { + int get_next(int64_t& timestamp, int64_t& value) { GET_TYPED_NEXT(timestamp, int64_t, INT64, value); } - int get_next(int64_t ×tamp, float &value) { + int get_next(int64_t& timestamp, float& value) { GET_TYPED_NEXT(timestamp, float, FLOAT, value); } - int get_next(int64_t ×tamp, double &value) { + int get_next(int64_t& timestamp, double& value) { GET_TYPED_NEXT(timestamp, double, DOUBLE, value); } private: - const Tablet &tablet_; + const Tablet& tablet_; TSDataType data_type_; int col_idx_; int row_iter_; diff --git a/cpp/src/common/tsblock/tsblock.cc b/cpp/src/common/tsblock/tsblock.cc index c6a675c3f..9d69566be 100644 --- a/cpp/src/common/tsblock/tsblock.cc +++ b/cpp/src/common/tsblock/tsblock.cc @@ -49,7 +49,7 @@ int TsBlock::init() { } int TsBlock::build_vector(common::TSDataType type, uint32_t row_count) { - Vector *vec; + Vector* vec; int ret = 0; if (LIKELY(type != common::TEXT && type != common::STRING && type != common::BLOB)) { @@ -67,35 +67,35 @@ int TsBlock::build_vector(common::TSDataType type, uint32_t row_count) { return ret; } -void TsBlock::write_data(ByteStream *__restrict byte_stream, - char *__restrict val, uint32_t len, bool has_null, +void TsBlock::write_data(ByteStream* __restrict byte_stream, + char* __restrict val, uint32_t len, bool has_null, TSDataType type) { std::string strval; switch (type) { case common::INT64: { - int64_t ival = *reinterpret_cast(val); + int64_t ival = *reinterpret_cast(val); strval = std::to_string(ival); break; } case common::INT32: { - int32_t ival = *reinterpret_cast(val); + int32_t ival = *reinterpret_cast(val); strval = std::to_string(ival); break; } case common::FLOAT: { - float ival = *reinterpret_cast( + float ival = *reinterpret_cast( val); // cppcheck-suppress invalidPointerCast strval = std::to_string(ival); break; } case common::DOUBLE: { - double ival = *reinterpret_cast( + double ival = *reinterpret_cast( val); // cppcheck-suppress invalidPointerCast strval = std::to_string(ival); break; } case common::BOOLEAN: { - bool ival = *reinterpret_cast(val); + bool ival = *reinterpret_cast(val); if (ival) { strval = "true"; } else { @@ -117,14 +117,14 @@ void TsBlock::write_data(ByteStream *__restrict byte_stream, } } if (LIKELY(!has_null)) { - byte_stream->write_buf(const_cast(strval.c_str()), + byte_stream->write_buf(const_cast(strval.c_str()), strval.length()); } else { byte_stream->write_buf("null", 4); } } -void TsBlock::tsblock_to_json(ByteStream *byte_stream) { +void TsBlock::tsblock_to_json(ByteStream* byte_stream) { // 1. append start tag byte_stream->write_buf("{\n", 2); @@ -157,7 +157,7 @@ void TsBlock::tsblock_to_json(ByteStream *byte_stream) { while (!time_iter.end()) { uint32_t ilen; byte_stream->write_buf(" ", 4); - char *val = time_iter.read(&ilen); + char* val = time_iter.read(&ilen); if (!is_first) { byte_stream->write_buf(",\n", 2); } @@ -179,7 +179,7 @@ void TsBlock::tsblock_to_json(ByteStream *byte_stream) { while (!value_iter.end()) { uint32_t ilen = 0; byte_stream->write_buf(" ", 6); - char *val = value_iter.read(&ilen); + char* val = value_iter.read(&ilen); if (!is_first) { byte_stream->write_buf(",\n", 2); } @@ -193,7 +193,7 @@ void TsBlock::tsblock_to_json(ByteStream *byte_stream) { bool inull; uint32_t ilen = 0; byte_stream->write_buf(" ", 6); - char *val = value_iter.read(&ilen, &inull); + char* val = value_iter.read(&ilen, &inull); if (!is_first) { byte_stream->write_buf(",\n", 2); } @@ -244,39 +244,39 @@ std::string RowIterator::debug_string() { for (uint32_t i = 0; i < column_count_; ++i) { bool is_null = false; uint32_t len = 0; - void *value = read(i, &len, &is_null); + void* value = read(i, &len, &is_null); if (is_null) { out << "NULL"; } else { - ColumnSchema &col_schema = + ColumnSchema& col_schema = tsblock_->tuple_desc_->get_column_schema(i); switch (col_schema.data_type_) { case common::BOOLEAN: { - out << *static_cast(value); + out << *static_cast(value); break; } case common::INT32: { - out << *static_cast(value); + out << *static_cast(value); break; } case common::INT64: { - out << *static_cast(value); + out << *static_cast(value); break; } case common::FLOAT: { - out << *static_cast(value); + out << *static_cast(value); break; } case common::DOUBLE: { - out << *static_cast(value); + out << *static_cast(value); break; } case common::TEXT: { - out << std::string(static_cast(value), len); + out << std::string(static_cast(value), len); break; } case common::STRING: { - out << *static_cast(value); + out << *static_cast(value); break; } default: { @@ -292,10 +292,10 @@ std::string RowIterator::debug_string() { } #endif // TODO use memcpy in vector instead of using iter/appender -int merge_tsblock_by_row(TsBlock *sea, TsBlock *river) { +int merge_tsblock_by_row(TsBlock* sea, TsBlock* river) { int ret = E_OK; - TupleDesc *sea_tuple_desc = sea->get_tuple_desc(); - TupleDesc *river_tupe_desc = river->get_tuple_desc(); + TupleDesc* sea_tuple_desc = sea->get_tuple_desc(); + TupleDesc* river_tupe_desc = river->get_tuple_desc(); if (!sea_tuple_desc->equal_to(*river_tupe_desc)) { ret = E_NOT_MATCH; } else { @@ -306,7 +306,7 @@ int merge_tsblock_by_row(TsBlock *sea, TsBlock *river) { for (uint32_t c = 0; c < sea_tuple_desc->get_column_count(); c++) { uint32_t len = 0; bool null = false; - char *val = river_iter.read(c, &len, &null); + char* val = river_iter.read(c, &len, &null); sea_appender.append(c, val, len); } river_iter.next(); diff --git a/cpp/src/common/tsblock/tuple_desc.cc b/cpp/src/common/tsblock/tuple_desc.cc index f0550eb1d..fb00e3024 100644 --- a/cpp/src/common/tsblock/tuple_desc.cc +++ b/cpp/src/common/tsblock/tuple_desc.cc @@ -19,7 +19,7 @@ #include "tuple_desc.h" namespace common { -uint32_t TupleDesc::get_single_row_len(int *erro_code) { +uint32_t TupleDesc::get_single_row_len(int* erro_code) { int size = get_column_count(); int total_len = 0; for (int i = 0; i < size; ++i) { diff --git a/cpp/src/common/tsblock/tuple_desc.h b/cpp/src/common/tsblock/tuple_desc.h index 85ba13097..6010d677b 100644 --- a/cpp/src/common/tsblock/tuple_desc.h +++ b/cpp/src/common/tsblock/tuple_desc.h @@ -57,12 +57,12 @@ class TupleDesc { return column_list_.size(); } - FORCE_INLINE ColumnSchema &operator[](uint32_t index) { + FORCE_INLINE ColumnSchema& operator[](uint32_t index) { ASSERT(index < column_list_.size()); return column_list_[index]; } - FORCE_INLINE ColumnSchema &get_column_schema(uint32_t index) { + FORCE_INLINE ColumnSchema& get_column_schema(uint32_t index) { ASSERT(index < column_list_.size()); return column_list_[index]; } @@ -86,15 +86,15 @@ class TupleDesc { // get the single row len, ignore nulls and select-list memory for the // moment - uint32_t get_single_row_len(int *erro_code); + uint32_t get_single_row_len(int* erro_code); - bool equal_to(const TupleDesc &that) const { + bool equal_to(const TupleDesc& that) const { if (column_list_.size() != that.column_list_.size()) { return false; } for (uint32_t i = 0; i < column_list_.size(); i++) { - const ColumnSchema &this_col_schema = column_list_[i]; - const ColumnSchema &that_col_schema = that.column_list_[i]; + const ColumnSchema& this_col_schema = column_list_[i]; + const ColumnSchema& that_col_schema = that.column_list_[i]; if (this_col_schema != that_col_schema) { return false; } @@ -102,7 +102,7 @@ class TupleDesc { return true; } - void clone_from(TupleDesc *that) { + void clone_from(TupleDesc* that) { ASSERT(column_list_.size() == 0); column_list_ = that->column_list_; // deep copy } diff --git a/cpp/src/common/tsblock/vector/fixed_length_vector.h b/cpp/src/common/tsblock/vector/fixed_length_vector.h index 9eca267a2..df20c97d9 100644 --- a/cpp/src/common/tsblock/vector/fixed_length_vector.h +++ b/cpp/src/common/tsblock/vector/fixed_length_vector.h @@ -25,7 +25,7 @@ namespace common { class FixedLengthVector : public Vector { public: FixedLengthVector(common::TSDataType type, uint32_t max_row_num, - uint32_t type_size, common::TsBlock *tsblock) + uint32_t type_size, common::TsBlock* tsblock) : Vector(type, max_row_num, tsblock), type_len_(type_size) { values_.init(type_size * max_row_num); } @@ -45,12 +45,12 @@ class FixedLengthVector : public Vector { FORCE_INLINE void update_offset() OVERRIDE { offset_ += type_len_; } // cppcheck-suppress missingOverride - FORCE_INLINE void append(const char *value, uint32_t len) OVERRIDE { + FORCE_INLINE void append(const char* value, uint32_t len) OVERRIDE { values_.append_fixed_value(value, len); } // cppcheck-suppress missingOverride - FORCE_INLINE char *read(uint32_t *__restrict len, bool *__restrict null, + FORCE_INLINE char* read(uint32_t* __restrict len, bool* __restrict null, uint32_t rowid) OVERRIDE { *len = type_len_; if (UNLIKELY(has_null_)) { @@ -59,7 +59,7 @@ class FixedLengthVector : public Vector { *null = false; } if (LIKELY(!(*null))) { - char *result = values_.read(offset_, type_len_); + char* result = values_.read(offset_, type_len_); return result; } else { return nullptr; @@ -67,9 +67,9 @@ class FixedLengthVector : public Vector { } // cppcheck-suppress missingOverride - FORCE_INLINE char *read(uint32_t *len) OVERRIDE { + FORCE_INLINE char* read(uint32_t* len) OVERRIDE { *len = type_len_; - char *result = values_.read(offset_, type_len_); + char* result = values_.read(offset_, type_len_); return result; } diff --git a/cpp/src/common/tsblock/vector/variable_length_vector.h b/cpp/src/common/tsblock/vector/variable_length_vector.h index 23ebb75d9..b98a9c739 100644 --- a/cpp/src/common/tsblock/vector/variable_length_vector.h +++ b/cpp/src/common/tsblock/vector/variable_length_vector.h @@ -25,7 +25,7 @@ namespace common { class VariableLengthVector : public Vector { public: VariableLengthVector(common::TSDataType type, uint32_t max_row_num, - uint32_t type_size, common::TsBlock *tsblock) + uint32_t type_size, common::TsBlock* tsblock) : Vector(type, max_row_num, tsblock), variable_type_len_(sizeof(uint32_t)), last_value_len_(0) { @@ -50,12 +50,12 @@ class VariableLengthVector : public Vector { } // cppcheck-suppress missingOverride - FORCE_INLINE void append(const char *value, uint32_t len) OVERRIDE { + FORCE_INLINE void append(const char* value, uint32_t len) OVERRIDE { values_.append_variable_value(value, len); } // cppcheck-suppress missingOverride - FORCE_INLINE char *read(uint32_t *__restrict len, bool *__restrict null, + FORCE_INLINE char* read(uint32_t* __restrict len, bool* __restrict null, uint32_t rowid) OVERRIDE { if (UNLIKELY(has_null_)) { *null = nulls_.test(rowid); @@ -64,7 +64,7 @@ class VariableLengthVector : public Vector { *len = 0; } if (LIKELY(!(*null))) { - char *result = values_.read(offset_, len); + char* result = values_.read(offset_, len); last_value_len_ = *len; return result; } else { @@ -73,8 +73,8 @@ class VariableLengthVector : public Vector { } // cppcheck-suppress missingOverride - FORCE_INLINE char *read(uint32_t *len) OVERRIDE { - char *result = values_.read(offset_, len); + FORCE_INLINE char* read(uint32_t* len) OVERRIDE { + char* result = values_.read(offset_, len); last_value_len_ = *len; return result; } diff --git a/cpp/src/common/tsfile_common.cc b/cpp/src/common/tsfile_common.cc index 31c718b4e..7d79b90e8 100644 --- a/cpp/src/common/tsfile_common.cc +++ b/cpp/src/common/tsfile_common.cc @@ -28,7 +28,7 @@ using namespace common; namespace storage { -const char *MAGIC_STRING_TSFILE = "TsFile"; +const char* MAGIC_STRING_TSFILE = "TsFile"; const char VERSION_NUM_BYTE = 0x04; // 0x03; const char CHUNK_GROUP_HEADER_MARKER = 0; const char CHUNK_HEADER_MARKER = 1; @@ -37,7 +37,7 @@ const char SEPARATOR_MARKER = 2; const char OPERATION_INDEX_RANGE = 4; /* ================ TimeseriesIndex ================ */ -int TimeseriesIndex::add_chunk_meta(ChunkMeta *chunk_meta, +int TimeseriesIndex::add_chunk_meta(ChunkMeta* chunk_meta, bool serialize_statistic) { int ret = E_OK; if (IS_NULL(chunk_meta)) { @@ -60,11 +60,11 @@ int TSMIterator::init() { chunk_group_meta_iter++) { auto chunk_meta_list = chunk_group_meta_iter.get()->chunk_meta_list_; // Use a map to group chunks by measurement_name_ - std::map> groups; + std::map> groups; std::vector order; for (auto it = chunk_meta_list.begin(); it != chunk_meta_list.end(); it++) { - auto *chunk_meta = it.get(); + auto* chunk_meta = it.get(); if (groups.find(chunk_meta->measurement_name_) == groups.end()) { order.push_back(chunk_meta->measurement_name_); } @@ -73,16 +73,16 @@ int TSMIterator::init() { // Sort each group of chunk metas by offset for (auto it = groups.begin(); it != groups.end(); ++it) { - std::vector &group = it->second; + std::vector& group = it->second; std::sort(group.begin(), group.end(), - [](ChunkMeta *a, ChunkMeta *b) { + [](ChunkMeta* a, ChunkMeta* b) { return a->offset_of_chunk_header_ < b->offset_of_chunk_header_; }); } // Clear and refill chunk_group_meta_list chunk_group_meta_iter.get()->chunk_meta_list_.clear(); - for (const auto &measurement_name : order) { + for (const auto& measurement_name : order) { for (auto chunk_meta : groups[measurement_name]) { chunk_group_meta_iter.get()->chunk_meta_list_.push_back( chunk_meta); @@ -95,7 +95,7 @@ int TSMIterator::init() { while (chunk_group_meta_iter_ != chunk_group_meta_list_.end()) { chunk_meta_iter_ = chunk_group_meta_iter_.get()->chunk_meta_list_.begin(); - std::map> tmp; + std::map> tmp; while (chunk_meta_iter_ != chunk_group_meta_iter_.get()->chunk_meta_list_.end()) { tmp[chunk_meta_iter_.get()->measurement_name_].emplace_back( @@ -121,11 +121,11 @@ bool TSMIterator::has_next() const { return tsm_device_iter_ != tsm_chunk_meta_info_.end(); } -int TSMIterator::get_next(std::shared_ptr &ret_device_id, - String &ret_measurement_name, - TimeseriesIndex &ret_ts_index) { +int TSMIterator::get_next(std::shared_ptr& ret_device_id, + String& ret_measurement_name, + TimeseriesIndex& ret_ts_index) { int ret = E_OK; - SimpleList chunk_meta_list_of_this_ts( + SimpleList chunk_meta_list_of_this_ts( 1024, MOD_TIMESERIES_INDEX_OBJ); // FIXME if (tsm_measurement_iter_ == tsm_device_iter_->second.end()) { tsm_device_iter_++; @@ -145,7 +145,7 @@ int TSMIterator::get_next(std::shared_ptr &ret_device_id, } const bool multi_chunks = chunk_meta_list_of_this_ts.size() > 1; - ChunkMeta *first_chunk_meta = chunk_meta_list_of_this_ts.front(); + ChunkMeta* first_chunk_meta = chunk_meta_list_of_this_ts.front(); const char meta_type = (multi_chunks ? 1 : 0) | (first_chunk_meta->mask_); const TSDataType data_type = first_chunk_meta->data_type_; @@ -154,12 +154,12 @@ int TSMIterator::get_next(std::shared_ptr &ret_device_id, ret_ts_index.set_data_type(data_type); ret_ts_index.init_statistic(data_type); - SimpleList::Iterator ts_chunk_meta_iter = + SimpleList::Iterator ts_chunk_meta_iter = chunk_meta_list_of_this_ts.begin(); for (; IS_SUCC(ret) && ts_chunk_meta_iter != chunk_meta_list_of_this_ts.end(); ts_chunk_meta_iter++) { - ChunkMeta *chunk_meta = ts_chunk_meta_iter.get(); + ChunkMeta* chunk_meta = ts_chunk_meta_iter.get(); if (RET_FAIL(ret_ts_index.add_chunk_meta(chunk_meta, multi_chunks))) { } } @@ -175,17 +175,17 @@ int TSMIterator::get_next(std::shared_ptr &ret_device_id, return ret; } -int TsFileMeta::serialize_to(common::ByteStream &out) { +int TsFileMeta::serialize_to(common::ByteStream& out) { auto start_idx = out.total_size(); common::SerializationUtil::write_var_uint( table_metadata_index_node_map_.size(), out); - for (auto &idx_nodes_iter : table_metadata_index_node_map_) { + for (auto& idx_nodes_iter : table_metadata_index_node_map_) { common::SerializationUtil::write_var_str(idx_nodes_iter.first, out); idx_nodes_iter.second->serialize_to(out); } common::SerializationUtil::write_var_uint(table_schemas_.size(), out); - for (auto &table_schema_iter : table_schemas_) { + for (auto& table_schema_iter : table_schemas_) { common::SerializationUtil::write_var_str(table_schema_iter.first, out); table_schema_iter.second->serialize_to(out); } @@ -199,7 +199,7 @@ int TsFileMeta::serialize_to(common::ByteStream &out) { } common::SerializationUtil::write_var_int(tsfile_properties_.size(), out); - for (const auto &tsfile_property : tsfile_properties_) { + for (const auto& tsfile_property : tsfile_properties_) { common::SerializationUtil::write_var_str(tsfile_property.first, out); common::SerializationUtil::write_var_char_ptr(tsfile_property.second, out); @@ -208,10 +208,10 @@ int TsFileMeta::serialize_to(common::ByteStream &out) { return out.total_size() - start_idx; } -int TsFileMeta::deserialize_from(common::ByteStream &in) { +int TsFileMeta::deserialize_from(common::ByteStream& in) { int ret = common::E_OK; - void *index_node_buf = page_arena_->alloc(sizeof(MetaIndexNode)); - void *bloom_filter_buf = page_arena_->alloc(sizeof(BloomFilter)); + void* index_node_buf = page_arena_->alloc(sizeof(MetaIndexNode)); + void* bloom_filter_buf = page_arena_->alloc(sizeof(BloomFilter)); if (IS_NULL(index_node_buf) || IS_NULL(bloom_filter_buf)) { return common::E_OOM; } @@ -262,8 +262,8 @@ int TsFileMeta::deserialize_from(common::ByteStream &in) { /* ================ MetaIndexNode ================ */ int MetaIndexNode::binary_search_children( std::shared_ptr key, bool exact_search, - std::shared_ptr &ret_index_entry, - int64_t &ret_end_offset) { + std::shared_ptr& ret_index_entry, + int64_t& ret_end_offset) { #if DEBUG_SE std::cout << "MetaIndexNode::binary_search_children start, name=" << key << ", exact_search=" << exact_search diff --git a/cpp/src/common/tsfile_mgr.cc b/cpp/src/common/tsfile_mgr.cc index 88fcfd08d..6b3f9f459 100644 --- a/cpp/src/common/tsfile_mgr.cc +++ b/cpp/src/common/tsfile_mgr.cc @@ -29,7 +29,7 @@ using namespace common; namespace storage { -TsFileMgr &TsFileMgr::get_instance() { +TsFileMgr& TsFileMgr::get_instance() { static TsFileMgr g_s_tsfile_mgr; return g_s_tsfile_mgr; } @@ -40,20 +40,20 @@ int TsFileMgr::init() { } // used when recover -int TsFileMgr::add_new_file(const std::string &file_path) { +int TsFileMgr::add_new_file(const std::string& file_path) { int ret = E_OK; MutexGuard mg(all_open_files_mutex_); // TODO return ret; } -int TsFileMgr::add_new_file(const FileID &file_id, OpenFile *open_file) { +int TsFileMgr::add_new_file(const FileID& file_id, OpenFile* open_file) { MutexGuard mg(all_open_files_mutex_); AllOpenFileMapIter find_iter = all_open_files_.find(file_id); if (find_iter != all_open_files_.end()) { return E_ALREADY_EXIST; } - std::pair pair; + std::pair pair; pair.first = file_id; pair.second = open_file; std::pair ins_res = all_open_files_.insert(pair); @@ -68,10 +68,10 @@ int TsFileMgr::add_new_file(const FileID &file_id, OpenFile *open_file) { * Currently, we only allow sequence data writing, * So we have only one DataRun returned. */ -int TsFileMgr::get_files_for_query(const TsID &ts_id, - const TimeFilter *time_filter, - DataRun *ret_data_run, - int64_t &ret_version) { +int TsFileMgr::get_files_for_query(const TsID& ts_id, + const TimeFilter* time_filter, + DataRun* ret_data_run, + int64_t& ret_version) { int ret = E_OK; // Step 1: get all tsfiles that contain this ts_id, store them in tsfile_vec @@ -80,7 +80,7 @@ int TsFileMgr::get_files_for_query(const TsID &ts_id, all_open_files_mutex_.lock(); for (AllOpenFileMapIter iter = all_open_files_.begin(); iter != all_open_files_.end() && IS_SUCC(ret); iter++) { - OpenFile *open_file = iter->second; + OpenFile* open_file = iter->second; TimeRange time_range; int tmp_ret = open_file->get_time_range(ts_id, time_range); if (tmp_ret == E_OK) { @@ -113,8 +113,8 @@ int TsFileMgr::get_files_for_query(const TsID &ts_id, return ret; } -bool TsFileMgr::time_range_stasify(const TimeFilter *time_filter, - const TimeRange &time_range) { +bool TsFileMgr::time_range_stasify(const TimeFilter* time_filter, + const TimeRange& time_range) { // TODO UNUSED(time_filter); UNUSED(time_range); @@ -122,7 +122,7 @@ bool TsFileMgr::time_range_stasify(const TimeFilter *time_filter, } #ifndef NDEBUG -void TsFileMgr::DEBUG_dump(const char *tag) { +void TsFileMgr::DEBUG_dump(const char* tag) { MutexGuard mg(all_open_files_mutex_); AllOpenFileMapIter it; std::cout << tag << "Dump TsFileMgr Start" << std::endl; diff --git a/cpp/src/common/tsfile_mgr.h b/cpp/src/common/tsfile_mgr.h index 3772769a1..5dac4e36d 100644 --- a/cpp/src/common/tsfile_mgr.h +++ b/cpp/src/common/tsfile_mgr.h @@ -31,51 +31,51 @@ class TimeFilter; struct TimeRangeOpenFilePair { TimeRange time_range_; - OpenFile *open_file_; + OpenFile* open_file_; }; FORCE_INLINE bool compare_timerange_openfile_pair( - const TimeRangeOpenFilePair &x, const TimeRangeOpenFilePair &y) { + const TimeRangeOpenFilePair& x, const TimeRangeOpenFilePair& y) { return x.time_range_.start_time_ < y.time_range_.start_time_; } -FORCE_INLINE void merge_time_range(TimeRange &dest, const TimeRange &src) { +FORCE_INLINE void merge_time_range(TimeRange& dest, const TimeRange& src) { dest.start_time_ = UTIL_MIN(dest.start_time_, src.start_time_); dest.end_time_ = UTIL_MAX(dest.end_time_, src.end_time_); } class TsFileMgr { public: - typedef std::map AllOpenFileMap; + typedef std::map AllOpenFileMap; typedef AllOpenFileMap::iterator AllOpenFileMapIter; public: TsFileMgr() : all_open_files_(), version_(0), all_open_files_mutex_() {} - static TsFileMgr &get_instance(); + static TsFileMgr& get_instance(); int init(); void destroy() { all_open_files_.clear(); } - int add_new_file(const std::string &file_path); - int add_new_file(const common::FileID &file_id, OpenFile *open_file); + int add_new_file(const std::string& file_path); + int add_new_file(const common::FileID& file_id, OpenFile* open_file); // int get_files_for_query(const common::TsID &ts_id, // const TimeFilter &time_filter, // common::SimpleList &ret_data_runs); - int get_files_for_query(const common::TsID &ts_id, - const TimeFilter *time_filter, - DataRun *ret_data_run, int64_t &ret_version); + int get_files_for_query(const common::TsID& ts_id, + const TimeFilter* time_filter, + DataRun* ret_data_run, int64_t& ret_version); int64_t get_version() { common::MutexGuard mg(all_open_files_mutex_); return version_; } #ifndef NDEBUG - void DEBUG_dump(const char *tag); + void DEBUG_dump(const char* tag); #endif private: - bool time_range_stasify(const TimeFilter *time_filter, - const TimeRange &time_range); + bool time_range_stasify(const TimeFilter* time_filter, + const TimeRange& time_range); private: // Map diff --git a/cpp/src/compress/compressor.h b/cpp/src/compress/compressor.h index 1a4c3cb2d..1a8d50397 100644 --- a/cpp/src/compress/compressor.h +++ b/cpp/src/compress/compressor.h @@ -35,14 +35,14 @@ class Compressor { // false - for uncompression virtual int reset(bool for_compress) = 0; virtual void destroy() = 0; - virtual int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, - uint32_t &compressed_buf_len) = 0; - virtual void after_compress(char *compressed_buf) = 0; - virtual int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) = 0; - virtual void after_uncompress(char *uncompressed_buf) = 0; + virtual int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, + uint32_t& compressed_buf_len) = 0; + virtual void after_compress(char* compressed_buf) = 0; + virtual int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) = 0; + virtual void after_uncompress(char* uncompressed_buf) = 0; // TODO other style API }; diff --git a/cpp/src/compress/compressor_factory.h b/cpp/src/compress/compressor_factory.h index ea4b464c0..912b4628e 100644 --- a/cpp/src/compress/compressor_factory.h +++ b/cpp/src/compress/compressor_factory.h @@ -42,10 +42,10 @@ namespace storage { #define ALLOC_AND_RETURN_COMPRESSPR(CompressorClass) \ do { \ - void *buf = common::mem_alloc(sizeof(CompressorClass), \ + void* buf = common::mem_alloc(sizeof(CompressorClass), \ common::MOD_COMPRESSOR_OBJ); \ if (buf != nullptr) { \ - CompressorClass *c = new (buf) CompressorClass; \ + CompressorClass* c = new (buf) CompressorClass; \ return c; \ } else { \ return nullptr; \ @@ -54,7 +54,7 @@ namespace storage { class CompressorFactory { public: - static Compressor *alloc_compressor(common::CompressionType type) { + static Compressor* alloc_compressor(common::CompressionType type) { if (type == common::UNCOMPRESSED) { ALLOC_AND_RETURN_COMPRESSPR(UncompressedCompressor); } else if (type == common::SNAPPY) { @@ -93,7 +93,7 @@ class CompressorFactory { } } - static void free(Compressor *c) { common::mem_free(c); } + static void free(Compressor* c) { common::mem_free(c); } }; } // end namespace storage diff --git a/cpp/src/compress/gzip_compressor.cc b/cpp/src/compress/gzip_compressor.cc index 9b4f9cd61..b49830bf2 100644 --- a/cpp/src/compress/gzip_compressor.cc +++ b/cpp/src/compress/gzip_compressor.cc @@ -70,14 +70,14 @@ int GzipCompressor::end_zstream() { return E_OK; } -int GzipCompressor::compress_into_bytestream(char *uncompressed_buf, +int GzipCompressor::compress_into_bytestream(char* uncompressed_buf, uint32_t uncompressed_buf_len, - ByteStream &out) { + ByteStream& out) { int ret = Z_OK; - compress_stream_.next_in = (Bytef *)uncompressed_buf; + compress_stream_.next_in = (Bytef*)uncompressed_buf; compress_stream_.avail_in = uncompressed_buf_len; - compress_stream_.next_out = (Bytef *)compressed_buf; + compress_stream_.next_out = (Bytef*)compressed_buf; compress_stream_.avail_out = DEFLATE_BUFFER_SIZE; if (uncompressed_buf == nullptr || uncompressed_buf_len == 0) { // no more @@ -90,7 +90,7 @@ int GzipCompressor::compress_into_bytestream(char *uncompressed_buf, } out.write_buf(compressed_buf, DEFLATE_BUFFER_SIZE - compress_stream_.avail_out); - compress_stream_.next_out = (Bytef *)compressed_buf; + compress_stream_.next_out = (Bytef*)compressed_buf; compress_stream_.avail_out = DEFLATE_BUFFER_SIZE; } } @@ -107,13 +107,13 @@ int GzipCompressor::compress_into_bytestream(char *uncompressed_buf, if (compress_stream_.avail_in == 0) { // current input data are all out.write_buf(compressed_buf, DEFLATE_BUFFER_SIZE - compress_stream_.avail_out); - compress_stream_.next_out = (Bytef *)compressed_buf; + compress_stream_.next_out = (Bytef*)compressed_buf; compress_stream_.avail_out = DEFLATE_BUFFER_SIZE; break; } else if (compress_stream_.avail_out == 0) { // no more space for output out.write_buf(compressed_buf, DEFLATE_BUFFER_SIZE); - compress_stream_.next_out = (Bytef *)compressed_buf; + compress_stream_.next_out = (Bytef*)compressed_buf; compress_stream_.avail_out = DEFLATE_BUFFER_SIZE; } } @@ -121,10 +121,10 @@ int GzipCompressor::compress_into_bytestream(char *uncompressed_buf, return E_OK; } -int GzipCompressor::compress(char *uncompressed_buf, +int GzipCompressor::compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, - uint32_t &compressed_buf_len) { + char*& compressed_buf, + uint32_t& compressed_buf_len) { int ret = E_OK; ByteStream out(DEFLATE_BUFFER_SIZE, MOD_COMPRESSOR_OBJ); if (RET_FAIL(compress_into_bytestream(uncompressed_buf, @@ -188,14 +188,14 @@ int GzipDeCompressor::reset() { return ret; } -int GzipDeCompressor::decompress_into_bytestream(char *compressed_buf, +int GzipDeCompressor::decompress_into_bytestream(char* compressed_buf, uint32_t compressed_buf_len, - ByteStream &out) { + ByteStream& out) { int ret = Z_OK; - decompress_stream_.next_in = (Bytef *)compressed_buf; + decompress_stream_.next_in = (Bytef*)compressed_buf; decompress_stream_.avail_in = compressed_buf_len; - decompress_stream_.next_out = (Bytef *)decompressed_buf; + decompress_stream_.next_out = (Bytef*)decompressed_buf; decompress_stream_.avail_out = INFLATE_BUFFER_SIZE; if (compressed_buf == nullptr || compressed_buf_len == 0) { @@ -209,7 +209,7 @@ int GzipDeCompressor::decompress_into_bytestream(char *compressed_buf, out.write_buf( decompressed_buf, INFLATE_BUFFER_SIZE - decompress_stream_.avail_out); - decompress_stream_.next_out = (Bytef *)decompressed_buf; + decompress_stream_.next_out = (Bytef*)decompressed_buf; decompress_stream_.avail_out = INFLATE_BUFFER_SIZE; } } @@ -230,12 +230,12 @@ int GzipDeCompressor::decompress_into_bytestream(char *compressed_buf, if (decompress_stream_.avail_in == 0) { out.write_buf(decompressed_buf, INFLATE_BUFFER_SIZE - decompress_stream_.avail_out); - decompress_stream_.next_out = (Bytef *)decompressed_buf; + decompress_stream_.next_out = (Bytef*)decompressed_buf; decompress_stream_.avail_out = INFLATE_BUFFER_SIZE; break; } else if (decompress_stream_.avail_out == 0) { out.write_buf(decompressed_buf, INFLATE_BUFFER_SIZE); - decompress_stream_.next_out = (Bytef *)decompressed_buf; + decompress_stream_.next_out = (Bytef*)decompressed_buf; decompress_stream_.avail_out = INFLATE_BUFFER_SIZE; } } @@ -243,10 +243,10 @@ int GzipDeCompressor::decompress_into_bytestream(char *compressed_buf, return E_OK; } -int GzipDeCompressor::uncompress(char *compressed_buf, +int GzipDeCompressor::uncompress(char* compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) { + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) { int ret = E_OK; ByteStream out(INFLATE_BUFFER_SIZE, MOD_COMPRESSOR_OBJ); if (RET_FAIL(decompress_into_bytestream(compressed_buf, compressed_buf_len, diff --git a/cpp/src/compress/gzip_compressor.h b/cpp/src/compress/gzip_compressor.h index 69680421b..677b72663 100644 --- a/cpp/src/compress/gzip_compressor.h +++ b/cpp/src/compress/gzip_compressor.h @@ -44,12 +44,12 @@ class GzipCompressor { ~GzipCompressor(); int reset(); void destroy() { end_zstream(); } - int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, uint32_t &compressed_buf_len); - void after_compress(char *compressed_buf) { ::free(compressed_buf); } - int compress_into_bytestream(char *uncompressed_buf, + int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, uint32_t& compressed_buf_len); + void after_compress(char* compressed_buf) { ::free(compressed_buf); } + int compress_into_bytestream(char* uncompressed_buf, uint32_t uncompressed_buf_len, - common::ByteStream &out); + common::ByteStream& out); private: int init_zstream(); @@ -67,12 +67,12 @@ class GzipDeCompressor { ~GzipDeCompressor(); int reset(); void destroy() { end_zstream(); } - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, uint32_t &uncompressed_buf_len); - void after_uncompress(char *uncompressed_buf) { ::free(uncompressed_buf); } - int decompress_into_bytestream(char *compressed_buf, + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, uint32_t& uncompressed_buf_len); + void after_uncompress(char* uncompressed_buf) { ::free(uncompressed_buf); } + int decompress_into_bytestream(char* compressed_buf, uint32_t compressed_buf_len, - common::ByteStream &out); + common::ByteStream& out); private: int init_zstream(); @@ -100,23 +100,23 @@ class GZIPCompressor : public Compressor { gzip_decompressor_.destroy(); } - int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, uint32_t &compressed_buf_len) OVERRIDE { + int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, uint32_t& compressed_buf_len) OVERRIDE { return gzip_compressor_.compress(uncompressed_buf, uncompressed_buf_len, compressed_buf, compressed_buf_len); } - void after_compress(char *compressed_buf) OVERRIDE { + void after_compress(char* compressed_buf) OVERRIDE { gzip_compressor_.after_compress(compressed_buf); } - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) OVERRIDE { + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) OVERRIDE { return gzip_decompressor_.uncompress(compressed_buf, compressed_buf_len, uncompressed_buf, uncompressed_buf_len); } - void after_uncompress(char *uncompressed_buf) OVERRIDE { + void after_uncompress(char* uncompressed_buf) OVERRIDE { gzip_decompressor_.after_uncompress(uncompressed_buf); } diff --git a/cpp/src/compress/lz4_compressor.cc b/cpp/src/compress/lz4_compressor.cc index 06bd10cfd..88c64466f 100644 --- a/cpp/src/compress/lz4_compressor.cc +++ b/cpp/src/compress/lz4_compressor.cc @@ -41,14 +41,14 @@ int LZ4Compressor::reset(bool for_compress) { return E_OK; } -int LZ4Compressor::compress(char *uncompressed_buf, +int LZ4Compressor::compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, - uint32_t &compressed_buf_len) { + char*& compressed_buf, + uint32_t& compressed_buf_len) { int ret = E_OK; int max_dst_size = LZ4_compressBound(uncompressed_buf_len); compressed_buf_ = - (char *)mem_alloc((size_t)max_dst_size, MOD_COMPRESSOR_OBJ); + (char*)mem_alloc((size_t)max_dst_size, MOD_COMPRESSOR_OBJ); if (compressed_buf_ != nullptr) { int compressed_data_size = @@ -58,7 +58,7 @@ int LZ4Compressor::compress(char *uncompressed_buf, if (compressed_data_size <= 0) { ret = E_COMPRESS_ERR; } else { - char *compressed_data = (char *)mem_realloc( + char* compressed_data = (char*)mem_realloc( compressed_buf_, (size_t)compressed_data_size); if (compressed_data == nullptr) { @@ -75,16 +75,16 @@ int LZ4Compressor::compress(char *uncompressed_buf, return ret; } -void LZ4Compressor::after_compress(char *compressed_buf) { +void LZ4Compressor::after_compress(char* compressed_buf) { if (compressed_buf != nullptr) { mem_free(compressed_buf_); compressed_buf_ = nullptr; } } -int LZ4Compressor::uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) { +int LZ4Compressor::uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) { int ret = E_OK; float ratios[] = {1.5, 2.5, 3.5, 4.5, 255}; for (int i = 0; i < UNCOMPRESSED_TIME; i++) { @@ -97,15 +97,15 @@ int LZ4Compressor::uncompress(char *compressed_buf, uint32_t compressed_buf_len, return ret; } -int LZ4Compressor::uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len, float ratio) { +int LZ4Compressor::uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len, float ratio) { int ret = E_OK; - char *regen_buffer = nullptr; + char* regen_buffer = nullptr; int src_size = 0; if (ratio > 0) { src_size = (int)(compressed_buf_len * ratio); - regen_buffer = (char *)mem_alloc(src_size, MOD_COMPRESSOR_OBJ); + regen_buffer = (char*)mem_alloc(src_size, MOD_COMPRESSOR_OBJ); } else { ret = E_COMPRESS_ERR; } @@ -130,7 +130,7 @@ int LZ4Compressor::uncompress(char *compressed_buf, uint32_t compressed_buf_len, return ret; } -void LZ4Compressor::after_uncompress(char *uncompressed_buf) { +void LZ4Compressor::after_uncompress(char* uncompressed_buf) { if (uncompressed_buf != nullptr) { mem_free(uncompressed_buf_); uncompressed_buf_ = nullptr; diff --git a/cpp/src/compress/lz4_compressor.h b/cpp/src/compress/lz4_compressor.h index e7f47a872..b33732c67 100644 --- a/cpp/src/compress/lz4_compressor.h +++ b/cpp/src/compress/lz4_compressor.h @@ -45,20 +45,20 @@ class LZ4Compressor : public Compressor { // false - for uncompression int reset(bool for_compress) OVERRIDE; void destroy() OVERRIDE; - int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, uint32_t &compressed_buf_len) OVERRIDE; - void after_compress(char *compressed_buf) OVERRIDE; - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) OVERRIDE; - void after_uncompress(char *uncompressed_buf) OVERRIDE; + int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, uint32_t& compressed_buf_len) OVERRIDE; + void after_compress(char* compressed_buf) OVERRIDE; + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) OVERRIDE; + void after_uncompress(char* uncompressed_buf) OVERRIDE; private: - char *compressed_buf_; - char *uncompressed_buf_; + char* compressed_buf_; + char* uncompressed_buf_; - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, uint32_t &uncompressed_buf_len, + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, uint32_t& uncompressed_buf_len, float ratio); }; diff --git a/cpp/src/compress/lzo_compressor.cc b/cpp/src/compress/lzo_compressor.cc index 0ccde9f6c..0400b039c 100644 --- a/cpp/src/compress/lzo_compressor.cc +++ b/cpp/src/compress/lzo_compressor.cc @@ -41,24 +41,24 @@ int LZOCompressor::reset(bool for_compress) { return E_OK; } -int LZOCompressor::compress(char *uncompressed_buf, +int LZOCompressor::compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, - uint32_t &compressed_buf_len) { + char*& compressed_buf, + uint32_t& compressed_buf_len) { int ret = E_OK; size_t max_dst_size = lzokay::compress_worst_size(uncompressed_buf_len); - compressed_buf = (char *)mem_alloc(max_dst_size, MOD_COMPRESSOR_OBJ); + compressed_buf = (char*)mem_alloc(max_dst_size, MOD_COMPRESSOR_OBJ); if (compressed_buf == nullptr) { ret = E_OOM; } else { size_t compressed_len = 0; - uint8_t *srcUint8 = reinterpret_cast(uncompressed_buf); - uint8_t *dstUint8 = reinterpret_cast(compressed_buf); + uint8_t* srcUint8 = reinterpret_cast(uncompressed_buf); + uint8_t* dstUint8 = reinterpret_cast(compressed_buf); lzokay::EResult compress_result = lzokay::compress(srcUint8, uncompressed_buf_len, dstUint8, max_dst_size, compressed_len); if (compress_result == lzokay::EResult::Success) { - char *compress_data = (char *)mem_realloc(dstUint8, compressed_len); + char* compress_data = (char*)mem_realloc(dstUint8, compressed_len); if (compress_data == nullptr) { ret = E_OOM; } else { @@ -73,36 +73,35 @@ int LZOCompressor::compress(char *uncompressed_buf, return ret; } -void LZOCompressor::after_compress(char *compressed_buf) { +void LZOCompressor::after_compress(char* compressed_buf) { if (compressed_buf != nullptr) { mem_free(compressed_buf); } } -int LZOCompressor::uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) { +int LZOCompressor::uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) { int ret = E_OK; - char *regen_buffer = nullptr; + char* regen_buffer = nullptr; size_t ulength; constexpr float ratio[] = {1.5, 2.5, 3.5, 4.5, 255}; for (uint8_t i = 0; i < UNCOMPRESSED_TIME; ++i) { - regen_buffer = (char *)mem_alloc(compressed_buf_len * ratio[i], - MOD_COMPRESSOR_OBJ); + regen_buffer = + (char*)mem_alloc(compressed_buf_len * ratio[i], MOD_COMPRESSOR_OBJ); if (regen_buffer == nullptr) { ret = E_OOM; } else { lzokay::EResult result = lzokay::decompress( - reinterpret_cast(compressed_buf), compressed_buf_len, - reinterpret_cast(regen_buffer), + reinterpret_cast(compressed_buf), compressed_buf_len, + reinterpret_cast(regen_buffer), compressed_buf_len * ratio[i], ulength); if (result != lzokay::EResult::Success) { mem_free(regen_buffer); regen_buffer = nullptr; ret = E_COMPRESS_ERR; } else { - char *compress_data = - (char *)mem_realloc(regen_buffer, ulength); + char* compress_data = (char*)mem_realloc(regen_buffer, ulength); if (regen_buffer == nullptr) { ret = E_OOM; } else { @@ -118,7 +117,7 @@ int LZOCompressor::uncompress(char *compressed_buf, uint32_t compressed_buf_len, return ret; } -void LZOCompressor::after_uncompress(char *uncompressed_buf) { +void LZOCompressor::after_uncompress(char* uncompressed_buf) { if (uncompressed_buf != nullptr) { mem_free(uncompressed_buf); } diff --git a/cpp/src/compress/lzo_compressor.h b/cpp/src/compress/lzo_compressor.h index f80b6117b..6297336aa 100644 --- a/cpp/src/compress/lzo_compressor.h +++ b/cpp/src/compress/lzo_compressor.h @@ -45,17 +45,17 @@ class LZOCompressor : public Compressor { // false - for uncompression int reset(bool for_compress) OVERRIDE; void destroy() OVERRIDE; - int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, uint32_t &compressed_buf_len) OVERRIDE; - void after_compress(char *compressed_buf) OVERRIDE; - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) OVERRIDE; - void after_uncompress(char *uncompressed_buf) OVERRIDE; + int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, uint32_t& compressed_buf_len) OVERRIDE; + void after_compress(char* compressed_buf) OVERRIDE; + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) OVERRIDE; + void after_uncompress(char* uncompressed_buf) OVERRIDE; private: - char *compressed_buf_; - char *uncompressed_buf_; + char* compressed_buf_; + char* uncompressed_buf_; }; } // end namespace storage diff --git a/cpp/src/compress/snappy_compressor.cc b/cpp/src/compress/snappy_compressor.cc index 2dbba4ec7..6a2735e7b 100644 --- a/cpp/src/compress/snappy_compressor.cc +++ b/cpp/src/compress/snappy_compressor.cc @@ -41,13 +41,13 @@ int SnappyCompressor::reset(bool for_compress) { return E_OK; } -int SnappyCompressor::compress(char *uncompressed_buf, +int SnappyCompressor::compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, - uint32_t &compressed_buf_len) { + char*& compressed_buf, + uint32_t& compressed_buf_len) { int ret = E_OK; size_t max_dst_size = snappy::MaxCompressedLength(uncompressed_buf_len); - compressed_buf = (char *)mem_alloc(max_dst_size, MOD_COMPRESSOR_OBJ); + compressed_buf = (char*)mem_alloc(max_dst_size, MOD_COMPRESSOR_OBJ); if (compressed_buf == nullptr) { ret = E_OOM; } else { @@ -57,7 +57,7 @@ int SnappyCompressor::compress(char *uncompressed_buf, if (compressed_buf == nullptr) { ret = E_COMPRESS_ERR; } else { - char *compressed_data = (char *)mem_realloc( + char* compressed_data = (char*)mem_realloc( compressed_buf, static_cast(compressed_len)); if (compressed_data == nullptr) { ret = E_OOM; @@ -72,19 +72,19 @@ int SnappyCompressor::compress(char *uncompressed_buf, return ret; } -void SnappyCompressor::after_compress(char *compressed_buf) { +void SnappyCompressor::after_compress(char* compressed_buf) { if (compressed_buf != nullptr) { mem_free(compressed_buf_); compressed_buf_ = nullptr; } } -int SnappyCompressor::uncompress(char *compressed_buf, +int SnappyCompressor::uncompress(char* compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) { + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) { int ret = E_OK; - char *regen_buffer = nullptr; + char* regen_buffer = nullptr; size_t ulength; if (!snappy::GetUncompressedLength(compressed_buf, compressed_buf_len, @@ -92,8 +92,8 @@ int SnappyCompressor::uncompress(char *compressed_buf, ulength > UINT32_MAX) { ret = E_COMPRESS_ERR; } else { - regen_buffer = (char *)mem_alloc(static_cast(ulength), - MOD_COMPRESSOR_OBJ); + regen_buffer = (char*)mem_alloc(static_cast(ulength), + MOD_COMPRESSOR_OBJ); if (regen_buffer == nullptr) { ret = E_OOM; } else { @@ -107,7 +107,7 @@ int SnappyCompressor::uncompress(char *compressed_buf, return ret; } -void SnappyCompressor::after_uncompress(char *uncompressed_buf) { +void SnappyCompressor::after_uncompress(char* uncompressed_buf) { if (uncompressed_buf != nullptr) { mem_free(uncompressed_buf_); uncompressed_buf_ = nullptr; diff --git a/cpp/src/compress/snappy_compressor.h b/cpp/src/compress/snappy_compressor.h index af0e86bf0..69675e466 100644 --- a/cpp/src/compress/snappy_compressor.h +++ b/cpp/src/compress/snappy_compressor.h @@ -43,17 +43,17 @@ class SnappyCompressor : public Compressor { // false - for uncompression int reset(bool for_compress) OVERRIDE; void destroy() OVERRIDE; - int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, uint32_t &compressed_buf_len) OVERRIDE; - void after_compress(char *compressed_buf) OVERRIDE; - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, - uint32_t &uncompressed_buf_len) OVERRIDE; - void after_uncompress(char *uncompressed_buf) OVERRIDE; + int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, uint32_t& compressed_buf_len) OVERRIDE; + void after_compress(char* compressed_buf) OVERRIDE; + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, + uint32_t& uncompressed_buf_len) OVERRIDE; + void after_uncompress(char* uncompressed_buf) OVERRIDE; private: - char *compressed_buf_; - char *uncompressed_buf_; + char* compressed_buf_; + char* uncompressed_buf_; }; } // end namespace storage diff --git a/cpp/src/compress/uncompressed_compressor.h b/cpp/src/compress/uncompressed_compressor.h index 1d698e9a3..c262837a8 100644 --- a/cpp/src/compress/uncompressed_compressor.h +++ b/cpp/src/compress/uncompressed_compressor.h @@ -33,21 +33,21 @@ class UncompressedCompressor : public Compressor { return common::E_OK; } void destroy() {} - int compress(char *uncompressed_buf, uint32_t uncompressed_buf_len, - char *&compressed_buf, uint32_t &compressed_buf_len) { + int compress(char* uncompressed_buf, uint32_t uncompressed_buf_len, + char*& compressed_buf, uint32_t& compressed_buf_len) { compressed_buf = uncompressed_buf; compressed_buf_len = uncompressed_buf_len; return common::E_OK; } - void after_compress(char *compressed_buf) { UNUSED(compressed_buf); } + void after_compress(char* compressed_buf) { UNUSED(compressed_buf); } - int uncompress(char *compressed_buf, uint32_t compressed_buf_len, - char *&uncompressed_buf, uint32_t &uncompressed_buf_len) { + int uncompress(char* compressed_buf, uint32_t compressed_buf_len, + char*& uncompressed_buf, uint32_t& uncompressed_buf_len) { uncompressed_buf = compressed_buf; uncompressed_buf_len = compressed_buf_len; return common::E_OK; } - void after_uncompress(char *uncompressed_buf) { UNUSED(uncompressed_buf); } + void after_uncompress(char* uncompressed_buf) { UNUSED(uncompressed_buf); } }; } // end namespace storage diff --git a/cpp/src/encoding/decoder.h b/cpp/src/encoding/decoder.h index 4dc247817..c290b5791 100644 --- a/cpp/src/encoding/decoder.h +++ b/cpp/src/encoding/decoder.h @@ -29,14 +29,14 @@ class Decoder { Decoder() {} virtual ~Decoder() {} virtual void reset() = 0; - virtual bool has_remaining(const common::ByteStream &buffer) = 0; - virtual int read_boolean(bool &ret_value, common::ByteStream &in) = 0; - virtual int read_int32(int32_t &ret_value, common::ByteStream &in) = 0; - virtual int read_int64(int64_t &ret_value, common::ByteStream &in) = 0; - virtual int read_float(float &ret_value, common::ByteStream &in) = 0; - virtual int read_double(double &ret_value, common::ByteStream &in) = 0; - virtual int read_String(common::String &ret_value, common::PageArena &pa, - common::ByteStream &in) = 0; + virtual bool has_remaining(const common::ByteStream& buffer) = 0; + virtual int read_boolean(bool& ret_value, common::ByteStream& in) = 0; + virtual int read_int32(int32_t& ret_value, common::ByteStream& in) = 0; + virtual int read_int64(int64_t& ret_value, common::ByteStream& in) = 0; + virtual int read_float(float& ret_value, common::ByteStream& in) = 0; + virtual int read_double(double& ret_value, common::ByteStream& in) = 0; + virtual int read_String(common::String& ret_value, common::PageArena& pa, + common::ByteStream& in) = 0; }; } // end namespace storage diff --git a/cpp/src/encoding/dictionary_encoder.h b/cpp/src/encoding/dictionary_encoder.h index 16b73458b..fad4ef68f 100644 --- a/cpp/src/encoding/dictionary_encoder.h +++ b/cpp/src/encoding/dictionary_encoder.h @@ -41,22 +41,22 @@ class DictionaryEncoder : public Encoder { DictionaryEncoder() {} ~DictionaryEncoder() override {} - int encode(bool value, common::ByteStream &out_stream) override { + int encode(bool value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(int32_t value, common::ByteStream &out_stream) override { + int encode(int32_t value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(int64_t value, common::ByteStream &out_stream) override { + int encode(int64_t value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(float value, common::ByteStream &out_stream) override { + int encode(float value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(double value, common::ByteStream &out_stream) override { + int encode(double value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(common::String value, common::ByteStream &out_stream) override { + int encode(common::String value, common::ByteStream& out_stream) override { encode(value.to_std_string(), out_stream); return common::E_OK; } @@ -75,11 +75,11 @@ class DictionaryEncoder : public Encoder { values_encoder_.reset(); } - int encode(const char *value, common::ByteStream &out) { + int encode(const char* value, common::ByteStream& out) { return encode(std::string(value), out); } - int encode(std::string value, common::ByteStream &out) { + int encode(std::string value, common::ByteStream& out) { if (entry_index_.count(value) == 0) { index_entry_.push_back(value); map_size_ = map_size_ + value.length(); @@ -89,7 +89,7 @@ class DictionaryEncoder : public Encoder { return common::E_OK; } - int flush(common::ByteStream &out) override { + int flush(common::ByteStream& out) override { int ret = common::E_OK; ret = write_map(out); if (ret != common::E_OK) { @@ -100,7 +100,7 @@ class DictionaryEncoder : public Encoder { return ret; } - int write_map(common::ByteStream &out) { + int write_map(common::ByteStream& out) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_var_int( (int)index_entry_.size(), out))) { @@ -116,7 +116,7 @@ class DictionaryEncoder : public Encoder { return common::E_OK; } - void write_encoded_data(common::ByteStream &out) { + void write_encoded_data(common::ByteStream& out) { values_encoder_.flush(out); } diff --git a/cpp/src/encoding/encoder.h b/cpp/src/encoding/encoder.h index 77242dbeb..921686446 100644 --- a/cpp/src/encoding/encoder.h +++ b/cpp/src/encoding/encoder.h @@ -32,14 +32,14 @@ class Encoder { virtual void reset() = 0; virtual void destroy() = 0; // virtual int init(common::TSDataType data_type) = 0; - virtual int encode(bool value, common::ByteStream &out_stream) = 0; - virtual int encode(int32_t value, common::ByteStream &out_stream) = 0; - virtual int encode(int64_t value, common::ByteStream &out_stream) = 0; - virtual int encode(float value, common::ByteStream &out_stream) = 0; - virtual int encode(double value, common::ByteStream &out_stream) = 0; + virtual int encode(bool value, common::ByteStream& out_stream) = 0; + virtual int encode(int32_t value, common::ByteStream& out_stream) = 0; + virtual int encode(int64_t value, common::ByteStream& out_stream) = 0; + virtual int encode(float value, common::ByteStream& out_stream) = 0; + virtual int encode(double value, common::ByteStream& out_stream) = 0; virtual int encode(common::String value, - common::ByteStream &out_stream) = 0; - virtual int flush(common::ByteStream &out_stream) = 0; + common::ByteStream& out_stream) = 0; + virtual int flush(common::ByteStream& out_stream) = 0; /** * The maximal possible memory size occupied by current Encoder. This diff --git a/cpp/src/encoding/encoder_factory.h b/cpp/src/encoding/encoder_factory.h index e19aeecf8..aaaee2029 100644 --- a/cpp/src/encoding/encoder_factory.h +++ b/cpp/src/encoding/encoder_factory.h @@ -38,10 +38,10 @@ namespace storage { #define ALLOC_AND_RETURN_ENCODER(EncoderType) \ do { \ - void *buf = \ + void* buf = \ common::mem_alloc(sizeof(EncoderType), common::MOD_ENCODER_OBJ); \ if (buf != nullptr) { \ - EncoderType *encoder = new (buf) EncoderType; \ + EncoderType* encoder = new (buf) EncoderType; \ return encoder; \ } else { \ return nullptr; \ @@ -50,7 +50,7 @@ namespace storage { class EncoderFactory { public: - static Encoder *alloc_time_encoder() { + static Encoder* alloc_time_encoder() { if (common::g_config_value_.time_encoding_type_ == common::PLAIN) { ALLOC_AND_RETURN_ENCODER(PlainEncoder); } else if (common::g_config_value_.time_encoding_type_ == @@ -62,7 +62,7 @@ class EncoderFactory { } } - static Encoder *alloc_time_encoder(common::TSEncoding encoding) { + static Encoder* alloc_time_encoder(common::TSEncoding encoding) { if (encoding == common::PLAIN) { ALLOC_AND_RETURN_ENCODER(PlainEncoder); } else if (encoding == common::TS_2DIFF) { @@ -73,7 +73,7 @@ class EncoderFactory { } } - static Encoder *alloc_value_encoder(common::TSEncoding encoding, + static Encoder* alloc_value_encoder(common::TSEncoding encoding, common::TSDataType data_type) { using namespace common; @@ -171,7 +171,7 @@ class EncoderFactory { return nullptr; } - static void free(Encoder *encoder) { + static void free(Encoder* encoder) { encoder->~Encoder(); common::mem_free(encoder); } diff --git a/cpp/src/encoding/float_sprintz_decoder.h b/cpp/src/encoding/float_sprintz_decoder.h index abbef9f57..558017348 100644 --- a/cpp/src/encoding/float_sprintz_decoder.h +++ b/cpp/src/encoding/float_sprintz_decoder.h @@ -52,24 +52,24 @@ class FloatSprintzDecoder : public SprintzDecoder { ~FloatSprintzDecoder() override = default; - void set_predict_method(const std::string &method) { + void set_predict_method(const std::string& method) { predict_scheme_ = method; } - int read_boolean(bool &ret_value, common::ByteStream &in) { + int read_boolean(bool& ret_value, common::ByteStream& in) { return common::E_TYPE_NOT_MATCH; } - int read_int32(int32_t &ret_value, common::ByteStream &in) { + int read_int32(int32_t& ret_value, common::ByteStream& in) { return common::E_TYPE_NOT_MATCH; } - int read_int64(int64_t &ret_value, common::ByteStream &in) { + int read_int64(int64_t& ret_value, common::ByteStream& in) { return common::E_TYPE_NOT_MATCH; } - int read_double(double &ret_value, common::ByteStream &in) { + int read_double(double& ret_value, common::ByteStream& in) { return common::E_TYPE_NOT_MATCH; } - int read_String(common::String &ret_value, common::PageArena &pa, - common::ByteStream &in) { + int read_String(common::String& ret_value, common::PageArena& pa, + common::ByteStream& in) { return common::E_TYPE_NOT_MATCH; } @@ -85,13 +85,13 @@ class FloatSprintzDecoder : public SprintzDecoder { fire_pred_.reset(); } - bool has_remaining(const common::ByteStream &input) override { + bool has_remaining(const common::ByteStream& input) override { size_t min_length = sizeof(uint32_t) + 1; return (is_block_read_ && current_count_ < decode_size_) || input.remaining_size() >= min_length; } - int read_float(float &ret_value, common::ByteStream &input) override { + int read_float(float& ret_value, common::ByteStream& input) override { int ret = common::E_OK; if (!is_block_read_) { if (RET_FAIL(decode_block(input))) { @@ -107,7 +107,7 @@ class FloatSprintzDecoder : public SprintzDecoder { } protected: - int decode_block(common::ByteStream &input) override { + int decode_block(common::ByteStream& input) override { // read header bitWidth int ret = common::E_OK; uint8_t byte; @@ -135,8 +135,8 @@ class FloatSprintzDecoder : public SprintzDecoder { // read packed data std::vector pack_buf(bit_width_); uint32_t read_len = 0; - input.read_buf(reinterpret_cast(pack_buf.data()), - bit_width_, read_len); + input.read_buf(reinterpret_cast(pack_buf.data()), bit_width_, + read_len); packer_ = std::make_shared(bit_width_); std::vector tmp_buffer(block_size_); packer_->unpack_8values(pack_buf.data(), 0, tmp_buffer.data()); diff --git a/cpp/src/encoding/gorilla_encoder.h b/cpp/src/encoding/gorilla_encoder.h index 3fa6eccf2..6a721937a 100644 --- a/cpp/src/encoding/gorilla_encoder.h +++ b/cpp/src/encoding/gorilla_encoder.h @@ -73,7 +73,7 @@ class GorillaEncoder : public Encoder { } // If full, flush bits cached in 'buffer_' to out_stream. - void flush_byte_if_full(common::ByteStream &out) { + void flush_byte_if_full(common::ByteStream& out) { if (bits_left_ == 0) { out.write_buf(&buffer_, 1); buffer_ = 0; @@ -82,13 +82,13 @@ class GorillaEncoder : public Encoder { } // Stores a 0 in 'buffer_' and increases the count of bits by 1. - FORCE_INLINE void write_bit_zero(common::ByteStream &out) { + FORCE_INLINE void write_bit_zero(common::ByteStream& out) { bits_left_--; flush_byte_if_full(out); } // Stores a 1 in 'buffer_' and increases the count of bits by 1. - FORCE_INLINE void write_bit_one(common::ByteStream &out) { + FORCE_INLINE void write_bit_one(common::ByteStream& out) { buffer_ |= (1 << (bits_left_ - 1)); bits_left_--; flush_byte_if_full(out); @@ -101,7 +101,7 @@ class GorillaEncoder : public Encoder { * value: The long value to be written * bits: How many bits are stored to the stream */ - void write_bits(int64_t value, int bits, common::ByteStream &out) { + void write_bits(int64_t value, int bits, common::ByteStream& out) { while (bits > 0) { int shift = bits - bits_left_; if (shift >= 0) { @@ -120,20 +120,20 @@ class GorillaEncoder : public Encoder { } int get_max_byte_size(); - void write_first(T value, common::ByteStream &out); - void write_existing_leading(T xor_value, common::ByteStream &out); + void write_first(T value, common::ByteStream& out); + void write_existing_leading(T xor_value, common::ByteStream& out); void write_new_leading(T xor_value, int leading_zeros, int trailing_zeros, - common::ByteStream &out); - void compress_value(T value, common::ByteStream &out); - int do_encode(T value, common::ByteStream &out); - int flush(common::ByteStream &out); - - int encode(bool value, common::ByteStream &out_stream); - int encode(int32_t value, common::ByteStream &out_stream); - int encode(int64_t value, common::ByteStream &out_stream); - int encode(float value, common::ByteStream &out_stream); - int encode(double value, common::ByteStream &out_stream); - int encode(common::String value, common::ByteStream &out_stream); + common::ByteStream& out); + void compress_value(T value, common::ByteStream& out); + int do_encode(T value, common::ByteStream& out); + int flush(common::ByteStream& out); + + int encode(bool value, common::ByteStream& out_stream); + int encode(int32_t value, common::ByteStream& out_stream); + int encode(int64_t value, common::ByteStream& out_stream); + int encode(float value, common::ByteStream& out_stream); + int encode(double value, common::ByteStream& out_stream); + int encode(common::String value, common::ByteStream& out_stream); public: common::TSEncoding type_; // for debug @@ -156,14 +156,14 @@ FORCE_INLINE int GorillaEncoder::get_max_byte_size() { template <> FORCE_INLINE void GorillaEncoder::write_first( - int32_t value, common::ByteStream &out) { + int32_t value, common::ByteStream& out) { stored_value_ = value; write_bits(value, VALUE_BITS_LENGTH_32BIT, out); } template <> FORCE_INLINE void GorillaEncoder::write_first( - int64_t value, common::ByteStream &out) { + int64_t value, common::ByteStream& out) { stored_value_ = value; write_bits(value, VALUE_BITS_LENGTH_64BIT, out); } @@ -175,7 +175,7 @@ FORCE_INLINE void GorillaEncoder::write_first( */ template <> FORCE_INLINE void GorillaEncoder::write_existing_leading( - int32_t xor_value, common::ByteStream &out) { + int32_t xor_value, common::ByteStream& out) { write_bit_zero(out); int significant_bits = VALUE_BITS_LENGTH_32BIT - stored_leading_zeros_ - stored_trailing_zeros_; @@ -185,7 +185,7 @@ FORCE_INLINE void GorillaEncoder::write_existing_leading( template <> FORCE_INLINE void GorillaEncoder::write_existing_leading( - int64_t xor_value, common::ByteStream &out) { + int64_t xor_value, common::ByteStream& out) { write_bit_zero(out); int significant_bits = VALUE_BITS_LENGTH_64BIT - stored_leading_zeros_ - stored_trailing_zeros_; @@ -201,7 +201,7 @@ FORCE_INLINE void GorillaEncoder::write_existing_leading( template <> FORCE_INLINE void GorillaEncoder::write_new_leading( int32_t xor_value, int leading_zeros, int trailing_zeros, - common::ByteStream &out) { + common::ByteStream& out) { write_bit_one(out); int significant_bits = @@ -218,7 +218,7 @@ FORCE_INLINE void GorillaEncoder::write_new_leading( template <> FORCE_INLINE void GorillaEncoder::write_new_leading( int64_t xor_value, int leading_zeros, int trailing_zeros, - common::ByteStream &out) { + common::ByteStream& out) { write_bit_one(out); int significant_bits = @@ -234,7 +234,7 @@ FORCE_INLINE void GorillaEncoder::write_new_leading( template FORCE_INLINE void GorillaEncoder::compress_value(T value, - common::ByteStream &out) { + common::ByteStream& out) { T xor_value = stored_value_ ^ value; stored_value_ = value; if (xor_value == 0) { @@ -254,7 +254,7 @@ FORCE_INLINE void GorillaEncoder::compress_value(T value, template FORCE_INLINE int GorillaEncoder::do_encode(T value, - common::ByteStream &out) { + common::ByteStream& out) { if (LIKELY(first_value_was_written_)) { compress_value(value, out); } else { @@ -265,7 +265,7 @@ FORCE_INLINE int GorillaEncoder::do_encode(T value, } template <> -FORCE_INLINE int GorillaEncoder::flush(common::ByteStream &out) { +FORCE_INLINE int GorillaEncoder::flush(common::ByteStream& out) { // ending stream do_encode(GORILLA_ENCODING_ENDING_INTEGER, out); @@ -280,7 +280,7 @@ FORCE_INLINE int GorillaEncoder::flush(common::ByteStream &out) { } template <> -FORCE_INLINE int GorillaEncoder::flush(common::ByteStream &out) { +FORCE_INLINE int GorillaEncoder::flush(common::ByteStream& out) { // ending stream do_encode(GORILLA_ENCODING_ENDING_LONG, out); @@ -296,12 +296,12 @@ FORCE_INLINE int GorillaEncoder::flush(common::ByteStream &out) { class FloatGorillaEncoder : public GorillaEncoder { public: - int do_encode(float value, common::ByteStream &out) { + int do_encode(float value, common::ByteStream& out) { int32_t value_int = common::float_to_int(value); return GorillaEncoder::do_encode(value_int, out); } - int flush(common::ByteStream &out) { + int flush(common::ByteStream& out) { // ending stream float f = GORILLA_ENCODING_ENDING_FLOAT; do_encode(f, out); @@ -316,21 +316,21 @@ class FloatGorillaEncoder : public GorillaEncoder { return common::E_OK; } - int encode(bool value, common::ByteStream &out_stream); - int encode(int32_t value, common::ByteStream &out_stream); - int encode(int64_t value, common::ByteStream &out_stream); - int encode(float value, common::ByteStream &out_stream); - int encode(double value, common::ByteStream &out_stream); + int encode(bool value, common::ByteStream& out_stream); + int encode(int32_t value, common::ByteStream& out_stream); + int encode(int64_t value, common::ByteStream& out_stream); + int encode(float value, common::ByteStream& out_stream); + int encode(double value, common::ByteStream& out_stream); }; class DoubleGorillaEncoder : public GorillaEncoder { public: - int do_encode(double value, common::ByteStream &out) { + int do_encode(double value, common::ByteStream& out) { int64_t value_long = common::double_to_long(value); return GorillaEncoder::do_encode(value_long, out); } - int flush(common::ByteStream &out) { + int flush(common::ByteStream& out) { // ending stream double d = GORILLA_ENCODING_ENDING_DOUBLE; do_encode(d, out); @@ -345,11 +345,11 @@ class DoubleGorillaEncoder : public GorillaEncoder { return common::E_OK; } - int encode(bool value, common::ByteStream &out_stream); - int encode(int32_t value, common::ByteStream &out_stream); - int encode(int64_t value, common::ByteStream &out_stream); - int encode(float value, common::ByteStream &out_stream); - int encode(double value, common::ByteStream &out_stream); + int encode(bool value, common::ByteStream& out_stream); + int encode(int32_t value, common::ByteStream& out_stream); + int encode(int64_t value, common::ByteStream& out_stream); + int encode(float value, common::ByteStream& out_stream); + int encode(double value, common::ByteStream& out_stream); }; typedef GorillaEncoder IntGorillaEncoder; @@ -357,123 +357,123 @@ typedef GorillaEncoder LongGorillaEncoder; template <> FORCE_INLINE int IntGorillaEncoder::encode(bool value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntGorillaEncoder::encode(int32_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return do_encode(value, out_stream); } template <> FORCE_INLINE int IntGorillaEncoder::encode(int64_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntGorillaEncoder::encode(float value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntGorillaEncoder::encode(double value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntGorillaEncoder::encode(common::String value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongGorillaEncoder::encode(bool value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongGorillaEncoder::encode(int32_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongGorillaEncoder::encode(int64_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return do_encode(value, out_stream); } template <> FORCE_INLINE int LongGorillaEncoder::encode(float value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongGorillaEncoder::encode(double value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongGorillaEncoder::encode(common::String value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatGorillaEncoder::encode(bool value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatGorillaEncoder::encode(int32_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatGorillaEncoder::encode(int64_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatGorillaEncoder::encode(float value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return do_encode(value, out_stream); } FORCE_INLINE int FloatGorillaEncoder::encode(double value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleGorillaEncoder::encode(bool value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleGorillaEncoder::encode(int32_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleGorillaEncoder::encode(int64_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleGorillaEncoder::encode(float value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { ASSERT(false); return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleGorillaEncoder::encode(double value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return do_encode(value, out_stream); } diff --git a/cpp/src/encoding/int32_rle_encoder.h b/cpp/src/encoding/int32_rle_encoder.h index 69ffc1b52..d9eecf5dd 100644 --- a/cpp/src/encoding/int32_rle_encoder.h +++ b/cpp/src/encoding/int32_rle_encoder.h @@ -35,13 +35,13 @@ class Int32RleEncoder : public Encoder { int bitpacked_group_count_; int num_buffered_values_; int bit_width_; - Int32Packer *packer_; + Int32Packer* packer_; common::ByteStream byte_cache_; std::vector values_; // all data tobe encoded int32_t buffered_values_[8]; // encode each 8 values std::vector bytes_buffer_; - void inner_flush(common::ByteStream &out) { + void inner_flush(common::ByteStream& out) { int last_bitpacked_num = num_buffered_values_; if (num_buffered_values_ > 0) { clear_buffer(); @@ -66,17 +66,17 @@ class Int32RleEncoder : public Encoder { byte_cache_(1024, common::MOD_ENCODER_OBJ) {} ~Int32RleEncoder() override { destroy(); } - int encode(bool value, common::ByteStream &out_stream) override { + int encode(bool value, common::ByteStream& out_stream) override { int32_t bool_value = value == true ? 1 : 0; return encode(bool_value, out_stream); } - int encode(float value, common::ByteStream &out_stream) override { + int encode(float value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(double value, common::ByteStream &out_stream) override { + int encode(double value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(common::String value, common::ByteStream &out_stream) override { + int encode(common::String value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } @@ -100,11 +100,11 @@ class Int32RleEncoder : public Encoder { packer_ = nullptr; } - FORCE_INLINE int encode(int64_t value, common::ByteStream &out) override { + FORCE_INLINE int encode(int64_t value, common::ByteStream& out) override { return common::E_TYPE_NOT_MATCH; } - FORCE_INLINE int encode(int32_t value, common::ByteStream &out) override { + FORCE_INLINE int encode(int32_t value, common::ByteStream& out) override { values_.push_back(value); // The current_bit_width must be at least 1, even if value is 0. int current_bit_width = @@ -115,7 +115,7 @@ class Int32RleEncoder : public Encoder { return common::E_OK; } - int flush(common::ByteStream &out) override { + int flush(common::ByteStream& out) override { ASSERT(packer_ == nullptr); if (bit_width_ == 0) return common::E_OK; packer_ = new Int32Packer(bit_width_); @@ -145,7 +145,7 @@ class Int32RleEncoder : public Encoder { void convert_buffer() { // TODO: put the bytes on the stack instead on the heap - unsigned char *bytes = (unsigned char *)common::mem_alloc( + unsigned char* bytes = (unsigned char*)common::mem_alloc( bit_width_, common::MOD_BITENCODE_OBJ); int32_t tmp_buffer[8]; for (int i = 0; i < 8; i++) { diff --git a/cpp/src/encoding/int32_sprintz_decoder.h b/cpp/src/encoding/int32_sprintz_decoder.h index ef98e978e..df9a7c8f1 100644 --- a/cpp/src/encoding/int32_sprintz_decoder.h +++ b/cpp/src/encoding/int32_sprintz_decoder.h @@ -51,35 +51,35 @@ class Int32SprintzDecoder : public SprintzDecoder { ~Int32SprintzDecoder() override = default; - void set_predict_method(const std::string &method) { + void set_predict_method(const std::string& method) { predict_scheme_ = method; } - bool has_remaining(const common::ByteStream &in) { + bool has_remaining(const common::ByteStream& in) { uint32_t min_len = sizeof(int32_t) + 1; return (is_block_read_ && current_count_ < block_size_) || in.remaining_size() >= min_len; } - int read_boolean(bool &ret_value, common::ByteStream &in) override { + int read_boolean(bool& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_int64(int64_t &ret_value, common::ByteStream &in) override { + int read_int64(int64_t& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_float(float &ret_value, common::ByteStream &in) override { + int read_float(float& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_double(double &ret_value, common::ByteStream &in) override { + int read_double(double& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_String(common::String &ret_value, common::PageArena &pa, - common::ByteStream &in) override { + int read_String(common::String& ret_value, common::PageArena& pa, + common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_int32(int32_t &ret_value, common::ByteStream &in) { + int read_int32(int32_t& ret_value, common::ByteStream& in) { int ret = common::E_OK; if (!is_block_read_) { if (RET_FAIL(decode_block(in))) { @@ -102,14 +102,14 @@ class Int32SprintzDecoder : public SprintzDecoder { std::fill(current_buffer_.begin(), current_buffer_.end(), 0); } - bool has_next(common::ByteStream &input) { + bool has_next(common::ByteStream& input) { uint32_t min_length = sizeof(int32_t) + 1; return (is_block_read_ && current_count_ < block_size_) || input.remaining_size() >= min_length; } protected: - int decode_block(common::ByteStream &input) override { + int decode_block(common::ByteStream& input) override { // read header bitWidth int ret = common::E_OK; uint8_t byte; @@ -136,8 +136,8 @@ class Int32SprintzDecoder : public SprintzDecoder { std::vector pack_buf(bit_width_); uint32_t read_len = 0; - input.read_buf(reinterpret_cast(pack_buf.data()), - bit_width_, read_len); + input.read_buf(reinterpret_cast(pack_buf.data()), bit_width_, + read_len); std::vector tmp_buffer(8); packer_ = std::make_shared(bit_width_); diff --git a/cpp/src/encoding/int64_rle_decoder.h b/cpp/src/encoding/int64_rle_decoder.h index 7b98cc0c2..b2f85ed1e 100644 --- a/cpp/src/encoding/int64_rle_decoder.h +++ b/cpp/src/encoding/int64_rle_decoder.h @@ -38,9 +38,9 @@ class Int64RleDecoder : public Decoder { bool is_length_and_bitwidth_readed_; int current_count_; common::ByteStream byte_cache_; - int64_t *current_buffer_; - Int64Packer *packer_; - uint8_t *tmp_buf_; + int64_t* current_buffer_; + Int64Packer* packer_; + uint8_t* tmp_buf_; public: Int64RleDecoder() @@ -55,27 +55,27 @@ class Int64RleDecoder : public Decoder { tmp_buf_(nullptr) {} ~Int64RleDecoder() override { destroy(); } - bool has_remaining(const common::ByteStream &buffer) override { + bool has_remaining(const common::ByteStream& buffer) override { return buffer.has_remaining() || has_next_package(); } - int read_boolean(bool &ret_value, common::ByteStream &in) override { + int read_boolean(bool& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_int32(int32_t &ret_value, common::ByteStream &in) override { + int read_int32(int32_t& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_int64(int64_t &ret_value, common::ByteStream &in) override { + int read_int64(int64_t& ret_value, common::ByteStream& in) override { ret_value = read_int(in); return common::E_OK; } - int read_float(float &ret_value, common::ByteStream &in) override { + int read_float(float& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_double(double &ret_value, common::ByteStream &in) override { + int read_double(double& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_String(common::String &ret_value, common::PageArena &pa, - common::ByteStream &in) override { + int read_String(common::String& ret_value, common::PageArena& pa, + common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } @@ -88,7 +88,7 @@ class Int64RleDecoder : public Decoder { current_count_ = 0; } - bool has_next(common::ByteStream &buffer) { + bool has_next(common::ByteStream& buffer) { if (current_count_ > 0 || buffer.remaining_size() > 0 || has_next_package()) { return true; @@ -100,7 +100,7 @@ class Int64RleDecoder : public Decoder { return current_count_ > 0 || byte_cache_.remaining_size() > 0; } - int64_t read_int(common::ByteStream &buffer) { + int64_t read_int(common::ByteStream& buffer) { if (!is_length_and_bitwidth_readed_) { // start to reader a new rle+bit-packing pattern read_length_and_bitwidth(buffer); @@ -169,25 +169,25 @@ class Int64RleDecoder : public Decoder { current_buffer_); // decode from bytes, save in currentBuffer } - int read_length_and_bitwidth(common::ByteStream &buffer) { + int read_length_and_bitwidth(common::ByteStream& buffer) { int ret = common::E_OK; if (RET_FAIL( common::SerializationUtil::read_var_uint(length_, buffer))) { return common::E_PARTIAL_READ; } else { tmp_buf_ = - (uint8_t *)common::mem_alloc(length_, common::MOD_DECODER_OBJ); + (uint8_t*)common::mem_alloc(length_, common::MOD_DECODER_OBJ); if (tmp_buf_ == nullptr) { return common::E_OOM; } uint32_t ret_read_len = 0; - if (RET_FAIL(buffer.read_buf((uint8_t *)tmp_buf_, length_, + if (RET_FAIL(buffer.read_buf((uint8_t*)tmp_buf_, length_, ret_read_len))) { return ret; } else if (length_ != ret_read_len) { ret = common::E_PARTIAL_READ; } - byte_cache_.wrap_from((char *)tmp_buf_, length_); + byte_cache_.wrap_from((char*)tmp_buf_, length_); is_length_and_bitwidth_readed_ = true; uint8_t tmp_bit_width; common::SerializationUtil::read_ui8(tmp_bit_width, byte_cache_); diff --git a/cpp/src/encoding/int64_rle_encoder.h b/cpp/src/encoding/int64_rle_encoder.h index abcac68b8..82fd40f38 100644 --- a/cpp/src/encoding/int64_rle_encoder.h +++ b/cpp/src/encoding/int64_rle_encoder.h @@ -35,13 +35,13 @@ class Int64RleEncoder : public Encoder { int bitpacked_group_count_; int num_buffered_values_; int bit_width_; - Int64Packer *packer_; + Int64Packer* packer_; common::ByteStream byte_cache_; std::vector values_; // all data tobe encoded int64_t buffered_values_[8]; // encode each 8 values std::vector bytes_buffer_; - void inner_flush(common::ByteStream &out) { + void inner_flush(common::ByteStream& out) { int last_bitpacked_num = num_buffered_values_; if (num_buffered_values_ > 0) { clear_buffer(); @@ -66,16 +66,16 @@ class Int64RleEncoder : public Encoder { byte_cache_(1024, common::MOD_ENCODER_OBJ) {} ~Int64RleEncoder() override { destroy(); } - int encode(bool value, common::ByteStream &out_stream) override { + int encode(bool value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(float value, common::ByteStream &out_stream) override { + int encode(float value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(double value, common::ByteStream &out_stream) override { + int encode(double value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(common::String value, common::ByteStream &out_stream) override { + int encode(common::String value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } @@ -100,7 +100,7 @@ class Int64RleEncoder : public Encoder { memset(buffered_values_, 0, sizeof(buffered_values_)); } - FORCE_INLINE int encode(int64_t value, common::ByteStream &out) override { + FORCE_INLINE int encode(int64_t value, common::ByteStream& out) override { values_.push_back(value); // The current_bit_width must be at least 1, even if value is 0. int current_bit_width = @@ -111,11 +111,11 @@ class Int64RleEncoder : public Encoder { return common::E_OK; } - FORCE_INLINE int encode(int32_t value, common::ByteStream &out) override { + FORCE_INLINE int encode(int32_t value, common::ByteStream& out) override { return common::E_TYPE_NOT_MATCH; } - int flush(common::ByteStream &out) override { + int flush(common::ByteStream& out) override { ASSERT(packer_ == nullptr); if (bit_width_ == 0) return common::E_OK; packer_ = new Int64Packer(bit_width_); @@ -145,7 +145,7 @@ class Int64RleEncoder : public Encoder { void convert_buffer() { // TODO: put the bytes on the stack instead on the heap - unsigned char *bytes = (unsigned char *)common::mem_alloc( + unsigned char* bytes = (unsigned char*)common::mem_alloc( bit_width_, common::MOD_BITENCODE_OBJ); int64_t tmp_buffer[8]; for (int i = 0; i < 8; i++) { diff --git a/cpp/src/encoding/plain_encoder.h b/cpp/src/encoding/plain_encoder.h index f04ca08e5..b768c9bf0 100644 --- a/cpp/src/encoding/plain_encoder.h +++ b/cpp/src/encoding/plain_encoder.h @@ -33,32 +33,32 @@ class PlainEncoder : public Encoder { void reset() { /* do thing for PlainEncoder */ } - FORCE_INLINE int encode(bool value, common::ByteStream &out_stream) { + FORCE_INLINE int encode(bool value, common::ByteStream& out_stream) { return common::SerializationUtil::write_i8(value ? 1 : 0, out_stream); } - FORCE_INLINE int encode(int32_t value, common::ByteStream &out_stream) { + FORCE_INLINE int encode(int32_t value, common::ByteStream& out_stream) { return common::SerializationUtil::write_var_int(value, out_stream); } - FORCE_INLINE int encode(int64_t value, common::ByteStream &out_stream) { + FORCE_INLINE int encode(int64_t value, common::ByteStream& out_stream) { return common::SerializationUtil::write_i64(value, out_stream); } - FORCE_INLINE int encode(float value, common::ByteStream &out_stream) { + FORCE_INLINE int encode(float value, common::ByteStream& out_stream) { return common::SerializationUtil::write_float(value, out_stream); } - FORCE_INLINE int encode(double value, common::ByteStream &out_stream) { + FORCE_INLINE int encode(double value, common::ByteStream& out_stream) { return common::SerializationUtil::write_double(value, out_stream); } FORCE_INLINE int encode(common::String value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return common::SerializationUtil::write_mystring(value, out_stream); } - int flush(common::ByteStream &out_stream) { + int flush(common::ByteStream& out_stream) { // do nothing for PlainEncoder return common::E_OK; } diff --git a/cpp/src/encoding/ts2diff_decoder.h b/cpp/src/encoding/ts2diff_decoder.h index c1e102700..c43dcf9d3 100644 --- a/cpp/src/encoding/ts2diff_decoder.h +++ b/cpp/src/encoding/ts2diff_decoder.h @@ -48,19 +48,19 @@ class TS2DIFFDecoder : public Decoder { current_index_ = 0; } - FORCE_INLINE bool has_remaining(const common::ByteStream &buffer) { + FORCE_INLINE bool has_remaining(const common::ByteStream& buffer) { if (buffer.has_remaining()) return true; return bits_left_ != 0 || (current_index_ <= write_index_ && write_index_ != -1 && current_index_ != 0); } - void read_header(common::ByteStream &in) { + void read_header(common::ByteStream& in) { common::SerializationUtil::read_i32(write_index_, in); common::SerializationUtil::read_i32(bit_width_, in); } // If empty, cache 8 bits from in_stream to 'buffer_'. - void read_byte_if_empty(common::ByteStream &in) { + void read_byte_if_empty(common::ByteStream& in) { if (bits_left_ == 0) { uint32_t read_len = 0; in.read_buf(&buffer_, 1, read_len); @@ -70,7 +70,7 @@ class TS2DIFFDecoder : public Decoder { } } - int64_t read_long(int bits, common::ByteStream &in) { + int64_t read_long(int bits, common::ByteStream& in) { int64_t value = 0; while (bits > 0) { read_byte_if_empty(in); @@ -97,14 +97,14 @@ class TS2DIFFDecoder : public Decoder { return value; } - T decode(common::ByteStream &in); - int read_boolean(bool &ret_value, common::ByteStream &in); - int read_int32(int32_t &ret_value, common::ByteStream &in); - int read_int64(int64_t &ret_value, common::ByteStream &in); - int read_float(float &ret_value, common::ByteStream &in); - int read_double(double &ret_value, common::ByteStream &in); - int read_String(common::String &ret_value, common::PageArena &pa, - common::ByteStream &in); + T decode(common::ByteStream& in); + int read_boolean(bool& ret_value, common::ByteStream& in); + int read_int32(int32_t& ret_value, common::ByteStream& in); + int read_int64(int64_t& ret_value, common::ByteStream& in); + int read_float(float& ret_value, common::ByteStream& in); + int read_double(double& ret_value, common::ByteStream& in); + int read_String(common::String& ret_value, common::PageArena& pa, + common::ByteStream& in); public: T first_value_; @@ -119,7 +119,7 @@ class TS2DIFFDecoder : public Decoder { }; template <> -inline int32_t TS2DIFFDecoder::decode(common::ByteStream &in) { +inline int32_t TS2DIFFDecoder::decode(common::ByteStream& in) { int32_t ret_value = stored_value_; if (UNLIKELY(current_index_ == 0)) { read_header(in); @@ -148,7 +148,7 @@ inline int32_t TS2DIFFDecoder::decode(common::ByteStream &in) { } template <> -inline int64_t TS2DIFFDecoder::decode(common::ByteStream &in) { +inline int64_t TS2DIFFDecoder::decode(common::ByteStream& in) { int64_t ret_value = stored_value_; if (UNLIKELY(current_index_ == 0)) { read_header(in); @@ -174,30 +174,30 @@ inline int64_t TS2DIFFDecoder::decode(common::ByteStream &in) { class FloatTS2DIFFDecoder : public TS2DIFFDecoder { public: - float decode(common::ByteStream &in) { + float decode(common::ByteStream& in) { int32_t value_int = TS2DIFFDecoder::decode(in); return common::int_to_float(value_int); } - int read_boolean(bool &ret_value, common::ByteStream &in); - int read_int32(int32_t &ret_value, common::ByteStream &in); - int read_int64(int64_t &ret_value, common::ByteStream &in); - int read_float(float &ret_value, common::ByteStream &in); - int read_double(double &ret_value, common::ByteStream &in); + int read_boolean(bool& ret_value, common::ByteStream& in); + int read_int32(int32_t& ret_value, common::ByteStream& in); + int read_int64(int64_t& ret_value, common::ByteStream& in); + int read_float(float& ret_value, common::ByteStream& in); + int read_double(double& ret_value, common::ByteStream& in); }; class DoubleTS2DIFFDecoder : public TS2DIFFDecoder { public: - double decode(common::ByteStream &in) { + double decode(common::ByteStream& in) { int64_t value_long = TS2DIFFDecoder::decode(in); return common::long_to_double(value_long); } - int read_boolean(bool &ret_value, common::ByteStream &in); - int read_int32(int32_t &ret_value, common::ByteStream &in); - int read_int64(int64_t &ret_value, common::ByteStream &in); - int read_float(float &ret_value, common::ByteStream &in); - int read_double(double &ret_value, common::ByteStream &in); + int read_boolean(bool& ret_value, common::ByteStream& in); + int read_int32(int32_t& ret_value, common::ByteStream& in); + int read_int64(int64_t& ret_value, common::ByteStream& in); + int read_float(float& ret_value, common::ByteStream& in); + int read_double(double& ret_value, common::ByteStream& in); }; typedef TS2DIFFDecoder IntTS2DIFFDecoder; @@ -205,126 +205,126 @@ typedef TS2DIFFDecoder LongTS2DIFFDecoder; // wrap as Decoder interface template <> -FORCE_INLINE int IntTS2DIFFDecoder::read_boolean(bool &ret_value, - common::ByteStream &in) { +FORCE_INLINE int IntTS2DIFFDecoder::read_boolean(bool& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int IntTS2DIFFDecoder::read_int32(int32_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int IntTS2DIFFDecoder::read_int32(int32_t& ret_value, + common::ByteStream& in) { ret_value = decode(in); return common::E_OK; } template <> -FORCE_INLINE int IntTS2DIFFDecoder::read_int64(int64_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int IntTS2DIFFDecoder::read_int64(int64_t& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int IntTS2DIFFDecoder::read_float(float &ret_value, - common::ByteStream &in) { +FORCE_INLINE int IntTS2DIFFDecoder::read_float(float& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int IntTS2DIFFDecoder::read_double(double &ret_value, - common::ByteStream &in) { +FORCE_INLINE int IntTS2DIFFDecoder::read_double(double& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int IntTS2DIFFDecoder::read_String(common::String &ret_value, - common::PageArena &pa, - common::ByteStream &in) { +FORCE_INLINE int IntTS2DIFFDecoder::read_String(common::String& ret_value, + common::PageArena& pa, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int LongTS2DIFFDecoder::read_boolean(bool &ret_value, - common::ByteStream &in) { +FORCE_INLINE int LongTS2DIFFDecoder::read_boolean(bool& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int LongTS2DIFFDecoder::read_int32(int32_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int LongTS2DIFFDecoder::read_int32(int32_t& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int LongTS2DIFFDecoder::read_int64(int64_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int LongTS2DIFFDecoder::read_int64(int64_t& ret_value, + common::ByteStream& in) { ret_value = decode(in); return common::E_OK; } template <> -FORCE_INLINE int LongTS2DIFFDecoder::read_float(float &ret_value, - common::ByteStream &in) { +FORCE_INLINE int LongTS2DIFFDecoder::read_float(float& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int LongTS2DIFFDecoder::read_double(double &ret_value, - common::ByteStream &in) { +FORCE_INLINE int LongTS2DIFFDecoder::read_double(double& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } template <> -FORCE_INLINE int LongTS2DIFFDecoder::read_String(common::String &ret_value, - common::PageArena &pa, - common::ByteStream &in) { +FORCE_INLINE int LongTS2DIFFDecoder::read_String(common::String& ret_value, + common::PageArena& pa, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int FloatTS2DIFFDecoder::read_boolean(bool &ret_value, - common::ByteStream &in) { +FORCE_INLINE int FloatTS2DIFFDecoder::read_boolean(bool& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int FloatTS2DIFFDecoder::read_int32(int32_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int FloatTS2DIFFDecoder::read_int32(int32_t& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int FloatTS2DIFFDecoder::read_int64(int64_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int FloatTS2DIFFDecoder::read_int64(int64_t& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int FloatTS2DIFFDecoder::read_float(float &ret_value, - common::ByteStream &in) { +FORCE_INLINE int FloatTS2DIFFDecoder::read_float(float& ret_value, + common::ByteStream& in) { ret_value = decode(in); return common::E_OK; } -FORCE_INLINE int FloatTS2DIFFDecoder::read_double(double &ret_value, - common::ByteStream &in) { +FORCE_INLINE int FloatTS2DIFFDecoder::read_double(double& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int DoubleTS2DIFFDecoder::read_boolean(bool &ret_value, - common::ByteStream &in) { +FORCE_INLINE int DoubleTS2DIFFDecoder::read_boolean(bool& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int DoubleTS2DIFFDecoder::read_int32(int32_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int DoubleTS2DIFFDecoder::read_int32(int32_t& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int DoubleTS2DIFFDecoder::read_int64(int64_t &ret_value, - common::ByteStream &in) { +FORCE_INLINE int DoubleTS2DIFFDecoder::read_int64(int64_t& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int DoubleTS2DIFFDecoder::read_float(float &ret_value, - common::ByteStream &in) { +FORCE_INLINE int DoubleTS2DIFFDecoder::read_float(float& ret_value, + common::ByteStream& in) { ASSERT(false); return common::E_NOT_SUPPORT; } -FORCE_INLINE int DoubleTS2DIFFDecoder::read_double(double &ret_value, - common::ByteStream &in) { +FORCE_INLINE int DoubleTS2DIFFDecoder::read_double(double& ret_value, + common::ByteStream& in) { ret_value = decode(in); return common::E_OK; } diff --git a/cpp/src/encoding/ts2diff_encoder.h b/cpp/src/encoding/ts2diff_encoder.h index db3a28303..18272e3e2 100644 --- a/cpp/src/encoding/ts2diff_encoder.h +++ b/cpp/src/encoding/ts2diff_encoder.h @@ -41,21 +41,21 @@ struct SIMDOps; template <> struct SIMDOps { #ifdef USE_SSE - static void rebase(int32_t *arr, int32_t min_val, size_t size) { + static void rebase(int32_t* arr, int32_t min_val, size_t size) { const __m128i min_vec = _mm_set1_epi32(min_val); size_t i = 0; for (; i + 3 < size; i += 4) { __m128i vec = - _mm_loadu_si128(reinterpret_cast(arr + i)); + _mm_loadu_si128(reinterpret_cast(arr + i)); vec = _mm_sub_epi32(vec, min_vec); - _mm_storeu_si128(reinterpret_cast<__m128i *>(arr + i), vec); + _mm_storeu_si128(reinterpret_cast<__m128i*>(arr + i), vec); } for (; i < size; ++i) { arr[i] -= min_val; } } #else - static void rebase(int32_t *arr, int32_t min_val, size_t size) { + static void rebase(int32_t* arr, int32_t min_val, size_t size) { for (size_t i = 0; i < size; ++i) { arr[i] -= min_val; } @@ -66,21 +66,21 @@ struct SIMDOps { template <> struct SIMDOps { #ifdef USE_AVX2 - static void rebase(int64_t *arr, int64_t min_val, size_t size) { + static void rebase(int64_t* arr, int64_t min_val, size_t size) { const __m256i min_vec = _mm256_set1_epi64x(min_val); size_t i = 0; for (; i + 3 < size; i += 4) { __m256i vec = - _mm256_loadu_si256(reinterpret_cast(arr + i)); + _mm256_loadu_si256(reinterpret_cast(arr + i)); vec = _mm256_sub_epi64(vec, min_vec); - _mm256_storeu_si256(reinterpret_cast<__m256i *>(arr + i), vec); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(arr + i), vec); } for (; i < size; ++i) { arr[i] -= min_val; } } #else - static void rebase(int64_t *arr, int64_t min_val, size_t size) { + static void rebase(int64_t* arr, int64_t min_val, size_t size) { for (size_t i = 0; i < size; ++i) { arr[i] -= min_val; } @@ -100,8 +100,8 @@ class TS2DIFFEncoder : public Encoder { void init() { block_size_ = 128; // block_size_ = 16; - delta_arr_ = (T *)common::mem_alloc(sizeof(T) * block_size_, - common::MOD_TS2DIFF_OBJ); + delta_arr_ = (T*)common::mem_alloc(sizeof(T) * block_size_, + common::MOD_TS2DIFF_OBJ); write_index_ = -1; bits_left_ = 8; buffer_ = 0; @@ -118,7 +118,7 @@ class TS2DIFFEncoder : public Encoder { } } - void write_bits(int64_t value, int bits, common::ByteStream &out_stream) { + void write_bits(int64_t value, int bits, common::ByteStream& out_stream) { while (bits > 0) { int shift = bits - bits_left_; if (shift >= 0) { @@ -136,7 +136,7 @@ class TS2DIFFEncoder : public Encoder { } } - void flush_remaining(common::ByteStream &out_stream) { + void flush_remaining(common::ByteStream& out_stream) { // FIXME bits_left_ != 0 does not means something to be flushed. (=8) if (bits_left_ != 0 && bits_left_ != 8) { bits_left_ = 0; @@ -144,7 +144,7 @@ class TS2DIFFEncoder : public Encoder { } } - void flush_byte_if_full(common::ByteStream &out_stream) { + void flush_byte_if_full(common::ByteStream& out_stream) { if (bits_left_ == 0) { out_stream.write_buf(&buffer_, 1); buffer_ = 0; @@ -163,15 +163,15 @@ class TS2DIFFEncoder : public Encoder { return bit_width; } - int do_encode(T value, common::ByteStream &out_stream); - int encode(bool value, common::ByteStream &out_stream); - int encode(int32_t value, common::ByteStream &out_stream); - int encode(int64_t value, common::ByteStream &out_stream); - int encode(float value, common::ByteStream &out_stream); - int encode(double value, common::ByteStream &out_stream); - int encode(common::String value, common::ByteStream &out_stream); + int do_encode(T value, common::ByteStream& out_stream); + int encode(bool value, common::ByteStream& out_stream); + int encode(int32_t value, common::ByteStream& out_stream); + int encode(int64_t value, common::ByteStream& out_stream); + int encode(float value, common::ByteStream& out_stream); + int encode(double value, common::ByteStream& out_stream); + int encode(common::String value, common::ByteStream& out_stream); - int flush(common::ByteStream &out_stream); + int flush(common::ByteStream& out_stream); int get_max_byte_size() { // The meaning of 24 is: index(4)+width(4)+minDeltaBase(8)+firstValue(8) @@ -180,7 +180,7 @@ class TS2DIFFEncoder : public Encoder { public: int block_size_; - T *delta_arr_; + T* delta_arr_; T first_value_; T previous_value_; T delta_arr_min_; @@ -191,7 +191,7 @@ class TS2DIFFEncoder : public Encoder { }; template -int TS2DIFFEncoder::do_encode(T value, common::ByteStream &out_stream) { +int TS2DIFFEncoder::do_encode(T value, common::ByteStream& out_stream) { if (write_index_ == -1) { first_value_ = value; previous_value_ = first_value_; @@ -222,7 +222,7 @@ int TS2DIFFEncoder::do_encode(T value, common::ByteStream &out_stream) { } template <> -inline int TS2DIFFEncoder::flush(common::ByteStream &out_stream) { +inline int TS2DIFFEncoder::flush(common::ByteStream& out_stream) { int ret = common::E_OK; if (write_index_ == -1) { return common::E_OK; @@ -246,7 +246,7 @@ inline int TS2DIFFEncoder::flush(common::ByteStream &out_stream) { } template <> -inline int TS2DIFFEncoder::flush(common::ByteStream &out_stream) { +inline int TS2DIFFEncoder::flush(common::ByteStream& out_stream) { int ret = common::E_OK; if (write_index_ == -1) { return common::E_OK; @@ -271,28 +271,28 @@ inline int TS2DIFFEncoder::flush(common::ByteStream &out_stream) { class FloatTS2DIFFEncoder : public TS2DIFFEncoder { public: - int do_encode(float value, common::ByteStream &out_stream) { + int do_encode(float value, common::ByteStream& out_stream) { int32_t value_int = common::float_to_int(value); return TS2DIFFEncoder::do_encode(value_int, out_stream); } - int encode(bool value, common::ByteStream &out_stream); - int encode(int32_t value, common::ByteStream &out_stream); - int encode(int64_t value, common::ByteStream &out_stream); - int encode(float value, common::ByteStream &out_stream); - int encode(double value, common::ByteStream &out_stream); + int encode(bool value, common::ByteStream& out_stream); + int encode(int32_t value, common::ByteStream& out_stream); + int encode(int64_t value, common::ByteStream& out_stream); + int encode(float value, common::ByteStream& out_stream); + int encode(double value, common::ByteStream& out_stream); }; class DoubleTS2DIFFEncoder : public TS2DIFFEncoder { public: - int do_encode(double value, common::ByteStream &out_stream) { + int do_encode(double value, common::ByteStream& out_stream) { int64_t value_long = common::double_to_long(value); return TS2DIFFEncoder::do_encode(value_long, out_stream); } - int encode(bool value, common::ByteStream &out_stream); - int encode(int32_t value, common::ByteStream &out_stream); - int encode(int64_t value, common::ByteStream &out_stream); - int encode(float value, common::ByteStream &out_stream); - int encode(double value, common::ByteStream &out_stream); + int encode(bool value, common::ByteStream& out_stream); + int encode(int32_t value, common::ByteStream& out_stream); + int encode(int64_t value, common::ByteStream& out_stream); + int encode(float value, common::ByteStream& out_stream); + int encode(double value, common::ByteStream& out_stream); }; typedef TS2DIFFEncoder IntTS2DIFFEncoder; @@ -301,104 +301,104 @@ typedef TS2DIFFEncoder LongTS2DIFFEncoder; // wrap as Encoder template <> FORCE_INLINE int IntTS2DIFFEncoder::encode(bool value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntTS2DIFFEncoder::encode(int32_t value, - common::ByteStream &out) { + common::ByteStream& out) { return do_encode(value, out); } template <> FORCE_INLINE int IntTS2DIFFEncoder::encode(int64_t value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntTS2DIFFEncoder::encode(float value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntTS2DIFFEncoder::encode(double value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int IntTS2DIFFEncoder::encode(common::String value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongTS2DIFFEncoder::encode(bool value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongTS2DIFFEncoder::encode(int32_t value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongTS2DIFFEncoder::encode(int64_t value, - common::ByteStream &out) { + common::ByteStream& out) { return do_encode(value, out); } template <> FORCE_INLINE int LongTS2DIFFEncoder::encode(float value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongTS2DIFFEncoder::encode(double value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } template <> FORCE_INLINE int LongTS2DIFFEncoder::encode(common::String value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatTS2DIFFEncoder::encode(bool value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatTS2DIFFEncoder::encode(int32_t value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatTS2DIFFEncoder::encode(int64_t value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int FloatTS2DIFFEncoder::encode(float value, - common::ByteStream &out) { + common::ByteStream& out) { return do_encode(value, out); } FORCE_INLINE int FloatTS2DIFFEncoder::encode(double value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleTS2DIFFEncoder::encode(bool value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleTS2DIFFEncoder::encode(int32_t value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleTS2DIFFEncoder::encode(int64_t value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleTS2DIFFEncoder::encode(float value, - common::ByteStream &out) { + common::ByteStream& out) { return common::E_TYPE_NOT_MATCH; } FORCE_INLINE int DoubleTS2DIFFEncoder::encode(double value, - common::ByteStream &out) { + common::ByteStream& out) { return do_encode(value, out); } diff --git a/cpp/src/encoding/zigzag_decoder.h b/cpp/src/encoding/zigzag_decoder.h index e12f74897..69ef3b209 100644 --- a/cpp/src/encoding/zigzag_decoder.h +++ b/cpp/src/encoding/zigzag_decoder.h @@ -46,28 +46,28 @@ class ZigzagDecoder : public Decoder { zigzag_decode_arr_ = nullptr; } - bool has_remaining(const common::ByteStream &buffer) override { + bool has_remaining(const common::ByteStream& buffer) override { return buffer.has_remaining() || !list_transit_in_zd_.empty(); } - int read_boolean(bool &ret_value, common::ByteStream &in) override { + int read_boolean(bool& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - inline int read_int32(int32_t &ret_value, common::ByteStream &in) override { + inline int read_int32(int32_t& ret_value, common::ByteStream& in) override { ret_value = decode(in); return common::E_OK; } - inline int read_int64(int64_t &ret_value, common::ByteStream &in) override { + inline int read_int64(int64_t& ret_value, common::ByteStream& in) override { ret_value = decode(in); return common::E_OK; } - int read_float(float &ret_value, common::ByteStream &in) override { + int read_float(float& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_double(double &ret_value, common::ByteStream &in) override { + int read_double(double& ret_value, common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } - int read_String(common::String &ret_value, common::PageArena &pa, - common::ByteStream &in) override { + int read_String(common::String& ret_value, common::PageArena& pa, + common::ByteStream& in) override { return common::E_TYPE_NOT_MATCH; } @@ -97,12 +97,12 @@ class ZigzagDecoder : public Decoder { } } - void read_header(common::ByteStream &in) { + void read_header(common::ByteStream& in) { common::SerializationUtil::read_var_uint(zigzag_length_, in); common::SerializationUtil::read_var_uint(int_length_, in); } - void flush_byte_if_empty(common::ByteStream &in) { + void flush_byte_if_empty(common::ByteStream& in) { if (bits_left_ == 0) { uint32_t read_len = 0; in.read_buf(&buffer_, 1, read_len); @@ -147,11 +147,11 @@ class ZigzagDecoder : public Decoder { return stored_value_; } - inline T decode(common::ByteStream &in); + inline T decode(common::ByteStream& in); public: common::TSEncoding type_; - uint8_t *zigzag_decode_arr_; + uint8_t* zigzag_decode_arr_; uint64_t stored_value_; int bits_left_; uint8_t buffer_; @@ -164,11 +164,11 @@ class ZigzagDecoder : public Decoder { }; template <> -inline int32_t ZigzagDecoder::decode(common::ByteStream &in) { +inline int32_t ZigzagDecoder::decode(common::ByteStream& in) { if (UNLIKELY(first_read_ == true)) { read_header(in); zigzag_decode_arr_ = - (uint8_t *)common::mem_alloc(10, common::MOD_ZIGZAG_OBJ); + (uint8_t*)common::mem_alloc(10, common::MOD_ZIGZAG_OBJ); buffer_ = 0; first_read_ = false; list_transit_in_zd_.clear(); @@ -197,11 +197,11 @@ inline int32_t ZigzagDecoder::decode(common::ByteStream &in) { } template <> -inline int64_t ZigzagDecoder::decode(common::ByteStream &in) { +inline int64_t ZigzagDecoder::decode(common::ByteStream& in) { if (UNLIKELY(first_read_ == true)) { read_header(in); zigzag_decode_arr_ = - (uint8_t *)common::mem_alloc(10, common::MOD_ZIGZAG_OBJ); + (uint8_t*)common::mem_alloc(10, common::MOD_ZIGZAG_OBJ); buffer_ = 0; first_read_ = false; list_transit_in_zd_.clear(); diff --git a/cpp/src/encoding/zigzag_encoder.h b/cpp/src/encoding/zigzag_encoder.h index 841b8b050..96d3cb9cc 100644 --- a/cpp/src/encoding/zigzag_encoder.h +++ b/cpp/src/encoding/zigzag_encoder.h @@ -38,18 +38,18 @@ class ZigzagEncoder : public Encoder { void destroy() override {} // int init(common::TSDataType data_type) = 0; - int encode(bool value, common::ByteStream &out_stream) override { + int encode(bool value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(int32_t value, common::ByteStream &out_stream) override; - int encode(int64_t value, common::ByteStream &out_stream) override; - int encode(float value, common::ByteStream &out_stream) override { + int encode(int32_t value, common::ByteStream& out_stream) override; + int encode(int64_t value, common::ByteStream& out_stream) override; + int encode(float value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(double value, common::ByteStream &out_stream) override { + int encode(double value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } - int encode(common::String value, common::ByteStream &out_stream) override { + int encode(common::String value, common::ByteStream& out_stream) override { return common::E_TYPE_NOT_MATCH; } @@ -77,7 +77,7 @@ class ZigzagEncoder : public Encoder { first_read_ = true; } - void flush_byte(common::ByteStream &out) { + void flush_byte(common::ByteStream& out) { out.write_buf(&buffer_, 1); buffer_ = 0; } @@ -100,7 +100,7 @@ class ZigzagEncoder : public Encoder { inline int encode(T value); - inline int flush(common::ByteStream &out) override; + inline int flush(common::ByteStream& out) override; public: common::TSEncoding type_; @@ -113,13 +113,13 @@ class ZigzagEncoder : public Encoder { template inline int ZigzagEncoder::encode(int32_t /*value*/, - common::ByteStream & /*out*/) { + common::ByteStream& /*out*/) { return common::E_TYPE_NOT_MATCH; } template inline int ZigzagEncoder::encode(int64_t /*value*/, - common::ByteStream & /*out*/) { + common::ByteStream& /*out*/) { return common::E_TYPE_NOT_MATCH; } @@ -151,7 +151,7 @@ inline int ZigzagEncoder::encode(int32_t value) { template <> inline int ZigzagEncoder::encode(int32_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return encode(value); } @@ -183,12 +183,12 @@ inline int ZigzagEncoder::encode(int64_t value) { template <> inline int ZigzagEncoder::encode(int64_t value, - common::ByteStream &out_stream) { + common::ByteStream& out_stream) { return encode(value); } template <> -inline int ZigzagEncoder::flush(common::ByteStream &out) { +inline int ZigzagEncoder::flush(common::ByteStream& out) { common::SerializationUtil::write_var_uint(length_of_encode_bytestream_, out); common::SerializationUtil::write_var_uint(length_of_input_bytestream_, out); @@ -202,7 +202,7 @@ inline int ZigzagEncoder::flush(common::ByteStream &out) { } template <> -inline int ZigzagEncoder::flush(common::ByteStream &out) { +inline int ZigzagEncoder::flush(common::ByteStream& out) { common::SerializationUtil::write_var_uint(length_of_encode_bytestream_, out); common::SerializationUtil::write_var_uint(length_of_input_bytestream_, out); diff --git a/cpp/src/file/open_file.cc b/cpp/src/file/open_file.cc index 1d9002466..1fe5a3682 100644 --- a/cpp/src/file/open_file.cc +++ b/cpp/src/file/open_file.cc @@ -24,7 +24,7 @@ using namespace common; namespace storage { int OpenFile::init() { - void *buf = mem_alloc(sizeof(TsTimeRangeMap), MOD_OPEN_FILE_OBJ); + void* buf = mem_alloc(sizeof(TsTimeRangeMap), MOD_OPEN_FILE_OBJ); fd_ = -1; if (IS_NULL(buf)) { return E_OOM; @@ -46,19 +46,19 @@ void OpenFile::reset() { } } -void OpenFile::set_file_id_and_path(const FileID &file_id, - const std::string &file_path) { +void OpenFile::set_file_id_and_path(const FileID& file_id, + const std::string& file_path) { ASSERT(file_id.is_valid()); file_id_ = file_id; file_path_ = file_path; } int OpenFile::build_from( - const std::vector &time_index_vec) { + const std::vector& time_index_vec) { MutexGuard mg(mutex_); ASSERT(ts_time_range_map_ != nullptr); for (size_t i = 0; i < time_index_vec.size(); i++) { - const TimeseriesTimeIndexEntry &ti_entry = time_index_vec[i]; + const TimeseriesTimeIndexEntry& ti_entry = time_index_vec[i]; std::pair pair; pair.first = ti_entry.ts_id_; pair.second = ti_entry.time_range_; @@ -71,7 +71,7 @@ int OpenFile::build_from( return E_OK; } -int OpenFile::add(const TsID &ts_id, const TimeRange &time_range) { +int OpenFile::add(const TsID& ts_id, const TimeRange& time_range) { MutexGuard mg(mutex_); TsTimeRangeMapIterator find_iter = ts_time_range_map_->find(ts_id); if (find_iter != ts_time_range_map_->end()) { @@ -90,14 +90,14 @@ int OpenFile::add(const TsID &ts_id, const TimeRange &time_range) { return E_OK; } -bool OpenFile::contain_timeseries(const TsID &ts_id) const { +bool OpenFile::contain_timeseries(const TsID& ts_id) const { MutexGuard mg(mutex_); TsTimeRangeMapIterator find_iter = ts_time_range_map_->find(ts_id); return find_iter != ts_time_range_map_->end(); } -int OpenFile::get_time_range(const TsID &ts_id, - TimeRange &ret_time_range) const { +int OpenFile::get_time_range(const TsID& ts_id, + TimeRange& ret_time_range) const { int ret = E_OK; MutexGuard mg(mutex_); TsTimeRangeMapIterator find_iter = ts_time_range_map_->find(ts_id); diff --git a/cpp/src/file/open_file.h b/cpp/src/file/open_file.h index f1189e96e..7b42ff95f 100644 --- a/cpp/src/file/open_file.h +++ b/cpp/src/file/open_file.h @@ -68,19 +68,19 @@ class OpenFile { // reset the map to reclaim memory void reset(); - void set_file_id_and_path(const common::FileID &file_id, - const std::string &file_path); + void set_file_id_and_path(const common::FileID& file_id, + const std::string& file_path); FORCE_INLINE common::FileID get_file_id() { return file_id_; } FORCE_INLINE std::string get_file_path() { return file_path_; } - int build_from(const std::vector &time_index_vec); - int add(const common::TsID &ts_id, const TimeRange &time_range); + int build_from(const std::vector& time_index_vec); + int add(const common::TsID& ts_id, const TimeRange& time_range); - bool contain_timeseries(const common::TsID &ts_id) const; - int get_time_range(const common::TsID &ts_id, - TimeRange &ret_time_range) const; + bool contain_timeseries(const common::TsID& ts_id) const; + int get_time_range(const common::TsID& ts_id, + TimeRange& ret_time_range) const; #ifndef NDEBUG - friend std::ostream &operator<<(std::ostream &out, OpenFile &open_file) { + friend std::ostream& operator<<(std::ostream& out, OpenFile& open_file) { out << "file_id=" << open_file.file_id_ << ", file_path=" << open_file.file_path_ << ", fd=" << open_file.fd_ << ", ts_time_range_map="; @@ -109,16 +109,16 @@ class OpenFile { * Why use pointer instead of object: * we may want to reclaim the memory in case of memory overused. */ - BloomFilter *bloom_filter_; - TsTimeRangeMap - *ts_time_range_map_; // TODO: use custom hashtable to monitor memory. + BloomFilter* bloom_filter_; + TsTimeRangeMap* + ts_time_range_map_; // TODO: use custom hashtable to monitor memory. mutable common::Mutex mutex_; }; class OpenFileFactory { public: - static OpenFile *alloc() { - void *buf = + static OpenFile* alloc() { + void* buf = common::mem_alloc(sizeof(OpenFile), common::MOD_OPEN_FILE_OBJ); if (IS_NULL(buf)) { return nullptr; @@ -126,7 +126,7 @@ class OpenFileFactory { return new (buf) OpenFile; } - static void free(OpenFile *of) { + static void free(OpenFile* of) { if (of != nullptr) { common::mem_free(of); } diff --git a/cpp/src/file/read_file.cc b/cpp/src/file/read_file.cc index cc08bf25b..6fa9b809a 100644 --- a/cpp/src/file/read_file.cc +++ b/cpp/src/file/read_file.cc @@ -30,7 +30,7 @@ #include #include -ssize_t pread(int fd, void *buf, size_t count, uint64_t offset); +ssize_t pread(int fd, void* buf, size_t count, uint64_t offset); #endif using namespace common; @@ -44,7 +44,7 @@ void ReadFile::close() { file_size_ = -1; } -int ReadFile::open(const std::string &file_path) { +int ReadFile::open(const std::string& file_path) { int ret = E_OK; file_path_ = file_path; fd_ = ::open(file_path_.c_str(), O_RDONLY); @@ -65,7 +65,7 @@ int ReadFile::open(const std::string &file_path) { return ret; } -int ReadFile::get_file_size(int32_t &file_size) { +int ReadFile::get_file_size(int32_t& file_size) { struct stat s; if (fstat(fd_, &s) < 0) { LOGE("fstat error, file_path=" << file_path_.c_str() << "fd=" << fd_ @@ -109,8 +109,8 @@ int ReadFile::check_file_magic() { return ret; } -int ReadFile::read(int32_t offset, char *buf, int32_t buf_size, - int32_t &read_len) { +int ReadFile::read(int32_t offset, char* buf, int32_t buf_size, + int32_t& read_len) { int ret = E_OK; read_len = 0; while (read_len < buf_size) { @@ -133,7 +133,7 @@ int ReadFile::read(int32_t offset, char *buf, int32_t buf_size, } // end namespace storage #ifdef _WIN32 -ssize_t pread(int fd, void *buf, size_t count, uint64_t offset) { +ssize_t pread(int fd, void* buf, size_t count, uint64_t offset) { long unsigned int read_bytes = 0; OVERLAPPED overlapped; diff --git a/cpp/src/file/read_file.h b/cpp/src/file/read_file.h index a06482842..64fe25f51 100644 --- a/cpp/src/file/read_file.h +++ b/cpp/src/file/read_file.h @@ -35,21 +35,21 @@ class ReadFile { ~ReadFile() { destroy(); } void destroy() { close(); } - int open(const std::string &file_path); + int open(const std::string& file_path); FORCE_INLINE bool is_opened() const { return fd_ > 0; } FORCE_INLINE int32_t file_size() const { return file_size_; } - FORCE_INLINE const std::string &file_path() const { return file_path_; } + FORCE_INLINE const std::string& file_path() const { return file_path_; } /* * try to reader @buf_size bytes from @offset of this file * into @buf. @read_len return the actual len reader. */ - int read(int32_t offset, char *buf, int32_t buf_size, - int32_t &ret_read_len); + int read(int32_t offset, char* buf, int32_t buf_size, + int32_t& ret_read_len); void close(); private: - int get_file_size(int32_t &file_size); + int get_file_size(int32_t& file_size); int check_file_magic(); private: diff --git a/cpp/src/file/tsfile_io_reader.h b/cpp/src/file/tsfile_io_reader.h index 709dd3543..a62ccc145 100644 --- a/cpp/src/file/tsfile_io_reader.h +++ b/cpp/src/file/tsfile_io_reader.h @@ -48,41 +48,41 @@ class TsFileIOReader { tsfile_meta_page_arena_.init(512, common::MOD_DEFAULT); } - int init(const std::string &file_path); + int init(const std::string& file_path); - int init(ReadFile *read_file); + int init(ReadFile* read_file); void reset(); int alloc_ssi(std::shared_ptr device_id, - const std::string &measurement_name, - TsFileSeriesScanIterator *&ssi, common::PageArena &pa, - Filter *time_filter = nullptr); + const std::string& measurement_name, + TsFileSeriesScanIterator*& ssi, common::PageArena& pa, + Filter* time_filter = nullptr); - void revert_ssi(TsFileSeriesScanIterator *ssi); + void revert_ssi(TsFileSeriesScanIterator* ssi); std::string get_file_path() const { return read_file_->file_path(); } - TsFileMeta *get_tsfile_meta() { + TsFileMeta* get_tsfile_meta() { load_tsfile_meta_if_necessary(); return &tsfile_meta_; } int get_device_timeseries_meta_without_chunk_meta( std::shared_ptr device_id, - std::vector ×eries_indexs, - common::PageArena &pa); + std::vector& timeseries_indexs, + common::PageArena& pa); int get_chunk_metadata_list(IDeviceID device_id, std::string measurement, - std::vector &chunk_meta_list); + std::vector& chunk_meta_list); int read_device_meta_index(int32_t start_offset, int32_t end_offset, - common::PageArena &pa, - MetaIndexNode *&device_meta_index, bool leaf); + common::PageArena& pa, + MetaIndexNode*& device_meta_index, bool leaf); int get_timeseries_indexes( std::shared_ptr device_id, - const std::unordered_set &measurement_names, - std::vector ×eries_indexs, - common::PageArena &pa); + const std::unordered_set& measurement_names, + std::vector& timeseries_indexs, + common::PageArena& pa); private: FORCE_INLINE int32_t file_size() const { return read_file_->file_size(); } @@ -93,62 +93,62 @@ class TsFileIOReader { int load_device_index_entry( std::shared_ptr target_name, - std::shared_ptr &device_index_entry, - int64_t &end_offset); + std::shared_ptr& device_index_entry, + int64_t& end_offset); int load_measurement_index_entry( - const std::string &measurement_name, + const std::string& measurement_name, std::shared_ptr top_node, - std::shared_ptr &ret_measurement_index_entry, - int64_t &ret_end_offset); + std::shared_ptr& ret_measurement_index_entry, + int64_t& ret_end_offset); int load_all_measurement_index_entry( - int64_t start_offset, int64_t end_offset, common::PageArena &pa, - std::vector, int64_t> > - &ret_measurement_index_entry); + int64_t start_offset, int64_t end_offset, common::PageArena& pa, + std::vector, int64_t>>& + ret_measurement_index_entry); bool is_aligned_device(std::shared_ptr measurement_node); int get_time_column_metadata( std::shared_ptr measurement_node, - TimeseriesIndex *&ret_timeseries_index, common::PageArena &pa); + TimeseriesIndex*& ret_timeseries_index, common::PageArena& pa); - int do_load_timeseries_index(const std::string &measurement_name_str, + int do_load_timeseries_index(const std::string& measurement_name_str, int64_t start_offset, int64_t end_offset, - common::PageArena &pa, - ITimeseriesIndex *&ts_index, + common::PageArena& pa, + ITimeseriesIndex*& ts_index, bool is_aligned = false); int do_load_all_timeseries_index( - std::vector, int64_t> > - &index_node_entry_list, - common::PageArena &in_timeseries_index_pa, - std::vector &ts_indexs); + std::vector, int64_t>>& + index_node_entry_list, + common::PageArena& in_timeseries_index_pa, + std::vector& ts_indexs); int load_timeseries_index_for_ssi(std::shared_ptr device_id, - const std::string &measurement_name, - TsFileSeriesScanIterator *&ssi); + const std::string& measurement_name, + TsFileSeriesScanIterator*& ssi); int search_from_leaf_node(std::shared_ptr target_name, std::shared_ptr index_node, - std::shared_ptr &ret_index_entry, - int64_t &ret_end_offset); + std::shared_ptr& ret_index_entry, + int64_t& ret_end_offset); int search_from_internal_node( std::shared_ptr target_name, bool is_device, std::shared_ptr index_node, - std::shared_ptr &ret_index_entry, - int64_t &ret_end_offset); + std::shared_ptr& ret_index_entry, + int64_t& ret_end_offset); - bool filter_stasify(ITimeseriesIndex *ts_index, Filter *time_filter); + bool filter_stasify(ITimeseriesIndex* ts_index, Filter* time_filter); int get_all_leaf( std::shared_ptr index_node, - std::vector, int64_t> > - &index_node_entry_list); + std::vector, int64_t>>& + index_node_entry_list); private: - ReadFile *read_file_; + ReadFile* read_file_; common::PageArena tsfile_meta_page_arena_; TsFileMeta tsfile_meta_; bool tsfile_meta_ready_; diff --git a/cpp/src/file/tsfile_io_writer.cc b/cpp/src/file/tsfile_io_writer.cc index f65aebc2d..d6888086f 100644 --- a/cpp/src/file/tsfile_io_writer.cc +++ b/cpp/src/file/tsfile_io_writer.cc @@ -60,7 +60,7 @@ int TsFileIOWriter::init() { } #endif -int TsFileIOWriter::init(WriteFile *write_file) { +int TsFileIOWriter::init(WriteFile* write_file) { int ret = E_OK; const uint32_t page_size = 1024; meta_allocator_.init(page_size, MOD_TSFILE_WRITER_META); @@ -126,7 +126,7 @@ int TsFileIOWriter::start_flush_chunk_group( } } if (!use_prev_alloc_cgm_) { - void *buf = meta_allocator_.alloc(sizeof(*cur_chunk_group_meta_)); + void* buf = meta_allocator_.alloc(sizeof(*cur_chunk_group_meta_)); if (IS_NULL(buf)) { ret = E_OOM; } else { @@ -137,8 +137,8 @@ int TsFileIOWriter::start_flush_chunk_group( return ret; } -int TsFileIOWriter::start_flush_chunk(ByteStream &chunk_data, - ColumnSchema &col_schema, +int TsFileIOWriter::start_flush_chunk(ByteStream& chunk_data, + ColumnSchema& col_schema, int32_t num_of_pages) { std::string measurement_name = col_schema.get_measurement_name_str(); return start_flush_chunk(chunk_data, measurement_name, @@ -146,8 +146,8 @@ int TsFileIOWriter::start_flush_chunk(ByteStream &chunk_data, col_schema.compression_, num_of_pages); } -int TsFileIOWriter::start_flush_chunk(common::ByteStream &chunk_data, - std::string &measurement_name, +int TsFileIOWriter::start_flush_chunk(common::ByteStream& chunk_data, + std::string& measurement_name, common::TSDataType data_type, common::TSEncoding encoding, common::CompressionType compression, @@ -157,15 +157,15 @@ int TsFileIOWriter::start_flush_chunk(common::ByteStream &chunk_data, // Step 1. record chunk meta const int mask = 0; // for common chunk ASSERT(cur_chunk_meta_ == nullptr); - void *buf1 = meta_allocator_.alloc(sizeof(*cur_chunk_meta_)); - void *buf2 = meta_allocator_.alloc(get_typed_statistic_sizeof(data_type)); + void* buf1 = meta_allocator_.alloc(sizeof(*cur_chunk_meta_)); + void* buf2 = meta_allocator_.alloc(get_typed_statistic_sizeof(data_type)); if (IS_NULL(buf1) || IS_NULL(buf2)) { ret = E_OOM; } else { cur_chunk_meta_ = new (buf1) ChunkMeta(); - Statistic *chunk_statistic_copy = + Statistic* chunk_statistic_copy = placement_new_statistic(data_type, buf2); - String mname((char *)measurement_name.c_str(), + String mname((char*)measurement_name.c_str(), strlen(measurement_name.c_str())); ret = cur_chunk_meta_->init(mname, data_type, cur_file_position(), chunk_statistic_copy, mask, encoding, @@ -200,7 +200,7 @@ int TsFileIOWriter::start_flush_chunk(common::ByteStream &chunk_data, return ret; } -int TsFileIOWriter::flush_chunk(ByteStream &chunk_data) { +int TsFileIOWriter::flush_chunk(ByteStream& chunk_data) { int ret = E_OK; if (RET_FAIL(write_chunk_data(chunk_data))) { // log_err("writer chunk data error, ret=%d", ret); @@ -210,7 +210,7 @@ int TsFileIOWriter::flush_chunk(ByteStream &chunk_data) { return ret; } -int TsFileIOWriter::write_chunk_data(ByteStream &chunk_data) { +int TsFileIOWriter::write_chunk_data(ByteStream& chunk_data) { OFFSET_DEBUG("before writer chunk data"); // may print chunk_data here for debug. #if DEBUG_SE @@ -225,7 +225,7 @@ int TsFileIOWriter::write_chunk_data(ByteStream &chunk_data) { return ret; } -int TsFileIOWriter::end_flush_chunk(Statistic *chunk_statistic) { +int TsFileIOWriter::end_flush_chunk(Statistic* chunk_statistic) { int ret = E_OK; chunk_meta_count_++; cur_chunk_meta_->clone_statistic_from(chunk_statistic); @@ -289,12 +289,12 @@ int TsFileIOWriter::write_log_index_range() { } #if DEBUG_SE -void debug_print_chunk_group_meta(ChunkGroupMeta *cgm) { +void debug_print_chunk_group_meta(ChunkGroupMeta* cgm) { std::cout << "ChunkGroupMeta = {device_id_=" << cgm->device_id_ << ", chunk_meta_list_={"; - SimpleList::Iterator cm_it = cgm->chunk_meta_list_.begin(); + SimpleList::Iterator cm_it = cgm->chunk_meta_list_.begin(); for (; cm_it != cgm->chunk_meta_list_.end(); cm_it++) { - ChunkMeta *cm = cm_it.get(); + ChunkMeta* cm = cm_it.get(); std::cout << "{measurement=" << cm->measurement_name_ << ", offset_of_chunk_header=" << cm->offset_of_chunk_header_ << ", statistic=" << cm->statistic_->to_string() << "}}}"; @@ -303,10 +303,10 @@ void debug_print_chunk_group_meta(ChunkGroupMeta *cgm) { } void debug_print_chunk_group_meta_list( - common::SimpleList &cgm_list) { - SimpleList::Iterator cgm_it = cgm_list.begin(); + common::SimpleList& cgm_list) { + SimpleList::Iterator cgm_it = cgm_list.begin(); for (; cgm_it != cgm_list.end(); cgm_it++) { - ChunkGroupMeta *cgm = cgm_it.get(); + ChunkGroupMeta* cgm = cgm_it.get(); debug_print_chunk_group_meta(cgm); } } @@ -331,7 +331,7 @@ int TsFileIOWriter::write_file_index() { int entry_count_in_cur_device = 0; std::shared_ptr meta_index_entry = nullptr; std::shared_ptr cur_index_node = nullptr; - SimpleList> *cur_index_node_queue = nullptr; + SimpleList>* cur_index_node_queue = nullptr; DeviceNodeMap device_map; TSMIterator tsm_iter(chunk_group_meta_list_); @@ -442,16 +442,16 @@ int TsFileIOWriter::write_file_index() { tsfile_meta.bloom_filter_ = &filter; // split device by table std::map table_device_nodes_map; - for (const auto &entry : device_map) { + for (const auto& entry : device_map) { std::string table_name = entry.first->get_table_name(); - auto &table_map = table_device_nodes_map[table_name]; + auto& table_map = table_device_nodes_map[table_name]; if (table_map.empty() || table_map.find(entry.first) == table_map.end()) { table_map[entry.first] = entry.second; } } std::map> table_nodes_map; - for (auto &entry : table_device_nodes_map) { + for (auto& entry : table_device_nodes_map) { auto meta_index_node = std::make_shared(&meta_allocator_); build_device_level(entry.second, meta_index_node, writing_mm); @@ -485,9 +485,9 @@ int TsFileIOWriter::write_file_index() { return ret; } -int TsFileIOWriter::build_device_level(DeviceNodeMap &device_map, - std::shared_ptr &ret_root, - FileIndexWritingMemManager &wmm) { +int TsFileIOWriter::build_device_level(DeviceNodeMap& device_map, + std::shared_ptr& ret_root, + FileIndexWritingMemManager& wmm) { int ret = E_OK; SimpleList> node_queue( @@ -545,12 +545,12 @@ int TsFileIOWriter::build_device_level(DeviceNodeMap &device_map, return ret; } -int TsFileIOWriter::write_separator_marker(int64_t &meta_offset) { +int TsFileIOWriter::write_separator_marker(int64_t& meta_offset) { meta_offset = cur_file_position(); return write_byte(SEPARATOR_MARKER); } -int TsFileIOWriter::init_bloom_filter(BloomFilter &filter) { +int TsFileIOWriter::init_bloom_filter(BloomFilter& filter) { int ret = E_OK; int32_t path_count = get_path_count(chunk_group_meta_list_); if (RET_FAIL(filter.init( @@ -561,16 +561,16 @@ int TsFileIOWriter::init_bloom_filter(BloomFilter &filter) { } int32_t TsFileIOWriter::get_path_count( - common::SimpleList &cgm_list) { + common::SimpleList& cgm_list) { int32_t path_count = 0; String prev_measurement; - SimpleList::Iterator cgm_it = cgm_list.begin(); + SimpleList::Iterator cgm_it = cgm_list.begin(); for (; cgm_it != cgm_list.end(); cgm_it++) { - ChunkGroupMeta *cgm = cgm_it.get(); - SimpleList::Iterator cm_it = cgm->chunk_meta_list_.begin(); + ChunkGroupMeta* cgm = cgm_it.get(); + SimpleList::Iterator cm_it = cgm->chunk_meta_list_.begin(); for (; cm_it != cgm->chunk_meta_list_.end(); cm_it++) { - ChunkMeta *cm = cm_it.get(); + ChunkMeta* cm = cm_it.get(); // TODO currently, we do not have multi chunks of same timeseries in // tsfile. if (!cm->measurement_name_.equal_to(prev_measurement)) { @@ -591,14 +591,14 @@ int TsFileIOWriter::write_file_footer() { } int TsFileIOWriter::alloc_and_init_meta_index_entry( - FileIndexWritingMemManager &wmm, - std::shared_ptr &ret_entry, - const std::shared_ptr &device_id) { - void *buf = wmm.pa_.alloc(sizeof(DeviceMetaIndexEntry)); + FileIndexWritingMemManager& wmm, + std::shared_ptr& ret_entry, + const std::shared_ptr& device_id) { + void* buf = wmm.pa_.alloc(sizeof(DeviceMetaIndexEntry)); if (IS_NULL(buf)) { return E_OOM; } - auto entry_ptr = static_cast(buf); + auto entry_ptr = static_cast(buf); new (entry_ptr) DeviceMetaIndexEntry(device_id, cur_file_position()); ret_entry = std::shared_ptr( entry_ptr, IMetaIndexEntry::self_destructor); @@ -610,13 +610,13 @@ int TsFileIOWriter::alloc_and_init_meta_index_entry( } int TsFileIOWriter::alloc_and_init_meta_index_entry( - FileIndexWritingMemManager &wmm, - std::shared_ptr &ret_entry, common::String &name) { - void *buf = wmm.pa_.alloc(sizeof(MeasurementMetaIndexEntry)); + FileIndexWritingMemManager& wmm, + std::shared_ptr& ret_entry, common::String& name) { + void* buf = wmm.pa_.alloc(sizeof(MeasurementMetaIndexEntry)); if (IS_NULL(buf)) { return E_OOM; } - auto entry_ptr = static_cast(buf); + auto entry_ptr = static_cast(buf); new (entry_ptr) MeasurementMetaIndexEntry(name, cur_file_position(), wmm.pa_); ret_entry = std::shared_ptr( @@ -629,7 +629,7 @@ int TsFileIOWriter::alloc_and_init_meta_index_entry( } int TsFileIOWriter::alloc_and_init_meta_index_node( - FileIndexWritingMemManager &wmm, std::shared_ptr &ret_node, + FileIndexWritingMemManager& wmm, std::shared_ptr& ret_node, MetaIndexNodeType node_type) { // void *buf = wmm.pa_.alloc(sizeof(MetaIndexNode)); // if (IS_NULL(buf)) { @@ -651,7 +651,7 @@ int TsFileIOWriter::alloc_and_init_meta_index_node( int TsFileIOWriter::add_cur_index_node_to_queue( std::shared_ptr node, - SimpleList> *queue) const { + SimpleList>* queue) const { node->end_offset_ = cur_file_position(); #if DEBUG_SE std::cout << "add_cur_index_node_to_queue, node=" << *node @@ -661,9 +661,9 @@ int TsFileIOWriter::add_cur_index_node_to_queue( } int TsFileIOWriter::alloc_meta_index_node_queue( - FileIndexWritingMemManager &wmm, - SimpleList> *&queue) { - void *buf = wmm.pa_.alloc(sizeof(*queue)); + FileIndexWritingMemManager& wmm, + SimpleList>*& queue) { + void* buf = wmm.pa_.alloc(sizeof(*queue)); if (IS_NULL(buf)) { return E_OOM; } @@ -672,10 +672,10 @@ int TsFileIOWriter::alloc_meta_index_node_queue( } int TsFileIOWriter::add_device_node( - DeviceNodeMap &device_map, std::shared_ptr device_id, - common::SimpleList> - *measurement_index_node_queue, - FileIndexWritingMemManager &wmm) { + DeviceNodeMap& device_map, std::shared_ptr device_id, + common::SimpleList>* + measurement_index_node_queue, + FileIndexWritingMemManager& wmm) { ASSERT(measurement_index_node_queue->size() > 0); int ret = E_OK; auto find_iter = device_map.find(device_id); @@ -701,9 +701,9 @@ void TsFileIOWriter::set_generate_table_schema(bool generate_table_schema) { } int TsFileIOWriter::generate_root( - SimpleList> *node_queue, - std::shared_ptr &root_node, MetaIndexNodeType node_type, - FileIndexWritingMemManager &wmm) { + SimpleList>* node_queue, + std::shared_ptr& root_node, MetaIndexNodeType node_type, + FileIndexWritingMemManager& wmm) { int ret = E_OK; ASSERT(node_queue->size() > 0); @@ -721,8 +721,8 @@ int TsFileIOWriter::generate_root( return ret; } - common::SimpleList> *from = &list_x; - common::SimpleList> *to = &list_y; + common::SimpleList>* from = &list_x; + common::SimpleList>* to = &list_y; std::shared_ptr cur_index_node = nullptr; if (RET_FAIL( @@ -811,7 +811,7 @@ int TsFileIOWriter::generate_root( } void TsFileIOWriter::destroy_node_list( - common::SimpleList> *list) { + common::SimpleList>* list) { if (list) { for (auto iter = list->begin(); iter != list->end(); iter++) { if (iter.get()) { @@ -822,8 +822,8 @@ void TsFileIOWriter::destroy_node_list( } int TsFileIOWriter::clone_node_list( - SimpleList> *src, - SimpleList> *dest) { + SimpleList>* src, + SimpleList>* dest) { int ret = E_OK; SimpleList>::Iterator it; for (it = src->begin(); IS_SUCC(ret) && it != src->end(); it++) { @@ -876,7 +876,7 @@ int TsFileIOWriter::flush_stream_to_file() { return ret; } -void TsFileIOWriter::add_ts_time_index_entry(TimeseriesIndex &ts_index) { +void TsFileIOWriter::add_ts_time_index_entry(TimeseriesIndex& ts_index) { TimeseriesTimeIndexEntry time_index_entry; time_index_entry.ts_id_ = ts_index.get_ts_id(); time_index_entry.time_range_.start_time_ = diff --git a/cpp/src/file/tsfile_io_writer.h b/cpp/src/file/tsfile_io_writer.h index 6debbf022..901b2a5b5 100644 --- a/cpp/src/file/tsfile_io_writer.h +++ b/cpp/src/file/tsfile_io_writer.h @@ -91,28 +91,28 @@ class TsFileIOWriter { int init(); FORCE_INLINE common::FileID get_file_id() { return file_->get_file_id(); } #endif - int init(WriteFile *write_file); + int init(WriteFile* write_file); void destroy(); void set_generate_table_schema(bool generate_table_schema); int start_file(); int start_flush_chunk_group(std::shared_ptr device_id, bool is_aligned = false); - int start_flush_chunk(common::ByteStream &chunk_data, - common::ColumnSchema &col_schema, + int start_flush_chunk(common::ByteStream& chunk_data, + common::ColumnSchema& col_schema, int32_t num_of_pages); - int start_flush_chunk(common::ByteStream &chunk_data, - std::string &measurement_name, + int start_flush_chunk(common::ByteStream& chunk_data, + std::string& measurement_name, common::TSDataType data_type, common::TSEncoding encoding, common::CompressionType compression, int32_t num_of_pages); - int flush_chunk(common::ByteStream &chunk_data); - int end_flush_chunk(Statistic *chunk_statistic); + int flush_chunk(common::ByteStream& chunk_data); + int end_flush_chunk(Statistic* chunk_statistic); int end_flush_chunk_group(bool is_aligned = false); int end_file(); - FORCE_INLINE std::vector & + FORCE_INLINE std::vector& get_ts_time_index_vector() { return ts_time_index_vector_; } @@ -125,17 +125,17 @@ class TsFileIOWriter { FORCE_INLINE int sync_file() { return file_->sync(); } FORCE_INLINE int close_file() { return file_->close(); } int flush_stream_to_file(); - int write_chunk_data(common::ByteStream &chunk_data); + int write_chunk_data(common::ByteStream& chunk_data); FORCE_INLINE int64_t cur_file_position() const { return write_stream_.total_size(); } - FORCE_INLINE int write_buf(const char *buf, uint32_t len) { + FORCE_INLINE int write_buf(const char* buf, uint32_t len) { return write_stream_.write_buf(buf, len); } FORCE_INLINE int write_byte(const char byte) { return common::SerializationUtil::write_char(byte, write_stream_); } - FORCE_INLINE int write_string(const std::string &str) { + FORCE_INLINE int write_string(const std::string& str) { int ret = common::E_OK; if (RET_FAIL(common::SerializationUtil::write_var_int(str.size(), write_stream_))) { @@ -144,70 +144,70 @@ class TsFileIOWriter { return ret; } int write_file_footer(); - int build_device_level(DeviceNodeMap &device_map, - std::shared_ptr &ret_root, - FileIndexWritingMemManager &wmm); + int build_device_level(DeviceNodeMap& device_map, + std::shared_ptr& ret_root, + FileIndexWritingMemManager& wmm); int alloc_and_init_meta_index_entry( - FileIndexWritingMemManager &wmm, - std::shared_ptr &ret_entry, common::String &name); + FileIndexWritingMemManager& wmm, + std::shared_ptr& ret_entry, common::String& name); int alloc_and_init_meta_index_entry( - FileIndexWritingMemManager &wmm, - std::shared_ptr &ret_entry, - const std::shared_ptr &device_id); - int alloc_and_init_meta_index_node(FileIndexWritingMemManager &wmm, - std::shared_ptr &ret_node, + FileIndexWritingMemManager& wmm, + std::shared_ptr& ret_entry, + const std::shared_ptr& device_id); + int alloc_and_init_meta_index_node(FileIndexWritingMemManager& wmm, + std::shared_ptr& ret_node, MetaIndexNodeType node_type); int add_cur_index_node_to_queue( std::shared_ptr node, - common::SimpleList> *queue) const; + common::SimpleList>* queue) const; int alloc_meta_index_node_queue( - FileIndexWritingMemManager &wmm, - common::SimpleList> *&queue); - int add_device_node(DeviceNodeMap &device_map, + FileIndexWritingMemManager& wmm, + common::SimpleList>*& queue); + int add_device_node(DeviceNodeMap& device_map, std::shared_ptr device_id, - common::SimpleList> - *measurement_index_node_queue, - FileIndexWritingMemManager &wmm); + common::SimpleList>* + measurement_index_node_queue, + FileIndexWritingMemManager& wmm); void destroy_node_list( - common::SimpleList> *list); + common::SimpleList>* list); int clone_node_list( - common::SimpleList> *src, - common::SimpleList> *dest); + common::SimpleList>* src, + common::SimpleList>* dest); int generate_root( - common::SimpleList> *node_queue, - std::shared_ptr &root_node, MetaIndexNodeType node_type, - FileIndexWritingMemManager &wmm); + common::SimpleList>* node_queue, + std::shared_ptr& root_node, MetaIndexNodeType node_type, + FileIndexWritingMemManager& wmm); FORCE_INLINE void swap_list( - common::SimpleList> *&l1, - common::SimpleList> *&l2) { + common::SimpleList>*& l1, + common::SimpleList>*& l2) { auto tmp = l1; l1 = l2; l2 = tmp; } std::shared_ptr check_and_build_level_index( - DeviceNodeMap &device_metadata_index_map); + DeviceNodeMap& device_metadata_index_map); - int write_separator_marker(int64_t &meta_offset); + int write_separator_marker(int64_t& meta_offset); // for bloom filter - int init_bloom_filter(BloomFilter &filter); - int32_t get_path_count(common::SimpleList &cgm_list); + int init_bloom_filter(BloomFilter& filter); + int32_t get_path_count(common::SimpleList& cgm_list); // for open file - void add_ts_time_index_entry(TimeseriesIndex &ts_index); + void add_ts_time_index_entry(TimeseriesIndex& ts_index); private: common::PageArena meta_allocator_; common::ByteStream write_stream_; common::ByteStream::Consumer write_stream_consumer_; - ChunkMeta *cur_chunk_meta_; - ChunkGroupMeta *cur_chunk_group_meta_; + ChunkMeta* cur_chunk_meta_; + ChunkGroupMeta* cur_chunk_group_meta_; int32_t chunk_meta_count_; // for debug - common::SimpleList chunk_group_meta_list_; + common::SimpleList chunk_group_meta_list_; bool use_prev_alloc_cgm_; // chunk group meta std::shared_ptr cur_device_name_; - WriteFile *file_; + WriteFile* file_; std::vector ts_time_index_vector_; bool write_file_created_; bool generate_table_schema_; diff --git a/cpp/src/file/write_file.cc b/cpp/src/file/write_file.cc index c8c2cbbaf..004a3e9d4 100644 --- a/cpp/src/file/write_file.cc +++ b/cpp/src/file/write_file.cc @@ -40,7 +40,7 @@ using namespace common; namespace storage { #ifndef LIBTSFILE_SDK -int WriteFile::create(const FileID &file_id, int flags, mode_t mode) { +int WriteFile::create(const FileID& file_id, int flags, mode_t mode) { if (fd_ > 0) { // log_err("file already opened, fd=%d", fd_); ASSERT(false); @@ -52,7 +52,7 @@ int WriteFile::create(const FileID &file_id, int flags, mode_t mode) { } #endif -int WriteFile::create(const std::string &file_path, int flags, mode_t mode) { +int WriteFile::create(const std::string& file_path, int flags, mode_t mode) { if (fd_ > 0) { // log_err("file already opened, fd=%d", fd_); ASSERT(false); @@ -74,7 +74,7 @@ int WriteFile::do_create(int flags, mode_t mode) { return ret; } -int WriteFile::write(const char *buf, uint32_t len) { +int WriteFile::write(const char* buf, uint32_t len) { ASSERT(fd_ > 0); #if 0 // DEBUG_SE diff --git a/cpp/src/file/write_file.h b/cpp/src/file/write_file.h index 3346d7ad5..1c1f85118 100644 --- a/cpp/src/file/write_file.h +++ b/cpp/src/file/write_file.h @@ -35,13 +35,13 @@ class WriteFile { WriteFile() : path_(), file_id_(), fd_(-1) {} FORCE_INLINE common::FileID get_file_id() const { return file_id_; } FORCE_INLINE int get_fd() const { return fd_; } - int create(const common::FileID &file_id, int flags, mode_t mode); + int create(const common::FileID& file_id, int flags, mode_t mode); #else WriteFile() : path_(), fd_(-1) {} #endif - int create(const std::string &file_name, int flags, mode_t mode); + int create(const std::string& file_name, int flags, mode_t mode); bool file_opened() const { return fd_ > 0; } - int write(const char *buf, uint32_t len); + int write(const char* buf, uint32_t len); // int flush() { return common::E_OK; } // TODO int sync(); int close(); diff --git a/cpp/src/parser/generated/PathParser.cpp b/cpp/src/parser/generated/PathParser.cpp index 6dc7a4ba7..63024fa2a 100644 --- a/cpp/src/parser/generated/PathParser.cpp +++ b/cpp/src/parser/generated/PathParser.cpp @@ -26,7 +26,7 @@ using namespace antlrcpp; using namespace antlr4; -PathParser::PathParser(TokenStream *input) : Parser(input) { +PathParser::PathParser(TokenStream* input) : Parser(input) { _interpreter = new atn::ParserATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache); } @@ -35,28 +35,28 @@ PathParser::~PathParser() { delete _interpreter; } std::string PathParser::getGrammarFileName() const { return "PathParser.g4"; } -const std::vector &PathParser::getRuleNames() const { +const std::vector& PathParser::getRuleNames() const { return _ruleNames; } -dfa::Vocabulary &PathParser::getVocabulary() const { return _vocabulary; } +dfa::Vocabulary& PathParser::getVocabulary() const { return _vocabulary; } //----------------- PathContext //------------------------------------------------------------------ -PathParser::PathContext::PathContext(ParserRuleContext *parent, +PathParser::PathContext::PathContext(ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -PathParser::PrefixPathContext *PathParser::PathContext::prefixPath() { +PathParser::PrefixPathContext* PathParser::PathContext::prefixPath() { return getRuleContext(0); } -tree::TerminalNode *PathParser::PathContext::EOF() { +tree::TerminalNode* PathParser::PathContext::EOF() { return getToken(PathParser::EOF, 0); } -PathParser::SuffixPathContext *PathParser::PathContext::suffixPath() { +PathParser::SuffixPathContext* PathParser::PathContext::suffixPath() { return getRuleContext(0); } @@ -64,25 +64,25 @@ size_t PathParser::PathContext::getRuleIndex() const { return PathParser::RulePath; } -void PathParser::PathContext::enterRule(tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); +void PathParser::PathContext::enterRule(tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterPath(this); } -void PathParser::PathContext::exitRule(tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); +void PathParser::PathContext::exitRule(tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitPath(this); } -antlrcpp::Any PathParser::PathContext::accept(tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) +antlrcpp::Any PathParser::PathContext::accept(tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitPath(this); else return visitor->visitChildren(this); } -PathParser::PathContext *PathParser::path() { - PathContext *_localctx = +PathParser::PathContext* PathParser::path() { + PathContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 0, PathParser::RulePath); @@ -124,7 +124,7 @@ PathParser::PathContext *PathParser::path() { throw NoViableAltException(this); } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -136,28 +136,28 @@ PathParser::PathContext *PathParser::path() { //----------------- PrefixPathContext //------------------------------------------------------------------ -PathParser::PrefixPathContext::PrefixPathContext(ParserRuleContext *parent, +PathParser::PrefixPathContext::PrefixPathContext(ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode *PathParser::PrefixPathContext::ROOT() { +tree::TerminalNode* PathParser::PrefixPathContext::ROOT() { return getToken(PathParser::ROOT, 0); } -std::vector PathParser::PrefixPathContext::DOT() { +std::vector PathParser::PrefixPathContext::DOT() { return getTokens(PathParser::DOT); } -tree::TerminalNode *PathParser::PrefixPathContext::DOT(size_t i) { +tree::TerminalNode* PathParser::PrefixPathContext::DOT(size_t i) { return getToken(PathParser::DOT, i); } -std::vector +std::vector PathParser::PrefixPathContext::nodeName() { return getRuleContexts(); } -PathParser::NodeNameContext *PathParser::PrefixPathContext::nodeName(size_t i) { +PathParser::NodeNameContext* PathParser::PrefixPathContext::nodeName(size_t i) { return getRuleContext(i); } @@ -166,27 +166,27 @@ size_t PathParser::PrefixPathContext::getRuleIndex() const { } void PathParser::PrefixPathContext::enterRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterPrefixPath(this); } void PathParser::PrefixPathContext::exitRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitPrefixPath(this); } antlrcpp::Any PathParser::PrefixPathContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitPrefixPath(this); else return visitor->visitChildren(this); } -PathParser::PrefixPathContext *PathParser::prefixPath() { - PrefixPathContext *_localctx = +PathParser::PrefixPathContext* PathParser::prefixPath() { + PrefixPathContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 2, PathParser::RulePrefixPath); size_t _la = 0; @@ -215,7 +215,7 @@ PathParser::PrefixPathContext *PathParser::prefixPath() { _la = _input->LA(1); } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -227,24 +227,24 @@ PathParser::PrefixPathContext *PathParser::prefixPath() { //----------------- SuffixPathContext //------------------------------------------------------------------ -PathParser::SuffixPathContext::SuffixPathContext(ParserRuleContext *parent, +PathParser::SuffixPathContext::SuffixPathContext(ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -std::vector +std::vector PathParser::SuffixPathContext::nodeName() { return getRuleContexts(); } -PathParser::NodeNameContext *PathParser::SuffixPathContext::nodeName(size_t i) { +PathParser::NodeNameContext* PathParser::SuffixPathContext::nodeName(size_t i) { return getRuleContext(i); } -std::vector PathParser::SuffixPathContext::DOT() { +std::vector PathParser::SuffixPathContext::DOT() { return getTokens(PathParser::DOT); } -tree::TerminalNode *PathParser::SuffixPathContext::DOT(size_t i) { +tree::TerminalNode* PathParser::SuffixPathContext::DOT(size_t i) { return getToken(PathParser::DOT, i); } @@ -253,27 +253,27 @@ size_t PathParser::SuffixPathContext::getRuleIndex() const { } void PathParser::SuffixPathContext::enterRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterSuffixPath(this); } void PathParser::SuffixPathContext::exitRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitSuffixPath(this); } antlrcpp::Any PathParser::SuffixPathContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitSuffixPath(this); else return visitor->visitChildren(this); } -PathParser::SuffixPathContext *PathParser::suffixPath() { - SuffixPathContext *_localctx = +PathParser::SuffixPathContext* PathParser::suffixPath() { + SuffixPathContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 4, PathParser::RuleSuffixPath); size_t _la = 0; @@ -302,7 +302,7 @@ PathParser::SuffixPathContext *PathParser::suffixPath() { _la = _input->LA(1); } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -314,24 +314,24 @@ PathParser::SuffixPathContext *PathParser::suffixPath() { //----------------- NodeNameContext //------------------------------------------------------------------ -PathParser::NodeNameContext::NodeNameContext(ParserRuleContext *parent, +PathParser::NodeNameContext::NodeNameContext(ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -std::vector +std::vector PathParser::NodeNameContext::wildcard() { return getRuleContexts(); } -PathParser::WildcardContext *PathParser::NodeNameContext::wildcard(size_t i) { +PathParser::WildcardContext* PathParser::NodeNameContext::wildcard(size_t i) { return getRuleContext(i); } -PathParser::NodeNameSliceContext *PathParser::NodeNameContext::nodeNameSlice() { +PathParser::NodeNameSliceContext* PathParser::NodeNameContext::nodeNameSlice() { return getRuleContext(0); } -PathParser::NodeNameWithoutWildcardContext * +PathParser::NodeNameWithoutWildcardContext* PathParser::NodeNameContext::nodeNameWithoutWildcard() { return getRuleContext(0); } @@ -340,26 +340,26 @@ size_t PathParser::NodeNameContext::getRuleIndex() const { return PathParser::RuleNodeName; } -void PathParser::NodeNameContext::enterRule(tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); +void PathParser::NodeNameContext::enterRule(tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterNodeName(this); } -void PathParser::NodeNameContext::exitRule(tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); +void PathParser::NodeNameContext::exitRule(tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitNodeName(this); } antlrcpp::Any PathParser::NodeNameContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitNodeName(this); else return visitor->visitChildren(this); } -PathParser::NodeNameContext *PathParser::nodeName() { - NodeNameContext *_localctx = +PathParser::NodeNameContext* PathParser::nodeName() { + NodeNameContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 6, PathParser::RuleNodeName); size_t _la = 0; @@ -422,7 +422,7 @@ PathParser::NodeNameContext *PathParser::nodeName() { break; } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -435,10 +435,10 @@ PathParser::NodeNameContext *PathParser::nodeName() { //------------------------------------------------------------------ PathParser::NodeNameWithoutWildcardContext::NodeNameWithoutWildcardContext( - ParserRuleContext *parent, size_t invokingState) + ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -PathParser::IdentifierContext * +PathParser::IdentifierContext* PathParser::NodeNameWithoutWildcardContext::identifier() { return getRuleContext(0); } @@ -448,30 +448,30 @@ size_t PathParser::NodeNameWithoutWildcardContext::getRuleIndex() const { } void PathParser::NodeNameWithoutWildcardContext::enterRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterNodeNameWithoutWildcard(this); } void PathParser::NodeNameWithoutWildcardContext::exitRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitNodeNameWithoutWildcard(this); } antlrcpp::Any PathParser::NodeNameWithoutWildcardContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitNodeNameWithoutWildcard(this); else return visitor->visitChildren(this); } -PathParser::NodeNameWithoutWildcardContext * +PathParser::NodeNameWithoutWildcardContext* PathParser::nodeNameWithoutWildcard() { - NodeNameWithoutWildcardContext *_localctx = + NodeNameWithoutWildcardContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 8, PathParser::RuleNodeNameWithoutWildcard); @@ -488,7 +488,7 @@ PathParser::nodeNameWithoutWildcard() { setState(52); identifier(); - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -501,14 +501,14 @@ PathParser::nodeNameWithoutWildcard() { //------------------------------------------------------------------ PathParser::NodeNameSliceContext::NodeNameSliceContext( - ParserRuleContext *parent, size_t invokingState) + ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -PathParser::IdentifierContext *PathParser::NodeNameSliceContext::identifier() { +PathParser::IdentifierContext* PathParser::NodeNameSliceContext::identifier() { return getRuleContext(0); } -tree::TerminalNode *PathParser::NodeNameSliceContext::INTEGER_LITERAL() { +tree::TerminalNode* PathParser::NodeNameSliceContext::INTEGER_LITERAL() { return getToken(PathParser::INTEGER_LITERAL, 0); } @@ -517,27 +517,27 @@ size_t PathParser::NodeNameSliceContext::getRuleIndex() const { } void PathParser::NodeNameSliceContext::enterRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterNodeNameSlice(this); } void PathParser::NodeNameSliceContext::exitRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitNodeNameSlice(this); } antlrcpp::Any PathParser::NodeNameSliceContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitNodeNameSlice(this); else return visitor->visitChildren(this); } -PathParser::NodeNameSliceContext *PathParser::nodeNameSlice() { - NodeNameSliceContext *_localctx = +PathParser::NodeNameSliceContext* PathParser::nodeNameSlice() { + NodeNameSliceContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 10, PathParser::RuleNodeNameSlice); @@ -572,7 +572,7 @@ PathParser::NodeNameSliceContext *PathParser::nodeNameSlice() { throw NoViableAltException(this); } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -584,19 +584,19 @@ PathParser::NodeNameSliceContext *PathParser::nodeNameSlice() { //----------------- IdentifierContext //------------------------------------------------------------------ -PathParser::IdentifierContext::IdentifierContext(ParserRuleContext *parent, +PathParser::IdentifierContext::IdentifierContext(ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode *PathParser::IdentifierContext::DURATION_LITERAL() { +tree::TerminalNode* PathParser::IdentifierContext::DURATION_LITERAL() { return getToken(PathParser::DURATION_LITERAL, 0); } -tree::TerminalNode *PathParser::IdentifierContext::ID() { +tree::TerminalNode* PathParser::IdentifierContext::ID() { return getToken(PathParser::ID, 0); } -tree::TerminalNode *PathParser::IdentifierContext::QUOTED_ID() { +tree::TerminalNode* PathParser::IdentifierContext::QUOTED_ID() { return getToken(PathParser::QUOTED_ID, 0); } @@ -605,27 +605,27 @@ size_t PathParser::IdentifierContext::getRuleIndex() const { } void PathParser::IdentifierContext::enterRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterIdentifier(this); } void PathParser::IdentifierContext::exitRule( - tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); + tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitIdentifier(this); } antlrcpp::Any PathParser::IdentifierContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitIdentifier(this); else return visitor->visitChildren(this); } -PathParser::IdentifierContext *PathParser::identifier() { - IdentifierContext *_localctx = +PathParser::IdentifierContext* PathParser::identifier() { + IdentifierContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 12, PathParser::RuleIdentifier); size_t _la = 0; @@ -651,7 +651,7 @@ PathParser::IdentifierContext *PathParser::identifier() { consume(); } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); @@ -663,15 +663,15 @@ PathParser::IdentifierContext *PathParser::identifier() { //----------------- WildcardContext //------------------------------------------------------------------ -PathParser::WildcardContext::WildcardContext(ParserRuleContext *parent, +PathParser::WildcardContext::WildcardContext(ParserRuleContext* parent, size_t invokingState) : ParserRuleContext(parent, invokingState) {} -tree::TerminalNode *PathParser::WildcardContext::STAR() { +tree::TerminalNode* PathParser::WildcardContext::STAR() { return getToken(PathParser::STAR, 0); } -tree::TerminalNode *PathParser::WildcardContext::DOUBLE_STAR() { +tree::TerminalNode* PathParser::WildcardContext::DOUBLE_STAR() { return getToken(PathParser::DOUBLE_STAR, 0); } @@ -679,26 +679,26 @@ size_t PathParser::WildcardContext::getRuleIndex() const { return PathParser::RuleWildcard; } -void PathParser::WildcardContext::enterRule(tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); +void PathParser::WildcardContext::enterRule(tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->enterWildcard(this); } -void PathParser::WildcardContext::exitRule(tree::ParseTreeListener *listener) { - auto parserListener = dynamic_cast(listener); +void PathParser::WildcardContext::exitRule(tree::ParseTreeListener* listener) { + auto parserListener = dynamic_cast(listener); if (parserListener != nullptr) parserListener->exitWildcard(this); } antlrcpp::Any PathParser::WildcardContext::accept( - tree::ParseTreeVisitor *visitor) { - if (auto parserVisitor = dynamic_cast(visitor)) + tree::ParseTreeVisitor* visitor) { + if (auto parserVisitor = dynamic_cast(visitor)) return parserVisitor->visitWildcard(this); else return visitor->visitChildren(this); } -PathParser::WildcardContext *PathParser::wildcard() { - WildcardContext *_localctx = +PathParser::WildcardContext* PathParser::wildcard() { + WildcardContext* _localctx = _tracker.createInstance(_ctx, getState()); enterRule(_localctx, 14, PathParser::RuleWildcard); size_t _la = 0; @@ -723,7 +723,7 @@ PathParser::WildcardContext *PathParser::wildcard() { consume(); } - } catch (RecognitionException &e) { + } catch (RecognitionException& e) { _errHandler->reportError(this, e); _localctx->exception = std::current_exception(); _errHandler->recover(this, _localctx->exception); diff --git a/cpp/src/parser/generated/PathParser.h b/cpp/src/parser/generated/PathParser.h index 2336c5766..bfb36966c 100644 --- a/cpp/src/parser/generated/PathParser.h +++ b/cpp/src/parser/generated/PathParser.h @@ -75,16 +75,16 @@ class PathParser : public antlr4::Parser { RuleWildcard = 7 }; - explicit PathParser(antlr4::TokenStream *input); + explicit PathParser(antlr4::TokenStream* input); ~PathParser(); virtual std::string getGrammarFileName() const override; - virtual const antlr4::atn::ATN &getATN() const override { return _atn; }; - virtual const std::vector &getTokenNames() const override { + virtual const antlr4::atn::ATN& getATN() const override { return _atn; }; + virtual const std::vector& getTokenNames() const override { return _tokenNames; }; // deprecated: use vocabulary instead. - virtual const std::vector &getRuleNames() const override; - virtual antlr4::dfa::Vocabulary &getVocabulary() const override; + virtual const std::vector& getRuleNames() const override; + virtual antlr4::dfa::Vocabulary& getVocabulary() const override; class PathContext; class PrefixPathContext; @@ -97,162 +97,162 @@ class PathParser : public antlr4::Parser { class PathContext : public antlr4::ParserRuleContext { public: - PathContext(antlr4::ParserRuleContext *parent, size_t invokingState); + PathContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - PrefixPathContext *prefixPath(); - antlr4::tree::TerminalNode *EOF(); - SuffixPathContext *suffixPath(); + PrefixPathContext* prefixPath(); + antlr4::tree::TerminalNode* EOF(); + SuffixPathContext* suffixPath(); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - PathContext *path(); + PathContext* path(); class PrefixPathContext : public antlr4::ParserRuleContext { public: - PrefixPathContext(antlr4::ParserRuleContext *parent, + PrefixPathContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - antlr4::tree::TerminalNode *ROOT(); - std::vector DOT(); - antlr4::tree::TerminalNode *DOT(size_t i); - std::vector nodeName(); - NodeNameContext *nodeName(size_t i); + antlr4::tree::TerminalNode* ROOT(); + std::vector DOT(); + antlr4::tree::TerminalNode* DOT(size_t i); + std::vector nodeName(); + NodeNameContext* nodeName(size_t i); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - PrefixPathContext *prefixPath(); + PrefixPathContext* prefixPath(); class SuffixPathContext : public antlr4::ParserRuleContext { public: - SuffixPathContext(antlr4::ParserRuleContext *parent, + SuffixPathContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - std::vector nodeName(); - NodeNameContext *nodeName(size_t i); - std::vector DOT(); - antlr4::tree::TerminalNode *DOT(size_t i); + std::vector nodeName(); + NodeNameContext* nodeName(size_t i); + std::vector DOT(); + antlr4::tree::TerminalNode* DOT(size_t i); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - SuffixPathContext *suffixPath(); + SuffixPathContext* suffixPath(); class NodeNameContext : public antlr4::ParserRuleContext { public: - NodeNameContext(antlr4::ParserRuleContext *parent, + NodeNameContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - std::vector wildcard(); - WildcardContext *wildcard(size_t i); - NodeNameSliceContext *nodeNameSlice(); - NodeNameWithoutWildcardContext *nodeNameWithoutWildcard(); + std::vector wildcard(); + WildcardContext* wildcard(size_t i); + NodeNameSliceContext* nodeNameSlice(); + NodeNameWithoutWildcardContext* nodeNameWithoutWildcard(); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - NodeNameContext *nodeName(); + NodeNameContext* nodeName(); class NodeNameWithoutWildcardContext : public antlr4::ParserRuleContext { public: - NodeNameWithoutWildcardContext(antlr4::ParserRuleContext *parent, + NodeNameWithoutWildcardContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - IdentifierContext *identifier(); + IdentifierContext* identifier(); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - NodeNameWithoutWildcardContext *nodeNameWithoutWildcard(); + NodeNameWithoutWildcardContext* nodeNameWithoutWildcard(); class NodeNameSliceContext : public antlr4::ParserRuleContext { public: - NodeNameSliceContext(antlr4::ParserRuleContext *parent, + NodeNameSliceContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - IdentifierContext *identifier(); - antlr4::tree::TerminalNode *INTEGER_LITERAL(); + IdentifierContext* identifier(); + antlr4::tree::TerminalNode* INTEGER_LITERAL(); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - NodeNameSliceContext *nodeNameSlice(); + NodeNameSliceContext* nodeNameSlice(); class IdentifierContext : public antlr4::ParserRuleContext { public: - IdentifierContext(antlr4::ParserRuleContext *parent, + IdentifierContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - antlr4::tree::TerminalNode *DURATION_LITERAL(); - antlr4::tree::TerminalNode *ID(); - antlr4::tree::TerminalNode *QUOTED_ID(); + antlr4::tree::TerminalNode* DURATION_LITERAL(); + antlr4::tree::TerminalNode* ID(); + antlr4::tree::TerminalNode* QUOTED_ID(); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - IdentifierContext *identifier(); + IdentifierContext* identifier(); class WildcardContext : public antlr4::ParserRuleContext { public: - WildcardContext(antlr4::ParserRuleContext *parent, + WildcardContext(antlr4::ParserRuleContext* parent, size_t invokingState); virtual size_t getRuleIndex() const override; - antlr4::tree::TerminalNode *STAR(); - antlr4::tree::TerminalNode *DOUBLE_STAR(); + antlr4::tree::TerminalNode* STAR(); + antlr4::tree::TerminalNode* DOUBLE_STAR(); virtual void enterRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual void exitRule( - antlr4::tree::ParseTreeListener *listener) override; + antlr4::tree::ParseTreeListener* listener) override; virtual antlrcpp::Any accept( - antlr4::tree::ParseTreeVisitor *visitor) override; + antlr4::tree::ParseTreeVisitor* visitor) override; }; - WildcardContext *wildcard(); + WildcardContext* wildcard(); private: static std::vector _decisionToDFA; diff --git a/cpp/src/parser/generated/PathParserBaseVisitor.h b/cpp/src/parser/generated/PathParserBaseVisitor.h index 06c57cfd2..ea327763e 100644 --- a/cpp/src/parser/generated/PathParserBaseVisitor.h +++ b/cpp/src/parser/generated/PathParserBaseVisitor.h @@ -30,42 +30,42 @@ */ class PathParserBaseVisitor : public PathParserVisitor { public: - virtual antlrcpp::Any visitPath(PathParser::PathContext *ctx) override { + virtual antlrcpp::Any visitPath(PathParser::PathContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitPrefixPath( - PathParser::PrefixPathContext *ctx) override { + PathParser::PrefixPathContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitSuffixPath( - PathParser::SuffixPathContext *ctx) override { + PathParser::SuffixPathContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitNodeName( - PathParser::NodeNameContext *ctx) override { + PathParser::NodeNameContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitNodeNameWithoutWildcard( - PathParser::NodeNameWithoutWildcardContext *ctx) override { + PathParser::NodeNameWithoutWildcardContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitNodeNameSlice( - PathParser::NodeNameSliceContext *ctx) override { + PathParser::NodeNameSliceContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitIdentifier( - PathParser::IdentifierContext *ctx) override { + PathParser::IdentifierContext* ctx) override { return visitChildren(ctx); } virtual antlrcpp::Any visitWildcard( - PathParser::WildcardContext *ctx) override { + PathParser::WildcardContext* ctx) override { return visitChildren(ctx); } }; diff --git a/cpp/src/parser/generated/PathParserListener.h b/cpp/src/parser/generated/PathParserListener.h index feb50e3b7..ec9961881 100644 --- a/cpp/src/parser/generated/PathParserListener.h +++ b/cpp/src/parser/generated/PathParserListener.h @@ -29,29 +29,29 @@ */ class PathParserListener : public antlr4::tree::ParseTreeListener { public: - virtual void enterPath(PathParser::PathContext *ctx) = 0; - virtual void exitPath(PathParser::PathContext *ctx) = 0; + virtual void enterPath(PathParser::PathContext* ctx) = 0; + virtual void exitPath(PathParser::PathContext* ctx) = 0; - virtual void enterPrefixPath(PathParser::PrefixPathContext *ctx) = 0; - virtual void exitPrefixPath(PathParser::PrefixPathContext *ctx) = 0; + virtual void enterPrefixPath(PathParser::PrefixPathContext* ctx) = 0; + virtual void exitPrefixPath(PathParser::PrefixPathContext* ctx) = 0; - virtual void enterSuffixPath(PathParser::SuffixPathContext *ctx) = 0; - virtual void exitSuffixPath(PathParser::SuffixPathContext *ctx) = 0; + virtual void enterSuffixPath(PathParser::SuffixPathContext* ctx) = 0; + virtual void exitSuffixPath(PathParser::SuffixPathContext* ctx) = 0; - virtual void enterNodeName(PathParser::NodeNameContext *ctx) = 0; - virtual void exitNodeName(PathParser::NodeNameContext *ctx) = 0; + virtual void enterNodeName(PathParser::NodeNameContext* ctx) = 0; + virtual void exitNodeName(PathParser::NodeNameContext* ctx) = 0; virtual void enterNodeNameWithoutWildcard( - PathParser::NodeNameWithoutWildcardContext *ctx) = 0; + PathParser::NodeNameWithoutWildcardContext* ctx) = 0; virtual void exitNodeNameWithoutWildcard( - PathParser::NodeNameWithoutWildcardContext *ctx) = 0; + PathParser::NodeNameWithoutWildcardContext* ctx) = 0; - virtual void enterNodeNameSlice(PathParser::NodeNameSliceContext *ctx) = 0; - virtual void exitNodeNameSlice(PathParser::NodeNameSliceContext *ctx) = 0; + virtual void enterNodeNameSlice(PathParser::NodeNameSliceContext* ctx) = 0; + virtual void exitNodeNameSlice(PathParser::NodeNameSliceContext* ctx) = 0; - virtual void enterIdentifier(PathParser::IdentifierContext *ctx) = 0; - virtual void exitIdentifier(PathParser::IdentifierContext *ctx) = 0; + virtual void enterIdentifier(PathParser::IdentifierContext* ctx) = 0; + virtual void exitIdentifier(PathParser::IdentifierContext* ctx) = 0; - virtual void enterWildcard(PathParser::WildcardContext *ctx) = 0; - virtual void exitWildcard(PathParser::WildcardContext *ctx) = 0; + virtual void enterWildcard(PathParser::WildcardContext* ctx) = 0; + virtual void exitWildcard(PathParser::WildcardContext* ctx) = 0; }; diff --git a/cpp/src/parser/generated/PathParserVisitor.h b/cpp/src/parser/generated/PathParserVisitor.h index 27a5e5d85..20e152231 100644 --- a/cpp/src/parser/generated/PathParserVisitor.h +++ b/cpp/src/parser/generated/PathParserVisitor.h @@ -32,26 +32,26 @@ class PathParserVisitor : public antlr4::tree::AbstractParseTreeVisitor { /** * Visit parse trees produced by PathParser. */ - virtual antlrcpp::Any visitPath(PathParser::PathContext *context) = 0; + virtual antlrcpp::Any visitPath(PathParser::PathContext* context) = 0; virtual antlrcpp::Any visitPrefixPath( - PathParser::PrefixPathContext *context) = 0; + PathParser::PrefixPathContext* context) = 0; virtual antlrcpp::Any visitSuffixPath( - PathParser::SuffixPathContext *context) = 0; + PathParser::SuffixPathContext* context) = 0; virtual antlrcpp::Any visitNodeName( - PathParser::NodeNameContext *context) = 0; + PathParser::NodeNameContext* context) = 0; virtual antlrcpp::Any visitNodeNameWithoutWildcard( - PathParser::NodeNameWithoutWildcardContext *context) = 0; + PathParser::NodeNameWithoutWildcardContext* context) = 0; virtual antlrcpp::Any visitNodeNameSlice( - PathParser::NodeNameSliceContext *context) = 0; + PathParser::NodeNameSliceContext* context) = 0; virtual antlrcpp::Any visitIdentifier( - PathParser::IdentifierContext *context) = 0; + PathParser::IdentifierContext* context) = 0; virtual antlrcpp::Any visitWildcard( - PathParser::WildcardContext *context) = 0; + PathParser::WildcardContext* context) = 0; }; diff --git a/cpp/src/reader/block/device_ordered_tsblock_reader.cc b/cpp/src/reader/block/device_ordered_tsblock_reader.cc index e1c46ffa0..6fb540954 100644 --- a/cpp/src/reader/block/device_ordered_tsblock_reader.cc +++ b/cpp/src/reader/block/device_ordered_tsblock_reader.cc @@ -21,7 +21,7 @@ namespace storage { -int DeviceOrderedTsBlockReader::has_next(bool &has_next) { +int DeviceOrderedTsBlockReader::has_next(bool& has_next) { int ret = common::E_OK; if (current_reader_ != nullptr && IS_SUCC(current_reader_->has_next(has_next)) && has_next) { @@ -32,7 +32,7 @@ int DeviceOrderedTsBlockReader::has_next(bool &has_next) { current_reader_ = nullptr; } while (device_task_iterator_->has_next()) { - DeviceQueryTask *task = nullptr; + DeviceQueryTask* task = nullptr; if (IS_FAIL(device_task_iterator_->next(task))) { return ret; } @@ -72,7 +72,7 @@ int DeviceOrderedTsBlockReader::has_next(bool &has_next) { return ret; } -int DeviceOrderedTsBlockReader::next(common::TsBlock *&ret_block) { +int DeviceOrderedTsBlockReader::next(common::TsBlock*& ret_block) { int ret = common::E_OK; bool next = false; if (RET_FAIL(has_next(next)) || !next) { diff --git a/cpp/src/reader/block/device_ordered_tsblock_reader.h b/cpp/src/reader/block/device_ordered_tsblock_reader.h index fb546e871..b00d751a1 100644 --- a/cpp/src/reader/block/device_ordered_tsblock_reader.h +++ b/cpp/src/reader/block/device_ordered_tsblock_reader.h @@ -31,9 +31,9 @@ class DeviceOrderedTsBlockReader : public TsBlockReader { public: explicit DeviceOrderedTsBlockReader( std::unique_ptr device_task_iterator, - IMetadataQuerier *metadata_querier, int32_t block_size, - TsFileIOReader *tsfile_io_reader, Filter *time_filter, - Filter *field_filter) + IMetadataQuerier* metadata_querier, int32_t block_size, + TsFileIOReader* tsfile_io_reader, Filter* time_filter, + Filter* field_filter) : device_task_iterator_(std::move(device_task_iterator)), metadata_querier_(metadata_querier), block_size_(block_size), @@ -42,18 +42,18 @@ class DeviceOrderedTsBlockReader : public TsBlockReader { field_filter_(field_filter) {} ~DeviceOrderedTsBlockReader() override { close(); } - int has_next(bool &has_next) override; - int next(common::TsBlock *&ret_block) override; + int has_next(bool& has_next) override; + int next(common::TsBlock*& ret_block) override; void close() override; private: std::unique_ptr device_task_iterator_; - IMetadataQuerier *metadata_querier_; + IMetadataQuerier* metadata_querier_; int32_t block_size_; - SingleDeviceTsBlockReader *current_reader_ = nullptr; - TsFileIOReader *tsfile_io_reader_; - Filter *time_filter_ = nullptr; - Filter *field_filter_ = nullptr; + SingleDeviceTsBlockReader* current_reader_ = nullptr; + TsFileIOReader* tsfile_io_reader_; + Filter* time_filter_ = nullptr; + Filter* field_filter_ = nullptr; }; } // namespace storage diff --git a/cpp/src/reader/block/tsblock_reader.h b/cpp/src/reader/block/tsblock_reader.h index de6d98b5c..8d3bd37a0 100644 --- a/cpp/src/reader/block/tsblock_reader.h +++ b/cpp/src/reader/block/tsblock_reader.h @@ -25,20 +25,20 @@ namespace storage { class TsBlockReader { public: virtual ~TsBlockReader() = default; - virtual int has_next(bool &has_next) = 0; - virtual int next(common::TsBlock *&ret_block) = 0; + virtual int has_next(bool& has_next) = 0; + virtual int next(common::TsBlock*& ret_block) = 0; virtual void close() = 0; }; class EmptyTsBlockReader : public TsBlockReader { public: EmptyTsBlockReader() = default; - int has_next(bool &has_next) override { + int has_next(bool& has_next) override { has_next = false; return common::E_OK; } - int next(common::TsBlock *&ret_block) override { return common::E_OK; } + int next(common::TsBlock*& ret_block) override { return common::E_OK; } }; } // namespace storage diff --git a/cpp/src/reader/bloom_filter.cc b/cpp/src/reader/bloom_filter.cc index 591bb6c85..068c96e27 100644 --- a/cpp/src/reader/bloom_filter.cc +++ b/cpp/src/reader/bloom_filter.cc @@ -70,7 +70,7 @@ double math_log(double in) { #endif /* ================ BitSet ================ */ -void BitSet::to_bytes(uint8_t *&ret_bytes, int32_t &ret_len) const { +void BitSet::to_bytes(uint8_t*& ret_bytes, int32_t& ret_len) const { int32_t words_in_use = get_words_in_use(); if (words_in_use == 0) { return; @@ -83,8 +83,7 @@ void BitSet::to_bytes(uint8_t *&ret_bytes, int32_t &ret_len) const { x = x >> 8; } - uint8_t *res = - (uint8_t *)mem_alloc(sizeof(uint8_t) * len, MOD_BLOOM_FILTER); + uint8_t* res = (uint8_t*)mem_alloc(sizeof(uint8_t) * len, MOD_BLOOM_FILTER); int32_t res_pos = 0; for (int32_t w = 0; w < words_in_use - 1; w++) { uint64_t word = words_[w]; @@ -106,13 +105,13 @@ void BitSet::to_bytes(uint8_t *&ret_bytes, int32_t &ret_len) const { } // TODO byte-wise unittest -int BitSet::from_bytes(uint8_t *filter_data, uint32_t filter_data_bytes_len) { +int BitSet::from_bytes(uint8_t* filter_data, uint32_t filter_data_bytes_len) { int ret = E_OK; word_count_ = (filter_data_bytes_len / 8) + (filter_data_bytes_len % 8 == 0 ? 0 : 1); words_ = - (uint64_t *)mem_alloc(word_count_ * sizeof(uint64_t), MOD_BLOOM_FILTER); + (uint64_t*)mem_alloc(word_count_ * sizeof(uint64_t), MOD_BLOOM_FILTER); if (IS_NULL(words_)) { return E_OOM; } @@ -120,7 +119,7 @@ int BitSet::from_bytes(uint8_t *filter_data, uint32_t filter_data_bytes_len) { uint32_t word_idx = 0; for (; word_idx < (filter_data_bytes_len / 8); word_idx += 1) { uint64_t cur_word = 0; - uint8_t *cur_word_start_byte = filter_data + (word_idx * 8); + uint8_t* cur_word_start_byte = filter_data + (word_idx * 8); for (int b = 0; b < 8; ++b) { cur_word |= static_cast(cur_word_start_byte[b]) << (8 * b); @@ -130,7 +129,7 @@ int BitSet::from_bytes(uint8_t *filter_data, uint32_t filter_data_bytes_len) { if (filter_data_bytes_len > word_idx * 8) { uint64_t cur_word = 0; - uint8_t *cur_word_start_byte = filter_data + (word_idx * 8); + uint8_t* cur_word_start_byte = filter_data + (word_idx * 8); int remain = filter_data_bytes_len - word_idx * 8; for (int b = 0; b < remain; ++b) { cur_word |= static_cast(cur_word_start_byte[b]) @@ -169,11 +168,11 @@ int BloomFilter::init(double error_percent, int entry_count) { return ret; } -String BloomFilter::get_entry_string(const String &device_name, - const String &measurement_name) { +String BloomFilter::get_entry_string(const String& device_name, + const String& measurement_name) { String ret_str; int len = device_name.len_ + measurement_name.len_ + 2; // '.' and '\0' - char *path_buf = (char *)mem_alloc(len, MOD_BLOOM_FILTER); + char* path_buf = (char*)mem_alloc(len, MOD_BLOOM_FILTER); if (IS_NULL(path_buf)) { return ret_str; } @@ -189,8 +188,8 @@ String BloomFilter::get_entry_string(const String &device_name, return ret_str; } -int BloomFilter::add_path_entry(const String &device_name, - const String &measurement_name) { +int BloomFilter::add_path_entry(const String& device_name, + const String& measurement_name) { if (device_name.is_null()) { return E_INVALID_ARG; } @@ -201,7 +200,7 @@ int BloomFilter::add_path_entry(const String &device_name, } for (uint32_t i = 0; i < hash_func_count_; i++) { - HashFunction &hf = hash_func_arr_[i]; + HashFunction& hf = hash_func_arr_[i]; int32_t hv = hf.hash(entry); bitset_.set(hv); } @@ -209,9 +208,9 @@ int BloomFilter::add_path_entry(const String &device_name, return E_OK; } -int BloomFilter::serialize_to(ByteStream &out) { +int BloomFilter::serialize_to(ByteStream& out) { int ret = E_OK; - uint8_t *filter_data_bytes = nullptr; + uint8_t* filter_data_bytes = nullptr; int32_t filter_data_bytes_len = 0; bitset_.to_bytes(filter_data_bytes, filter_data_bytes_len); if (RET_FAIL( @@ -228,14 +227,14 @@ int BloomFilter::serialize_to(ByteStream &out) { return ret; } -int BloomFilter::deserialize_from(ByteStream &in) { +int BloomFilter::deserialize_from(ByteStream& in) { int ret = E_OK; uint32_t filter_data_bytes_len = 0; uint32_t ret_read_len = 0; - uint8_t *filter_data = nullptr; + uint8_t* filter_data = nullptr; if (RET_FAIL(SerializationUtil::read_var_uint(filter_data_bytes_len, in))) { } else if (UNLIKELY(nullptr == - (filter_data = (uint8_t *)mem_alloc( + (filter_data = (uint8_t*)mem_alloc( filter_data_bytes_len, MOD_BLOOM_FILTER)))) { ret = E_OOM; } else if (RET_FAIL(in.read_buf(filter_data, filter_data_bytes_len, diff --git a/cpp/src/reader/bloom_filter.h b/cpp/src/reader/bloom_filter.h index a43b264a0..b00de4a84 100644 --- a/cpp/src/reader/bloom_filter.h +++ b/cpp/src/reader/bloom_filter.h @@ -56,7 +56,7 @@ class BitSet { word_count_ = (size - 1) / 64 + 1; int32_t alloc_size = word_count_ * sizeof(uint64_t); words_ = - (uint64_t *)common::mem_alloc(alloc_size, common::MOD_BLOOM_FILTER); + (uint64_t*)common::mem_alloc(alloc_size, common::MOD_BLOOM_FILTER); if (IS_NULL(words_)) { return common::E_OOM; } @@ -82,12 +82,12 @@ class BitSet { } return 0; } - void to_bytes(uint8_t *&ret_bytes, int32_t &ret_len) const; - void revert_bytes(uint8_t *bytes) { common::mem_free(bytes); } - int from_bytes(uint8_t *filter_data, uint32_t filter_data_bytes_len); + void to_bytes(uint8_t*& ret_bytes, int32_t& ret_len) const; + void revert_bytes(uint8_t* bytes) { common::mem_free(bytes); } + int from_bytes(uint8_t* filter_data, uint32_t filter_data_bytes_len); private: - uint64_t *words_; + uint64_t* words_; int32_t word_count_; }; @@ -105,16 +105,16 @@ class BloomFilter { ~BloomFilter() { destroy(); } int init(double error_percent, int entry_count); void destroy() { bitset_.destroy(); } - int add_path_entry(const common::String &device_name, - const common::String &measurement_name); - int serialize_to(common::ByteStream &out); - int deserialize_from(common::ByteStream &in); - BitSet *get_bit_set() { return &bitset_; } + int add_path_entry(const common::String& device_name, + const common::String& measurement_name); + int serialize_to(common::ByteStream& out); + int deserialize_from(common::ByteStream& in); + BitSet* get_bit_set() { return &bitset_; } private: - common::String get_entry_string(const common::String &device_name, - const common::String &measurement_name); - FORCE_INLINE void free_entry_buf(char *entry_buf) { + common::String get_entry_string(const common::String& device_name, + const common::String& measurement_name); + FORCE_INLINE void free_entry_buf(char* entry_buf) { common::mem_free(entry_buf); } diff --git a/cpp/src/reader/chunk_reader.cc b/cpp/src/reader/chunk_reader.cc index d4ab50f1a..91de1e14c 100644 --- a/cpp/src/reader/chunk_reader.cc +++ b/cpp/src/reader/chunk_reader.cc @@ -25,8 +25,8 @@ using namespace common; namespace storage { -int ChunkReader::init(ReadFile *read_file, String m_name, TSDataType data_type, - Filter *time_filter) { +int ChunkReader::init(ReadFile* read_file, String m_name, TSDataType data_type, + Filter* time_filter) { read_file_ = read_file; measurement_name_.shallow_copy_from(m_name); time_decoder_ = DecoderFactory::alloc_time_decoder(); @@ -45,7 +45,7 @@ void ChunkReader::reset() { chunk_header_.reset(); cur_page_header_.reset(); - char *file_data_buf = in_stream_.get_wrapped_buf(); + char* file_data_buf = in_stream_.get_wrapped_buf(); if (file_data_buf != nullptr) { mem_free(file_data_buf); } @@ -70,7 +70,7 @@ void ChunkReader::destroy() { CompressorFactory::free(compressor_); compressor_ = nullptr; } - char *buf = in_stream_.get_wrapped_buf(); + char* buf = in_stream_.get_wrapped_buf(); if (buf != nullptr) { mem_free(buf); in_stream_.clear_wrapped_buf(); @@ -79,7 +79,7 @@ void ChunkReader::destroy() { chunk_header_.~ChunkHeader(); } -int ChunkReader::load_by_meta(ChunkMeta *meta) { +int ChunkReader::load_by_meta(ChunkMeta* meta) { int ret = E_OK; chunk_meta_ = meta; #if DEBUG_SE @@ -90,8 +90,8 @@ int ChunkReader::load_by_meta(ChunkMeta *meta) { // TODO configurable file_data_buf_size_ = 1024; int32_t ret_read_len = 0; - char *file_data_buf = - (char *)mem_alloc(file_data_buf_size_, MOD_CHUNK_READER); + char* file_data_buf = + (char*)mem_alloc(file_data_buf_size_, MOD_CHUNK_READER); if (IS_NULL(file_data_buf)) { return E_OOM; } @@ -149,10 +149,10 @@ int ChunkReader::alloc_compressor_and_value_decoder( return E_OK; } -int ChunkReader::get_next_page(TsBlock *ret_tsblock, Filter *oneshoot_filter, - PageArena &pa) { +int ChunkReader::get_next_page(TsBlock* ret_tsblock, Filter* oneshoot_filter, + PageArena& pa) { int ret = E_OK; - Filter *filter = + Filter* filter = (oneshoot_filter != nullptr ? oneshoot_filter : time_filter_); if (prev_page_not_finish()) { @@ -227,13 +227,13 @@ int ChunkReader::get_cur_page_header() { int ChunkReader::read_from_file_and_rewrap(int want_size) { int ret = E_OK; const int DEFAULT_READ_SIZE = 4096; // may use page_size + page_header_size - char *file_data_buf = in_stream_.get_wrapped_buf(); + char* file_data_buf = in_stream_.get_wrapped_buf(); int offset = chunk_meta_->offset_of_chunk_header_ + chunk_visit_offset_; int read_size = (want_size < DEFAULT_READ_SIZE ? DEFAULT_READ_SIZE : want_size); if (file_data_buf_size_ < read_size || read_size < file_data_buf_size_ / 10) { - file_data_buf = (char *)mem_realloc(file_data_buf, read_size); + file_data_buf = (char*)mem_realloc(file_data_buf, read_size); if (IS_NULL(file_data_buf)) { return E_OOM; } @@ -249,7 +249,7 @@ int ChunkReader::read_from_file_and_rewrap(int want_size) { return ret; } -bool ChunkReader::cur_page_statisify_filter(Filter *filter) { +bool ChunkReader::cur_page_statisify_filter(Filter* filter) { return filter == nullptr || cur_page_header_.statistic_ == nullptr || filter->satisfy(cur_page_header_.statistic_); } @@ -262,8 +262,8 @@ int ChunkReader::skip_cur_page() { return ret; } -int ChunkReader::decode_cur_page_data(TsBlock *&ret_tsblock, Filter *filter, - PageArena &pa) { +int ChunkReader::decode_cur_page_data(TsBlock*& ret_tsblock, Filter* filter, + PageArena& pa) { int ret = E_OK; // Step 1: make sure we load the whole page data in @in_stream_ @@ -276,12 +276,12 @@ int ChunkReader::decode_cur_page_data(TsBlock *&ret_tsblock, Filter *filter, } } - char *compressed_buf = nullptr; - char *uncompressed_buf = nullptr; + char* compressed_buf = nullptr; + char* uncompressed_buf = nullptr; uint32_t compressed_buf_size = 0; // cppcheck-suppress unreadVariable uint32_t uncompressed_buf_size = 0; - char *time_buf = nullptr; - char *value_buf = nullptr; + char* time_buf = nullptr; + char* value_buf = nullptr; uint32_t time_buf_size = 0; uint32_t value_buf_size = 0; @@ -381,16 +381,16 @@ int ChunkReader::decode_cur_page_data(TsBlock *&ret_tsblock, Filter *filter, } else { \ /*std::cout << "decoder: time=" << time << ", value=" << value \ * << std::endl;*/ \ - row_appender.append(0, (char *)&time, sizeof(time)); \ - row_appender.append(1, (char *)&value, sizeof(value)); \ + row_appender.append(0, (char*)&time, sizeof(time)); \ + row_appender.append(1, (char*)&value, sizeof(value)); \ } \ } \ } while (false) -int ChunkReader::i32_DECODE_TYPED_TV_INTO_TSBLOCK(ByteStream &time_in, - ByteStream &value_in, - RowAppender &row_appender, - Filter *filter) { +int ChunkReader::i32_DECODE_TYPED_TV_INTO_TSBLOCK(ByteStream& time_in, + ByteStream& value_in, + RowAppender& row_appender, + Filter* filter) { int ret = E_OK; do { int64_t time = 0; @@ -408,19 +408,19 @@ int ChunkReader::i32_DECODE_TYPED_TV_INTO_TSBLOCK(ByteStream &time_in, } else { /*std::cout << "decoder: time=" << time << ", value=" << value * << std::endl;*/ - row_appender.append(0, (char *)&time, sizeof(time)); - row_appender.append(1, (char *)&value, sizeof(value)); + row_appender.append(0, (char*)&time, sizeof(time)); + row_appender.append(1, (char*)&value, sizeof(value)); } } } while (false); return ret; } -int ChunkReader::STRING_DECODE_TYPED_TV_INTO_TSBLOCK(ByteStream &time_in, - ByteStream &value_in, - RowAppender &row_appender, - PageArena &pa, - Filter *filter) { +int ChunkReader::STRING_DECODE_TYPED_TV_INTO_TSBLOCK(ByteStream& time_in, + ByteStream& value_in, + RowAppender& row_appender, + PageArena& pa, + Filter* filter) { int ret = E_OK; int64_t time = 0; common::String value; @@ -435,18 +435,18 @@ int ChunkReader::STRING_DECODE_TYPED_TV_INTO_TSBLOCK(ByteStream &time_in, row_appender.backoff_add_row(); continue; } else { - row_appender.append(0, (char *)&time, sizeof(time)); + row_appender.append(0, (char*)&time, sizeof(time)); row_appender.append(1, value.buf_, value.len_); } } return ret; } -int ChunkReader::decode_tv_buf_into_tsblock_by_datatype(ByteStream &time_in, - ByteStream &value_in, - TsBlock *ret_tsblock, - Filter *filter, - common::PageArena *pa) { +int ChunkReader::decode_tv_buf_into_tsblock_by_datatype(ByteStream& time_in, + ByteStream& value_in, + TsBlock* ret_tsblock, + Filter* filter, + common::PageArena* pa) { int ret = E_OK; RowAppender row_appender(ret_tsblock); switch (chunk_header_.data_type_) { diff --git a/cpp/src/reader/chunk_reader.h b/cpp/src/reader/chunk_reader.h index 23be4847b..52c7f7a59 100644 --- a/cpp/src/reader/chunk_reader.h +++ b/cpp/src/reader/chunk_reader.h @@ -48,8 +48,8 @@ class ChunkReader : public IChunkReader { time_in_(), value_in_(), uncompressed_buf_(nullptr) {} - int init(ReadFile *read_file, common::String m_name, - common::TSDataType data_type, Filter *time_filter) override; + int init(ReadFile* read_file, common::String m_name, + common::TSDataType data_type, Filter* time_filter) override; void reset() override; void destroy() override; ~ChunkReader() override = default; @@ -59,16 +59,16 @@ class ChunkReader : public IChunkReader { (chunk_visit_offset_ - chunk_header_.serialized_size_ < chunk_header_.data_size_); } - ChunkHeader &get_chunk_header() override { return chunk_header_; } + ChunkHeader& get_chunk_header() override { return chunk_header_; } /* * prepare data buffer, load the chunk_header * and the first page_header. */ - int load_by_meta(ChunkMeta *meta) override; + int load_by_meta(ChunkMeta* meta) override; - int get_next_page(common::TsBlock *tsblock, Filter *oneshoot_filter, - common::PageArena &pa) override; + int get_next_page(common::TsBlock* tsblock, Filter* oneshoot_filter, + common::PageArena& pa) override; private: FORCE_INLINE bool chunk_has_only_one_page() const { @@ -81,33 +81,33 @@ class ChunkReader : public IChunkReader { common::CompressionType compression_type); int get_cur_page_header(); int read_from_file_and_rewrap(int want_size = 0); - bool cur_page_statisify_filter(Filter *filter); + bool cur_page_statisify_filter(Filter* filter); int skip_cur_page(); - int decode_cur_page_data(common::TsBlock *&ret_tsblock, Filter *filter, - common::PageArena &pa); + int decode_cur_page_data(common::TsBlock*& ret_tsblock, Filter* filter, + common::PageArena& pa); bool prev_page_not_finish() const { return (time_decoder_ && time_decoder_->has_remaining(time_in_)) || time_in_.has_remaining(); } - int decode_tv_buf_into_tsblock_by_datatype(common::ByteStream &time_in, - common::ByteStream &value_in, - common::TsBlock *ret_tsblock, - Filter *filter, - common::PageArena *pa = nullptr); - int i32_DECODE_TYPED_TV_INTO_TSBLOCK(common::ByteStream &time_in, - common::ByteStream &value_in, - common::RowAppender &row_appender, - Filter *filter); - int STRING_DECODE_TYPED_TV_INTO_TSBLOCK(common::ByteStream &time_in, - common::ByteStream &value_in, - common::RowAppender &row_appender, - common::PageArena &pa, - Filter *filter); + int decode_tv_buf_into_tsblock_by_datatype(common::ByteStream& time_in, + common::ByteStream& value_in, + common::TsBlock* ret_tsblock, + Filter* filter, + common::PageArena* pa = nullptr); + int i32_DECODE_TYPED_TV_INTO_TSBLOCK(common::ByteStream& time_in, + common::ByteStream& value_in, + common::RowAppender& row_appender, + Filter* filter); + int STRING_DECODE_TYPED_TV_INTO_TSBLOCK(common::ByteStream& time_in, + common::ByteStream& value_in, + common::RowAppender& row_appender, + common::PageArena& pa, + Filter* filter); private: - ReadFile *read_file_; - ChunkMeta *chunk_meta_; + ReadFile* read_file_; + ChunkMeta* chunk_meta_; common::String measurement_name_; ChunkHeader chunk_header_; PageHeader cur_page_header_; @@ -130,14 +130,14 @@ class ChunkReader : public IChunkReader { uint32_t chunk_visit_offset_; // Statistic *page_statistic_; - Compressor *compressor_; - Filter *time_filter_; + Compressor* compressor_; + Filter* time_filter_; - Decoder *time_decoder_; - Decoder *value_decoder_; + Decoder* time_decoder_; + Decoder* value_decoder_; common::ByteStream time_in_; common::ByteStream value_in_; - char *uncompressed_buf_; + char* uncompressed_buf_; }; } // end namespace storage diff --git a/cpp/src/reader/column_mapping.h b/cpp/src/reader/column_mapping.h index 97c2cc39e..abf9eafba 100644 --- a/cpp/src/reader/column_mapping.h +++ b/cpp/src/reader/column_mapping.h @@ -24,7 +24,7 @@ namespace storage { class ColumnMapping { public: - int add(const std::string &column_name, int index, TableSchema &schema) { + int add(const std::string& column_name, int index, TableSchema& schema) { int column_index = schema.find_column_index(column_name); if (column_index < 0) { return common::E_COLUMN_NOT_EXIST; @@ -43,32 +43,32 @@ class ColumnMapping { return common::E_OK; } - int add(const Expression &measurementFilter) { + int add(const Expression& measurementFilter) { // TODO: get measurements in the filter and add them to // field_columns_ return common::E_OK; } - const std::vector &get_column_pos( - const std::string &column_name) const { + const std::vector& get_column_pos( + const std::string& column_name) const { static const std::vector empty; auto it = column_pos_map.find(column_name); return it != column_pos_map.end() ? it->second : empty; } - bool is_tag(const std::string &column_name) const { + bool is_tag(const std::string& column_name) const { return tag_columns_.find(column_name) != tag_columns_.end(); } - bool is_field(const std::string &column_name) const { + bool is_field(const std::string& column_name) const { return field_columns_.find(column_name) != field_columns_.end(); } - const std::unordered_set &get_id_columns() const { + const std::unordered_set& get_id_columns() const { return tag_columns_; } - const std::unordered_set &get_measurement_columns() const { + const std::unordered_set& get_measurement_columns() const { return field_columns_; } diff --git a/cpp/src/reader/expression.cc b/cpp/src/reader/expression.cc index 417bc1708..06a615e15 100644 --- a/cpp/src/reader/expression.cc +++ b/cpp/src/reader/expression.cc @@ -25,14 +25,14 @@ namespace storage { void QueryExpression::add_time_filter_to_series_filter( - Filter *time_filter, Expression *single_series_expr) { - Filter *filter = new AndFilter(single_series_expr->filter_, time_filter); + Filter* time_filter, Expression* single_series_expr) { + Filter* filter = new AndFilter(single_series_expr->filter_, time_filter); single_series_expr->filter_ = filter; my_filters_.push_back(filter); } -void QueryExpression::add_time_filter_to_query_filter(Filter *time_filter, - Expression *expression) { +void QueryExpression::add_time_filter_to_query_filter(Filter* time_filter, + Expression* expression) { if (expression->type_ == SERIES_EXPR) { add_time_filter_to_series_filter(time_filter, expression); } else if ((expression->type_ == AND_EXPR) || @@ -46,17 +46,17 @@ void QueryExpression::add_time_filter_to_query_filter(Filter *time_filter, } } -Expression *QueryExpression::combine_two_global_time_filter( - Expression *left, Expression *right, ExpressionType type) { +Expression* QueryExpression::combine_two_global_time_filter( + Expression* left, Expression* right, ExpressionType type) { if (type == AND_EXPR) { - Filter *filter = new AndFilter(left->filter_, right->filter_); - Expression *expr = new Expression(GLOBALTIME_EXPR, filter); + Filter* filter = new AndFilter(left->filter_, right->filter_); + Expression* expr = new Expression(GLOBALTIME_EXPR, filter); my_filters_.push_back(filter); my_exprs_.push_back(expr); return expr; } else if (type == OR_EXPR) { - Filter *filter = new OrFilter(left->filter_, right->filter_); - Expression *expr = new Expression(GLOBALTIME_EXPR, filter); + Filter* filter = new OrFilter(left->filter_, right->filter_); + Expression* expr = new Expression(GLOBALTIME_EXPR, filter); my_filters_.push_back(filter); my_exprs_.push_back(expr); return expr; @@ -65,17 +65,17 @@ Expression *QueryExpression::combine_two_global_time_filter( return nullptr; } -bool QueryExpression::update_filter_with_or(Expression *expression, - Filter *filter, Path &path) { +bool QueryExpression::update_filter_with_or(Expression* expression, + Filter* filter, Path& path) { if (expression->type_ == SERIES_EXPR && expression->series_path_ == path) { - Filter *node_filter = expression->filter_; + Filter* node_filter = expression->filter_; node_filter = new OrFilter(node_filter, filter); my_filters_.push_back(node_filter); expression->filter_ = node_filter; return true; } else if (expression->type_ == OR_EXPR) { - Expression *left = expression->left_; - Expression *right = expression->right_; + Expression* left = expression->left_; + Expression* right = expression->right_; return update_filter_with_or(left, filter, path) || update_filter_with_or(right, filter, path); } else { @@ -83,40 +83,40 @@ bool QueryExpression::update_filter_with_or(Expression *expression, } } -Expression *QueryExpression::merge_second_tree_to_first_tree( - Expression *left_expression, Expression *right_expression) { +Expression* QueryExpression::merge_second_tree_to_first_tree( + Expression* left_expression, Expression* right_expression) { if (right_expression->type_ == SERIES_EXPR) { - Expression *leaf = right_expression; + Expression* leaf = right_expression; update_filter_with_or(left_expression, leaf->filter_, leaf->series_path_); return left_expression; } else if (right_expression->type_ == OR_EXPR) { - Expression *left_child = right_expression->left_; - Expression *right_child = right_expression->right_; + Expression* left_child = right_expression->left_; + Expression* right_child = right_expression->right_; left_expression = merge_second_tree_to_first_tree(left_expression, left_child); left_expression = merge_second_tree_to_first_tree(left_expression, right_child); return left_expression; } else { - Expression *expr = + Expression* expr = new Expression(OR_EXPR, left_expression, right_expression); my_exprs_.push_back(expr); return expr; } } -Expression *QueryExpression::push_global_time_filter_to_all_series( - Expression *time_filter, std::vector &selected_series) { +Expression* QueryExpression::push_global_time_filter_to_all_series( + Expression* time_filter, std::vector& selected_series) { if (selected_series.size() == 0) { std::cout << "size of selectSeries could not be 0" << std::endl; } - Expression *expression = new Expression(SERIES_EXPR, selected_series.at(0), + Expression* expression = new Expression(SERIES_EXPR, selected_series.at(0), time_filter->filter_); my_exprs_.push_back(expression); for (uint32_t i = 1; i < selected_series.size(); i++) { - Expression *r = new Expression(SERIES_EXPR, selected_series.at(i), + Expression* r = new Expression(SERIES_EXPR, selected_series.at(i), time_filter->filter_); expression = new Expression(OR_EXPR, expression, r); my_exprs_.push_back(r); @@ -125,10 +125,10 @@ Expression *QueryExpression::push_global_time_filter_to_all_series( return expression; } -Expression *QueryExpression::handle_one_global_time_filter( - Expression *left, Expression *expression, - std::vector &selected_series, ExpressionType type) { - Expression *expr = optimize(expression, selected_series); +Expression* QueryExpression::handle_one_global_time_filter( + Expression* left, Expression* expression, + std::vector& selected_series, ExpressionType type) { + Expression* expr = optimize(expression, selected_series); if (expr->type_ == GLOBALTIME_EXPR) { return combine_two_global_time_filter(left, expr, type); @@ -138,7 +138,7 @@ Expression *QueryExpression::handle_one_global_time_filter( add_time_filter_to_query_filter(left->filter_, expr); return expr; } else if (type == OR_EXPR) { - Expression *after_transform = + Expression* after_transform = push_global_time_filter_to_all_series(left, selected_series); return merge_second_tree_to_first_tree(after_transform, expr); } @@ -146,14 +146,14 @@ Expression *QueryExpression::handle_one_global_time_filter( return nullptr; } -Expression *QueryExpression::optimize(Expression *expression, - std::vector &series_paths) { +Expression* QueryExpression::optimize(Expression* expression, + std::vector& series_paths) { ExpressionType type = expression->type_; if (type == GLOBALTIME_EXPR || type == SERIES_EXPR) { return expression; } else if (type == AND_EXPR || type == OR_EXPR) { - Expression *left = expression->left_; - Expression *right = expression->right_; + Expression* left = expression->left_; + Expression* right = expression->right_; if (left->type_ == GLOBALTIME_EXPR && right->type_ == GLOBALTIME_EXPR) { return combine_two_global_time_filter(left, right, type); } else if (left->type_ == GLOBALTIME_EXPR && @@ -166,9 +166,9 @@ Expression *QueryExpression::optimize(Expression *expression, type); } else if (left->type_ != GLOBALTIME_EXPR && right->type_ != GLOBALTIME_EXPR) { - Expression *regular_left = optimize(left, series_paths); - Expression *regular_right = optimize(right, series_paths); - Expression *mid_ret = nullptr; + Expression* regular_left = optimize(left, series_paths); + Expression* regular_right = optimize(right, series_paths); + Expression* mid_ret = nullptr; if (type == AND_EXPR) { mid_ret = new Expression(AND_EXPR, regular_left, regular_right); my_exprs_.push_back(mid_ret); diff --git a/cpp/src/reader/expression.h b/cpp/src/reader/expression.h index f38404b0c..1cf72b6d2 100644 --- a/cpp/src/reader/expression.h +++ b/cpp/src/reader/expression.h @@ -40,9 +40,9 @@ enum ExpressionType { struct Expression { ExpressionType type_; - Expression *left_; - Expression *right_; - Filter *filter_; + Expression* left_; + Expression* right_; + Filter* filter_; Path series_path_; Expression(ExpressionType t) @@ -51,15 +51,15 @@ struct Expression { right_(nullptr), filter_(nullptr), series_path_() {} - Expression(ExpressionType t, Expression *l, Expression *r) + Expression(ExpressionType t, Expression* l, Expression* r) : type_(t), left_(l), right_(r), filter_(nullptr), series_path_() {} - Expression(ExpressionType t, Filter *f) + Expression(ExpressionType t, Filter* f) : type_(t), left_(nullptr), right_(nullptr), filter_(f), series_path_() {} - Expression(ExpressionType t, const Path &path, Filter *f) + Expression(ExpressionType t, const Path& path, Filter* f) : type_(t), left_(nullptr), right_(nullptr), @@ -87,61 +87,61 @@ class QueryExpression { QueryExpression() : has_filter_(false), expression_(nullptr) {} ~QueryExpression() { destory(); } - static QueryExpression *create(const std::vector &selected_series, - Expression *expression) { - QueryExpression *ret = new QueryExpression(); + static QueryExpression* create(const std::vector& selected_series, + Expression* expression) { + QueryExpression* ret = new QueryExpression(); ret->selected_series_ = selected_series; ret->expression_ = expression; ret->has_filter_ = (expression != nullptr); return ret; } - static void destory(QueryExpression *expr) { + static void destory(QueryExpression* expr) { if (expr) { delete expr; } } FORCE_INLINE void set_select_series( - const std::vector &selected_series) { + const std::vector& selected_series) { selected_series_ = selected_series; } - FORCE_INLINE void add_select_series(const Path &path) { + FORCE_INLINE void add_select_series(const Path& path) { selected_series_.push_back(path); } - FORCE_INLINE void set_expression(Expression *expression) { + FORCE_INLINE void set_expression(Expression* expression) { if (expression) { expression_ = expression; has_filter_ = true; } } - Expression *optimize(Expression *expression, - std::vector &series_paths); + Expression* optimize(Expression* expression, + std::vector& series_paths); void destory(); private: - Expression *combine_two_global_time_filter(Expression *left, - Expression *right, + Expression* combine_two_global_time_filter(Expression* left, + Expression* right, ExpressionType type); - Expression *handle_one_global_time_filter( - Expression *left, Expression *expression, - std::vector &selected_series, ExpressionType type); - void add_time_filter_to_query_filter(Filter *time_filter, - Expression *expression); - void add_time_filter_to_series_filter(Filter *time_filter, - Expression *single_series_expr); - Expression *push_global_time_filter_to_all_series( - Expression *time_filter, std::vector &selected_series); - Expression *merge_second_tree_to_first_tree(Expression *left_expression, - Expression *right_expression); - bool update_filter_with_or(Expression *expression, Filter *filter, - Path &path); + Expression* handle_one_global_time_filter( + Expression* left, Expression* expression, + std::vector& selected_series, ExpressionType type); + void add_time_filter_to_query_filter(Filter* time_filter, + Expression* expression); + void add_time_filter_to_series_filter(Filter* time_filter, + Expression* single_series_expr); + Expression* push_global_time_filter_to_all_series( + Expression* time_filter, std::vector& selected_series); + Expression* merge_second_tree_to_first_tree(Expression* left_expression, + Expression* right_expression); + bool update_filter_with_or(Expression* expression, Filter* filter, + Path& path); public: bool has_filter_; std::vector selected_series_; std::vector data_types_; - Expression *expression_; - std::vector my_exprs_; - std::vector my_filters_; + Expression* expression_; + std::vector my_exprs_; + std::vector my_filters_; }; } // namespace storage diff --git a/cpp/src/reader/filter/and_filter.h b/cpp/src/reader/filter/and_filter.h index 8706e372b..0d01000f8 100644 --- a/cpp/src/reader/filter/and_filter.h +++ b/cpp/src/reader/filter/and_filter.h @@ -28,9 +28,9 @@ class AndFilter : public BinaryFilter { public: AndFilter() : BinaryFilter() {} ~AndFilter() {} - AndFilter(Filter *left, Filter *right) : BinaryFilter(left, right) {} + AndFilter(Filter* left, Filter* right) : BinaryFilter(left, right) {} - FORCE_INLINE bool satisfy(Statistic *statistic) { + FORCE_INLINE bool satisfy(Statistic* statistic) { return left_->satisfy(statistic) && right_->satisfy(statistic); } @@ -50,25 +50,25 @@ class AndFilter : public BinaryFilter { right_->contain_start_end_time(start_time, end_time); } - std::vector *get_time_ranges() { - std::vector *result = new std::vector(); - std::vector *left_time_ranges = left_->get_time_ranges(); - std::vector *right_time_ranges = right_->get_time_ranges(); + std::vector* get_time_ranges() { + std::vector* result = new std::vector(); + std::vector* left_time_ranges = left_->get_time_ranges(); + std::vector* right_time_ranges = right_->get_time_ranges(); int left_index = 0, right_index = 0; int left_size = left_time_ranges->size(); int right_size = right_time_ranges->size(); while (left_index < left_size && right_index < right_size) { - TimeRange *left_range = left_time_ranges->at(left_index); - TimeRange *right_range = right_time_ranges->at(right_index); + TimeRange* left_range = left_time_ranges->at(left_index); + TimeRange* right_range = right_time_ranges->at(right_index); if (left_range->end_time_ < right_range->start_time_) { left_index++; } else if (right_range->end_time_ < left_range->start_time_) { right_index++; } else { - TimeRange *intersection = new TimeRange( + TimeRange* intersection = new TimeRange( std::max(left_range->start_time_, right_range->start_time_), std::min(left_range->end_time_, right_range->end_time_)); result->push_back(intersection); diff --git a/cpp/src/reader/filter/between.h b/cpp/src/reader/filter/between.h index 1928a36fb..f460d15f0 100644 --- a/cpp/src/reader/filter/between.h +++ b/cpp/src/reader/filter/between.h @@ -37,7 +37,7 @@ class Between : public Filter { virtual ~Between() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (type_ == TIME_FILTER) { if (not_) { return statistic->end_time_ < value1_ || @@ -52,8 +52,8 @@ class Between : public Filter { return true; } else { if (statistic->get_type() == common::INT32) { - Int32Statistic *stat = - dynamic_cast(statistic); + Int32Statistic* stat = + dynamic_cast(statistic); if (not_) { return ((stat->min_value_ < value1_) || (stat->max_value_ > value2_)); @@ -62,8 +62,8 @@ class Between : public Filter { (stat->min_value_ <= value2_)); } } else if (statistic->get_type() == common::INT64) { - Int64Statistic *stat = - dynamic_cast(statistic); + Int64Statistic* stat = + dynamic_cast(statistic); if (not_) { return ((stat->min_value_ < value1_) || (stat->max_value_ > value2_)); @@ -72,8 +72,8 @@ class Between : public Filter { (stat->min_value_ <= value2_)); } } else if (statistic->get_type() == common::FLOAT) { - FloatStatistic *stat = - dynamic_cast(statistic); + FloatStatistic* stat = + dynamic_cast(statistic); if (not_) { return ((stat->min_value_ < value1_) || (stat->max_value_ > value2_)); @@ -82,8 +82,8 @@ class Between : public Filter { (stat->min_value_ <= value2_)); } } else if (statistic->get_type() == common::DOUBLE) { - DoubleStatistic *stat = - dynamic_cast(statistic); + DoubleStatistic* stat = + dynamic_cast(statistic); if (not_) { return ((stat->min_value_ < value1_) || (stat->max_value_ > value2_)); diff --git a/cpp/src/reader/filter/binary_filter.h b/cpp/src/reader/filter/binary_filter.h index 14f113369..4cacd52a1 100644 --- a/cpp/src/reader/filter/binary_filter.h +++ b/cpp/src/reader/filter/binary_filter.h @@ -26,18 +26,18 @@ namespace storage { class BinaryFilter : public Filter { public: BinaryFilter() : Filter() {} - BinaryFilter(Filter *left, Filter *right) + BinaryFilter(Filter* left, Filter* right) : Filter(), left_(left), right_(right) {} virtual ~BinaryFilter() {} - void set_left(Filter *left) { left_ = left; } - void set_right(Filter *right) { right_ = right; } + void set_left(Filter* left) { left_ = left; } + void set_right(Filter* right) { right_ = right; } Filter get_left() { return *left_; } Filter get_right() { return *right_; } protected: - Filter *left_; - Filter *right_; + Filter* left_; + Filter* right_; }; } // namespace storage diff --git a/cpp/src/reader/filter/eq.h b/cpp/src/reader/filter/eq.h index 13e917b9b..bb425b8da 100644 --- a/cpp/src/reader/filter/eq.h +++ b/cpp/src/reader/filter/eq.h @@ -31,7 +31,7 @@ class Eq : public UnaryFilter { virtual ~Eq() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (this->type_ == TIME_FILTER) { return this->value_ >= statistic->start_time_ && this->value_ <= statistic->end_time_; diff --git a/cpp/src/reader/filter/gt.h b/cpp/src/reader/filter/gt.h index 5db7b9704..448ecf111 100644 --- a/cpp/src/reader/filter/gt.h +++ b/cpp/src/reader/filter/gt.h @@ -30,7 +30,7 @@ class Gt : public UnaryFilter { Gt(T value, FilterType type) : UnaryFilter(value, type) {} virtual ~Gt() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (this->type_ == TIME_FILTER) { return this->value_ < statistic->end_time_; } else { diff --git a/cpp/src/reader/filter/gt_eq.h b/cpp/src/reader/filter/gt_eq.h index 067c56087..688c08df3 100644 --- a/cpp/src/reader/filter/gt_eq.h +++ b/cpp/src/reader/filter/gt_eq.h @@ -31,7 +31,7 @@ class GtEq : public UnaryFilter { virtual ~GtEq() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (this->type_ == TIME_FILTER) { return this->value_ <= statistic->end_time_; } else { diff --git a/cpp/src/reader/filter/in.h b/cpp/src/reader/filter/in.h index 0c95de95e..135d2b6b8 100644 --- a/cpp/src/reader/filter/in.h +++ b/cpp/src/reader/filter/in.h @@ -30,11 +30,11 @@ template class In : public Filter { public: In() {} - In(std::vector &values, FilterType type, bool not_in) + In(std::vector& values, FilterType type, bool not_in) : values_(values), type_(type), not_(not_in) {} virtual ~In() {} - bool satisfy(Statistic *statistic) { return true; } + bool satisfy(Statistic* statistic) { return true; } bool satisfy(long time, Object value) { Object v = (type_ == TIME_FILTER ? time : value); diff --git a/cpp/src/reader/filter/lt.h b/cpp/src/reader/filter/lt.h index 062fb3af8..f254ec345 100644 --- a/cpp/src/reader/filter/lt.h +++ b/cpp/src/reader/filter/lt.h @@ -29,7 +29,7 @@ class Lt : public UnaryFilter { Lt(T value, FilterType type) : UnaryFilter(value, type) {} virtual ~Lt() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (this->type_ == TIME_FILTER) { return this->value_ > statistic->start_time_; } else { diff --git a/cpp/src/reader/filter/lt_eq.h b/cpp/src/reader/filter/lt_eq.h index aa866057b..d24f31100 100644 --- a/cpp/src/reader/filter/lt_eq.h +++ b/cpp/src/reader/filter/lt_eq.h @@ -32,7 +32,7 @@ class LtEq : public UnaryFilter { LtEq(T value, FilterType type) : UnaryFilter(value, type) {} virtual ~LtEq() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (this->type_ == TIME_FILTER) { return this->value_ >= statistic->start_time_; } else { diff --git a/cpp/src/reader/filter/not_eq.h b/cpp/src/reader/filter/not_eq.h index d9d543597..7bf5c413b 100644 --- a/cpp/src/reader/filter/not_eq.h +++ b/cpp/src/reader/filter/not_eq.h @@ -30,7 +30,7 @@ class NotEq : public UnaryFilter { NotEq(T value, FilterType type) : UnaryFilter(value, type) {} virtual ~NotEq() {} - bool satisfy(Statistic *statistic) { + bool satisfy(Statistic* statistic) { if (this->type_ == TIME_FILTER) { return !(this->value_ == statistic->start_time_ && this->value_ == statistic->end_time_); diff --git a/cpp/src/reader/filter/object.h b/cpp/src/reader/filter/object.h index 37d9f0bcc..c0117357b 100644 --- a/cpp/src/reader/filter/object.h +++ b/cpp/src/reader/filter/object.h @@ -33,56 +33,56 @@ class Object { int64_t lval_; float fval_; double dval_; - common::String *strval_; - char *sval_; + common::String* strval_; + char* sval_; } values_; Object() {} ~Object() {} - Object(const bool &val) { + Object(const bool& val) { type_ = common::BOOLEAN; values_.bval_ = val; } - Object(const int32_t &val) { + Object(const int32_t& val) { type_ = common::INT32; values_.ival_ = val; } - Object(const int64_t &val) { + Object(const int64_t& val) { type_ = common::INT64; values_.lval_ = val; } - Object(const float &val) { + Object(const float& val) { type_ = common::FLOAT; values_.fval_ = val; } - Object(const double &val) { + Object(const double& val) { type_ = common::DOUBLE; values_.dval_ = val; } - Object(char *val) { + Object(char* val) { type_ = common::TEXT; values_.sval_ = val; } - Object(common::String *val) { + Object(common::String* val) { type_ = common::STRING; pa.init(512, common::MOD_TSFILE_READER); values_.strval_ = new common::String(); values_.strval_->dup_from(*val, pa); } - Object(const std::string &val) { + Object(const std::string& val) { type_ = common::TEXT; - values_.sval_ = const_cast(val.c_str()); + values_.sval_ = const_cast(val.c_str()); } - bool equals(const Object &object) { + bool equals(const Object& object) { if (object.get_type() != type_) { return false; } @@ -104,7 +104,7 @@ class Object { } } - bool operator==(const Object &object) const { + bool operator==(const Object& object) const { if (object.get_type() != type_) { return false; } @@ -126,7 +126,7 @@ class Object { } } - bool operator!=(const Object &object) const { + bool operator!=(const Object& object) const { if (object.get_type() != type_) { return false; } @@ -148,7 +148,7 @@ class Object { } } - bool operator<(const Object &object) const { + bool operator<(const Object& object) const { if (object.get_type() != type_) { return false; } @@ -170,7 +170,7 @@ class Object { } } - bool operator<=(const Object &object) const { + bool operator<=(const Object& object) const { if (object.get_type() != type_) { return false; } @@ -192,7 +192,7 @@ class Object { } } - bool operator>(const Object &object) const { + bool operator>(const Object& object) const { if (object.get_type() != type_) { return false; } @@ -214,7 +214,7 @@ class Object { } } - bool operator>=(const Object &object) const { + bool operator>=(const Object& object) const { if (object.get_type() != type_) { return false; } @@ -236,31 +236,31 @@ class Object { } } - friend bool operator>=(const Object &object1, const Object &objec2) { + friend bool operator>=(const Object& object1, const Object& objec2) { return object1.operator>=(objec2); } - friend bool operator>(const Object &object1, const Object &objec2) { + friend bool operator>(const Object& object1, const Object& objec2) { return object1.operator>(objec2); } - friend bool operator==(const Object &object1, const Object &objec2) { + friend bool operator==(const Object& object1, const Object& objec2) { return object1.operator==(objec2); } - friend bool operator<=(const Object &object1, const Object &objec2) { + friend bool operator<=(const Object& object1, const Object& objec2) { return object1.operator<=(objec2); } - friend bool operator<(const Object &object1, const Object &objec2) { + friend bool operator<(const Object& object1, const Object& objec2) { return object1.operator<(objec2); } - friend bool operator!=(const Object &object1, const Object &objec2) { + friend bool operator!=(const Object& object1, const Object& objec2) { return object1.operator!=(objec2); } - bool operator>=(const int64_t &time) const {} - bool operator<=(const int64_t &time) const {} - bool operator==(const int64_t &time) const {} - bool operator>(const int64_t &time) const {} - bool operator<(const int64_t &time) const {} - bool operator!=(const int64_t &time) const {} + bool operator>=(const int64_t& time) const {} + bool operator<=(const int64_t& time) const {} + bool operator==(const int64_t& time) const {} + bool operator>(const int64_t& time) const {} + bool operator<(const int64_t& time) const {} + bool operator!=(const int64_t& time) const {} FORCE_INLINE const common::TSDataType get_type() const { return type_; } diff --git a/cpp/src/reader/filter/or_filter.h b/cpp/src/reader/filter/or_filter.h index 41ff86b2d..1d4aa6aa7 100644 --- a/cpp/src/reader/filter/or_filter.h +++ b/cpp/src/reader/filter/or_filter.h @@ -27,10 +27,10 @@ namespace storage { class OrFilter : public BinaryFilter { public: OrFilter() {} - OrFilter(Filter *left, Filter *right) : BinaryFilter(left, right) {} + OrFilter(Filter* left, Filter* right) : BinaryFilter(left, right) {} ~OrFilter() {} - FORCE_INLINE bool satisfy(Statistic *statistic) { + FORCE_INLINE bool satisfy(Statistic* statistic) { return left_->satisfy(statistic) || right_->satisfy(statistic); } @@ -50,18 +50,18 @@ class OrFilter : public BinaryFilter { right_->contain_start_end_time(start_time, end_time); } - std::vector *get_time_ranges() { - std::vector *result = new std::vector(); - std::vector *left_time_ranges = left_->get_time_ranges(); - std::vector *right_time_ranges = right_->get_time_ranges(); + std::vector* get_time_ranges() { + std::vector* result = new std::vector(); + std::vector* left_time_ranges = left_->get_time_ranges(); + std::vector* right_time_ranges = right_->get_time_ranges(); int left_index = 0, right_index = 0; int left_size = left_time_ranges->size(); int right_size = right_time_ranges->size(); - TimeRange *range = choose_next_range( + TimeRange* range = choose_next_range( left_time_ranges, right_time_ranges, left_index, right_index); while (left_index < left_size || right_index < right_size) { - TimeRange *choosen_range = choose_next_range( + TimeRange* choosen_range = choose_next_range( left_time_ranges, right_time_ranges, left_index, right_index); if (choosen_range->start_time_ > range->end_time_) { result->push_back( @@ -77,14 +77,14 @@ class OrFilter : public BinaryFilter { } private: - TimeRange *choose_next_range(std::vector *left_time_ranges, - std::vector *right_time_ranges, - int &left_index, int &right_index) { + TimeRange* choose_next_range(std::vector* left_time_ranges, + std::vector* right_time_ranges, + int& left_index, int& right_index) { int left_size = left_time_ranges->size(); int right_size = right_time_ranges->size(); if (left_index < left_size && right_index < right_size) { - TimeRange *left_range = left_time_ranges->at(left_index); - TimeRange *right_range = right_time_ranges->at(right_index); + TimeRange* left_range = left_time_ranges->at(left_index); + TimeRange* right_range = right_time_ranges->at(right_index); // Choose the range with the smaller minimum start time if (left_range->start_time_ <= right_range->start_time_) { left_index++; diff --git a/cpp/src/reader/filter/time_operator.cc b/cpp/src/reader/filter/time_operator.cc index b57e41038..19f33b599 100644 --- a/cpp/src/reader/filter/time_operator.cc +++ b/cpp/src/reader/filter/time_operator.cc @@ -28,7 +28,7 @@ TimeBetween::TimeBetween(int64_t value1, int64_t value2, bool not_between) TimeBetween::~TimeBetween() {} -bool TimeBetween::satisfy(Statistic *statistic) { +bool TimeBetween::satisfy(Statistic* statistic) { if (not_) { return statistic->end_time_ < value1_ || statistic->start_time_ > value2_; @@ -62,8 +62,8 @@ bool TimeBetween::contain_start_end_time(int64_t start_time, int64_t end_time) { } } -std::vector *TimeBetween::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeBetween::get_time_ranges() { + std::vector* result = new std::vector(); if (not_) { if (value1_ != std::numeric_limits::min()) { result->push_back(new TimeRange(std::numeric_limits::min(), @@ -80,12 +80,12 @@ std::vector *TimeBetween::get_time_ranges() { } // TimeIn -TimeIn::TimeIn(const std::vector &values, bool not_in) +TimeIn::TimeIn(const std::vector& values, bool not_in) : values_(values), type_(TIME_FILTER), not_(not_in) {} TimeIn::~TimeIn() {} -bool TimeIn::satisfy(Statistic *statistic) { return true; } +bool TimeIn::satisfy(Statistic* statistic) { return true; } bool TimeIn::satisfy(int64_t time, int64_t value) { std::vector::iterator it = @@ -109,8 +109,8 @@ bool TimeIn::contain_start_end_time(int64_t start_time, int64_t end_time) { return true; } -std::vector *TimeIn::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeIn::get_time_ranges() { + std::vector* result = new std::vector(); int size = values_.size(); for (int i = 0; i < size; ++i) { result->push_back(new TimeRange(values_[i], values_[i])); @@ -122,7 +122,7 @@ std::vector *TimeIn::get_time_ranges() { TimeEq::TimeEq(int64_t value) : value_(value), type_(TIME_FILTER) {} TimeEq::~TimeEq() {} -bool TimeEq::satisfy(Statistic *statistic) { +bool TimeEq::satisfy(Statistic* statistic) { return value_ >= statistic->start_time_ && value_ <= statistic->end_time_; } @@ -140,8 +140,8 @@ bool TimeEq::contain_start_end_time(int64_t start_time, int64_t end_time) { return value_ == start_time && value_ == end_time; } -std::vector *TimeEq::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeEq::get_time_ranges() { + std::vector* result = new std::vector(); result->push_back(new TimeRange(value_, value_)); return result; } @@ -150,7 +150,7 @@ std::vector *TimeEq::get_time_ranges() { TimeNotEq::TimeNotEq(int64_t value) : value_(value), type_(TIME_FILTER) {} TimeNotEq::~TimeNotEq() {} -bool TimeNotEq::satisfy(Statistic *statistic) { +bool TimeNotEq::satisfy(Statistic* statistic) { return !(value_ == statistic->start_time_ && value_ == statistic->end_time_); } @@ -171,8 +171,8 @@ bool TimeNotEq::contain_start_end_time(int64_t start_time, int64_t end_time) { return value_ < start_time || value_ > end_time; } -std::vector *TimeNotEq::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeNotEq::get_time_ranges() { + std::vector* result = new std::vector(); if (value_ == std::numeric_limits::min()) { result->push_back( new TimeRange(value_ + 1, std::numeric_limits::max())); @@ -192,7 +192,7 @@ std::vector *TimeNotEq::get_time_ranges() { TimeGt::TimeGt(int64_t value) : value_(value), type_(TIME_FILTER) {} TimeGt::~TimeGt() {} -bool TimeGt::satisfy(Statistic *statistic) { +bool TimeGt::satisfy(Statistic* statistic) { return value_ < statistic->end_time_; } @@ -210,8 +210,8 @@ bool TimeGt::contain_start_end_time(int64_t start_time, int64_t end_time) { return value_ < start_time; } -std::vector *TimeGt::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeGt::get_time_ranges() { + std::vector* result = new std::vector(); if (value_ != std::numeric_limits::max()) { result->push_back( new TimeRange(value_ + 1, std::numeric_limits::max())); @@ -223,7 +223,7 @@ std::vector *TimeGt::get_time_ranges() { TimeGtEq::TimeGtEq(int64_t value) : value_(value), type_(TIME_FILTER) {} TimeGtEq::~TimeGtEq() {} -bool TimeGtEq::satisfy(Statistic *statistic) { +bool TimeGtEq::satisfy(Statistic* statistic) { return value_ <= statistic->end_time_; } @@ -241,8 +241,8 @@ bool TimeGtEq::contain_start_end_time(int64_t start_time, int64_t end_time) { return value_ <= start_time; } -std::vector *TimeGtEq::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeGtEq::get_time_ranges() { + std::vector* result = new std::vector(); result->push_back( new TimeRange(value_, std::numeric_limits::max())); return result; @@ -252,7 +252,7 @@ std::vector *TimeGtEq::get_time_ranges() { TimeLt::TimeLt(int64_t value) : value_(value), type_(TIME_FILTER) {} TimeLt::~TimeLt() {} -bool TimeLt::satisfy(Statistic *statistic) { +bool TimeLt::satisfy(Statistic* statistic) { return value_ > statistic->start_time_; } @@ -270,8 +270,8 @@ bool TimeLt::contain_start_end_time(int64_t start_time, int64_t end_time) { return value_ > end_time; } -std::vector *TimeLt::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeLt::get_time_ranges() { + std::vector* result = new std::vector(); if (value_ != std::numeric_limits::min()) { result->push_back( new TimeRange(std::numeric_limits::min(), value_ - 1)); @@ -283,7 +283,7 @@ std::vector *TimeLt::get_time_ranges() { TimeLtEq::TimeLtEq(int64_t value) : value_(value), type_(TIME_FILTER) {} TimeLtEq::~TimeLtEq() {} -bool TimeLtEq::satisfy(Statistic *statistic) { +bool TimeLtEq::satisfy(Statistic* statistic) { return value_ >= statistic->start_time_; } @@ -301,8 +301,8 @@ bool TimeLtEq::contain_start_end_time(int64_t start_time, int64_t end_time) { return value_ >= end_time; } -std::vector *TimeLtEq::get_time_ranges() { - std::vector *result = new std::vector(); +std::vector* TimeLtEq::get_time_ranges() { + std::vector* result = new std::vector(); result->push_back( new TimeRange(std::numeric_limits::min(), value_)); return result; diff --git a/cpp/src/reader/filter/time_operator.h b/cpp/src/reader/filter/time_operator.h index b3007e539..29930b88a 100644 --- a/cpp/src/reader/filter/time_operator.h +++ b/cpp/src/reader/filter/time_operator.h @@ -36,7 +36,7 @@ class TimeBetween : public Filter { ~TimeBetween(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -46,7 +46,7 @@ class TimeBetween : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } private: @@ -58,11 +58,11 @@ class TimeBetween : public Filter { class TimeIn : public Filter { public: - TimeIn(const std::vector &values, bool not_in); + TimeIn(const std::vector& values, bool not_in); ~TimeIn(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -72,7 +72,7 @@ class TimeIn : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } @@ -87,7 +87,7 @@ class TimeEq : public Filter { explicit TimeEq(int64_t value); ~TimeEq(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -97,7 +97,7 @@ class TimeEq : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } @@ -111,7 +111,7 @@ class TimeNotEq : public Filter { explicit TimeNotEq(int64_t value); ~TimeNotEq(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -121,7 +121,7 @@ class TimeNotEq : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } private: @@ -134,7 +134,7 @@ class TimeGt : public Filter { explicit TimeGt(int64_t value); ~TimeGt(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -144,7 +144,7 @@ class TimeGt : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } @@ -158,7 +158,7 @@ class TimeGtEq : public Filter { explicit TimeGtEq(int64_t value); ~TimeGtEq(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -168,7 +168,7 @@ class TimeGtEq : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); void reset_value(int64_t val) { value_ = val; } FilterType get_filter_type() { return type_; } @@ -182,7 +182,7 @@ class TimeLt : public Filter { explicit TimeLt(int64_t value); ~TimeLt(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -192,7 +192,7 @@ class TimeLt : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } @@ -206,7 +206,7 @@ class TimeLtEq : public Filter { explicit TimeLtEq(int64_t value); ~TimeLtEq(); - bool satisfy(Statistic *statistic); + bool satisfy(Statistic* statistic); bool satisfy(int64_t time, int64_t value); @@ -216,7 +216,7 @@ class TimeLtEq : public Filter { bool contain_start_end_time(int64_t start_time, int64_t end_time); - std::vector *get_time_ranges(); + std::vector* get_time_ranges(); FilterType get_filter_type() { return type_; } private: diff --git a/cpp/src/reader/filter/unary_filter.h b/cpp/src/reader/filter/unary_filter.h index 16d55510b..135fc6192 100644 --- a/cpp/src/reader/filter/unary_filter.h +++ b/cpp/src/reader/filter/unary_filter.h @@ -39,7 +39,7 @@ class UnaryFilter : public Filter { FilterType get_filter_type() { return type_; } - virtual bool satisfy(Statistic *statistic) { + virtual bool satisfy(Statistic* statistic) { ASSERT(false); return false; } diff --git a/cpp/src/reader/ichunk_reader.h b/cpp/src/reader/ichunk_reader.h index b5f22b7de..ffb841fab 100644 --- a/cpp/src/reader/ichunk_reader.h +++ b/cpp/src/reader/ichunk_reader.h @@ -31,8 +31,8 @@ namespace storage { class IChunkReader { public: IChunkReader() {} - virtual int init(ReadFile *read_file, common::String m_name, - common::TSDataType data_type, Filter *time_filter) { + virtual int init(ReadFile* read_file, common::String m_name, + common::TSDataType data_type, Filter* time_filter) { return common::E_OK; } virtual ~IChunkReader() = default; @@ -41,18 +41,18 @@ class IChunkReader { virtual bool has_more_data() const { return false; } - virtual int load_by_meta(ChunkMeta *meta) { return common::E_INVALID_ARG; } - virtual int load_by_aligned_meta(ChunkMeta *time_meta, - ChunkMeta *value_meta) { + virtual int load_by_meta(ChunkMeta* meta) { return common::E_INVALID_ARG; } + virtual int load_by_aligned_meta(ChunkMeta* time_meta, + ChunkMeta* value_meta) { return common::E_INVALID_ARG; } - virtual int get_next_page(common::TsBlock *tsblock, Filter *oneshoot_filter, - common::PageArena &pa) { + virtual int get_next_page(common::TsBlock* tsblock, Filter* oneshoot_filter, + common::PageArena& pa) { return common::E_OK; } - virtual ChunkHeader &get_chunk_header() { return chunk_header_; } + virtual ChunkHeader& get_chunk_header() { return chunk_header_; } protected: ChunkHeader chunk_header_; diff --git a/cpp/src/reader/qds_with_timegenerator.h b/cpp/src/reader/qds_with_timegenerator.h index 699168685..52892df14 100644 --- a/cpp/src/reader/qds_with_timegenerator.h +++ b/cpp/src/reader/qds_with_timegenerator.h @@ -33,10 +33,10 @@ enum NodeType { LEAF_NODE = 0, AND_NODE, OR_NODE }; static const int64_t INVALID_NEXT_TIMESTAMP = -1; struct SeriesScanStream { - TsFileIOReader *io_reader_; - TsFileSeriesScanIterator *ssi_; - common::TsBlock *tsblock_; - common::ColIterator *col_iter_; + TsFileIOReader* io_reader_; + TsFileSeriesScanIterator* ssi_; + common::TsBlock* tsblock_; + common::ColIterator* col_iter_; SeriesScanStream() : io_reader_(nullptr), @@ -53,14 +53,14 @@ struct SeriesScanStream { }; struct ValueAt { - TsFileSeriesScanIterator *ssi_; - common::TsBlock *tsblock_; - common::ColIterator *time_col_iter_; - common::ColIterator *value_col_iter_; + TsFileSeriesScanIterator* ssi_; + common::TsBlock* tsblock_; + common::ColIterator* time_col_iter_; + common::ColIterator* value_col_iter_; int64_t cur_time_; - TimeGtEq *tf_; + TimeGtEq* tf_; common::TSDataType data_type_; - TsFileIOReader *io_reader_; + TsFileIOReader* io_reader_; ValueAt() : ssi_(nullptr), @@ -73,7 +73,7 @@ struct ValueAt { io_reader_(nullptr) {} // get value object pointer at time @target_timestamp // if no such TV exists, return nullptr - void *at(int64_t target_timestamp); + void* at(int64_t target_timestamp); void destroy(); }; @@ -86,8 +86,8 @@ enum NextDirection { }; struct Node { - Node *left_; - Node *right_; + Node* left_; + Node* right_; SeriesScanStream sss_; NodeType type_; NextDirection next_direction_; @@ -116,22 +116,22 @@ class QDSWithTimeGenerator : public ResultSet { value_at_vec_() {} ~QDSWithTimeGenerator() { close(); } - int init(TsFileIOReader *io_reader, QueryExpression *qe); + int init(TsFileIOReader* io_reader, QueryExpression* qe); void close(); - int next(bool &has_next); - bool is_null(const std::string &column_name); + int next(bool& has_next); + bool is_null(const std::string& column_name); bool is_null(uint32_t column_index); - RowRecord *get_row_record(); + RowRecord* get_row_record(); std::shared_ptr get_metadata(); private: - int construct_node_tree(Expression *expr, Node *&node); + int construct_node_tree(Expression* expr, Node*& node); private: std::shared_ptr result_set_metadata_; - TsFileIOReader *io_reader_; - QueryExpression *qe_; - Node *tree_; + TsFileIOReader* io_reader_; + QueryExpression* qe_; + Node* tree_; std::vector value_at_vec_; }; diff --git a/cpp/src/reader/qds_without_timegenerator.h b/cpp/src/reader/qds_without_timegenerator.h index ae1922faf..0619fa673 100644 --- a/cpp/src/reader/qds_without_timegenerator.h +++ b/cpp/src/reader/qds_without_timegenerator.h @@ -41,12 +41,12 @@ class QDSWithoutTimeGenerator : public ResultSet { value_iters_(), heap_time_() {} ~QDSWithoutTimeGenerator() { close(); } - int init(TsFileIOReader *io_reader, QueryExpression *qe); + int init(TsFileIOReader* io_reader, QueryExpression* qe); void close(); - int next(bool &has_next); - bool is_null(const std::string &column_name); + int next(bool& has_next); + bool is_null(const std::string& column_name); bool is_null(uint32_t column_index); - RowRecord *get_row_record(); + RowRecord* get_row_record(); std::shared_ptr get_metadata(); private: @@ -54,12 +54,12 @@ class QDSWithoutTimeGenerator : public ResultSet { private: std::shared_ptr result_set_metadata_; - TsFileIOReader *io_reader_; - QueryExpression *qe_; - std::vector ssi_vec_; - std::vector tsblocks_; - std::vector time_iters_; - std::vector value_iters_; + TsFileIOReader* io_reader_; + QueryExpression* qe_; + std::vector ssi_vec_; + std::vector tsblocks_; + std::vector time_iters_; + std::vector value_iters_; std::multimap heap_time_; // key-->time, value-->path_index }; diff --git a/cpp/src/reader/scan_iterator.cc b/cpp/src/reader/scan_iterator.cc index b7d398d4c..2d1d66fd0 100644 --- a/cpp/src/reader/scan_iterator.cc +++ b/cpp/src/reader/scan_iterator.cc @@ -23,14 +23,14 @@ using namespace common; namespace storage { -int DataRun::remove_tsfile(const FileID &to_remove) { +int DataRun::remove_tsfile(const FileID& to_remove) { ASSERT(run_type_ == DRT_TSFILE); int ret = E_OK; - SimpleList::Iterator it = tsfile_list_.begin(); - OpenFile *of = nullptr; + SimpleList::Iterator it = tsfile_list_.begin(); + OpenFile* of = nullptr; for (; it != tsfile_list_.end(); it++) { - OpenFile *cur = it.get(); + OpenFile* cur = it.get(); if (cur->get_file_id() == to_remove) { of = cur; break; @@ -42,7 +42,7 @@ int DataRun::remove_tsfile(const FileID &to_remove) { return ret; } -int DataRun::get_next(TsBlock *ret_block, TimeRange &ret_time_range, +int DataRun::get_next(TsBlock* ret_block, TimeRange& ret_time_range, bool alloc_tsblock) { if (run_type_ == DRT_TVLIST) { return tvlist_get_next(ret_block, ret_time_range, alloc_tsblock); @@ -52,7 +52,7 @@ int DataRun::get_next(TsBlock *ret_block, TimeRange &ret_time_range, } } -TsBlock *DataRun::alloc_tsblock() { +TsBlock* DataRun::alloc_tsblock() { tuple_desc_.reset(); // TODO default config of time_cd tuple_desc_.push_back(g_time_column_schema); @@ -60,7 +60,7 @@ TsBlock *DataRun::alloc_tsblock() { return (new TsBlock(&tuple_desc_)); } -int DataRun::tvlist_get_next(TsBlock *ret_block, TimeRange &ret_time_range, +int DataRun::tvlist_get_next(TsBlock* ret_block, TimeRange& ret_time_range, bool tsblock) { // TODO @tsblock int ret = E_OK; @@ -72,7 +72,7 @@ int DataRun::tvlist_get_next(TsBlock *ret_block, TimeRange &ret_time_range, if (tvlist_list_iter_ == tvlist_list_.end()) { return E_NO_MORE_DATA; } else { - SeqTVListBase *tvlist_base = tvlist_list_iter_.get(); + SeqTVListBase* tvlist_base = tvlist_list_iter_.get(); if (!tvlist_base->is_immutable()) { tvlist_base->lock(); } @@ -91,8 +91,8 @@ int DataRun::tvlist_get_next(TsBlock *ret_block, TimeRange &ret_time_range, return ret; } -int DataRun::fill_tsblock_from_tvlist(SeqTVListBase *tvlist, TsBlock *ret_block, - TimeRange &ret_time_range) { +int DataRun::fill_tsblock_from_tvlist(SeqTVListBase* tvlist, TsBlock* ret_block, + TimeRange& ret_time_range) { int ret = E_OK; switch (col_schema_->data_type_) { case common::BOOLEAN: @@ -123,12 +123,12 @@ int DataRun::fill_tsblock_from_tvlist(SeqTVListBase *tvlist, TsBlock *ret_block, } template -int DataRun::fill_tsblock_from_typed_tvlist(SeqTVListBase *tvlist, - TsBlock *ret_block, - TimeRange &ret_time_range) { +int DataRun::fill_tsblock_from_typed_tvlist(SeqTVListBase* tvlist, + TsBlock* ret_block, + TimeRange& ret_time_range) { int ret = E_OK; - SeqTVList *typed_tvlist = static_cast *>(tvlist); + SeqTVList* typed_tvlist = static_cast*>(tvlist); typename SeqTVList::Iterator it; it = typed_tvlist->scan_without_lock(); typename SeqTVList::TV tv; @@ -147,19 +147,19 @@ int DataRun::fill_tsblock_from_typed_tvlist(SeqTVListBase *tvlist, << std::endl; #endif row_appender.add_row(); - row_appender.append(0, reinterpret_cast(&tv.time_), + row_appender.append(0, reinterpret_cast(&tv.time_), sizeof(tv.time_)); - row_appender.append(1, reinterpret_cast(&tv.value_), + row_appender.append(1, reinterpret_cast(&tv.value_), sizeof(tv.value_)); } return ret; } -int DataRun::reinit_io_reader(SimpleList::Iterator &it, - common::PageArena *pa) { +int DataRun::reinit_io_reader(SimpleList::Iterator& it, + common::PageArena* pa) { int ret = E_OK; // maybe io_reader_ destroy before re-init - OpenFile *open_file = it.get(); + OpenFile* open_file = it.get(); io_reader_.reset(); if (RET_FAIL(io_reader_.init(open_file->get_file_path()))) { ////log_err("io_reader init error, ret=%d, file_path=%s", @@ -180,7 +180,7 @@ int DataRun::reinit_io_reader(SimpleList::Iterator &it, return ret; } -int DataRun::tsfile_get_next(TsBlock *ret_tsblock, TimeRange &ret_time_range, +int DataRun::tsfile_get_next(TsBlock* ret_tsblock, TimeRange& ret_time_range, bool alloc_tsblock) { int ret = E_OK; if (UNLIKELY(!tsfile_list_iter_.is_inited())) { @@ -205,8 +205,8 @@ int DataRun::tsfile_get_next(TsBlock *ret_tsblock, TimeRange &ret_time_range, return ret; } -DataRun *DataScanIterator::alloc_data_run(DataRunType run_type) { - void *buf = page_arena_.alloc(sizeof(DataRun)); +DataRun* DataScanIterator::alloc_data_run(DataRunType run_type) { + void* buf = page_arena_.alloc(sizeof(DataRun)); if (IS_NULL(buf)) { return nullptr; } @@ -215,7 +215,7 @@ DataRun *DataScanIterator::alloc_data_run(DataRunType run_type) { #ifndef NDEBUG void DataScanIterator::DEBUG_dump_data_run_list() { - SimpleList::Iterator it; + SimpleList::Iterator it; std::cout << "\n/---- DEBUG_dump_data_run_list: size=" << data_run_list_.size() << "----\\" << std::endl; int idx = 0; @@ -228,7 +228,7 @@ void DataScanIterator::DEBUG_dump_data_run_list() { } #endif -int DataScanIterator::get_next(TsBlock *ret_block, bool alloc_tsblock) { +int DataScanIterator::get_next(TsBlock* ret_block, bool alloc_tsblock) { #ifndef NDEBUG DEBUG_dump_data_run_list(); #endif @@ -240,7 +240,7 @@ int DataScanIterator::get_next(TsBlock *ret_block, bool alloc_tsblock) { while (true) { TimeRange time_range; - DataRun *data_run = cursor_.get(); + DataRun* data_run = cursor_.get(); ret = data_run->get_next(ret_block, time_range, alloc_tsblock); if (ret == E_OK) { return ret; diff --git a/cpp/src/reader/scan_iterator.h b/cpp/src/reader/scan_iterator.h index 3a15eb051..8769624f4 100644 --- a/cpp/src/reader/scan_iterator.h +++ b/cpp/src/reader/scan_iterator.h @@ -47,8 +47,8 @@ enum DataRunType { */ class DataRun { public: - DataRun(DataRunType run_type, common::ColumnSchema *col_schema, - common::PageArena *pa) + DataRun(DataRunType run_type, common::ColumnSchema* col_schema, + common::PageArena* pa) : run_type_(run_type), col_schema_(col_schema), time_range_(), @@ -60,37 +60,37 @@ class DataRun { ssi_(nullptr), tuple_desc_() {} - int get_next(common::TsBlock *ret_block, TimeRange &ret_time_range, + int get_next(common::TsBlock* ret_block, TimeRange& ret_time_range, bool alloc); - const char *get_data_run_type_name(DataRunType type) { + const char* get_data_run_type_name(DataRunType type) { ASSERT(type == DRT_TVLIST || type == DRT_TSFILE); - static const char *names[2] = {"TVLIST", "TSFILE"}; + static const char* names[2] = {"TVLIST", "TSFILE"}; return names[type]; } - int remove_tsfile(const common::FileID &file_id); + int remove_tsfile(const common::FileID& file_id); #ifndef NDEBUG - friend std::ostream &operator<<(std::ostream &out, DataRun &data_run) { + friend std::ostream& operator<<(std::ostream& out, DataRun& data_run) { out << "type=" << data_run.get_data_run_type_name(data_run.run_type_) << ", time_range={start=" << data_run.time_range_.start_time_ << ", end=" << data_run.time_range_.end_time_ << "}"; if (DRT_TVLIST == data_run.run_type_) { - common::SimpleList::Iterator it; + common::SimpleList::Iterator it; int count = 0; out << ", tvlist_list={"; for (it = data_run.tvlist_list_.begin(); it != data_run.tvlist_list_.end(); it++) { if (it == data_run.tvlist_list_.begin()) { - out << "[" << count << "]" << (void *)it.get(); + out << "[" << count << "]" << (void*)it.get(); } else { - out << ", [" << count << "]" << (void *)it.get(); + out << ", [" << count << "]" << (void*)it.get(); } count++; } out << "}"; } else if (DRT_TSFILE == data_run.run_type_) { - common::SimpleList::Iterator it; + common::SimpleList::Iterator it; int count = 0; out << ", tsfile_list={"; for (it = data_run.tsfile_list_.begin(); @@ -109,36 +109,36 @@ class DataRun { #endif private: - int tvlist_get_next(common::TsBlock *ret_block, TimeRange &ret_time_range, + int tvlist_get_next(common::TsBlock* ret_block, TimeRange& ret_time_range, bool alloc); - int fill_tsblock_from_tvlist(SeqTVListBase *tvlist, - common::TsBlock *ret_block, - TimeRange &ret_time_range); + int fill_tsblock_from_tvlist(SeqTVListBase* tvlist, + common::TsBlock* ret_block, + TimeRange& ret_time_range); template - int fill_tsblock_from_typed_tvlist(SeqTVListBase *tvlist, - common::TsBlock *ret_block, - TimeRange &ret_time_range); - int tsfile_get_next(common::TsBlock *ret_block, TimeRange &ret_time_range, + int fill_tsblock_from_typed_tvlist(SeqTVListBase* tvlist, + common::TsBlock* ret_block, + TimeRange& ret_time_range); + int tsfile_get_next(common::TsBlock* ret_block, TimeRange& ret_time_range, bool alloc); - int reinit_io_reader(common::SimpleList::Iterator &it, - common::PageArena *pa = nullptr); - common::TsBlock *alloc_tsblock(); + int reinit_io_reader(common::SimpleList::Iterator& it, + common::PageArena* pa = nullptr); + common::TsBlock* alloc_tsblock(); public: DataRunType run_type_; - common::ColumnSchema *col_schema_; + common::ColumnSchema* col_schema_; TimeRange time_range_; // invalid if run_type_ is DRT_TSFILE - common::SimpleList tvlist_list_; - common::SimpleList::Iterator tvlist_list_iter_; + common::SimpleList tvlist_list_; + common::SimpleList::Iterator tvlist_list_iter_; // invalid if run_type_ is DRT_TVLIST - common::SimpleList tsfile_list_; - common::SimpleList::Iterator tsfile_list_iter_; + common::SimpleList tsfile_list_; + common::SimpleList::Iterator tsfile_list_iter_; // TODO may bind TsFileIOReader on OpenFile ? TsFileIOReader io_reader_; - TsFileSeriesScanIterator *ssi_; + TsFileSeriesScanIterator* ssi_; common::TupleDesc tuple_desc_; }; @@ -159,8 +159,8 @@ class DataScanIterator { // TODO } - DataRun *alloc_data_run(DataRunType run_type); - FORCE_INLINE int add_data_run(DataRun *data_run) { + DataRun* alloc_data_run(DataRunType run_type); + FORCE_INLINE int add_data_run(DataRun* data_run) { ASSERT(data_run != nullptr); return data_run_list_.push_back(data_run); } @@ -173,8 +173,8 @@ class DataScanIterator { * E_INVALID_ARG - ret_block not init * E_NO_MORE_DATA - reader over */ - int get_next(common::TsBlock *block, bool alloc_tsblock = false); - void set_col_schema(const common::ColumnSchema &col_schema) { + int get_next(common::TsBlock* block, bool alloc_tsblock = false); + void set_col_schema(const common::ColumnSchema& col_schema) { col_schema_ = col_schema; } @@ -185,8 +185,8 @@ class DataScanIterator { private: common::ColumnSchema col_schema_; common::PageArena page_arena_; - common::SimpleList data_run_list_; - common::SimpleList::Iterator cursor_; + common::SimpleList data_run_list_; + common::SimpleList::Iterator cursor_; }; } // end namespace storage diff --git a/cpp/src/reader/task/device_query_task.cc b/cpp/src/reader/task/device_query_task.cc index 3c87a89c3..c7e7091ff 100644 --- a/cpp/src/reader/task/device_query_task.cc +++ b/cpp/src/reader/task/device_query_task.cc @@ -20,15 +20,15 @@ #include "reader/task/device_query_task.h" namespace storage { -DeviceQueryTask *DeviceQueryTask::create_device_query_task( +DeviceQueryTask* DeviceQueryTask::create_device_query_task( std::shared_ptr device_id, std::vector column_names, - std::shared_ptr column_mapping, MetaIndexNode *index_root, - std::shared_ptr table_schema, common::PageArena &pa) { - void *buf = pa.alloc(sizeof(DeviceQueryTask)); + std::shared_ptr column_mapping, MetaIndexNode* index_root, + std::shared_ptr table_schema, common::PageArena& pa) { + void* buf = pa.alloc(sizeof(DeviceQueryTask)); if (UNLIKELY(buf == nullptr)) { return nullptr; } - DeviceQueryTask *task = new (buf) DeviceQueryTask( + DeviceQueryTask* task = new (buf) DeviceQueryTask( device_id, column_names, column_mapping, index_root, table_schema); return task; } diff --git a/cpp/src/reader/task/device_query_task.h b/cpp/src/reader/task/device_query_task.h index 8ba4dceed..75043e44b 100644 --- a/cpp/src/reader/task/device_query_task.h +++ b/cpp/src/reader/task/device_query_task.h @@ -28,7 +28,7 @@ class DeviceQueryTask { DeviceQueryTask(std::shared_ptr device_id, std::vector column_names, std::shared_ptr column_mapping, - MetaIndexNode *index_root, + MetaIndexNode* index_root, std::shared_ptr table_schema) : device_id_(device_id), column_names_(column_names), @@ -37,14 +37,14 @@ class DeviceQueryTask { table_schema_(table_schema) {} ~DeviceQueryTask(); - static DeviceQueryTask *create_device_query_task( + static DeviceQueryTask* create_device_query_task( std::shared_ptr device_id, std::vector column_names, std::shared_ptr column_mapping, - MetaIndexNode *index_root, std::shared_ptr table_schema, - common::PageArena &pa); + MetaIndexNode* index_root, std::shared_ptr table_schema, + common::PageArena& pa); - const std::vector &get_column_names() const { + const std::vector& get_column_names() const { return column_names_; } @@ -52,9 +52,9 @@ class DeviceQueryTask { return table_schema_; } - const MetaIndexNode *get_index_root() const { return index_root_; } + const MetaIndexNode* get_index_root() const { return index_root_; } - const std::shared_ptr &get_column_mapping() const { + const std::shared_ptr& get_column_mapping() const { return column_mapping_; } @@ -64,7 +64,7 @@ class DeviceQueryTask { std::shared_ptr device_id_; std::vector column_names_; std::shared_ptr column_mapping_; - MetaIndexNode *index_root_; + MetaIndexNode* index_root_; std::shared_ptr table_schema_; }; diff --git a/cpp/src/reader/task/device_task_iterator.cc b/cpp/src/reader/task/device_task_iterator.cc index 52ab97ac7..86a1fe363 100644 --- a/cpp/src/reader/task/device_task_iterator.cc +++ b/cpp/src/reader/task/device_task_iterator.cc @@ -24,9 +24,9 @@ bool DeviceTaskIterator::has_next() const { return device_meta_iterator_->has_next(); } -int DeviceTaskIterator::next(DeviceQueryTask *&task) { +int DeviceTaskIterator::next(DeviceQueryTask*& task) { int ret = common::E_OK; - std::pair, MetaIndexNode *> device_meta_pair; + std::pair, MetaIndexNode*> device_meta_pair; if (RET_FAIL(device_meta_iterator_->next(device_meta_pair))) { } else { task = DeviceQueryTask::create_device_query_task( diff --git a/cpp/src/reader/task/device_task_iterator.h b/cpp/src/reader/task/device_task_iterator.h index ec30a472d..728e407d2 100644 --- a/cpp/src/reader/task/device_task_iterator.h +++ b/cpp/src/reader/task/device_task_iterator.h @@ -31,10 +31,10 @@ class DeviceQueryTask; class DeviceTaskIterator { public: explicit DeviceTaskIterator(std::vector column_names, - MetaIndexNode *index_root, + MetaIndexNode* index_root, std::shared_ptr column_mapping, - IMetadataQuerier *metadata_querier, - const Filter *id_filter, + IMetadataQuerier* metadata_querier, + const Filter* id_filter, std::shared_ptr table_schema) : column_names_(column_names), column_mapping_(column_mapping), @@ -45,10 +45,10 @@ class DeviceTaskIterator { } DeviceTaskIterator(std::vector column_names, - std::vector index_roots, + std::vector index_roots, std::shared_ptr column_mapping, - IMetadataQuerier *metadata_querier, - const Filter *id_filter, + IMetadataQuerier* metadata_querier, + const Filter* id_filter, std::shared_ptr table_schema) : column_names_(column_names), column_mapping_(column_mapping), @@ -62,7 +62,7 @@ class DeviceTaskIterator { bool has_next() const; - int next(DeviceQueryTask *&task); + int next(DeviceQueryTask*& task); private: std::vector column_names_; diff --git a/cpp/src/reader/tsfile_executor.cc b/cpp/src/reader/tsfile_executor.cc index 546a953fe..223d4cac3 100644 --- a/cpp/src/reader/tsfile_executor.cc +++ b/cpp/src/reader/tsfile_executor.cc @@ -38,7 +38,7 @@ TsFileExecutor::TsFileExecutor() TsFileExecutor::~TsFileExecutor() {} -int TsFileExecutor::init(ReadFile *read_file) { +int TsFileExecutor::init(ReadFile* read_file) { int ret = E_OK; io_reader_.reset(); if (RET_FAIL(io_reader_.init(read_file))) { @@ -48,7 +48,7 @@ int TsFileExecutor::init(ReadFile *read_file) { return ret; } -int TsFileExecutor::init(const std::string &file_path) { +int TsFileExecutor::init(const std::string& file_path) { int ret = E_OK; io_reader_.reset(); if (RET_FAIL(io_reader_.init(file_path))) { @@ -58,12 +58,12 @@ int TsFileExecutor::init(const std::string &file_path) { return ret; } -int TsFileExecutor::execute(QueryExpression *query_expr, ResultSet *&ret_qds) { +int TsFileExecutor::execute(QueryExpression* query_expr, ResultSet*& ret_qds) { ASSERT(is_inited_); query_exprs_ = query_expr; std::vector paths = query_exprs_->selected_series_; - Expression *origin_expr = query_exprs_->expression_; - Expression *regular_expr = nullptr; + Expression* origin_expr = query_exprs_->expression_; + Expression* regular_expr = nullptr; if (query_exprs_->has_filter_) { regular_expr = query_exprs_->optimize(origin_expr, paths); if (regular_expr == nullptr) { @@ -86,10 +86,10 @@ int TsFileExecutor::execute(QueryExpression *query_expr, ResultSet *&ret_qds) { } } -int TsFileExecutor::execute_may_with_global_timefilter(QueryExpression *qe, - ResultSet *&ret_qds) { +int TsFileExecutor::execute_may_with_global_timefilter(QueryExpression* qe, + ResultSet*& ret_qds) { int ret = E_OK; - QDSWithoutTimeGenerator *qds = new QDSWithoutTimeGenerator; + QDSWithoutTimeGenerator* qds = new QDSWithoutTimeGenerator; ret = qds->init(&io_reader_, qe); if (ret != E_OK) { delete qds; @@ -99,10 +99,10 @@ int TsFileExecutor::execute_may_with_global_timefilter(QueryExpression *qe, return ret; } -int TsFileExecutor::execute_with_timegenerator(QueryExpression *qe, - ResultSet *&ret_qds) { +int TsFileExecutor::execute_with_timegenerator(QueryExpression* qe, + ResultSet*& ret_qds) { int ret = E_OK; - QDSWithTimeGenerator *qds = new QDSWithTimeGenerator; + QDSWithTimeGenerator* qds = new QDSWithTimeGenerator; ret = qds->init(&io_reader_, qe); if (ret != E_OK) { delete qds; @@ -112,7 +112,7 @@ int TsFileExecutor::execute_with_timegenerator(QueryExpression *qe, return ret; } -void TsFileExecutor::destroy_query_data_set(ResultSet *qds) { +void TsFileExecutor::destroy_query_data_set(ResultSet* qds) { delete qds; qds = nullptr; } diff --git a/cpp/src/reader/tsfile_executor.h b/cpp/src/reader/tsfile_executor.h index a87dba2b4..1c370246c 100644 --- a/cpp/src/reader/tsfile_executor.h +++ b/cpp/src/reader/tsfile_executor.h @@ -32,25 +32,25 @@ class TsFileExecutor // : public QueryExecutor public: TsFileExecutor(); ~TsFileExecutor(); - int init(ReadFile *read_file); - int init(const std::string &file_path); - int execute(QueryExpression *query_expr, ResultSet *&ret_qds); - void destroy_query_data_set(ResultSet *qds); - TsFileMeta *get_tsfile_meta() { return io_reader_.get_tsfile_meta(); } - TsFileIOReader *get_tsfile_io_reader() { return &io_reader_; } + int init(ReadFile* read_file); + int init(const std::string& file_path); + int execute(QueryExpression* query_expr, ResultSet*& ret_qds); + void destroy_query_data_set(ResultSet* qds); + TsFileMeta* get_tsfile_meta() { return io_reader_.get_tsfile_meta(); } + TsFileIOReader* get_tsfile_io_reader() { return &io_reader_; } private: - int execute_may_with_global_timefilter(QueryExpression *qe, - ResultSet *&ret_qds); - int execute_with_timegenerator(QueryExpression *qe, ResultSet *&ret_qds); + int execute_may_with_global_timefilter(QueryExpression* qe, + ResultSet*& ret_qds); + int execute_with_timegenerator(QueryExpression* qe, ResultSet*& ret_qds); private: TsFileIOReader io_reader_; - QueryExpression *query_exprs_; - std::vector data_scan_iter_; - std::vector tsblocks_; - std::vector time_iters_; - std::vector value_iters_; + QueryExpression* query_exprs_; + std::vector data_scan_iter_; + std::vector tsblocks_; + std::vector time_iters_; + std::vector value_iters_; bool is_inited_; }; diff --git a/cpp/src/reader/tsfile_series_scan_iterator.h b/cpp/src/reader/tsfile_series_scan_iterator.h index e31c3e298..ad6fe8d94 100644 --- a/cpp/src/reader/tsfile_series_scan_iterator.h +++ b/cpp/src/reader/tsfile_series_scan_iterator.h @@ -51,8 +51,8 @@ class TsFileSeriesScanIterator { is_aligned_(false) {} ~TsFileSeriesScanIterator() { destroy(); } int init(std::shared_ptr device_id, - const std::string &measurement_name, ReadFile *read_file, - Filter *time_filter, common::PageArena &data_pa) { + const std::string& measurement_name, ReadFile* read_file, + Filter* time_filter, common::PageArena& data_pa) { ASSERT(read_file != nullptr); device_id_ = device_id; measurement_name_ = measurement_name; @@ -65,8 +65,8 @@ class TsFileSeriesScanIterator { /* * If oneshoot filter specified, use it instead of this->time_filter_ */ - int get_next(common::TsBlock *&ret_tsblock, bool alloc_tsblock, - Filter *oneshoot_filter = nullptr); + int get_next(common::TsBlock*& ret_tsblock, bool alloc_tsblock, + Filter* oneshoot_filter = nullptr); void revert_tsblock(); friend class TsFileIOReader; @@ -90,27 +90,27 @@ class TsFileSeriesScanIterator { chunk_meta_cursor_++; } } - FORCE_INLINE ChunkMeta *get_current_chunk_meta() { + FORCE_INLINE ChunkMeta* get_current_chunk_meta() { return chunk_meta_cursor_.get(); } - common::TsBlock *alloc_tsblock(); + common::TsBlock* alloc_tsblock(); private: - ReadFile *read_file_; + ReadFile* read_file_; std::shared_ptr device_id_; std::string measurement_name_; - ITimeseriesIndex *itimeseries_index_; + ITimeseriesIndex* itimeseries_index_; common::PageArena timeseries_index_pa_; - common::PageArena *data_pa_; - common::SimpleList::Iterator chunk_meta_cursor_; - common::SimpleList::Iterator time_chunk_meta_cursor_; - common::SimpleList::Iterator value_chunk_meta_cursor_; - IChunkReader *chunk_reader_; + common::PageArena* data_pa_; + common::SimpleList::Iterator chunk_meta_cursor_; + common::SimpleList::Iterator time_chunk_meta_cursor_; + common::SimpleList::Iterator value_chunk_meta_cursor_; + IChunkReader* chunk_reader_; common::TupleDesc tuple_desc_; - common::TsBlock *tsblock_; - Filter *time_filter_; + common::TsBlock* tsblock_; + Filter* time_filter_; bool is_aligned_ = false; }; diff --git a/cpp/src/reader/tsfile_tree_reader.cc b/cpp/src/reader/tsfile_tree_reader.cc index c7c9004a3..2b28c8647 100644 --- a/cpp/src/reader/tsfile_tree_reader.cc +++ b/cpp/src/reader/tsfile_tree_reader.cc @@ -27,19 +27,19 @@ TsFileTreeReader::TsFileTreeReader() { TsFileTreeReader::~TsFileTreeReader() = default; -int TsFileTreeReader::open(const std::string &file_path) { +int TsFileTreeReader::open(const std::string& file_path) { return tsfile_reader_->open(file_path); } int TsFileTreeReader::close() { return tsfile_reader_->close(); } -int TsFileTreeReader::query(const std::vector &device_ids, - const std::vector &measurement_names, +int TsFileTreeReader::query(const std::vector& device_ids, + const std::vector& measurement_names, int64_t start_time, int64_t end_time, - ResultSet *&result_set) { + ResultSet*& result_set) { std::vector path_list; - for (auto &device_id : device_ids) { - for (auto &measurement : measurement_names) { + for (auto& device_id : device_ids) { + for (auto& measurement : measurement_names) { path_list.emplace_back(device_id + PATH_SEPARATOR_CHAR + measurement); } @@ -47,12 +47,12 @@ int TsFileTreeReader::query(const std::vector &device_ids, return tsfile_reader_->query(path_list, start_time, end_time, result_set); } -void TsFileTreeReader::destroy_query_data_set(ResultSet *qds) { +void TsFileTreeReader::destroy_query_data_set(ResultSet* qds) { tsfile_reader_->destroy_query_data_set(qds); } std::vector TsFileTreeReader::get_device_schema( - const std::string &device_id) { + const std::string& device_id) { std::vector schemas; tsfile_reader_->get_timeseries_schema( std::make_shared(device_id), schemas); diff --git a/cpp/src/reader/tsfile_tree_reader.h b/cpp/src/reader/tsfile_tree_reader.h index 1d43c3b01..66341b7ed 100644 --- a/cpp/src/reader/tsfile_tree_reader.h +++ b/cpp/src/reader/tsfile_tree_reader.h @@ -39,7 +39,7 @@ class TsFileTreeReader { * @param file_path the path of the tsfile which will be opened * @return Returns 0 on success, or a non-zero error code on failure. */ - int open(const std::string &file_path); + int open(const std::string& file_path); /** * @brief close the tsfile, this method should be called after the @@ -63,9 +63,9 @@ class TsFileTreeReader { * The caller is responsible for destroying the result set using * destroy_query_data_set() */ - int query(const std::vector &device_ids, - const std::vector &measurement_names, - int64_t start_time, int64_t end_time, ResultSet *&result_set); + int query(const std::vector& device_ids, + const std::vector& measurement_names, + int64_t start_time, int64_t end_time, ResultSet*& result_set); /** * @brief Destroy and deallocate the query result set @@ -74,7 +74,7 @@ class TsFileTreeReader { * @note This method should be called after the result set is no longer * needed to prevent memory leaks */ - void destroy_query_data_set(ResultSet *result_set); + void destroy_query_data_set(ResultSet* result_set); /** * @brief Get the measurement schema for a specific device @@ -86,7 +86,7 @@ class TsFileTreeReader { * by the reader */ std::vector get_device_schema( - const std::string &device_id); + const std::string& device_id); /** * @brief Get all device identifiers in the TsFile diff --git a/cpp/src/utils/db_utils.h b/cpp/src/utils/db_utils.h index 8c0b89ce0..85d99b1a3 100644 --- a/cpp/src/utils/db_utils.h +++ b/cpp/src/utils/db_utils.h @@ -49,14 +49,14 @@ typedef struct FileID { merge_ = 0; } FORCE_INLINE bool is_valid() const { return seq_ != 0; } - FORCE_INLINE bool operator<(const FileID &that) const { + FORCE_INLINE bool operator<(const FileID& that) const { return this->seq_ < that.seq_; } - FORCE_INLINE bool operator==(const FileID &that) const { + FORCE_INLINE bool operator==(const FileID& that) const { return this->seq_ == that.seq_; } #ifndef NDEBUG - friend std::ostream &operator<<(std::ostream &out, const FileID &file_id) { + friend std::ostream& operator<<(std::ostream& out, const FileID& file_id) { out << "{seq_=" << file_id.seq_ << ", version_=" << file_id.version_ << ", merge_=" << file_id.merge_ << "}"; return out; @@ -105,11 +105,11 @@ struct TsID { return true; } - FORCE_INLINE bool operator==(const TsID &other) const { + FORCE_INLINE bool operator==(const TsID& other) const { return db_nid_ == other.db_nid_ && device_nid_ == other.device_nid_ && measurement_nid_ == other.measurement_nid_; } - FORCE_INLINE bool operator!=(const TsID &other) const { + FORCE_INLINE bool operator!=(const TsID& other) const { return db_nid_ != other.db_nid_ || device_nid_ != other.device_nid_ || measurement_nid_ != other.measurement_nid_; } @@ -121,21 +121,21 @@ struct TsID { return res; } - FORCE_INLINE bool operator<(const TsID &that) const { + FORCE_INLINE bool operator<(const TsID& that) const { return to_int64() < that.to_int64(); } - FORCE_INLINE bool operator>(const TsID &other) { + FORCE_INLINE bool operator>(const TsID& other) { return to_int64() > other.to_int64(); } - friend std::ostream &operator<<(std::ostream &out, TsID &ti) { + friend std::ostream& operator<<(std::ostream& out, TsID& ti) { out << "(" << ti.db_nid_ << ", " << ti.device_nid_ << ", " << ti.measurement_nid_ << ") "; return out; } - FORCE_INLINE void to_string(char *print_buf, int len) const { + FORCE_INLINE void to_string(char* print_buf, int len) const { snprintf(print_buf, len, "<%d,%d,%d>", db_nid_, device_nid_, measurement_nid_); } @@ -209,21 +209,21 @@ struct ColumnSchema { encoding_(get_value_encoder(data_type)), column_category_(column_category) {} - const std::string &get_column_name() const { return column_name_; } - const TSDataType &get_data_type() const { return data_type_; } - const ColumnCategory &get_column_category() const { + const std::string& get_column_name() const { return column_name_; } + const TSDataType& get_data_type() const { return data_type_; } + const ColumnCategory& get_column_category() const { return column_category_; } - const CompressionType &get_compression() const { return compression_; } - const TSEncoding &get_encoding() const { return encoding_; } - bool operator==(const ColumnSchema &other) const { + const CompressionType& get_compression() const { return compression_; } + const TSEncoding& get_encoding() const { return encoding_; } + bool operator==(const ColumnSchema& other) const { return (data_type_ == other.data_type_ && encoding_ == other.encoding_ && compression_ == other.compression_ && column_name_ == other.column_name_); } - bool operator!=(const ColumnSchema &other) const { + bool operator!=(const ColumnSchema& other) const { return (data_type_ != other.data_type_ || encoding_ != other.encoding_ || compression_ != other.compression_ || @@ -240,8 +240,8 @@ struct ColumnSchema { // TODO } - void get_device_name(char *ret_device_name_buf, const int buf_len, - uint32_t &ret_len) const { + void get_device_name(char* ret_device_name_buf, const int buf_len, + uint32_t& ret_len) const { int pos = column_name_.find_last_of('.'); ASSERT(pos > 0 && pos < buf_len); memcpy(ret_device_name_buf, column_name_.c_str(), pos); @@ -253,15 +253,15 @@ struct ColumnSchema { ASSERT(pos > 0); return column_name_.substr(0, pos); } - void get_device_name(String &device_name) const { + void get_device_name(String& device_name) const { int pos = column_name_.find_last_of('.'); ASSERT(pos > 0); - const char *c_string = column_name_.c_str(); - device_name.buf_ = (char *)c_string; + const char* c_string = column_name_.c_str(); + device_name.buf_ = (char*)c_string; device_name.len_ = pos; } - void get_measurement_name(char *ret_measurement_name_buf, const int buf_len, - uint32_t &ret_len) const { + void get_measurement_name(char* ret_measurement_name_buf, const int buf_len, + uint32_t& ret_len) const { int pos = column_name_.find_last_of('.'); ASSERT(pos > 0 && pos < buf_len); ret_len = column_name_.size() - pos - 1; @@ -275,19 +275,19 @@ struct ColumnSchema { return column_name_.substr(pos + 1, column_name_.size() - pos); } // TODO remove - void get_measurement_name(String &measurement_name) const { + void get_measurement_name(String& measurement_name) const { int pos = column_name_.find_last_of('.'); ASSERT(pos > 0); - const char *c_string = column_name_.c_str(); - measurement_name.buf_ = (char *)c_string + pos + 1; + const char* c_string = column_name_.c_str(); + measurement_name.buf_ = (char*)c_string + pos + 1; measurement_name.len_ = column_name_.size() - pos - 1; } String get_measurement_name() { int pos = column_name_.find_last_of('.'); ASSERT(pos > 0); - const char *c_string = column_name_.c_str(); + const char* c_string = column_name_.c_str(); String res; - res.buf_ = (char *)c_string + pos + 1; + res.buf_ = (char*)c_string + pos + 1; res.len_ = column_name_.size() - pos - 1; return res; } diff --git a/cpp/src/utils/storage_utils.h b/cpp/src/utils/storage_utils.h index 035bf6ed0..3d1a18954 100644 --- a/cpp/src/utils/storage_utils.h +++ b/cpp/src/utils/storage_utils.h @@ -31,20 +31,20 @@ namespace storage { struct InsertContext { bool has_time_val_; - common::TsBlock *tsblock_; - common::TupleDesc *tuple_desc_; - std::vector *> *values_; + common::TsBlock* tsblock_; + common::TupleDesc* tuple_desc_; + std::vector*>* values_; // add device name, etc - explicit InsertContext(common::TsBlock *tsblock) + explicit InsertContext(common::TsBlock* tsblock) : has_time_val_(false), tsblock_(tsblock), tuple_desc_(nullptr), values_(nullptr) {} - InsertContext(bool has_time_val, common::TupleDesc *tuple_desc, - std::vector *> *values) + InsertContext(bool has_time_val, common::TupleDesc* tuple_desc, + std::vector*>* values) : has_time_val_(has_time_val), tsblock_(nullptr), tuple_desc_(tuple_desc), @@ -56,7 +56,7 @@ struct InsertContext { struct InsertResult { public: InsertResult() : succ_rows_(0), has_err_(false), err_msg_() {} - void set_err_msg(const std::string &e) { + void set_err_msg(const std::string& e) { has_err_ = true; err_msg_ = e; } @@ -71,19 +71,19 @@ struct InsertResult { }; FORCE_INLINE std::string get_file_path_from_file_id( - const common::FileID &file_id) { + const common::FileID& file_id) { std::ostringstream oss; oss << "./" << file_id.seq_ << "-" << file_id.version_ << "-" << file_id.merge_ << ".tsfile"; return oss.str(); } -FORCE_INLINE static void to_lowercase_inplace(std::string &str) { +FORCE_INLINE static void to_lowercase_inplace(std::string& str) { std::transform( str.begin(), str.end(), str.begin(), [](unsigned char c) -> unsigned char { return std::tolower(c); }); } -FORCE_INLINE static std::string to_lower(const std::string &str) { +FORCE_INLINE static std::string to_lower(const std::string& str) { std::string result; std::transform( str.begin(), str.end(), std::back_inserter(result), diff --git a/cpp/src/writer/chunk_writer.cc b/cpp/src/writer/chunk_writer.cc index 6736ba2bb..d9f9603df 100644 --- a/cpp/src/writer/chunk_writer.cc +++ b/cpp/src/writer/chunk_writer.cc @@ -25,12 +25,12 @@ using namespace common; namespace storage { -int ChunkWriter::init(const ColumnSchema &col_schema) { +int ChunkWriter::init(const ColumnSchema& col_schema) { return init(col_schema.column_name_, col_schema.data_type_, col_schema.encoding_, col_schema.compression_); } -int ChunkWriter::init(const std::string &measurement_name, TSDataType data_type, +int ChunkWriter::init(const std::string& measurement_name, TSDataType data_type, TSEncoding encoding, CompressionType compression_type) { int ret = E_OK; chunk_statistic_ = StatisticFactory::alloc_statistic(data_type); @@ -135,12 +135,12 @@ int ChunkWriter::seal_cur_page(bool end_chunk) { return ret; } -void ChunkWriter::save_first_page_data(PageWriter &first_page_writer) { +void ChunkWriter::save_first_page_data(PageWriter& first_page_writer) { first_page_data_ = first_page_writer.get_cur_page_data(); first_page_statistic_->deep_copy_from(first_page_writer.get_statistic()); } -int ChunkWriter::write_first_page_data(ByteStream &pages_data, +int ChunkWriter::write_first_page_data(ByteStream& pages_data, bool with_statistic) { int ret = E_OK; if (with_statistic && diff --git a/cpp/src/writer/chunk_writer.h b/cpp/src/writer/chunk_writer.h index d12cf22ed..fc1a71134 100644 --- a/cpp/src/writer/chunk_writer.h +++ b/cpp/src/writer/chunk_writer.h @@ -55,8 +55,8 @@ class ChunkWriter { chunk_header_(), num_of_pages_(0) {} ~ChunkWriter() { destroy(); } - int init(const common::ColumnSchema &col_schema); - int init(const std::string &measurement_name, common::TSDataType data_type, + int init(const common::ColumnSchema& col_schema); + int init(const std::string& measurement_name, common::TSDataType data_type, common::TSEncoding encoding, common::CompressionType compression_type); void reset(); @@ -104,8 +104,8 @@ class ChunkWriter { } int end_encode_chunk(); - common::ByteStream &get_chunk_data() { return chunk_data_; } - Statistic *get_chunk_statistic() { return chunk_statistic_; } + common::ByteStream& get_chunk_data() { return chunk_data_; } + Statistic* get_chunk_statistic() { return chunk_statistic_; } bool hasData() { return num_of_pages_ > 0 || (page_writer_.get_statistic() != nullptr && page_writer_.get_statistic()->count_ > 0); @@ -145,19 +145,19 @@ class ChunkWriter { } } int seal_cur_page(bool end_chunk); - void save_first_page_data(PageWriter &first_page_writer); - int write_first_page_data(common::ByteStream &pages_data, + void save_first_page_data(PageWriter& first_page_writer); + int write_first_page_data(common::ByteStream& pages_data, bool with_statistic = true); private: common::TSDataType data_type_; PageWriter page_writer_; - Statistic *chunk_statistic_; + Statistic* chunk_statistic_; common::ByteStream chunk_data_; // to save first page data PageData first_page_data_; - Statistic *first_page_statistic_; + Statistic* first_page_statistic_; ChunkHeader chunk_header_; int32_t num_of_pages_; diff --git a/cpp/src/writer/page_writer.cc b/cpp/src/writer/page_writer.cc index 019004a02..b4822e6a2 100644 --- a/cpp/src/writer/page_writer.cc +++ b/cpp/src/writer/page_writer.cc @@ -29,15 +29,15 @@ using namespace common; namespace storage { /* ================ PageData ================ */ -int PageData::init(ByteStream &time_bs, ByteStream &value_bs, - Compressor *compressor) { +int PageData::init(ByteStream& time_bs, ByteStream& value_bs, + Compressor* compressor) { int ret = E_OK; time_buf_size_ = time_bs.total_size(); value_buf_size_ = value_bs.total_size(); uint32_t var_size = get_var_uint_size(time_buf_size_); uncompressed_size_ = var_size + time_buf_size_ + value_buf_size_; uncompressed_buf_ = - (char *)mem_alloc(uncompressed_size_, MOD_PAGE_WRITER_OUTPUT_STREAM); + (char*)mem_alloc(uncompressed_size_, MOD_PAGE_WRITER_OUTPUT_STREAM); compressor_ = compressor; if (IS_NULL(uncompressed_buf_)) { return E_OOM; @@ -148,7 +148,7 @@ void PageWriter::destroy() { } } -int PageWriter::write_to_chunk(ByteStream &pages_data, bool write_header, +int PageWriter::write_to_chunk(ByteStream& pages_data, bool write_header, bool write_statistic, bool write_data_to_chunk_data) { #if DEBUG_SE diff --git a/cpp/src/writer/page_writer.h b/cpp/src/writer/page_writer.h index 47ed32962..cff4b60ed 100644 --- a/cpp/src/writer/page_writer.h +++ b/cpp/src/writer/page_writer.h @@ -46,9 +46,9 @@ struct PageData { uint32_t value_buf_size_; uint32_t uncompressed_size_; uint32_t compressed_size_; - char *uncompressed_buf_; - char *compressed_buf_; - Compressor *compressor_; + char* uncompressed_buf_; + char* compressed_buf_; + Compressor* compressor_; PageData() : time_buf_size_(0), @@ -58,8 +58,8 @@ struct PageData { uncompressed_buf_(nullptr), compressed_buf_(nullptr), compressor_(nullptr) {} - int init(common::ByteStream &time_bs, common::ByteStream &value_bs, - Compressor *compressor); + int init(common::ByteStream& time_bs, common::ByteStream& value_bs, + Compressor* compressor); void destroy() { // Be careful about the memory if (uncompressed_buf_ != nullptr) { @@ -169,15 +169,15 @@ class PageWriter { time_encoder_->get_max_byte_size() + value_encoder_->get_max_byte_size(); } - int write_to_chunk(common::ByteStream &pages_data, bool write_header, + int write_to_chunk(common::ByteStream& pages_data, bool write_header, bool write_statistic, bool write_data_to_chunk_data); - FORCE_INLINE common::ByteStream &get_time_data() { + FORCE_INLINE common::ByteStream& get_time_data() { return time_out_stream_; } - FORCE_INLINE common::ByteStream &get_value_data() { + FORCE_INLINE common::ByteStream& get_value_data() { return value_out_stream_; } - FORCE_INLINE Statistic *get_statistic() { return statistic_; } + FORCE_INLINE Statistic* get_statistic() { return statistic_; } PageData get_cur_page_data() { return cur_page_data_; } void destroy_page_data() { cur_page_data_.destroy(); } @@ -189,8 +189,8 @@ class PageWriter { } return ret; } - int copy_page_data_to(common::ByteStream &my_page_data, - common::ByteStream &pages_data); + int copy_page_data_to(common::ByteStream& my_page_data, + common::ByteStream& pages_data); private: // static const uint32_t OUT_STREAM_PAGE_SIZE = 48; @@ -198,13 +198,13 @@ class PageWriter { private: common::TSDataType data_type_; - Encoder *time_encoder_; - Encoder *value_encoder_; - Statistic *statistic_; + Encoder* time_encoder_; + Encoder* value_encoder_; + Statistic* statistic_; common::ByteStream time_out_stream_; common::ByteStream value_out_stream_; PageData cur_page_data_; - Compressor *compressor_; + Compressor* compressor_; bool is_inited_; }; diff --git a/cpp/src/writer/time_chunk_writer.cc b/cpp/src/writer/time_chunk_writer.cc index 81fafc5a1..5f004a0f5 100644 --- a/cpp/src/writer/time_chunk_writer.cc +++ b/cpp/src/writer/time_chunk_writer.cc @@ -25,12 +25,12 @@ using namespace common; namespace storage { -int TimeChunkWriter::init(const ColumnSchema &col_schema) { +int TimeChunkWriter::init(const ColumnSchema& col_schema) { return init(col_schema.column_name_, col_schema.encoding_, col_schema.compression_); } -int TimeChunkWriter::init(const std::string &measurement_name, +int TimeChunkWriter::init(const std::string& measurement_name, TSEncoding encoding, CompressionType compression_type) { int ret = E_OK; @@ -141,12 +141,12 @@ int TimeChunkWriter::seal_cur_page(bool end_chunk) { return ret; } -void TimeChunkWriter::save_first_page_data(TimePageWriter &first_page_writer) { +void TimeChunkWriter::save_first_page_data(TimePageWriter& first_page_writer) { first_page_data_ = first_page_writer.get_cur_page_data(); first_page_statistic_->deep_copy_from(first_page_writer.get_statistic()); } -int TimeChunkWriter::write_first_page_data(ByteStream &pages_data, +int TimeChunkWriter::write_first_page_data(ByteStream& pages_data, bool with_statistic) { int ret = E_OK; if (with_statistic && diff --git a/cpp/src/writer/time_chunk_writer.h b/cpp/src/writer/time_chunk_writer.h index aff8e2af0..ac3b374b0 100644 --- a/cpp/src/writer/time_chunk_writer.h +++ b/cpp/src/writer/time_chunk_writer.h @@ -44,8 +44,8 @@ class TimeChunkWriter { chunk_header_(), num_of_pages_(0) {} ~TimeChunkWriter() { destroy(); } - int init(const common::ColumnSchema &col_schema); - int init(const std::string &measurement_name, common::TSEncoding encoding, + int init(const common::ColumnSchema& col_schema); + int init(const std::string& measurement_name, common::TSEncoding encoding, common::CompressionType compression_type); void reset(); void destroy(); @@ -64,8 +64,8 @@ class TimeChunkWriter { } int end_encode_chunk(); - common::ByteStream &get_chunk_data() { return chunk_data_; } - Statistic *get_chunk_statistic() { return chunk_statistic_; } + common::ByteStream& get_chunk_data() { return chunk_data_; } + Statistic* get_chunk_statistic() { return chunk_statistic_; } FORCE_INLINE int32_t num_of_pages() const { return num_of_pages_; } int64_t estimate_max_series_mem_size(); @@ -95,18 +95,18 @@ class TimeChunkWriter { } } int seal_cur_page(bool end_chunk); - void save_first_page_data(TimePageWriter &first_time_page_writer); - int write_first_page_data(common::ByteStream &pages_data, + void save_first_page_data(TimePageWriter& first_time_page_writer); + int write_first_page_data(common::ByteStream& pages_data, bool with_statistic = true); private: TimePageWriter time_page_writer_; - Statistic *chunk_statistic_; + Statistic* chunk_statistic_; common::ByteStream chunk_data_; // to save first page data TimePageData first_page_data_; - Statistic *first_page_statistic_; + Statistic* first_page_statistic_; ChunkHeader chunk_header_; int32_t num_of_pages_; diff --git a/cpp/src/writer/time_page_writer.cc b/cpp/src/writer/time_page_writer.cc index 55450a1d2..1b83ec929 100644 --- a/cpp/src/writer/time_page_writer.cc +++ b/cpp/src/writer/time_page_writer.cc @@ -28,12 +28,12 @@ using namespace common; namespace storage { -int TimePageData::init(ByteStream &time_bs, Compressor *compressor) { +int TimePageData::init(ByteStream& time_bs, Compressor* compressor) { int ret = E_OK; time_buf_size_ = time_bs.total_size(); uncompressed_size_ = time_buf_size_; uncompressed_buf_ = - (char *)mem_alloc(uncompressed_size_, MOD_PAGE_WRITER_OUTPUT_STREAM); + (char*)mem_alloc(uncompressed_size_, MOD_PAGE_WRITER_OUTPUT_STREAM); compressor_ = compressor; if (IS_NULL(uncompressed_buf_)) { return E_OOM; @@ -119,7 +119,7 @@ void TimePageWriter::destroy() { } } -int TimePageWriter::write_to_chunk(ByteStream &pages_data, bool write_header, +int TimePageWriter::write_to_chunk(ByteStream& pages_data, bool write_header, bool write_statistic, bool write_data_to_chunk_data) { #if DEBUG_SE diff --git a/cpp/src/writer/time_page_writer.h b/cpp/src/writer/time_page_writer.h index bbf70165d..4c01044a6 100644 --- a/cpp/src/writer/time_page_writer.h +++ b/cpp/src/writer/time_page_writer.h @@ -31,9 +31,9 @@ struct TimePageData { uint32_t time_buf_size_; uint32_t uncompressed_size_; uint32_t compressed_size_; - char *uncompressed_buf_; - char *compressed_buf_; - Compressor *compressor_; + char* uncompressed_buf_; + char* compressed_buf_; + Compressor* compressor_; TimePageData() : time_buf_size_(0), @@ -42,7 +42,7 @@ struct TimePageData { uncompressed_buf_(nullptr), compressed_buf_(nullptr), compressor_(nullptr) {} - int init(common::ByteStream &time_bs, Compressor *compressor); + int init(common::ByteStream& time_bs, Compressor* compressor); void destroy() { if (uncompressed_buf_ != nullptr) { common::mem_free(uncompressed_buf_); @@ -95,12 +95,12 @@ class TimePageWriter { return time_out_stream_.total_size() + time_encoder_->get_max_byte_size(); } - int write_to_chunk(common::ByteStream &pages_data, bool write_header, + int write_to_chunk(common::ByteStream& pages_data, bool write_header, bool write_statistic, bool write_data_to_chunk_data); - FORCE_INLINE common::ByteStream &get_time_data() { + FORCE_INLINE common::ByteStream& get_time_data() { return time_out_stream_; } - FORCE_INLINE Statistic *get_statistic() { return statistic_; } + FORCE_INLINE Statistic* get_statistic() { return statistic_; } TimePageData get_cur_page_data() { return cur_page_data_; } void destroy_page_data() { cur_page_data_.destroy(); } @@ -111,19 +111,19 @@ class TimePageWriter { } return ret; } - int copy_page_data_to(common::ByteStream &my_page_data, - common::ByteStream &pages_data); + int copy_page_data_to(common::ByteStream& my_page_data, + common::ByteStream& pages_data); private: static const uint32_t OUT_STREAM_PAGE_SIZE = 1024; private: common::TSDataType data_type_; - Encoder *time_encoder_; - Statistic *statistic_; + Encoder* time_encoder_; + Statistic* statistic_; common::ByteStream time_out_stream_; TimePageData cur_page_data_; - Compressor *compressor_; + Compressor* compressor_; bool is_inited_; }; diff --git a/cpp/src/writer/tsfile_writer.cc b/cpp/src/writer/tsfile_writer.cc index dec0cd61a..1f7d954ce 100644 --- a/cpp/src/writer/tsfile_writer.cc +++ b/cpp/src/writer/tsfile_writer.cc @@ -84,11 +84,11 @@ void TsFileWriter::destroy() { DeviceSchemasMapIter dev_iter; // cppcheck-suppress postfixOperator for (dev_iter = schemas_.begin(); dev_iter != schemas_.end(); dev_iter++) { - MeasurementSchemaMap &ms_map = + MeasurementSchemaMap& ms_map = dev_iter->second->measurement_schema_map_; MeasurementSchemaMapIter ms_iter; for (ms_iter = ms_map.begin(); ms_iter != ms_map.end(); ms_iter++) { - MeasurementSchema *ms = ms_iter->second; + MeasurementSchema* ms = ms_iter->second; if (ms != nullptr) { if (ms->chunk_writer_ != nullptr) { delete ms->chunk_writer_; @@ -105,7 +105,7 @@ void TsFileWriter::destroy() { record_count_since_last_flush_ = 0; } -int TsFileWriter::init(WriteFile *write_file) { +int TsFileWriter::init(WriteFile* write_file) { if (write_file == nullptr) { return E_INVALID_ARG; } else if (!write_file->file_opened()) { @@ -123,14 +123,14 @@ void TsFileWriter::set_generate_table_schema(bool generate_table_schema) { } int TsFileWriter::register_table( - const std::shared_ptr &table_schema) { + const std::shared_ptr& table_schema) { if (!table_schema) return E_INVALID_ARG; // Empty table name or column name is not allowed. if (table_schema->get_table_name().empty()) { return E_INVALID_ARG; } - for (const auto &name : table_schema->get_measurement_names()) { + for (const auto& name : table_schema->get_measurement_names()) { if (name.empty()) { return E_INVALID_ARG; } @@ -155,11 +155,11 @@ int TsFileWriter::register_table( return E_OK; } -bool check_file_exist(const std::string &file_path) { +bool check_file_exist(const std::string& file_path) { return access(file_path.c_str(), F_OK) == 0; } -int TsFileWriter::open(const std::string &file_path, int flags, mode_t mode) { +int TsFileWriter::open(const std::string& file_path, int flags, mode_t mode) { if (check_file_exist(file_path)) { return E_ALREADY_EXIST; } @@ -174,21 +174,21 @@ int TsFileWriter::open(const std::string &file_path, int flags, mode_t mode) { return ret; } -int TsFileWriter::open(const std::string &file_path) { +int TsFileWriter::open(const std::string& file_path) { return open(file_path, O_RDWR | O_CREAT | O_TRUNC, 0666); } int TsFileWriter::register_aligned_timeseries( - const std::string &device_id, const MeasurementSchema &measurement_schema) { - MeasurementSchema *ms = new MeasurementSchema( + const std::string& device_id, const MeasurementSchema& measurement_schema) { + MeasurementSchema* ms = new MeasurementSchema( measurement_schema.measurement_name_, measurement_schema.data_type_, measurement_schema.encoding_, measurement_schema.compression_type_); return register_timeseries(device_id, ms, true); } int TsFileWriter::register_aligned_timeseries( - const std::string &device_id, - const std::vector &measurement_schemas) { + const std::string& device_id, + const std::vector& measurement_schemas) { int ret = E_OK; for (auto it : measurement_schemas) { ret = register_timeseries(device_id, it, true); @@ -200,21 +200,21 @@ int TsFileWriter::register_aligned_timeseries( } int TsFileWriter::register_timeseries( - const std::string &device_id, const MeasurementSchema &measurement_schema) { - MeasurementSchema *ms = new MeasurementSchema( + const std::string& device_id, const MeasurementSchema& measurement_schema) { + MeasurementSchema* ms = new MeasurementSchema( measurement_schema.measurement_name_, measurement_schema.data_type_, measurement_schema.encoding_, measurement_schema.compression_type_); return register_timeseries(device_id, ms, false); } -int TsFileWriter::register_timeseries(const std::string &device_path, - MeasurementSchema *measurement_schema, +int TsFileWriter::register_timeseries(const std::string& device_path, + MeasurementSchema* measurement_schema, bool is_aligned) { std::shared_ptr device_id = std::make_shared(device_path); DeviceSchemasMapIter device_iter = schemas_.find(device_id); if (device_iter != schemas_.end()) { - MeasurementSchemaMap &msm = + MeasurementSchemaMap& msm = device_iter->second->measurement_schema_map_; MeasurementSchemaMapInsertResult ins_res = msm.insert(std::make_pair( measurement_schema->measurement_name_, measurement_schema)); @@ -222,7 +222,7 @@ int TsFileWriter::register_timeseries(const std::string &device_path, return E_ALREADY_EXIST; } } else { - MeasurementSchemaGroup *ms_group = new MeasurementSchemaGroup; + MeasurementSchemaGroup* ms_group = new MeasurementSchemaGroup; ms_group->is_aligned_ = is_aligned; ms_group->measurement_schema_map_.insert(std::make_pair( measurement_schema->measurement_name_, measurement_schema)); @@ -232,8 +232,8 @@ int TsFileWriter::register_timeseries(const std::string &device_path, } int TsFileWriter::register_timeseries( - const std::string &device_id, - const std::vector &measurement_schema_vec) { + const std::string& device_id, + const std::vector& measurement_schema_vec) { int ret = E_OK; auto it = measurement_schema_vec.begin(); for (; it != measurement_schema_vec.end(); @@ -249,9 +249,9 @@ int TsFileWriter::register_timeseries( struct MeasurementSchemaMapNamesGetter { public: explicit MeasurementSchemaMapNamesGetter( - const MeasurementSchemaMap &measurement_schema_map) + const MeasurementSchemaMap& measurement_schema_map) : measurement_schema_map_( - const_cast(measurement_schema_map)) { + const_cast(measurement_schema_map)) { measurement_name_idx_ = measurement_schema_map_.begin(); } @@ -259,64 +259,64 @@ struct MeasurementSchemaMapNamesGetter { return measurement_schema_map_.size(); } - FORCE_INLINE const std::string &next() { + FORCE_INLINE const std::string& next() { ASSERT(measurement_name_idx_ != measurement_schema_map_.end()); - std::string &ret = measurement_name_idx_->second->measurement_name_; + std::string& ret = measurement_name_idx_->second->measurement_name_; measurement_name_idx_++; return ret; } private: - MeasurementSchemaMap &measurement_schema_map_; + MeasurementSchemaMap& measurement_schema_map_; MeasurementSchemaMap::iterator measurement_name_idx_; }; struct MeasurementNamesFromRecord { public: - explicit MeasurementNamesFromRecord(const TsRecord &record) + explicit MeasurementNamesFromRecord(const TsRecord& record) : record_(record), measurement_name_idx_(0) {} FORCE_INLINE uint32_t get_count() const { return record_.points_.size(); } - FORCE_INLINE const std::string &next() { + FORCE_INLINE const std::string& next() { return this->at(measurement_name_idx_++); } private: - const TsRecord &record_; + const TsRecord& record_; size_t measurement_name_idx_; - FORCE_INLINE const std::string &at(size_t idx) const { + FORCE_INLINE const std::string& at(size_t idx) const { ASSERT(idx < record_.points_.size()); return record_.points_[idx].measurement_name_; } }; struct MeasurementNamesFromTablet { - explicit MeasurementNamesFromTablet(const Tablet &tablet) + explicit MeasurementNamesFromTablet(const Tablet& tablet) : tablet_(tablet), measurement_name_idx_(0) {} FORCE_INLINE uint32_t get_count() const { return tablet_.schema_vec_->size(); } - FORCE_INLINE const std::string &next() { + FORCE_INLINE const std::string& next() { return this->at(measurement_name_idx_++); } private: - const Tablet &tablet_; + const Tablet& tablet_; size_t measurement_name_idx_; - FORCE_INLINE const std::string &at(size_t idx) const { + FORCE_INLINE const std::string& at(size_t idx) const { ASSERT(idx < tablet_.schema_vec_->size()); return tablet_.schema_vec_->at(idx).measurement_name_; } }; -int TsFileWriter::do_check_and_prepare_tablet(Tablet &tablet) { +int TsFileWriter::do_check_and_prepare_tablet(Tablet& tablet) { if (tablet.column_categories_.empty()) { - auto &schema_map = io_writer_->get_schema()->table_schema_map_; + auto& schema_map = io_writer_->get_schema()->table_schema_map_; auto table_schema_it = schema_map.find(tablet.get_table_name()); auto table_schema = table_schema_it->second; uint32_t column_cnt = tablet.get_column_count(); for (uint32_t i = 0; i < column_cnt; i++) { - auto &col_name = tablet.get_column_name(i); + auto& col_name = tablet.get_column_name(i); int col_index = table_schema->find_column_index(col_name); if (col_index == -1) { return E_COLUMN_NOT_EXIST; @@ -339,17 +339,17 @@ int TsFileWriter::do_check_and_prepare_tablet(Tablet &tablet) { template int TsFileWriter::do_check_schema( std::shared_ptr device_id, - MeasurementNamesGetter &measurement_names, - SimpleVector &chunk_writers, - SimpleVector &data_types) { + MeasurementNamesGetter& measurement_names, + SimpleVector& chunk_writers, + SimpleVector& data_types) { int ret = E_OK; DeviceSchemasMapIter dev_it = schemas_.find(device_id); - MeasurementSchemaGroup *device_schema = nullptr; + MeasurementSchemaGroup* device_schema = nullptr; if (UNLIKELY(dev_it == schemas_.end()) || IS_NULL(device_schema = dev_it->second)) { return E_DEVICE_NOT_EXIST; } - MeasurementSchemaMap &msm = device_schema->measurement_schema_map_; + MeasurementSchemaMap& msm = device_schema->measurement_schema_map_; uint32_t measurement_count = measurement_names.get_count(); // chunk_writers.reserve(measurement_count); for (uint32_t i = 0; i < measurement_count; i++) { @@ -360,7 +360,7 @@ int TsFileWriter::do_check_schema( } else { // In Java we will check data_type. But in C++, no check here. // Because checks are performed at the chunk layer and page layer - MeasurementSchema *ms = ms_iter->second; + MeasurementSchema* ms = ms_iter->second; if (IS_NULL(ms->chunk_writer_)) { ms->chunk_writer_ = new ChunkWriter; ret = ms->chunk_writer_->init(ms->measurement_name_, @@ -391,13 +391,13 @@ int TsFileWriter::do_check_schema( template int TsFileWriter::do_check_schema_aligned( std::shared_ptr device_id, - MeasurementNamesGetter &measurement_names, - storage::TimeChunkWriter *&time_chunk_writer, - common::SimpleVector &value_chunk_writers, - SimpleVector &data_types) { + MeasurementNamesGetter& measurement_names, + storage::TimeChunkWriter*& time_chunk_writer, + common::SimpleVector& value_chunk_writers, + SimpleVector& data_types) { int ret = E_OK; auto dev_it = schemas_.find(device_id); - MeasurementSchemaGroup *device_schema = NULL; + MeasurementSchemaGroup* device_schema = NULL; if (UNLIKELY(dev_it == schemas_.end()) || IS_NULL(device_schema = dev_it->second)) { return E_DEVICE_NOT_EXIST; @@ -409,7 +409,7 @@ int TsFileWriter::do_check_schema_aligned( g_config_value_.time_compress_type_); } time_chunk_writer = device_schema->time_chunk_writer_; - MeasurementSchemaMap &msm = device_schema->measurement_schema_map_; + MeasurementSchemaMap& msm = device_schema->measurement_schema_map_; uint32_t measurement_count = measurement_names.get_count(); for (uint32_t i = 0; i < measurement_count; i++) { auto ms_iter = msm.find(measurement_names.next()); @@ -419,7 +419,7 @@ int TsFileWriter::do_check_schema_aligned( } else { // Here we may check data_type against ms_iter. But in Java // libtsfile, no check here. - MeasurementSchema *ms = ms_iter->second; + MeasurementSchema* ms = ms_iter->second; if (IS_NULL(ms->value_chunk_writer_)) { ms->value_chunk_writer_ = new ValueChunkWriter; ret = ms->value_chunk_writer_->init( @@ -449,15 +449,15 @@ int TsFileWriter::do_check_schema_aligned( } int TsFileWriter::do_check_schema_table( - std::shared_ptr device_id, Tablet &tablet, - storage::TimeChunkWriter *&time_chunk_writer, - common::SimpleVector &value_chunk_writers) { + std::shared_ptr device_id, Tablet& tablet, + storage::TimeChunkWriter*& time_chunk_writer, + common::SimpleVector& value_chunk_writers) { int ret = E_OK; auto dev_it = schemas_.find(device_id); - MeasurementSchemaGroup *device_schema = NULL; + MeasurementSchemaGroup* device_schema = NULL; - auto &schema_map = io_writer_->get_schema()->table_schema_map_; + auto& schema_map = io_writer_->get_schema()->table_schema_map_; auto table_schema_it = schema_map.find(tablet.get_table_name()); if (UNLIKELY(table_schema_it == schema_map.end())) { return E_TABLE_NOT_EXIST; @@ -497,7 +497,7 @@ int TsFileWriter::do_check_schema_table( uint32_t column_cnt = tablet.get_column_count(); time_chunk_writer = device_schema->time_chunk_writer_; - MeasurementSchemaMap &msm = device_schema->measurement_schema_map_; + MeasurementSchemaMap& msm = device_schema->measurement_schema_map_; for (uint32_t i = 0; i < column_cnt; i++) { if (tablet.column_categories_.at(i) != common::ColumnCategory::FIELD) { @@ -509,7 +509,7 @@ int TsFileWriter::do_check_schema_table( } else { // Here we may check data_type against ms_iter. But in Java // libtsfile, no check here. - MeasurementSchema *ms = ms_iter->second; + MeasurementSchema* ms = ms_iter->second; if (IS_NULL(ms->value_chunk_writer_)) { ms->value_chunk_writer_ = new ValueChunkWriter; ret = ms->value_chunk_writer_->init( @@ -542,19 +542,19 @@ int64_t TsFileWriter::calculate_mem_size_for_all_group() { DeviceSchemasMapIter device_iter; for (device_iter = schemas_.begin(); device_iter != schemas_.end(); device_iter++) { - MeasurementSchemaGroup *chunk_group = device_iter->second; - MeasurementSchemaMap &map = chunk_group->measurement_schema_map_; + MeasurementSchemaGroup* chunk_group = device_iter->second; + MeasurementSchemaMap& map = chunk_group->measurement_schema_map_; for (MeasurementSchemaMapIter ms_iter = map.begin(); ms_iter != map.end(); ms_iter++) { - MeasurementSchema *m_schema = ms_iter->second; + MeasurementSchema* m_schema = ms_iter->second; if (!chunk_group->is_aligned_) { - ChunkWriter *&chunk_writer = m_schema->chunk_writer_; + ChunkWriter*& chunk_writer = m_schema->chunk_writer_; if (chunk_writer != nullptr) { mem_total_size += chunk_writer->estimate_max_series_mem_size(); } } else { - ValueChunkWriter *&chunk_writer = m_schema->value_chunk_writer_; + ValueChunkWriter*& chunk_writer = m_schema->value_chunk_writer_; if (chunk_writer != nullptr) { mem_total_size += chunk_writer->estimate_max_series_mem_size(); @@ -562,7 +562,7 @@ int64_t TsFileWriter::calculate_mem_size_for_all_group() { } } if (chunk_group->is_aligned_) { - TimeChunkWriter *&time_chunk_writer = + TimeChunkWriter*& time_chunk_writer = chunk_group->time_chunk_writer_; if (time_chunk_writer != nullptr) { mem_total_size += @@ -591,10 +591,10 @@ int TsFileWriter::check_memory_size_and_may_flush_chunks() { return ret; } -int TsFileWriter::write_record(const TsRecord &record) { +int TsFileWriter::write_record(const TsRecord& record) { int ret = E_OK; // std::vector chunk_writers; - SimpleVector chunk_writers; + SimpleVector chunk_writers; SimpleVector data_types; MeasurementNamesFromRecord mnames_getter(record); if (RET_FAIL(do_check_schema( @@ -605,7 +605,7 @@ int TsFileWriter::write_record(const TsRecord &record) { ASSERT(chunk_writers.size() == record.points_.size()); for (uint32_t c = 0; c < chunk_writers.size(); c++) { - ChunkWriter *chunk_writer = chunk_writers[c]; + ChunkWriter* chunk_writer = chunk_writers[c]; if (IS_NULL(chunk_writer)) { continue; } @@ -619,11 +619,11 @@ int TsFileWriter::write_record(const TsRecord &record) { return ret; } -int TsFileWriter::write_record_aligned(const TsRecord &record) { +int TsFileWriter::write_record_aligned(const TsRecord& record) { int ret = E_OK; - SimpleVector value_chunk_writers; + SimpleVector value_chunk_writers; SimpleVector data_types; - TimeChunkWriter *time_chunk_writer; + TimeChunkWriter* time_chunk_writer; MeasurementNamesFromRecord mnames_getter(record); if (RET_FAIL(do_check_schema_aligned( std::make_shared(record.device_id_), @@ -636,7 +636,7 @@ int TsFileWriter::write_record_aligned(const TsRecord &record) { } time_chunk_writer->write(record.timestamp_); for (uint32_t c = 0; c < value_chunk_writers.size(); c++) { - ValueChunkWriter *value_chunk_writer = value_chunk_writers[c]; + ValueChunkWriter* value_chunk_writer = value_chunk_writers[c]; if (IS_NULL(value_chunk_writer)) { continue; } @@ -646,9 +646,9 @@ int TsFileWriter::write_record_aligned(const TsRecord &record) { return ret; } -int TsFileWriter::write_point(ChunkWriter *chunk_writer, int64_t timestamp, +int TsFileWriter::write_point(ChunkWriter* chunk_writer, int64_t timestamp, common::TSDataType data_type, - const DataPoint &point) { + const DataPoint& point) { switch (data_type) { case common::BOOLEAN: return chunk_writer->write(timestamp, point.u_.bool_val_); @@ -671,10 +671,10 @@ int TsFileWriter::write_point(ChunkWriter *chunk_writer, int64_t timestamp, } } -int TsFileWriter::write_point_aligned(ValueChunkWriter *value_chunk_writer, +int TsFileWriter::write_point_aligned(ValueChunkWriter* value_chunk_writer, int64_t timestamp, common::TSDataType data_type, - const DataPoint &point) { + const DataPoint& point) { bool isnull = point.isnull; switch (data_type) { case common::BOOLEAN: @@ -704,10 +704,10 @@ int TsFileWriter::write_point_aligned(ValueChunkWriter *value_chunk_writer, } } -int TsFileWriter::write_tablet_aligned(const Tablet &tablet) { +int TsFileWriter::write_tablet_aligned(const Tablet& tablet) { int ret = E_OK; - SimpleVector value_chunk_writers; - TimeChunkWriter *time_chunk_writer = nullptr; + SimpleVector value_chunk_writers; + TimeChunkWriter* time_chunk_writer = nullptr; SimpleVector data_types; MeasurementNamesFromTablet mnames_getter(tablet); if (RET_FAIL(do_check_schema_aligned( @@ -719,7 +719,7 @@ int TsFileWriter::write_tablet_aligned(const Tablet &tablet) { time_write_column(time_chunk_writer, tablet); ASSERT(value_chunk_writers.size() == tablet.get_column_count()); for (uint32_t c = 0; c < value_chunk_writers.size(); c++) { - ValueChunkWriter *value_chunk_writer = value_chunk_writers[c]; + ValueChunkWriter* value_chunk_writer = value_chunk_writers[c]; if (IS_NULL(value_chunk_writer)) { continue; } @@ -731,9 +731,9 @@ int TsFileWriter::write_tablet_aligned(const Tablet &tablet) { return ret; } -int TsFileWriter::write_tablet(const Tablet &tablet) { +int TsFileWriter::write_tablet(const Tablet& tablet) { int ret = E_OK; - SimpleVector chunk_writers; + SimpleVector chunk_writers; SimpleVector data_types; MeasurementNamesFromTablet mnames_getter(tablet); if (RET_FAIL(do_check_schema( @@ -743,7 +743,7 @@ int TsFileWriter::write_tablet(const Tablet &tablet) { } ASSERT(chunk_writers.size() == tablet.get_column_count()); for (uint32_t c = 0; c < chunk_writers.size(); c++) { - ChunkWriter *chunk_writer = chunk_writers[c]; + ChunkWriter* chunk_writer = chunk_writers[c]; if (IS_NULL(chunk_writer)) { continue; } @@ -757,7 +757,7 @@ int TsFileWriter::write_tablet(const Tablet &tablet) { return ret; } -int TsFileWriter::write_tree(const Tablet &tablet) { +int TsFileWriter::write_tree(const Tablet& tablet) { auto device_id = std::make_shared(tablet.insert_target_name_); if (schemas_.find(device_id) != schemas_.end()) { @@ -770,7 +770,7 @@ int TsFileWriter::write_tree(const Tablet &tablet) { return E_NOT_EXIST; } -int TsFileWriter::write_tree(const TsRecord &record) { +int TsFileWriter::write_tree(const TsRecord& record) { auto device_id = std::make_shared(record.device_id_); if (schemas_.find(device_id) != schemas_.end()) { auto schema = schemas_[device_id]; @@ -782,7 +782,7 @@ int TsFileWriter::write_tree(const TsRecord &record) { return E_NOT_EXIST; } -int TsFileWriter::write_table(Tablet &tablet) { +int TsFileWriter::write_table(Tablet& tablet) { int ret = E_OK; if (io_writer_->get_schema()->table_schema_map_.find( tablet.insert_target_name_) == @@ -796,13 +796,13 @@ int TsFileWriter::write_table(Tablet &tablet) { auto device_id_end_index_pairs = split_tablet_by_device(tablet); int start_idx = 0; - for (auto &device_id_end_index_pair : device_id_end_index_pairs) { + for (auto& device_id_end_index_pair : device_id_end_index_pairs) { auto device_id = device_id_end_index_pair.first; int end_idx = device_id_end_index_pair.second; if (end_idx == 0) continue; if (table_aligned_) { - SimpleVector value_chunk_writers; - TimeChunkWriter *time_chunk_writer = nullptr; + SimpleVector value_chunk_writers; + TimeChunkWriter* time_chunk_writer = nullptr; if (RET_FAIL(do_check_schema_table(device_id, tablet, time_chunk_writer, value_chunk_writers))) { @@ -817,7 +817,7 @@ int TsFileWriter::write_table(Tablet &tablet) { for (uint32_t i = 0; i < tablet.get_column_count(); ++i) { if (tablet.column_categories_[i] == common::ColumnCategory::FIELD) { - ValueChunkWriter *value_chunk_writer = + ValueChunkWriter* value_chunk_writer = value_chunk_writers[field_col_count]; if (IS_NULL(value_chunk_writer)) { continue; @@ -833,7 +833,7 @@ int TsFileWriter::write_table(Tablet &tablet) { start_idx = end_idx; } else { MeasurementNamesFromTablet mnames_getter(tablet); - SimpleVector chunk_writers; + SimpleVector chunk_writers; SimpleVector data_types; if (RET_FAIL(do_check_schema(device_id, mnames_getter, chunk_writers, data_types))) { @@ -841,7 +841,7 @@ int TsFileWriter::write_table(Tablet &tablet) { } ASSERT(chunk_writers.size() == tablet.get_column_count()); for (uint32_t c = 0; c < chunk_writers.size(); c++) { - ChunkWriter *chunk_writer = chunk_writers[c]; + ChunkWriter* chunk_writer = chunk_writers[c]; if (IS_NULL(chunk_writer)) { continue; } @@ -859,7 +859,7 @@ int TsFileWriter::write_table(Tablet &tablet) { } std::vector, int>> -TsFileWriter::split_tablet_by_device(const Tablet &tablet) { +TsFileWriter::split_tablet_by_device(const Tablet& tablet) { std::vector, int>> result; std::shared_ptr last_device_id = std::make_shared("last_device_id"); @@ -874,15 +874,15 @@ TsFileWriter::split_tablet_by_device(const Tablet &tablet) { return result; } -int TsFileWriter::write_column(ChunkWriter *chunk_writer, const Tablet &tablet, +int TsFileWriter::write_column(ChunkWriter* chunk_writer, const Tablet& tablet, int col_idx, uint32_t start_idx, uint32_t end_idx) { int ret = E_OK; common::TSDataType data_type = tablet.schema_vec_->at(col_idx).data_type_; - int64_t *timestamps = tablet.timestamps_; + int64_t* timestamps = tablet.timestamps_; Tablet::ValueMatrixEntry col_values = tablet.value_matrix_[col_idx]; - BitMap &col_notnull_bitmap = tablet.bitmaps_[col_idx]; + BitMap& col_notnull_bitmap = tablet.bitmaps_[col_idx]; end_idx = std::min(end_idx, tablet.max_row_num_); if (data_type == common::BOOLEAN) { @@ -914,10 +914,10 @@ int TsFileWriter::write_column(ChunkWriter *chunk_writer, const Tablet &tablet, return ret; } -int TsFileWriter::time_write_column(TimeChunkWriter *time_chunk_writer, - const Tablet &tablet, uint32_t start_idx, +int TsFileWriter::time_write_column(TimeChunkWriter* time_chunk_writer, + const Tablet& tablet, uint32_t start_idx, uint32_t end_idx) { - int64_t *timestamps = tablet.timestamps_; + int64_t* timestamps = tablet.timestamps_; int ret = E_OK; if (IS_NULL(time_chunk_writer) || IS_NULL(timestamps)) { return E_INVALID_ARG; @@ -930,48 +930,48 @@ int TsFileWriter::time_write_column(TimeChunkWriter *time_chunk_writer, return ret; } -int TsFileWriter::value_write_column(ValueChunkWriter *value_chunk_writer, - const Tablet &tablet, int col_idx, +int TsFileWriter::value_write_column(ValueChunkWriter* value_chunk_writer, + const Tablet& tablet, int col_idx, uint32_t start_idx, uint32_t end_idx) { int ret = E_OK; TSDataType data_type = tablet.schema_vec_->at(col_idx).data_type_; - int64_t *timestamps = tablet.timestamps_; + int64_t* timestamps = tablet.timestamps_; Tablet::ValueMatrixEntry col_values = tablet.value_matrix_[col_idx]; - BitMap &col_notnull_bitmap = tablet.bitmaps_[col_idx]; + BitMap& col_notnull_bitmap = tablet.bitmaps_[col_idx]; switch (data_type) { case common::BOOLEAN: ret = write_typed_column(value_chunk_writer, timestamps, - (bool *)col_values.bool_data, + (bool*)col_values.bool_data, col_notnull_bitmap, start_idx, end_idx); break; case common::DATE: case common::INT32: ret = write_typed_column(value_chunk_writer, timestamps, - (int32_t *)col_values.int32_data, + (int32_t*)col_values.int32_data, col_notnull_bitmap, start_idx, end_idx); break; case common::TIMESTAMP: case common::INT64: ret = write_typed_column(value_chunk_writer, timestamps, - (int64_t *)col_values.int64_data, + (int64_t*)col_values.int64_data, col_notnull_bitmap, start_idx, end_idx); break; case common::FLOAT: ret = write_typed_column(value_chunk_writer, timestamps, - (float *)col_values.float_data, + (float*)col_values.float_data, col_notnull_bitmap, start_idx, end_idx); break; case common::DOUBLE: ret = write_typed_column(value_chunk_writer, timestamps, - (double *)col_values.double_data, + (double*)col_values.double_data, col_notnull_bitmap, start_idx, end_idx); break; case common::STRING: case common::TEXT: case common::BLOB: ret = write_typed_column(value_chunk_writer, timestamps, - (common::String *)col_values.string_data, + (common::String*)col_values.string_data, col_notnull_bitmap, start_idx, end_idx); break; default: @@ -1013,88 +1013,88 @@ int TsFileWriter::value_write_column(ValueChunkWriter *value_chunk_writer, return ret; \ } while (false) -int TsFileWriter::write_typed_column(ChunkWriter *chunk_writer, - int64_t *timestamps, bool *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ChunkWriter* chunk_writer, + int64_t* timestamps, bool* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ChunkWriter *chunk_writer, - int64_t *timestamps, int32_t *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ChunkWriter* chunk_writer, + int64_t* timestamps, int32_t* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ChunkWriter *chunk_writer, - int64_t *timestamps, int64_t *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ChunkWriter* chunk_writer, + int64_t* timestamps, int64_t* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ChunkWriter *chunk_writer, - int64_t *timestamps, float *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ChunkWriter* chunk_writer, + int64_t* timestamps, float* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ChunkWriter *chunk_writer, - int64_t *timestamps, double *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ChunkWriter* chunk_writer, + int64_t* timestamps, double* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ChunkWriter *chunk_writer, - int64_t *timestamps, - common::String *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ChunkWriter* chunk_writer, + int64_t* timestamps, + common::String* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, bool *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, bool* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_VALUE_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, int32_t *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, int32_t* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_VALUE_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, int64_t *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, int64_t* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_VALUE_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, float *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, float* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_VALUE_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, double *col_values, - BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, double* col_values, + BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_VALUE_WRITE_TYPED_COLUMN(); } -int TsFileWriter::write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, - common::String *col_values, - common::BitMap &col_notnull_bitmap, +int TsFileWriter::write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, + common::String* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx) { DO_VALUE_WRITE_TYPED_COLUMN(); } @@ -1131,17 +1131,17 @@ int TsFileWriter::flush() { return ret; } -bool TsFileWriter::check_chunk_group_empty(MeasurementSchemaGroup *chunk_group, +bool TsFileWriter::check_chunk_group_empty(MeasurementSchemaGroup* chunk_group, bool is_aligned) { if (chunk_group->is_aligned_ && chunk_group->time_chunk_writer_ != nullptr && chunk_group->time_chunk_writer_->hasData()) { return false; } - MeasurementSchemaMap &map = chunk_group->measurement_schema_map_; + MeasurementSchemaMap& map = chunk_group->measurement_schema_map_; for (MeasurementSchemaMapIter ms_iter = map.begin(); ms_iter != map.end(); ms_iter++) { - MeasurementSchema *m_schema = ms_iter->second; + MeasurementSchema* m_schema = ms_iter->second; if (is_aligned) { if (m_schema->value_chunk_writer_ != NULL && m_schema->value_chunk_writer_->hasData()) { @@ -1172,13 +1172,13 @@ bool TsFileWriter::check_chunk_group_empty(MeasurementSchemaGroup *chunk_group, writer->reset(); \ } -int TsFileWriter::flush_chunk_group(MeasurementSchemaGroup *chunk_group, +int TsFileWriter::flush_chunk_group(MeasurementSchemaGroup* chunk_group, bool is_aligned) { int ret = E_OK; - MeasurementSchemaMap &map = chunk_group->measurement_schema_map_; + MeasurementSchemaMap& map = chunk_group->measurement_schema_map_; if (chunk_group->is_aligned_) { - TimeChunkWriter *&time_chunk_writer = chunk_group->time_chunk_writer_; + TimeChunkWriter*& time_chunk_writer = chunk_group->time_chunk_writer_; ChunkHeader chunk_header = time_chunk_writer->get_chunk_header(); FLUSH_CHUNK(time_chunk_writer, io_writer_, chunk_header.measurement_name_, chunk_header.data_type_, @@ -1188,15 +1188,15 @@ int TsFileWriter::flush_chunk_group(MeasurementSchemaGroup *chunk_group, for (MeasurementSchemaMapIter ms_iter = map.begin(); ms_iter != map.end(); ms_iter++) { - MeasurementSchema *m_schema = ms_iter->second; + MeasurementSchema* m_schema = ms_iter->second; if (!chunk_group->is_aligned_ && m_schema->chunk_writer_ != nullptr) { - ChunkWriter *&chunk_writer = m_schema->chunk_writer_; + ChunkWriter*& chunk_writer = m_schema->chunk_writer_; FLUSH_CHUNK(chunk_writer, io_writer_, m_schema->measurement_name_, m_schema->data_type_, m_schema->encoding_, m_schema->compression_type_, chunk_writer->num_of_pages()) } else if (m_schema->value_chunk_writer_ != nullptr) { - ValueChunkWriter *&value_chunk_writer = + ValueChunkWriter*& value_chunk_writer = m_schema->value_chunk_writer_; FLUSH_CHUNK(value_chunk_writer, io_writer_, m_schema->measurement_name_, m_schema->data_type_, diff --git a/cpp/src/writer/tsfile_writer.h b/cpp/src/writer/tsfile_writer.h index db16ae335..e80a1232b 100644 --- a/cpp/src/writer/tsfile_writer.h +++ b/cpp/src/writer/tsfile_writer.h @@ -52,35 +52,35 @@ class TsFileWriter { ~TsFileWriter(); void destroy(); - int open(const std::string &file_path, int flags, mode_t mode); - int open(const std::string &file_path); - int init(storage::WriteFile *write_file); + int open(const std::string& file_path, int flags, mode_t mode); + int open(const std::string& file_path); + int init(storage::WriteFile* write_file); void set_generate_table_schema(bool generate_table_schema); - int register_timeseries(const std::string &device_id, - const MeasurementSchema &measurement_schema); + int register_timeseries(const std::string& device_id, + const MeasurementSchema& measurement_schema); int register_timeseries( - const std::string &device_path, - const std::vector &measurement_schema_vec); + const std::string& device_path, + const std::vector& measurement_schema_vec); int register_aligned_timeseries( - const std::string &device_id, - const MeasurementSchema &measurement_schema); + const std::string& device_id, + const MeasurementSchema& measurement_schema); int register_aligned_timeseries( - const std::string &device_id, - const std::vector &measurement_schemas); - int register_table(const std::shared_ptr &table_schema); - int write_record(const TsRecord &record); - int write_tablet(const Tablet &tablet); - int write_record_aligned(const TsRecord &record); - int write_tablet_aligned(const Tablet &tablet); - int write_tree(const Tablet &tablet); - int write_tree(const TsRecord &record); - int write_table(Tablet &tablet); - - typedef std::map, MeasurementSchemaGroup *, + const std::string& device_id, + const std::vector& measurement_schemas); + int register_table(const std::shared_ptr& table_schema); + int write_record(const TsRecord& record); + int write_tablet(const Tablet& tablet); + int write_record_aligned(const TsRecord& record); + int write_tablet_aligned(const Tablet& tablet); + int write_tree(const Tablet& tablet); + int write_tree(const TsRecord& record); + int write_table(Tablet& tablet); + + typedef std::map, MeasurementSchemaGroup*, IDeviceIDComparator> DeviceSchemasMap; - typedef std::map, MeasurementSchemaGroup *, + typedef std::map, MeasurementSchemaGroup*, IDeviceIDComparator>::iterator DeviceSchemasMapIter; typedef std::unordered_map> @@ -89,7 +89,7 @@ class TsFileWriter { std::shared_ptr>::iterator TableSchemasMapIter; - DeviceSchemasMap *get_schema_group_map() { return &schemas_; } + DeviceSchemasMap* get_schema_group_map() { return &schemas_; } int64_t calculate_mem_size_for_all_group(); int check_memory_size_and_may_flush_chunks(); /* @@ -105,76 +105,76 @@ class TsFileWriter { int close(); private: - int write_point(storage::ChunkWriter *chunk_writer, int64_t timestamp, - common::TSDataType data_type, const DataPoint &point); - bool check_chunk_group_empty(MeasurementSchemaGroup *chunk_group, + int write_point(storage::ChunkWriter* chunk_writer, int64_t timestamp, + common::TSDataType data_type, const DataPoint& point); + bool check_chunk_group_empty(MeasurementSchemaGroup* chunk_group, bool is_aligned); - int write_point_aligned(ValueChunkWriter *value_chunk_writer, + int write_point_aligned(ValueChunkWriter* value_chunk_writer, int64_t timestamp, common::TSDataType data_type, - const DataPoint &point); - int flush_chunk_group(MeasurementSchemaGroup *chunk_group, bool is_aligned); + const DataPoint& point); + int flush_chunk_group(MeasurementSchemaGroup* chunk_group, bool is_aligned); - int write_typed_column(storage::ChunkWriter *chunk_writer, - int64_t *timestamps, bool *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(storage::ChunkWriter* chunk_writer, + int64_t* timestamps, bool* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(storage::ChunkWriter *chunk_writer, - int64_t *timestamps, int32_t *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(storage::ChunkWriter* chunk_writer, + int64_t* timestamps, int32_t* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(storage::ChunkWriter *chunk_writer, - int64_t *timestamps, int64_t *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(storage::ChunkWriter* chunk_writer, + int64_t* timestamps, int64_t* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(storage::ChunkWriter *chunk_writer, - int64_t *timestamps, float *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(storage::ChunkWriter* chunk_writer, + int64_t* timestamps, float* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(storage::ChunkWriter *chunk_writer, - int64_t *timestamps, double *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(storage::ChunkWriter* chunk_writer, + int64_t* timestamps, double* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(ChunkWriter *chunk_writer, int64_t *timestamps, - common::String *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ChunkWriter* chunk_writer, int64_t* timestamps, + common::String* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); template int do_check_schema( std::shared_ptr device_id, - MeasurementNamesGetter &measurement_names, - common::SimpleVector &chunk_writers, - common::SimpleVector &data_types); + MeasurementNamesGetter& measurement_names, + common::SimpleVector& chunk_writers, + common::SimpleVector& data_types); template int do_check_schema_aligned( std::shared_ptr device_id, - MeasurementNamesGetter &measurement_names, - storage::TimeChunkWriter *&time_chunk_writer, - common::SimpleVector &value_chunk_writers, - common::SimpleVector &data_types); + MeasurementNamesGetter& measurement_names, + storage::TimeChunkWriter*& time_chunk_writer, + common::SimpleVector& value_chunk_writers, + common::SimpleVector& data_types); int do_check_schema_table( - std::shared_ptr device_id, Tablet &tablet, - storage::TimeChunkWriter *&time_chunk_writer, - common::SimpleVector &value_chunk_writers); + std::shared_ptr device_id, Tablet& tablet, + storage::TimeChunkWriter*& time_chunk_writer, + common::SimpleVector& value_chunk_writers); - int do_check_and_prepare_tablet(Tablet &tablet); + int do_check_and_prepare_tablet(Tablet& tablet); // std::vector &chunk_writers); - int write_column(storage::ChunkWriter *chunk_writer, const Tablet &, + int write_column(storage::ChunkWriter* chunk_writer, const Tablet&, int col_idx, uint32_t start_idx = 0, uint32_t end_idx = UINT32_MAX); - int time_write_column(TimeChunkWriter *time_chunk_writer, - const Tablet &tablet, uint32_t start_idx = 0, + int time_write_column(TimeChunkWriter* time_chunk_writer, + const Tablet& tablet, uint32_t start_idx = 0, uint32_t end_idx = UINT32_MAX); - int register_timeseries(const std::string &device_path, - MeasurementSchema *measurement_schema, + int register_timeseries(const std::string& device_path, + MeasurementSchema* measurement_schema, bool is_aligned = false); std::vector, int>> - split_tablet_by_device(const Tablet &tablet); + split_tablet_by_device(const Tablet& tablet); private: - storage::WriteFile *write_file_; - storage::TsFileIOWriter *io_writer_; + storage::WriteFile* write_file_; + storage::TsFileIOWriter* io_writer_; // device_id -> MeasurementSchemaGroup DeviceSchemasMap schemas_; bool start_file_done_; @@ -185,37 +185,37 @@ class TsFileWriter { bool write_file_created_; bool table_aligned_ = true; - int write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, bool *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, bool* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, double *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, double* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, common::String *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, common::String* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, float *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, float* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, int32_t *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, int32_t* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int write_typed_column(ValueChunkWriter *value_chunk_writer, - int64_t *timestamps, int64_t *col_values, - common::BitMap &col_notnull_bitmap, + int write_typed_column(ValueChunkWriter* value_chunk_writer, + int64_t* timestamps, int64_t* col_values, + common::BitMap& col_notnull_bitmap, uint32_t start_idx, uint32_t end_idx); - int value_write_column(ValueChunkWriter *value_chunk_writer, - const Tablet &tablet, int col_idx, + int value_write_column(ValueChunkWriter* value_chunk_writer, + const Tablet& tablet, int col_idx, uint32_t start_idx, uint32_t end_idx); }; diff --git a/cpp/src/writer/value_chunk_writer.cc b/cpp/src/writer/value_chunk_writer.cc index b6b19a4f6..e4bb52658 100644 --- a/cpp/src/writer/value_chunk_writer.cc +++ b/cpp/src/writer/value_chunk_writer.cc @@ -25,12 +25,12 @@ using namespace common; namespace storage { -int ValueChunkWriter::init(const ColumnSchema &col_schema) { +int ValueChunkWriter::init(const ColumnSchema& col_schema) { return init(col_schema.column_name_, col_schema.data_type_, col_schema.encoding_, col_schema.compression_); } -int ValueChunkWriter::init(const std::string &measurement_name, +int ValueChunkWriter::init(const std::string& measurement_name, TSDataType data_type, TSEncoding encoding, CompressionType compression_type) { int ret = E_OK; @@ -142,12 +142,12 @@ int ValueChunkWriter::seal_cur_page(bool end_chunk) { } void ValueChunkWriter::save_first_page_data( - ValuePageWriter &first_page_writer) { + ValuePageWriter& first_page_writer) { first_page_data_ = first_page_writer.get_cur_page_data(); first_page_statistic_->deep_copy_from(first_page_writer.get_statistic()); } -int ValueChunkWriter::write_first_page_data(ByteStream &pages_data, +int ValueChunkWriter::write_first_page_data(ByteStream& pages_data, bool with_statistic) { int ret = E_OK; if (with_statistic && diff --git a/cpp/src/writer/value_chunk_writer.h b/cpp/src/writer/value_chunk_writer.h index 3aba7bbc5..859fb57b0 100644 --- a/cpp/src/writer/value_chunk_writer.h +++ b/cpp/src/writer/value_chunk_writer.h @@ -55,8 +55,8 @@ class ValueChunkWriter { chunk_header_(), num_of_pages_(0) {} ~ValueChunkWriter() { destroy(); } - int init(const common::ColumnSchema &col_schema); - int init(const std::string &measurement_name, common::TSDataType data_type, + int init(const common::ColumnSchema& col_schema); + int init(const std::string& measurement_name, common::TSDataType data_type, common::TSEncoding encoding, common::CompressionType compression_type); void reset(); @@ -110,8 +110,8 @@ class ValueChunkWriter { } int end_encode_chunk(); - common::ByteStream &get_chunk_data() { return chunk_data_; } - Statistic *get_chunk_statistic() { return chunk_statistic_; } + common::ByteStream& get_chunk_data() { return chunk_data_; } + Statistic* get_chunk_statistic() { return chunk_statistic_; } FORCE_INLINE int32_t num_of_pages() const { return num_of_pages_; } int64_t estimate_max_series_mem_size(); @@ -140,19 +140,19 @@ class ValueChunkWriter { } } int seal_cur_page(bool end_chunk); - void save_first_page_data(ValuePageWriter &first_page_writer); - int write_first_page_data(common::ByteStream &pages_data, + void save_first_page_data(ValuePageWriter& first_page_writer); + int write_first_page_data(common::ByteStream& pages_data, bool with_statistic = true); private: common::TSDataType data_type_; ValuePageWriter value_page_writer_; - Statistic *chunk_statistic_; + Statistic* chunk_statistic_; common::ByteStream chunk_data_; // to save first page data ValuePageData first_page_data_; - Statistic *first_page_statistic_; + Statistic* first_page_statistic_; ChunkHeader chunk_header_; int32_t num_of_pages_; diff --git a/cpp/src/writer/value_page_writer.cc b/cpp/src/writer/value_page_writer.cc index b95307f7b..feedb1870 100644 --- a/cpp/src/writer/value_page_writer.cc +++ b/cpp/src/writer/value_page_writer.cc @@ -30,15 +30,15 @@ namespace storage { uint32_t ValuePageWriter::MASK = 1 << 7; -int ValuePageData::init(ByteStream &col_notnull_bitmap_bs, ByteStream &value_bs, - Compressor *compressor, uint32_t size) { +int ValuePageData::init(ByteStream& col_notnull_bitmap_bs, ByteStream& value_bs, + Compressor* compressor, uint32_t size) { int ret = E_OK; col_notnull_bitmap_buf_size_ = col_notnull_bitmap_bs.total_size(); value_buf_size_ = value_bs.total_size(); uncompressed_size_ = sizeof(size) + col_notnull_bitmap_buf_size_ + value_buf_size_; uncompressed_buf_ = - (char *)mem_alloc(uncompressed_size_, MOD_PAGE_WRITER_OUTPUT_STREAM); + (char*)mem_alloc(uncompressed_size_, MOD_PAGE_WRITER_OUTPUT_STREAM); compressor_ = compressor; if (IS_NULL(uncompressed_buf_)) { return E_OOM; @@ -137,7 +137,7 @@ void ValuePageWriter::destroy() { } } -int ValuePageWriter::write_to_chunk(ByteStream &pages_data, bool write_header, +int ValuePageWriter::write_to_chunk(ByteStream& pages_data, bool write_header, bool write_statistic, bool write_data_to_chunk_data) { #if DEBUG_SE diff --git a/cpp/src/writer/value_page_writer.h b/cpp/src/writer/value_page_writer.h index 4cf2ffa92..60d75b0b8 100644 --- a/cpp/src/writer/value_page_writer.h +++ b/cpp/src/writer/value_page_writer.h @@ -35,9 +35,9 @@ struct ValuePageData { uint32_t value_buf_size_; uint32_t uncompressed_size_; uint32_t compressed_size_; - char *uncompressed_buf_; - char *compressed_buf_; - Compressor *compressor_; + char* uncompressed_buf_; + char* compressed_buf_; + Compressor* compressor_; ValuePageData() : col_notnull_bitmap_buf_size_(0), @@ -47,8 +47,8 @@ struct ValuePageData { uncompressed_buf_(nullptr), compressed_buf_(nullptr), compressor_(nullptr) {} - int init(common::ByteStream &col_notnull_bitmap_bs, - common::ByteStream &value_bs, Compressor *compressor, + int init(common::ByteStream& col_notnull_bitmap_bs, + common::ByteStream& value_bs, Compressor* compressor, uint32_t size); void destroy() { // Be careful about the memory @@ -172,15 +172,15 @@ class ValuePageWriter { value_out_stream_.total_size() + value_encoder_->get_max_byte_size(); } - int write_to_chunk(common::ByteStream &pages_data, bool write_header, + int write_to_chunk(common::ByteStream& pages_data, bool write_header, bool write_statistic, bool write_data_to_chunk_data); - FORCE_INLINE common::ByteStream &get_col_notnull_bitmap_data() { + FORCE_INLINE common::ByteStream& get_col_notnull_bitmap_data() { return col_notnull_bitmap_out_stream_; } - FORCE_INLINE common::ByteStream &get_value_data() { + FORCE_INLINE common::ByteStream& get_value_data() { return value_out_stream_; } - FORCE_INLINE Statistic *get_statistic() { return statistic_; } + FORCE_INLINE Statistic* get_statistic() { return statistic_; } ValuePageData get_cur_page_data() { return cur_page_data_; } void destroy_page_data() { cur_page_data_.destroy(); } @@ -195,20 +195,20 @@ class ValuePageWriter { } return ret; } - int copy_page_data_to(common::ByteStream &my_page_data, - common::ByteStream &pages_data); + int copy_page_data_to(common::ByteStream& my_page_data, + common::ByteStream& pages_data); private: static const uint32_t OUT_STREAM_PAGE_SIZE = 1024; private: common::TSDataType data_type_; - Encoder *value_encoder_; - Statistic *statistic_; + Encoder* value_encoder_; + Statistic* statistic_; common::ByteStream col_notnull_bitmap_out_stream_; common::ByteStream value_out_stream_; ValuePageData cur_page_data_; - Compressor *compressor_; + Compressor* compressor_; bool is_inited_; std::vector col_notnull_bitmap_; uint32_t size_; diff --git a/cpp/test/common/allocator/alloc_base_test.cc b/cpp/test/common/allocator/alloc_base_test.cc index 525f5baff..6946aa8c2 100644 --- a/cpp/test/common/allocator/alloc_base_test.cc +++ b/cpp/test/common/allocator/alloc_base_test.cc @@ -29,7 +29,7 @@ TEST(AllocBaseTest, BaseAllocator) { BaseAllocator allocator; for (AllocModID mod_id = MOD_DEFAULT; mod_id <= MOD_ZIGZAG_OBJ; mod_id = (AllocModID)(mod_id + 1)) { - void *ptr = allocator.alloc(100, mod_id); + void* ptr = allocator.alloc(100, mod_id); ASSERT_NE(ptr, nullptr); allocator.free(ptr); } @@ -38,10 +38,10 @@ TEST(AllocBaseTest, BaseAllocator) { TEST(AllocBaseTest, AllocSmallSize) { uint32_t size = 1024; AllocModID mid = MOD_DEFAULT; - void *ptr = mem_alloc(size, mid); + void* ptr = mem_alloc(size, mid); ASSERT_NE(ptr, nullptr); - char *p = (char *)ptr - HEADER_SIZE_4B; - uint32_t header = *((uint32_t *)p); + char* p = (char*)ptr - HEADER_SIZE_4B; + uint32_t header = *((uint32_t*)p); EXPECT_EQ(header >> 8, size); EXPECT_EQ(header & 0x7F, mid); mem_free(ptr); @@ -50,11 +50,11 @@ TEST(AllocBaseTest, AllocSmallSize) { TEST(AllocBaseTest, AllocLargeSize) { uint32_t size = 0x1000000; AllocModID mid = MOD_DEFAULT; - void *ptr = mem_alloc(size, mid); + void* ptr = mem_alloc(size, mid); ASSERT_NE(ptr, nullptr); - char *p = (char *)ptr - HEADER_SIZE_8B; - uint32_t high4b = *(uint32_t *)p; - uint32_t low4b = *(uint32_t *)(p + 4); + char* p = (char*)ptr - HEADER_SIZE_8B; + uint32_t high4b = *(uint32_t*)p; + uint32_t low4b = *(uint32_t*)(p + 4); uint64_t header = ((uint64_t)high4b << 32) | low4b; EXPECT_EQ((header >> 8), size); EXPECT_EQ((header & 0x7F), mid); @@ -65,13 +65,13 @@ TEST(AllocBaseTest, ReallocateToLargerSize) { const uint32_t initial_size = 1000; const uint32_t new_size = 2000; - void *ptr = mem_alloc(initial_size, MOD_DEFAULT); + void* ptr = mem_alloc(initial_size, MOD_DEFAULT); ASSERT_NE(ptr, nullptr); ptr = mem_realloc(ptr, new_size); ASSERT_NE(ptr, nullptr); - uint32_t *header = (uint32_t *)((char *)ptr - HEADER_SIZE_4B); + uint32_t* header = (uint32_t*)((char*)ptr - HEADER_SIZE_4B); ASSERT_EQ(*header >> 8, new_size); mem_free(ptr); @@ -81,13 +81,13 @@ TEST(AllocBaseTest, ReallocateToSmallerSize) { const uint32_t initial_size = 2000; const uint32_t new_size = 1000; - void *ptr = mem_alloc(initial_size, MOD_DEFAULT); + void* ptr = mem_alloc(initial_size, MOD_DEFAULT); ASSERT_NE(ptr, nullptr); ptr = mem_realloc(ptr, new_size); ASSERT_NE(ptr, nullptr); - uint32_t *header = (uint32_t *)((char *)ptr - HEADER_SIZE_4B); + uint32_t* header = (uint32_t*)((char*)ptr - HEADER_SIZE_4B); ASSERT_EQ(*header >> 8, new_size); mem_free(ptr); diff --git a/cpp/test/common/tsblock/tslock_test.cc b/cpp/test/common/tsblock/tslock_test.cc index c26f14713..91ee96a3b 100644 --- a/cpp/test/common/tsblock/tslock_test.cc +++ b/cpp/test/common/tsblock/tslock_test.cc @@ -58,7 +58,7 @@ TEST(TsBlockTest, ColAppender_AddRowAndAppend) { EXPECT_TRUE(row_appender.add_row()); EXPECT_TRUE(col_appender.add_row()); int32_t val = i; - col_appender.append((const char *)&val, sizeof(int32_t)); + col_appender.append((const char*)&val, sizeof(int32_t)); } EXPECT_EQ(col_appender.get_col_row_count(), 50); @@ -79,7 +79,7 @@ TEST(TsBlockTest, RowIterator_ReadAndNext) { EXPECT_TRUE(row_appender.add_row()); EXPECT_TRUE(col_appender.add_row()); int32_t val = i; - col_appender.append((const char *)&val, sizeof(int32_t)); + col_appender.append((const char*)&val, sizeof(int32_t)); } RowIterator row_iterator(&ts_block); @@ -87,17 +87,17 @@ TEST(TsBlockTest, RowIterator_ReadAndNext) { uint32_t len; bool null; - char *value = row_iterator.read(0, &len, &null); + char* value = row_iterator.read(0, &len, &null); EXPECT_EQ(len, sizeof(int32_t)); EXPECT_FALSE(null); - EXPECT_EQ(*((int32_t *)value), 0); + EXPECT_EQ(*((int32_t*)value), 0); row_iterator.next(); EXPECT_FALSE(row_iterator.end()); value = row_iterator.read(0, &len, &null); EXPECT_EQ(len, sizeof(int32_t)); EXPECT_FALSE(null); - EXPECT_EQ(*((int32_t *)value), 1); + EXPECT_EQ(*((int32_t*)value), 1); for (int i = 1; i < 10000; ++i) { row_iterator.next(); @@ -120,7 +120,7 @@ TEST(TsBlockTest, ColIterator_ReadAndNext) { EXPECT_TRUE(row_appender.add_row()); EXPECT_TRUE(col_appender.add_row()); int32_t val = i; - col_appender.append((const char *)&val, sizeof(int32_t)); + col_appender.append((const char*)&val, sizeof(int32_t)); } ColIterator col_iterator(0, &ts_block); @@ -128,17 +128,17 @@ TEST(TsBlockTest, ColIterator_ReadAndNext) { uint32_t len; bool null; - char *value = col_iterator.read(&len, &null); + char* value = col_iterator.read(&len, &null); EXPECT_EQ(len, sizeof(int32_t)); EXPECT_FALSE(null); - EXPECT_EQ(*((int32_t *)value), 0); + EXPECT_EQ(*((int32_t*)value), 0); col_iterator.next(); EXPECT_FALSE(col_iterator.end()); value = col_iterator.read(&len, &null); EXPECT_EQ(len, sizeof(int32_t)); EXPECT_FALSE(null); - EXPECT_EQ(*((int32_t *)value), 1); + EXPECT_EQ(*((int32_t*)value), 1); for (int i = 1; i < 10000; ++i) { col_iterator.next(); diff --git a/cpp/test/common/tsfile_common_test.cc b/cpp/test/common/tsfile_common_test.cc index 0b22b6afd..4b46dd827 100644 --- a/cpp/test/common/tsfile_common_test.cc +++ b/cpp/test/common/tsfile_common_test.cc @@ -164,8 +164,8 @@ class TSMIteratorTest : public ::testing::Test { void SetUp() override { arena.init(1024, common::MOD_DEFAULT); chunk_group_meta_list_ = - new common::SimpleList(&arena); - void *buf = arena.alloc(sizeof(ChunkGroupMeta)); + new common::SimpleList(&arena); + void* buf = arena.alloc(sizeof(ChunkGroupMeta)); auto chunk_group_meta = new (buf) ChunkGroupMeta(&arena); chunk_group_meta->device_id_ = std::make_shared("device_1"); @@ -192,8 +192,8 @@ class TSMIteratorTest : public ::testing::Test { } common::PageArena arena; - Statistic *stat_; - common::SimpleList *chunk_group_meta_list_; + Statistic* stat_; + common::SimpleList* chunk_group_meta_list_; }; TEST_F(TSMIteratorTest, InitSuccess) { @@ -203,7 +203,7 @@ TEST_F(TSMIteratorTest, InitSuccess) { TEST_F(TSMIteratorTest, InitEmptyList) { common::PageArena arena; - common::SimpleList empty_list(&arena); + common::SimpleList empty_list(&arena); TSMIterator iter(empty_list); ASSERT_EQ(iter.init(), common::E_OK); } @@ -240,7 +240,7 @@ TEST_F(TSMIteratorTest, GetNext) { class MetaIndexEntryTest : public ::testing::Test { protected: common::PageArena pa_; - common::ByteStream *out_; + common::ByteStream* out_; std::shared_ptr entry_; void SetUp() override { @@ -273,7 +273,7 @@ TEST_F(MetaIndexEntryTest, SerializeDeserialize) { class MetaIndexNodeTest : public ::testing::Test { protected: common::PageArena pa_; - common::ByteStream *out_; + common::ByteStream* out_; MetaIndexNode node_; MetaIndexNodeTest() : node_(&pa_) {} @@ -416,7 +416,7 @@ TEST_F(MetaIndexNodeSearchTest, NonExactSearchNotFound) { class TsFileMetaTest : public ::testing::Test { protected: common::PageArena pa_; - common::ByteStream *out_; + common::ByteStream* out_; TsFileMeta meta_; void SetUp() override { @@ -438,7 +438,7 @@ TEST_F(TsFileMetaTest, SerializeDeserialize) { meta_.table_metadata_index_node_map_.insert( std::make_pair(table_name, index_node)); - std::vector column_schemas; + std::vector column_schemas; std::vector column_categories; column_categories.emplace_back(common::ColumnCategory::FIELD); column_schemas.emplace_back(new MeasurementSchema()); @@ -452,7 +452,7 @@ TEST_F(TsFileMetaTest, SerializeDeserialize) { meta_.tsfile_properties_.insert(std::make_pair("null_key", nullptr)); meta_.meta_offset_ = 456; - void *buf = pa_.alloc(sizeof(BloomFilter)); + void* buf = pa_.alloc(sizeof(BloomFilter)); meta_.bloom_filter_ = new (buf) BloomFilter(); meta_.bloom_filter_->init(0.1, 100); diff --git a/cpp/test/compress/gzip_compressor_test.cc b/cpp/test/compress/gzip_compressor_test.cc index a6fb7121f..eece8328f 100644 --- a/cpp/test/compress/gzip_compressor_test.cc +++ b/cpp/test/compress/gzip_compressor_test.cc @@ -55,7 +55,7 @@ TEST_F(GZIPTest, TestBytes1) { storage::GZIPCompressor compressor; compressor.reset(true); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; auto start_time = std::chrono::high_resolution_clock::now(); compressor.compress(uncompressed.data(), uncompressed.size(), @@ -72,7 +72,7 @@ TEST_F(GZIPTest, TestBytes1) { << static_cast(compressed_buf_len) / uncompressed.size() << std::endl; - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); start_time = std::chrono::high_resolution_clock::now(); @@ -101,7 +101,7 @@ TEST_F(GZIPTest, TestBytes2) { std::string input = RandomString(n); std::vector uncompressed(input.begin(), input.end()); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; uint32_t compressed_buf_len_new = 0; compressor.reset(true); @@ -114,7 +114,7 @@ TEST_F(GZIPTest, TestBytes2) { compressed_buf, compressed_buf_len_new); EXPECT_EQ(compressed_buf_len_new, compressed_buf_len); - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); compressor.uncompress(compressed_buf, compressed_buf_len, decompressed_buf, diff --git a/cpp/test/compress/lz4_compressor_test.cc b/cpp/test/compress/lz4_compressor_test.cc index df2164ce7..c57ec0caf 100644 --- a/cpp/test/compress/lz4_compressor_test.cc +++ b/cpp/test/compress/lz4_compressor_test.cc @@ -55,7 +55,7 @@ TEST_F(LZ4Test, TestBytes1) { storage::LZ4Compressor compressor; compressor.reset(true); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; auto start_time = std::chrono::high_resolution_clock::now(); compressor.compress(uncompressed.data(), uncompressed.size(), @@ -72,7 +72,7 @@ TEST_F(LZ4Test, TestBytes1) { << static_cast(compressed_buf_len) / uncompressed.size() << std::endl; - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); start_time = std::chrono::high_resolution_clock::now(); @@ -101,7 +101,7 @@ TEST_F(LZ4Test, TestBytes2) { std::string input = RandomString(n); std::vector uncompressed(input.begin(), input.end()); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; uint32_t compressed_buf_len_new = 0; compressor.reset(true); @@ -113,7 +113,7 @@ TEST_F(LZ4Test, TestBytes2) { compressed_buf, compressed_buf_len_new); EXPECT_EQ(compressed_buf_len_new, compressed_buf_len); - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); compressor.uncompress(compressed_buf, compressed_buf_len, decompressed_buf, diff --git a/cpp/test/compress/lzo_compressor_test.cc b/cpp/test/compress/lzo_compressor_test.cc index 918ccb410..efc5534dc 100644 --- a/cpp/test/compress/lzo_compressor_test.cc +++ b/cpp/test/compress/lzo_compressor_test.cc @@ -55,7 +55,7 @@ TEST_F(LZOTest, TestBytes1) { storage::LZOCompressor compressor; compressor.reset(true); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; auto start_time = std::chrono::high_resolution_clock::now(); compressor.compress(uncompressed.data(), uncompressed.size(), @@ -72,7 +72,7 @@ TEST_F(LZOTest, TestBytes1) { << static_cast(compressed_buf_len) / uncompressed.size() << std::endl; - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); start_time = std::chrono::high_resolution_clock::now(); @@ -101,7 +101,7 @@ TEST_F(LZOTest, TestBytes2) { std::string input = RandomString(n); std::vector uncompressed(input.begin(), input.end()); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; uint32_t compressed_buf_len_new = 0; compressor.reset(true); @@ -113,7 +113,7 @@ TEST_F(LZOTest, TestBytes2) { compressed_buf, compressed_buf_len_new); EXPECT_EQ(compressed_buf_len_new, compressed_buf_len); - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); compressor.uncompress(compressed_buf, compressed_buf_len, decompressed_buf, diff --git a/cpp/test/compress/snappy_compressor_test.cc b/cpp/test/compress/snappy_compressor_test.cc old mode 100755 new mode 100644 index d7ac6cf91..d24915d70 --- a/cpp/test/compress/snappy_compressor_test.cc +++ b/cpp/test/compress/snappy_compressor_test.cc @@ -55,7 +55,7 @@ TEST_F(SnappyTest, TestBytes1) { storage::SnappyCompressor compressor; compressor.reset(true); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; auto start_time = std::chrono::high_resolution_clock::now(); compressor.compress(uncompressed.data(), uncompressed.size(), @@ -72,7 +72,7 @@ TEST_F(SnappyTest, TestBytes1) { << static_cast(compressed_buf_len) / uncompressed.size() << std::endl; - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); start_time = std::chrono::high_resolution_clock::now(); @@ -101,7 +101,7 @@ TEST_F(SnappyTest, TestBytes2) { std::string input = RandomString(n); std::vector uncompressed(input.begin(), input.end()); - char *compressed_buf = nullptr; + char* compressed_buf = nullptr; uint32_t compressed_buf_len = 0; uint32_t compressed_buf_len_new = 0; compressor.reset(true); @@ -113,7 +113,7 @@ TEST_F(SnappyTest, TestBytes2) { compressed_buf, compressed_buf_len_new); EXPECT_EQ(compressed_buf_len_new, compressed_buf_len); - char *decompressed_buf = nullptr; + char* decompressed_buf = nullptr; uint32_t decompressed_buf_len = uncompressed.size(); compressor.reset(false); compressor.uncompress(compressed_buf, compressed_buf_len, decompressed_buf, diff --git a/cpp/test/file/write_file_test.cc b/cpp/test/file/write_file_test.cc index 0ea9c0a2b..1345b7bee 100644 --- a/cpp/test/file/write_file_test.cc +++ b/cpp/test/file/write_file_test.cc @@ -59,7 +59,7 @@ TEST_F(WriteFileTest, WriteToFile) { EXPECT_EQ(write_file.create(file_name, flags, mode), E_OK); EXPECT_TRUE(write_file.file_opened()); - const char *content = "Hello, World!"; + const char* content = "Hello, World!"; uint32_t content_len = strlen(content); EXPECT_EQ(write_file.write(content, content_len), E_OK); @@ -87,7 +87,7 @@ TEST_F(WriteFileTest, SyncFile) { EXPECT_EQ(write_file.create(file_name, flags, mode), E_OK); EXPECT_TRUE(write_file.file_opened()); - const char *content = "Hello, Sync!"; + const char* content = "Hello, Sync!"; uint32_t content_len = strlen(content); EXPECT_EQ(write_file.write(content, content_len), E_OK); EXPECT_EQ(write_file.sync(), E_OK); @@ -107,7 +107,7 @@ TEST_F(WriteFileTest, CloseFile) { EXPECT_EQ(write_file.create(file_name, flags, mode), E_OK); EXPECT_TRUE(write_file.file_opened()); - const char *content = "Closing file."; + const char* content = "Closing file."; uint32_t content_len = strlen(content); EXPECT_EQ(write_file.write(content, content_len), E_OK); EXPECT_EQ(write_file.close(), E_OK); diff --git a/cpp/test/writer/tsfile_writer_test.cc b/cpp/test/writer/tsfile_writer_test.cc index 07d6cf783..25684e726 100644 --- a/cpp/test/writer/tsfile_writer_test.cc +++ b/cpp/test/writer/tsfile_writer_test.cc @@ -57,7 +57,7 @@ class TsFileWriterTest : public ::testing::Test { } std::string file_name_; - TsFileWriter *tsfile_writer_ = nullptr; + TsFileWriter* tsfile_writer_ = nullptr; public: static std::string generate_random_string(int length) { @@ -78,7 +78,7 @@ class TsFileWriterTest : public ::testing::Test { return random_string; } - static std::string field_to_string(storage::Field *value) { + static std::string field_to_string(storage::Field* value) { if (value->type_ == common::TEXT || value->type_ == STRING || value->type_ == BLOB) { return std::string(value->value_.sval_); @@ -138,12 +138,12 @@ TEST_F(TsFileWriterTest, WriteDiffDataType) { compression_type)); } - char *literal = new char[std::strlen("device_id") + 1]; + char* literal = new char[std::strlen("device_id") + 1]; std::strcpy(literal, "device_id"); String literal_str(literal, std::strlen("device_id")); std::time_t now = std::time(nullptr); - std::tm *local_time = std::localtime(&now); + std::tm* local_time = std::localtime(&now); std::tm today = {}; today.tm_year = local_time->tm_year; today.tm_mon = local_time->tm_mon; @@ -202,10 +202,10 @@ TEST_F(TsFileWriterTest, WriteDiffDataType) { storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(select_list, 1622505600000, 1622505600000 + row_num * 100, tmp_qds); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; int64_t cur_record_num = 0; bool has_next = false; @@ -218,10 +218,10 @@ TEST_F(TsFileWriterTest, WriteDiffDataType) { ASSERT_EQ(qds->get_value(3), (int64_t)415412); ASSERT_EQ(qds->get_value(4), true); ASSERT_EQ(qds->get_value(5), (double)2.0); - ASSERT_EQ(qds->get_value(6)->compare(literal_str), 0); + ASSERT_EQ(qds->get_value(6)->compare(literal_str), 0); ASSERT_EQ(qds->get_value(7), (int64_t)415412); - ASSERT_EQ(qds->get_value(8)->compare(literal_str), 0); - ASSERT_EQ(qds->get_value(9)->compare(literal_str), 0); + ASSERT_EQ(qds->get_value(8)->compare(literal_str), 0); + ASSERT_EQ(qds->get_value(9)->compare(literal_str), 0); ASSERT_TRUE( DateConverter::is_tm_ymd_equal(qds->get_value(10), today)); @@ -230,15 +230,15 @@ TEST_F(TsFileWriterTest, WriteDiffDataType) { (int64_t)415412); ASSERT_EQ(qds->get_value(measurement_names[2]), true); ASSERT_EQ(qds->get_value(measurement_names[3]), (double)2.0); - ASSERT_EQ(qds->get_value(measurement_names[4]) + ASSERT_EQ(qds->get_value(measurement_names[4]) ->compare(literal_str), 0); ASSERT_EQ(qds->get_value(measurement_names[5]), (int64_t)415412); - ASSERT_EQ(qds->get_value(measurement_names[6]) + ASSERT_EQ(qds->get_value(measurement_names[6]) ->compare(literal_str), 0); - ASSERT_EQ(qds->get_value(measurement_names[7]) + ASSERT_EQ(qds->get_value(measurement_names[7]) ->compare(literal_str), 0); ASSERT_TRUE(DateConverter::is_tm_ymd_equal( @@ -317,7 +317,7 @@ TEST_F(TsFileWriterTest, WriteDiffrentTypeCombination) { } } - char *literal = new char[std::strlen("literal") + 1]; + char* literal = new char[std::strlen("literal") + 1]; std::strcpy(literal, "literal"); String literal_str(literal, std::strlen("literal")); for (size_t l = 0; l < 100; ++l) { @@ -393,18 +393,18 @@ TEST_F(TsFileWriterTest, WriteMultipleTabletsMultiFlush) { select_list.push_back(path); } } - storage::QueryExpression *query_expr = + storage::QueryExpression* query_expr = storage::QueryExpression::create(select_list, nullptr); storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(query_expr, tmp_qds); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; - storage::RowRecord *record; + storage::RowRecord* record; int max_rows = max_tablet_num * 1; bool has_next = false; for (int cur_row = 0; cur_row < max_rows; cur_row++) { @@ -476,19 +476,19 @@ TEST_F(TsFileWriterTest, WriteMultipleTabletsAlignedMultiFlush) { select_list.push_back(path); } } - storage::QueryExpression *query_expr = + storage::QueryExpression* query_expr = storage::QueryExpression::create(select_list, nullptr); storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(query_expr, tmp_qds); ASSERT_EQ(ret, common::E_OK); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; - storage::RowRecord *record; + storage::RowRecord* record; int max_rows = max_tablet_num * 1; bool has_next = false; for (int cur_row = 0; cur_row < max_rows; cur_row++) { @@ -646,18 +646,18 @@ TEST_F(TsFileWriterTest, FlushMultipleDevice) { select_list.push_back(path); } } - storage::QueryExpression *query_expr = + storage::QueryExpression* query_expr = storage::QueryExpression::create(select_list, nullptr); storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(query_expr, tmp_qds); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; - storage::RowRecord *record; + storage::RowRecord* record; int64_t cur_record_num = 0; bool has_next = false; do { @@ -716,8 +716,8 @@ TEST_F(TsFileWriterTest, AnalyzeTsfileForload) { } auto schemas = tsfile_writer_->get_schema_group_map(); ASSERT_EQ(schemas->size(), 50); - for (const auto &device_iter : *schemas) { - for (const auto &chunk_iter : + for (const auto& device_iter : *schemas) { + for (const auto& chunk_iter : device_iter.second->measurement_schema_map_) { ASSERT_NE(chunk_iter.second->chunk_writer_, nullptr); ASSERT_TRUE(chunk_iter.second->chunk_writer_->hasData()); @@ -755,9 +755,9 @@ TEST_F(TsFileWriterTest, WriteAlignedTimeseries) { common::TSEncoding encoding = common::TSEncoding::PLAIN; common::CompressionType compression_type = common::CompressionType::UNCOMPRESSED; - std::vector measurement_schema_vec; - for (const auto &measurement_name : measurement_names) { - auto *ms = new MeasurementSchema(measurement_name, data_type, encoding, + std::vector measurement_schema_vec; + for (const auto& measurement_name : measurement_names) { + auto* ms = new MeasurementSchema(measurement_name, data_type, encoding, compression_type); measurement_schema_vec.push_back(ms); } @@ -766,7 +766,7 @@ TEST_F(TsFileWriterTest, WriteAlignedTimeseries) { for (int i = 0; i < row_num; ++i) { TsRecord record(1622505600000 + i * 1000, device_name); - for (const auto &measurement_name : measurement_names) { + for (const auto& measurement_name : measurement_names) { record.add_point(measurement_name, (int32_t)i); } ASSERT_EQ(tsfile_writer_->write_record_aligned(record), E_OK); @@ -781,18 +781,18 @@ TEST_F(TsFileWriterTest, WriteAlignedTimeseries) { storage::Path path(device_name, measurement_name); select_list.push_back(path); } - storage::QueryExpression *query_expr = + storage::QueryExpression* query_expr = storage::QueryExpression::create(select_list, nullptr); storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(query_expr, tmp_qds); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; - storage::RowRecord *record; + storage::RowRecord* record; bool has_next = false; for (int cur_row = 0; cur_row < row_num; cur_row++) { if (IS_FAIL(qds->next(has_next)) || !has_next) { @@ -825,9 +825,9 @@ TEST_F(TsFileWriterTest, WriteAlignedMultiFlush) { common::TSEncoding encoding = common::TSEncoding::PLAIN; common::CompressionType compression_type = common::CompressionType::UNCOMPRESSED; - std::vector measurement_schema_vec; - for (const auto &measurement_name : measurement_names) { - auto *ms = new MeasurementSchema(measurement_name, data_type, encoding, + std::vector measurement_schema_vec; + for (const auto& measurement_name : measurement_names) { + auto* ms = new MeasurementSchema(measurement_name, data_type, encoding, compression_type); measurement_schema_vec.push_back(ms); } @@ -836,7 +836,7 @@ TEST_F(TsFileWriterTest, WriteAlignedMultiFlush) { for (int i = 0; i < row_num; ++i) { TsRecord record(1622505600000 + i * 1000, device_name); - for (const auto &measurement_name : measurement_names) { + for (const auto& measurement_name : measurement_names) { record.add_point(measurement_name, (int32_t)i); } ASSERT_EQ(tsfile_writer_->write_record_aligned(record), E_OK); @@ -851,18 +851,18 @@ TEST_F(TsFileWriterTest, WriteAlignedMultiFlush) { storage::Path path(device_name, measurement_name); select_list.push_back(path); } - storage::QueryExpression *query_expr = + storage::QueryExpression* query_expr = storage::QueryExpression::create(select_list, nullptr); storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(query_expr, tmp_qds); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; - storage::RowRecord *record; + storage::RowRecord* record; bool has_next = false; for (int cur_row = 0; cur_row < row_num; cur_row++) { if (IS_FAIL(qds->next(has_next)) || !has_next) { @@ -895,9 +895,9 @@ TEST_F(TsFileWriterTest, WriteAlignedPartialData) { common::TSEncoding encoding = common::TSEncoding::PLAIN; common::CompressionType compression_type = common::CompressionType::UNCOMPRESSED; - std::vector measurement_schema_vec; - for (const auto &measurement_name : measurement_names) { - auto *ms = new MeasurementSchema(measurement_name, data_type, encoding, + std::vector measurement_schema_vec; + for (const auto& measurement_name : measurement_names) { + auto* ms = new MeasurementSchema(measurement_name, data_type, encoding, compression_type); measurement_schema_vec.push_back(ms); } @@ -906,7 +906,7 @@ TEST_F(TsFileWriterTest, WriteAlignedPartialData) { for (int i = 0; i < row_num; ++i) { TsRecord record(1622505600000 + i * 1000, device_name); - for (const auto &measurement_name : measurement_names) { + for (const auto& measurement_name : measurement_names) { record.add_point(measurement_name, (int32_t)i); } ASSERT_EQ(tsfile_writer_->write_record_aligned(record), E_OK); @@ -920,18 +920,18 @@ TEST_F(TsFileWriterTest, WriteAlignedPartialData) { storage::Path path(device_name, measurement_name); select_list.push_back(path); } - storage::QueryExpression *query_expr = + storage::QueryExpression* query_expr = storage::QueryExpression::create(select_list, nullptr); storage::TsFileReader reader; int ret = reader.open(file_name_); ASSERT_EQ(ret, common::E_OK); - storage::ResultSet *tmp_qds = nullptr; + storage::ResultSet* tmp_qds = nullptr; ret = reader.query(query_expr, tmp_qds); - auto *qds = (QDSWithoutTimeGenerator *)tmp_qds; + auto* qds = (QDSWithoutTimeGenerator*)tmp_qds; - storage::RowRecord *record; + storage::RowRecord* record; int64_t cur_row = 0; bool has_next = false; do { @@ -988,7 +988,7 @@ TEST_F(TsFileWriterTest, WriteTabletDataTypeMismatch) { } } ASSERT_EQ(E_TYPE_NOT_MATCH, tsfile_writer_->write_tablet(tablet)); - std::vector measurement_schemas; + std::vector measurement_schemas; for (int i = 0; i < 3; i++) { measurement_schemas.push_back(new MeasurementSchema( "measurement" + std::to_string(i), TSDataType::INT32)); diff --git a/cpp/test_all.sh b/cpp/test_all.sh deleted file mode 100644 index 585be9602..000000000 --- a/cpp/test_all.sh +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -#