feat: add common utilities including BinPacking, LinkedHashMap, LongCounter, Math, ScopeGuard, ThreadsafeQueue, and UUID by dalingmeng · Pull Request #5 · apache/paimon-cpp · GitHub
Skip to content

feat: add common utilities including BinPacking, LinkedHashMap, LongCounter, Math, ScopeGuard, ThreadsafeQueue, and UUID - #5

Merged
leaves12138 merged 2 commits into
apache:mainfrom
dalingmeng:feat/add-common-utils
May 25, 2026
Merged

feat: add common utilities including BinPacking, LinkedHashMap, LongCounter, Math, ScopeGuard, ThreadsafeQueue, and UUID #5
leaves12138 merged 2 commits into
apache:mainfrom
dalingmeng:feat/add-common-utils

Conversation

@dalingmeng

Copy link
Copy Markdown
Contributor

Purpose

No Linked issue.

Introduce common utility modules to the apache/paimon-cpp codebase. These modules provide reusable data structures and helper functions that other components depend on.

  • Introduce BinPacking for ordered bin packing of weighted items (bin_packing.h)
  • Introduce LinkedHashMap providing insertion-ordered key-value map (linked_hash_map.h)
  • Introduce LongCounter for simple int64 accumulation (long_counter.h)
  • Introduce Math utilities including InRange and EndianSwapValue (math.h)
  • Introduce ScopeGuard for RAII-style cleanup callbacks (scope_guard.h)
  • Introduce ThreadsafeQueue for thread-safe queue operations (threadsafe_queue.h)
  • Introduce UUID generator with cross-platform support for Linux and macOS (uuid.h)
  • Preserve third-party attribution comments (RocksDB/LevelDB, Facebook)

Tests

  • bin_packing_test.cpp — BinPacking ordered packing correctness
  • linked_hash_map_test.cpp — LinkedHashMap insertion, lookup, deletion and iteration
  • long_counter_test.cpp — LongCounter add, merge and reset
  • math_test.cpp — InRange and EndianSwapValue correctness
  • scope_guard_test.cpp — ScopeGuard execution and release
  • threadsafe_queue_test.cpp — ThreadsafeQueue push, pop and thread safety
  • uuid_test.cpp — UUID generation and format validation

API and Format

Documentation

Generative AI tooling

…ounter, Math, ScopeGuard, ThreadsafeQueue, and UUID

@leaves12138 leaves12138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for migrating these common utility headers and tests. I compared the added files with the existing source snapshot; aside from the ASF header migration, the utility code itself matches the original implementation, and the lightweight header syntax check passes.

One blocker before merge: this PR adds math.h and uuid.h, which retain comments saying they are adapted from RocksDB / LevelDB, but the Apache repository's LICENSE and NOTICE files in this PR are not updated with the corresponding third-party attribution/license text. Please add the relevant RocksDB / LevelDB entries to LICENSE and NOTICE in the same PR that introduces these files.

The rest of the migration looks fine for this staged import.

@dalingmeng
dalingmeng force-pushed the feat/add-common-utils branch from 9f92d1d to c96672f Compare May 22, 2026 10:29

@leaves12138 leaves12138 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The RocksDB / LevelDB attribution has been added to LICENSE and NOTICE, and the migrated utility files still match the source snapshot aside from the expected ASF header normalization. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants