Class FileDataStore
- java.lang.Object
-
- eu.svjatoslav.sixth.data.store.file.FileDataStore
-
-
Constructor Summary
Constructors Constructor Description FileDataStore(File backingFile)
-
Method Summary
All Methods Instance Methods Concrete 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.longgetDefragmentationStartAddress(int allowedFragmentationPercent, List<eu.svjatoslav.sixth.data.store.file.EntryRecord> allEntryRecords)voidincreaseEntriesTable()voidinitializeFromExistingFile(File backingFile)voidinitializeNewFile(File backingFile)intreadInt(long position)longreadLong(long position)byte[]readRecord(int id)Read entire record into byte array.longrelocateEntry(eu.svjatoslav.sixth.data.store.file.EntryRecord record, long newLocation)voidupdateRecord(int id, byte[] value)Update record with new value.voidvacuum(int allowedFragmentationPercent)Defragment empty space.voidwriteInt(long position, int value)voidwriteLong(long position, long value)
-
-
-
Constructor Detail
-
FileDataStore
public FileDataStore(File backingFile) throws IOException
- Throws:
IOException
-
-
Method Detail
-
close
public void close() throws IOExceptionDescription copied from interface:DataStoreClose datastore.- Specified by:
closein interfaceDataStore- Throws:
IOException
-
createRecord
public int createRecord(byte[] value) throws IOExceptionDescription copied from interface:DataStoreCreate new record and set its initial contents.- Specified by:
createRecordin interfaceDataStore- Throws:
IOException
-
deleteRecord
public void deleteRecord(int id) throws IOExceptionDescription copied from interface:DataStoreDelete record identified by given ID. DataStore will mark given ID as unused, and could reuse this ID later for another newly created record.- Specified by:
deleteRecordin interfaceDataStore- Throws:
IOException
-
getDefragmentationStartAddress
public long getDefragmentationStartAddress(int allowedFragmentationPercent, List<eu.svjatoslav.sixth.data.store.file.EntryRecord> allEntryRecords)
-
increaseEntriesTable
public void increaseEntriesTable() throws IOException- Throws:
IOException
-
initializeFromExistingFile
public void initializeFromExistingFile(File backingFile) throws IOException
- Throws:
IOException
-
initializeNewFile
public void initializeNewFile(File backingFile) throws IOException
- Throws:
IOException
-
readInt
public int readInt(long position) throws IOException- Throws:
IOException
-
readLong
public long readLong(long position) throws IOException- Throws:
IOException
-
readRecord
public byte[] readRecord(int id) throws IOExceptionDescription copied from interface:DataStoreRead entire record into byte array.- Specified by:
readRecordin interfaceDataStore- Throws:
IOException
-
relocateEntry
public long relocateEntry(eu.svjatoslav.sixth.data.store.file.EntryRecord record, long newLocation) throws IOException- Throws:
IOException
-
updateRecord
public void updateRecord(int id, byte[] value) throws IOExceptionDescription copied from interface:DataStoreUpdate record with new value.- Specified by:
updateRecordin interfaceDataStore- Throws:
IOException
-
vacuum
public void vacuum(int allowedFragmentationPercent) throws IOExceptionDefragment empty space.- Parameters:
allowedFragmentationPercent- allowed maximum percentage of free space, relative to total used space.- Throws:
IOException
-
writeInt
public void writeInt(long position, int value) throws IOException- Throws:
IOException
-
writeLong
public void writeLong(long position, long value) throws IOException- Throws:
IOException
-
-