public class TransactionalRecordWriter extends Object implements RecordWriter
Constructor and Description |
---|
TransactionalRecordWriter(File recordLocation) |
Modifier and Type | Method and Description |
---|---|
void |
closeWriter()
This closes the writer channel and releases all the resources
|
void |
flush()
Guarantees the changes are flushed to the disk
|
long |
getDiskSize()
Gets the disk size of the persistence storage
|
Index |
getIndex() |
long |
getSize()
Gets the amount of data streams / records stored
|
boolean |
isOpen()
Checks if the writer is already open
|
void |
openWriter()
This opens the writer for all access, needs to be done before any operations are done on the recordwriter
|
RecordIterator |
readAllRecords()
This returns an iterator that can iterate over all persisted records.
|
RecordIterator |
readAllRecords(int limit)
This returns an iterator that can iterate over all persisted records to a defined limit.
|
RecordResult |
readRecord(UUIDKey documentId)
This reads a specific record at the indicated record position
|
void |
removeRecord(UUIDKey documentId)
This will command the writer to remove the indicated record from storage.
|
void |
updateRecord(UUIDKey documentId,
ClonableDataStream dataStream)
This updates the record contents stored in storage for a given updated content and the current
record pointer to the record.
|
void |
verify(java.util.function.Function<RecordResult,UUIDKey> f) |
void |
writeRecord(UUIDKey documentId,
ClonableDataStream dataStream)
This writes the given content to the filesystem and returns the record pointer at which the record
can be retrieved on next attempt.
|
public TransactionalRecordWriter(File recordLocation)
public void openWriter() throws JasDBStorageException
RecordWriter
openWriter
in interface RecordWriter
JasDBStorageException
- If unable to open the writerpublic void closeWriter() throws JasDBStorageException
RecordWriter
closeWriter
in interface RecordWriter
JasDBStorageException
- If unable to close the writerpublic void flush() throws JasDBStorageException
RecordWriter
flush
in interface RecordWriter
JasDBStorageException
- If unable to flush changes to the diskpublic boolean isOpen()
RecordWriter
isOpen
in interface RecordWriter
public long getDiskSize() throws JasDBStorageException
RecordWriter
getDiskSize
in interface RecordWriter
JasDBStorageException
- If unable to get the disksizepublic long getSize()
RecordWriter
getSize
in interface RecordWriter
public RecordIterator readAllRecords() throws DatastoreException
RecordWriter
readAllRecords
in interface RecordWriter
DatastoreException
public RecordIterator readAllRecords(int limit) throws DatastoreException
RecordWriter
readAllRecords
in interface RecordWriter
DatastoreException
public RecordResult readRecord(UUIDKey documentId) throws JasDBStorageException
RecordWriter
readRecord
in interface RecordWriter
documentId
- The document key identifier used to identify the document to write to storageJasDBStorageException
- In case the record could not be found or readpublic void writeRecord(UUIDKey documentId, ClonableDataStream dataStream) throws JasDBStorageException
RecordWriter
writeRecord
in interface RecordWriter
documentId
- The document key identifier used to identify the document to write to storagedataStream
- The datastream to be written to storageJasDBStorageException
- If unable to write the record to the storagepublic void removeRecord(UUIDKey documentId) throws JasDBStorageException
RecordWriter
removeRecord
in interface RecordWriter
documentId
- The document key identifier used to identify the document to removeJasDBStorageException
- If unable to find the indicated record or removing failed.public void updateRecord(UUIDKey documentId, ClonableDataStream dataStream) throws JasDBStorageException
RecordWriter
updateRecord
in interface RecordWriter
documentId
- The document key identifier used to identify the document to write to storagedataStream
- The datastream to be written to storageJasDBStorageException
- If unable to update in case no record exists or unable to update in storage.public Index getIndex()
public void verify(java.util.function.Function<RecordResult,UUIDKey> f)
Copyright © 2015. All rights reserved.