Skip to content

Commit 9d983e1

Browse files
Update README.md
1 parent 5573d15 commit 9d983e1

1 file changed

Lines changed: 47 additions & 2 deletions

File tree

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
# database
2-
database management system written in go
1+
# Database Storage Engine Documentation
2+
3+
Welcome to the documentation for our database storage engine! This storage engine consists of two main components: the HeapManager and the IndexManager. Below, we'll provide an overview of each component along with their functionalities.
4+
5+
## HeapManager
6+
7+
The HeapManager is responsible for managing the heap of each table in the database. It handles the allocation and freeing of space for table records on disk. Here's a brief overview of its structure and functionality:
8+
9+
### Heap Structure
10+
11+
The heap is organized into pages, where each page contains a collection of records. The key components of the heap structure include:
12+
13+
- **HeapHeader**: Contains metadata about the heap such as the number of pages and the total number of rows.
14+
- **Page Structure**: Each page contains a header and a collection of records.
15+
- **Record Structure**: Describes the structure of each record within a page.
16+
- **SlotArray**: An array containing information about each record's offset and size within the page.
17+
18+
### HeapManager API
19+
20+
The HeapManager provides a set of functions for interacting with the heap. Notably, it deals with binary data, allowing users to insert and retrieve rows in the form of byte slices. Here are some of the key functions:
21+
22+
- `CreateHeap(name string)`: Creates a new heap file and initializes its header.
23+
- `AddRowToHeap(name string, row []byte)`: Adds a new row to the specified heap.
24+
- `GetRowFromHeap(name string, rowIndex int) []byte`: Retrieves a row from the heap based on its index.
25+
- `GetPageFromHeap(name string, pageIndex int) [][]byte`: Retrieves all records from a specific page in the heap.
26+
27+
## IndexManager
28+
29+
The IndexManager is responsible for managing indexes in the database. It utilizes the B+ tree data structure to optimize data retrieval. Below are the key aspects of the IndexManager:
30+
31+
### Index Metadata Structure
32+
33+
Metadata for indexes is stored in a file with the path `indexes/Table_Name/meta.data`. This metadata includes information such as the index name, column name, and root node offset of the B+ tree.
34+
35+
### Index Structure
36+
37+
Indexes are stored in files with paths like `indexes/Table_Name/Index_Name.data`. Each index follows the B+ tree structure for efficient data retrieval.
38+
39+
### Code of Conduct
40+
41+
The IndexManager follows specific guidelines to ensure consistency and integrity within the database. Key points include initializing indexes, updating them on row insertion or deletion, and handling operations like index or table deletion.
42+
43+
## Documentation
44+
45+
For detailed usage instructions and examples, please refer to the docs part in the repository. it provides comprehensive documentation on how to interact with both the HeapManager and IndexManager components.
46+
47+
Thank you for choosing our database storage engine! If you have any further questions or need assistance, feel free to reach out to our support team.

0 commit comments

Comments
 (0)