updated readme, and fixed linux compilation
This commit is contained in:
parent
4becf40f06
commit
8390db169f
8 changed files with 48 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@ tests
|
||||||
tmp
|
tmp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.idea
|
.idea
|
||||||
|
*.dat
|
||||||
|
|
|
||||||
39
README.md
Normal file
39
README.md
Normal 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
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
#include "record.hpp"
|
#include "record.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include <filesystem>
|
||||||
#include "record.hpp"
|
#include "record.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
|
||||||
2
makefile
2
makefile
|
|
@ -1,4 +1,4 @@
|
||||||
CXX = clang++
|
CXX = g++
|
||||||
CXXFLAGS = -g -std=c++20 -Iinclude -Wall -Wextra -Werror
|
CXXFLAGS = -g -std=c++20 -Iinclude -Wall -Wextra -Werror
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <vector>
|
||||||
#include "../include/file_reader.hpp"
|
#include "../include/file_reader.hpp"
|
||||||
|
|
||||||
void FileReader::refill_buffer()
|
void FileReader::refill_buffer()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <vector>
|
||||||
#include "../include/file_writer.hpp"
|
#include "../include/file_writer.hpp"
|
||||||
|
|
||||||
void FileWriter::write_buffer()
|
void FileWriter::write_buffer()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <algorithm>
|
||||||
|
#include <queue>
|
||||||
#include "../include/merge_sorter.hpp"
|
#include "../include/merge_sorter.hpp"
|
||||||
|
|
||||||
std::span<Record> MergeSorter::get_chunk_span(size_t chunk_index)
|
std::span<Record> MergeSorter::get_chunk_span(size_t chunk_index)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue