Inheritance diagram for FileBucket:
Public Member Functions | |
this (FilePath path, BlockSize block) | |
this (FilePath path, BlockSize block, uint initialRecords) | |
~this () | |
int | getBufferSize () |
FilePath | getFilePath () |
synchronized long | length () |
synchronized void[] | get (char[] key) |
synchronized void | remove (char[] key) |
synchronized void | put (char[] key, void[] data) |
synchronized void | close () |
Public Attributes | |
HalfK = {512-1} | |
OneK = {1024*1-1} | |
TwoK = {1024*2-1} | |
FourK = {1024*4-1} | |
EightK = {1024*8-1} | |
SixteenK = {1024*16-1} | |
ThirtyTwoK = {1024*32-1} | |
SixtyFourK = {1024*64-1} | |
Static Public Attributes | |
const BlockSize | EighthK = {128-1} |
Private Attributes | |
FilePath | path |
BlockSize | block |
FileConduit | file |
Record[char[]] | map |
Buffer | buffer |
long | fileSize |
long | waterLine |
Note that any and all stored data is rendered invalid the moment a FileBucket object is garbage-collected.
The implementation follows a fixed-capacity record scheme, where content can be rewritten in-place until said capacity is reached. At such time, the altered content is moved to a larger capacity record at end-of-file, and a hole remains at the prior location. These holes are not collected, since the lifespan of a FileBucket is limited to that of the host process.
All index keys must be unique. Writing to the FileBucket with an existing key will overwrite any previous content. What follows is a contrived example:
char[] text = "this is a test"; FileBucket bucket = new FileBucket (new FilePath("bucket.bin"), FileBucket.HalfK); // insert some data, and retrieve it again bucket.put ("a key", text); char[] b = cast(char[]) bucket.get ("a key"); assert (b == text); bucket.close();
Definition at line 82 of file FileBucket.d.
|
Destructor tries to close the file, if not already done. Definition at line 175 of file FileBucket.d. References close(). |
|
Construct a FileBucket with the provided path and record- size. Selecting a record size that roughly matches the serialized content will limit 'thrashing'. Definition at line 135 of file FileBucket.d. References block. |
|
Construct a FileBucket with the provided path, record-size, and inital record count. The latter causes records to be pre-allocated, saving a certain amount of growth activity. Selecting a record size that roughly matches the serialized content will limit 'thrashing'. Definition at line 150 of file FileBucket.d. References block, FileBucket::BlockSize::capacity, file, FileConduit, fileSize, FileConduit::seek(), and Buffer::setConduit(). |
|
Return the block-size in use for this FileBucket Reimplemented from IBitBucket. Definition at line 186 of file FileBucket.d. References block, and FileBucket::BlockSize::capacity. |
|
Return where the FileBucket is located Definition at line 197 of file FileBucket.d. |
|
Return the currently populated size of this FileBucket Reimplemented from IBitBucket. Definition at line 208 of file FileBucket.d. References waterLine. |
|
Return the serialized data for the provided key. Returns null if the key was not found. Reimplemented from IBitBucket. Definition at line 220 of file FileBucket.d. References FileBucket::Record::read(). Referenced by testFileBucket(). |
|
Remove the provided key from this FileBucket. Reimplemented from IBitBucket. Definition at line 238 of file FileBucket.d. |
|
Write a serialized block of data, and associate it with the provided key. All keys must be unique, and it is the responsibility of the programmer to ensure this. Reusing an existing key will overwrite previous data. Note that data is allowed to grow within the occupied bucket until it becomes larger than the allocated space. When this happens, the data is moved to a larger bucket at the file tail. Reimplemented from IBitBucket. Definition at line 257 of file FileBucket.d. References block, and FileBucket::Record::write(). Referenced by testFileBucket(). |
|
Close this FileBucket -- all content is lost. Definition at line 275 of file FileBucket.d. References file. Referenced by testFileBucket(), testVirtualCache(), and ~this(). |
|
Definition at line 96 of file FileBucket.d. Referenced by FileBucket::Record::eof(). |
|
Definition at line 99 of file FileBucket.d. Referenced by getBufferSize(), put(), and this(). |
|
Definition at line 102 of file FileBucket.d. Referenced by close(), FileBucket::Record::createBucket(), FileBucket::Record::read(), this(), and FileBucket::Record::write(). |
|
Definition at line 105 of file FileBucket.d. |
|
Definition at line 108 of file FileBucket.d. Referenced by FileBucket::Record::read(), and FileBucket::Record::write(). |
|
Definition at line 111 of file FileBucket.d. Referenced by FileBucket::Record::createBucket(), and this(). |
|
Definition at line 114 of file FileBucket.d. Referenced by FileBucket::Record::createBucket(), and length(). |
|
Definition at line 117 of file FileBucket.d. |
|
Definition at line 118 of file FileBucket.d. |
|
Definition at line 119 of file FileBucket.d. |
|
Definition at line 120 of file FileBucket.d. |
|
Definition at line 121 of file FileBucket.d. |
|
Definition at line 122 of file FileBucket.d. |
|
Definition at line 123 of file FileBucket.d. |
|
Definition at line 124 of file FileBucket.d. |
|
Definition at line 125 of file FileBucket.d. |