Inspired by sqlite, an attempt at building a ACID compliant embedded database.
- Contains persistence to disk
- Contains basic searching
- Contains insertion
- Flushes entire table to disk even when a single row has changed
- Loads entire file into memory before doing operation
- For searching does a linear search, making it extremely slow
- Implemented binary tree
- Row insert immediately flushes to disk for persistence
- Searching happens through binary tree
- Wrote tests to validate implementation
1. Tree becomes unbalance with certain type of data resulting in a worst case O(N) time complexity.
Need AVL or Red Black tree implementation
2. Insertion have become very slow, due to page fetch and close during every insert.
Two things come to mind to solve this:
1. Keep the file open and dont close it to persist in disk, rather do flush
2. Implement page system, where one page can hold multiple rows and then we do operation on a page rather than a row
and flush page after that
3. When scanning binary tree, keep the already scanned nodes in memory.
So that next time the same row is asked for, we dont have to fetch it from disk
Implemented the improvements listed in 2nd pr
- Enabling file descriptor for the database file to do io rather than opening closing it all time
- Implemented avl tree
- Updated table page layout, by saving offset of root row, coz in avl tree root row might change during rebalancing
- Added helper method to Row Class
- Added SmallInt col to represent 2 bit integer and updated IntCol to inherit from int class
- Fixed and updated test to validate all rotations of AVL tree
- Set row offset as negative to denote offset not set instead of -1
1. Insertion can still be improved further, maybe implementing B-Tree would help
2. Need to implement pager module. Although first we need to validate the point that just playing around with rows
involved too much io thus requiring the need of pager. Check the possibility that maybe too much io is also
leading to bad relatively bad insert performance.