updated readme, and fixed linux compilation

This commit is contained in:
bronku 2026-01-09 01:54:56 +01:00
parent 4becf40f06
commit 8390db169f
8 changed files with 48 additions and 1 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@ tests
tmp
.DS_Store
.idea
*.dat

39
README.md Normal file
View file

@ -0,0 +1,39 @@
# External Merge Sort (Big Buffer Strategy)
A C++20 implementation of an external sorting algorithm designed to sort files that are too large to fit into the system's RAM. This project uses a Big Buffer approach to minimize disk I/O by maximizing the use of available memory during both the initial run creation and the merging phases.
# Requirements
Clang++ or G++ (Support for C++20 required)
Make
# Compilation
```bash
make
````
# Usage
The binary is located in the build/ directory after compilation.
# Generate Data
# To generate a test file with 100,000 random records:
```bash
./build/main -g 100000 -o input.dat
```
# Sort Data
To sort the generated file using 11 buffers of 10 records each:
```bash
./build/main -i input.dat -o output.dat -n 11 -b 10
```
# Options
Flag Description
-i Input file path
-o Output file path
-n Number of buffers (minimum 3)
-b Size of each buffer (number of records)
-g Generate count random records
-e Evaluate and print the contents of a file
-d Temporary directory for merge runs

View file

@ -1,4 +1,5 @@
#pragma once
#include <vector>
#include "record.hpp"
#include <fstream>
#include <optional>

View file

@ -1,4 +1,6 @@
#pragma once
#include <vector>
#include <filesystem>
#include "record.hpp"
#include <fstream>
#include <span>

View file

@ -1,4 +1,4 @@
CXX = clang++
CXX = g++
CXXFLAGS = -g -std=c++20 -Iinclude -Wall -Wextra -Werror
LDFLAGS =

View file

@ -1,3 +1,4 @@
#include <vector>
#include "../include/file_reader.hpp"
void FileReader::refill_buffer()

View file

@ -1,3 +1,4 @@
#include <vector>
#include "../include/file_writer.hpp"
void FileWriter::write_buffer()

View file

@ -1,3 +1,5 @@
#include <algorithm>
#include <queue>
#include "../include/merge_sorter.hpp"
std::span<Record> MergeSorter::get_chunk_span(size_t chunk_index)