Skip to content

Natzgun/BufferClock-DB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buffer Manager - Component of LittleDB

This repository is part of my exploration into how Database Management Systems (DBMS) are built internally.
It contains an implementation of a Buffer Manager, which is a fundamental module in any DBMS.
This work is later integrated into my database system project: LittleDB.


Diagram

image

📖 Introduction

The Buffer Manager handles in-memory pages that represent data read from disk.
Because disk operations are far slower than memory access, a buffer pool combined with page replacement policies ensures efficient performance.

This project includes:

  • Buffer Pool – A memory region of fixed size used to store data pages.
  • Page Abstraction – An in-memory representation of a database page.
  • Frame System – Pages are stored in frames within the buffer pool.
  • Replacement Policies:
    • Least Recently Used (LRU)
    • Clock Cache Algorithm
  • Buffer Manager API – Functions to request, pin, unpin, and write back pages.

📂 Directory Layout

├── CMakeLists.txt
├── data
│   └── prueba_titanic.txt   # Example file
├── include                  # Header files
│   ├── BufferManager.h
│   ├── BufferPool.h
│   ├── Clock.h
│   ├── Frame.h
│   ├── LRU.h
│   └── Page.h
├── main.cpp                 # Usage example
├── makefile
└── src                      # Source code
    ├── Buffer_Pool.cpp
    ├── BufferManager.cpp
    ├── Clock.cpp
    ├── Frame.cpp
    ├── LRU.cpp
    └── Page.cpp

⚙️ Key Features

  • ✅ Load and replace pages between disk and memory
  • ✅ Pin/unpin pages to control eviction
  • ✅ Support for two replacement strategies (LRU, Clock)
  • ✅ Frame-based memory organization
  • ✅ Designed for integration with LittleDB

🏗️ Build Instructions

You can compile the project either with CMake or with the included makefile.

CMake

mkdir build && cd build
cmake ..
make
./main

Makefile

make
./main

🧪 Usage Example

A sample dataset (data/prueba_titanic.txt) is provided.
The file main.cpp demonstrates creating a buffer manager, loading pages, and applying replacement algorithms.


📚 Learning Outcomes

This project was built from the ground up with the purpose of understanding:

  • Internal design of DBMS buffer managers
  • Memory management at the system level
  • Implementation of LRU and Clock page replacement
  • Building modular and extensible software components

🔗 Connection to LittleDB

This Buffer Manager is one of the foundational modules of my database system:
👉 LittleDB


About

Implementation of buffer cache and Clock Algorithm for LittleDB (database managment)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •