This semester I am in the advanced database class at the University of Alabama. Me and a friend convinced the professor to have the final project to be an implementation of a NoSQL database. I have always been interested in creating things and making a database is one of things I have always wanted to make. Before I have not had to time due to class and work but now it is required for class so no one can yell at me for “wasting my time”.
We have written a fair bit of the database but the current part we are working on is the storage engine. We didn’t want to use anything pre-built or create a naive solution like a giant flat file where we have to copy data down to insert in the middle. In the end we designed a fake file system on top of the current file system with the extra method called insert. Insert allows the end user to write in the middle of a document without moving all the extra data down. For this we had to create a few classes which emulate common file system operations. We create a FileSystem class, File class, FileReader class, and a FileWriter class.
The FileSystem class is the main entry point for everything. It is what is used to open/create files and we also provide private functions which can be used by other classes in the same namespace. The conceptual idea of the FileSystem is that there are some files stored within it and we provide access to loading those files and to read and write to and from them. This requires us to save meta-data about the FileSystem and also meta-data about each File as well. This class ensures that everything is consistent when things are written and read from disk. Also it is tasked with creating a FileSystem on the disk if one does not exists and also allows for reading/saving the file systems data as well.
The File class is just an empty class that keeps track of the current properties about the file. It also has a pointer to the FileSystem object which created it. This was mainly to be used to allow readers and writers access to a File objects actual content on disk. The only problem I have with this is that if you open multiple files and one is modified the properties of the others is not. In the future this needs to be changed.
The FileReader class takes in a File and then provides a read interface for the file. This class does not really do any of the heavy lifting but rather leaves it up to the file system to handle that. I would like to be able to extend this to allow for more helpful write methods such as writeString, writeInt, and so forth.
Like the FileReader class this class facilities writing to a File but does no actual heaving lifting itself. Like the FileReader class I also want to implement methods like readInt and readString and so on.
I think that these are good classes to have for right now but I wish I could either pull out more things from the FileSystem class or merge them into smaller functions. Currently it has a lot of private methods and there are a few which repeat some work but with a little extra in it.
Will try to update more about this project in the coming weeks.
Total Views (243)