Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Refactor LogsDB: Remove pimpl idiom and extract helper classes into logsdb/ directory

Summary:

Successfully refactored LogsDB to remove the pimpl idiom and extract all helper classes into separate files in the cpp/core/logsdb/ directory. This makes the codebase more modular and allows components like CatchupReader to be used independently.

Recent Fixes:

  1. Moved constants to LogsDBCommon.hpp - Resolved circular dependency by moving constants to LogsDBConsts namespace
  2. Created LogsDBTypes.hpp - Extracted type definitions (LogsDBLogEntry, LogsDBRequest, LogsDBResponse) to separate header so helper classes can use them in std::array members
  3. Added RocksDBUtils.hpp include - LogsDBCommon.hpp now includes RocksDBUtils.hpp for ROCKS_DB_CHECKED macro

Changes Made:

  • Create cpp/core/logsdb/ directory structure
  • Extract helper classes from LogsDB.cpp into separate files
  • Move LogsDBData.hpp to logsdb/ directory
  • Remove pimpl idiom from LogsDB class
  • Update all includes and dependencies
  • Update CMakeLists.txt to include logsdb subdirectory files
  • Fix compilation: Move constants to LogsDBCommon.hpp
  • Fix compilation: Create LogsDBTypes.hpp for full type definitions
  • Fix compilation: Add RocksDBUtils.hpp include
  • Build and test to ensure everything works

File Structure:

cpp/core/logsdb/
├── Appender.hpp/cpp
├── BatchWriter.hpp/cpp
├── CatchupReader.hpp/cpp
├── DataPartitions.hpp/cpp
├── LeaderElection.hpp/cpp
├── LogMetadata.hpp/cpp
├── LogsDBCommon.hpp       - Constants and utility functions
├── LogsDBData.hpp         - Metadata key definitions
├── LogsDBTypes.hpp        - Type definitions (NEW)
└── ReqResp.hpp/cpp

All compilation issues resolved. Helper classes now have access to:

  • Full type definitions via LogsDBTypes.hpp
  • Constants via LogsDBConsts namespace
  • Utilities via LogsDBCommon.hpp
Original prompt

LogsDB is hiding behind pimpl idiom. I want in the future use CatchupReader separately. In order to do that I need LogsDB to be a regular header/implementation and at the same time it would be good to split up all the helper classes into separate header/cpp files. This would most likely deserve a logsdb folder.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits November 12, 2025 14:50
Co-authored-by: mcrnic <11664456+mcrnic@users.noreply.github.com>
Co-authored-by: mcrnic <11664456+mcrnic@users.noreply.github.com>
@mcrnic mcrnic added the ci If given to a PR, the PR will run CI checks. label Nov 12, 2025
Copilot AI changed the title [WIP] Refactor LogsDB to separate header implementation and helpers Refactor LogsDB: Remove pimpl idiom and extract helper classes into logsdb/ directory Nov 12, 2025
Copilot AI requested a review from mcrnic November 12, 2025 14:58
@mcrnic
Copy link
Collaborator

mcrnic commented Nov 12, 2025

@copilot this does not compile as lot of implementations are using constants from LogsDB class. Could you move those definitions to LogsDBCommon

Co-authored-by: mcrnic <11664456+mcrnic@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot this does not compile as lot of implementations are using constants from LogsDB class. Could you move those definitions to LogsDBCommon

Fixed in b7e520a. Moved all LogsDB constants to LogsDBConsts namespace in LogsDBCommon.hpp to resolve the circular dependency. The helper classes now reference LogsDBConsts:: instead of LogsDB::, and LogsDB maintains backward compatibility by aliasing these constants.

@mcrnic
Copy link
Collaborator

mcrnic commented Nov 12, 2025

@copilot

  1. LogsDBLogEntry needs to be fully defined for some helper classes as they are using std::array of it.
  2. ROCKS_DB_CHECKD needs #include "../RocksDBUtils.hpp"

- Created logsdb/LogsDBTypes.hpp to contain LogsDBLogEntry, LogsDBRequest, and LogsDBResponse definitions
- Helper classes using std::array<LogsDBLogEntry> now include full definition via LogsDBTypes.hpp
- Added RocksDBUtils.hpp include to LogsDBCommon.hpp for ROCKS_DB_CHECKED macro
- Updated Appender.hpp, LeaderElection.hpp, and BatchWriter.hpp to include LogsDBTypes.hpp
- Removed duplicate type definitions from LogsDB.hpp

Co-authored-by: mcrnic <11664456+mcrnic@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot

  1. LogsDBLogEntry needs to be fully defined for some helper classes as they are using std::array of it.
  2. ROCKS_DB_CHECKD needs #include "../RocksDBUtils.hpp"
    ...

Fixed in cd24103:

  1. Created LogsDBTypes.hpp with full definitions of LogsDBLogEntry, LogsDBRequest, and LogsDBResponse. Helper classes using std::array<LogsDBLogEntry> now include this header.
  2. Added #include "../RocksDBUtils.hpp" to LogsDBCommon.hpp for the ROCKS_DB_CHECKED macro.

@mcrnic mcrnic added ci If given to a PR, the PR will run CI checks. and removed ci If given to a PR, the PR will run CI checks. labels Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci If given to a PR, the PR will run CI checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants