Patricia File System - PatriciaDB/PatriciaDB GitHub Wiki
PatriciaFileSystem is composed by several components described in this diagram.
As mentioned before, the FileSystem provides a simple interface to the upper layer:
public interface PatriciaFileSystem {
FSSnapshot getSnapshot();
FSTransaction startTransaction();
void close();
}
public interface FSTransaction {
// Read the blockId
ByteBuffer read(long blockId);
// Returns a unique ID for this block of bytes
long write(ByteBuffer data);
// replace the content of a blockId
void overwrite(long blockId, ByteBuffer data);
// Delete a block data
void delete(long blockId);
// Commit this transaction (atomically)
void commit();
}
As shown in the diagram, there are 2 main components: a directory
and a storage
. A storage is where the data is saved physically. A directory is where we associate the blockId with a data pointer.
When use calls transaction.overwrite(blockId, payload)
what is happening is the follow:
- var dataPointer = storage.append(payload)
- directory.set(blockId, dataPointer)
The old data associated with this block is not deleted physically. For this reason you need to run a vacuum in order recover the unused space.