Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

std::unique_ptr<Block> block = Block::create_unique(xxxx);  // it is ok


1.3 Just return smart ptr not raw pointer

Sometimes we use C style code when write C++ code, especially for return value. Many of our code, return a raw pointer and then set the value to

the smart pointer. We could just return unique_ptr.

Image AddedImage Added

1.4 Could use smart pointer check nullable directly not need convert to raw pointer

Many developer use if (smart_pointer.get()) to check if the smart pointer is null, actually we could check the 

smart pointer directly.

Image Added

reference: https://en.cppreference.com/w/cpp/memory/shared_ptr/operator_bool

https://en.cppreference.com/w/cpp/memory/unique_ptr/operator_bool

1.5 Lock and Unlock

There are many lock and unlock code. Could not make sure that the lock is correctly released. Should use unique lock or lock guard. For example, in following example, the lock is conditionally locked by checking acquire_lock

...

10 Add log(fatal) before builtin unreachable()

builtin unreachable will trigger sigtrap signal, it is not very clear when in debug mode, should add log fatal before it and its core stack will be more clear.

https://github.com/apache/doris/pull/24101

...