Package eu.svjatoslav.sixth.data.store
Interface DataStore
-
- All Known Implementing Classes:
FileDataStore
public interface DataStoreData store acts as a numerical ID to corresponding record map.Record is basically an array of bytes of arbitrary length, identifiable by ID that is assigned to record during record creation.
Records can be updated with alternative content and length. Data store takes care of data fragmentation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Close datastore.intcreateRecord(byte[] value)Create new record and set its initial contents.voiddeleteRecord(int id)Delete record identified by given ID.byte[]readRecord(int id)Read entire record into byte array.voidupdateRecord(int id, byte[] value)Update record with new value.
-
-
-
Method Detail
-
close
void close() throws IOExceptionClose datastore.- Throws:
IOException
-
createRecord
int createRecord(byte[] value) throws IOExceptionCreate new record and set its initial contents.- Throws:
IOException
-
deleteRecord
void deleteRecord(int id) throws IOExceptionDelete record identified by given ID. DataStore will mark given ID as unused, and could reuse this ID later for another newly created record.- Throws:
IOException
-
readRecord
byte[] readRecord(int id) throws IOExceptionRead entire record into byte array.- Throws:
IOException
-
updateRecord
void updateRecord(int id, byte[] value) throws IOExceptionUpdate record with new value.- Throws:
IOException
-
-