A mapped file implementation of the Block abstraction
A mapped file implementation of the Block abstraction
(block-for {:keys [nr-blocks block-size stride mapped-byte-buffers]
:as block-file}
block-id)
Returns the byte buffer that references the given block.
Returns the byte buffer that references the given block.
(copy-block {:keys [mapped-byte-buffers block-size stride] :as block-file}
{:keys [byte-offset ro] :as block}
new-block-id)
Allocates a new block with a copy of the original block.
Allocates a new block with a copy of the original block.
(force-file {:keys [mapped-byte-buffers] :as block-file})
Ensures all cached data is written to disk. This returns synchronously after all data is written.
Ensures all cached data is written to disk. This returns synchronously after all data is written.
(get-nr-blocks {:keys [nr-blocks]})
Returns the number of blocks
Returns the number of blocks
(map-file! {:keys [nr-mapped-regions stride mapped-byte-buffers] :as block-file}
regions)
Expands a block-file to one that is mapped to the required number of regions. Returns a new block-file with the required mappings.
Expands a block-file to one that is mapped to the required number of regions. Returns a new block-file with the required mappings.
(next-size-increment {:keys [nr-blocks block-size stride] :as block-file})
Determine the next number of blocks that the file should move up to. The size increment of the file increases as the size of the file increases
Determine the next number of blocks that the file should move up to. The size increment of the file increases as the size of the file increases
(open-block-file file block-size init-nr-blocks)
Opens a file for storing blocks. Returns a structure with the block file and the RandomAccessFile that the block file uses. The file will need to be closed when block files based on this initial block file are no longer needed. When the init-nr-blocks is not nil, then it holds the recorded number of blocks in the file.
Opens a file for storing blocks. Returns a structure with the block file and the RandomAccessFile that the block file uses. The file will need to be closed when block files based on this initial block file are no longer needed. When the init-nr-blocks is not nil, then it holds the recorded number of blocks in the file.
(pow2 x)
Raise 2 to the power of x, with a floor value of 1.
Raise 2 to the power of x, with a floor value of 1.
Defines how many bits behind the region magnitude to increment the number of regions by. 4 bits behind means that it starts at incrementing by 1, until size 32. Then 2 until 64. Then 4 until 128, and so on.
Defines how many bits behind the region magnitude to increment the number of regions by. 4 bits behind means that it starts at incrementing by 1, until size 32. Then 2 until 64. Then 4 until 128, and so on.
(set-nr-blocks! {:keys [nr-blocks block-size nr-mapped-regions stride]
:as block-file}
new-nr)
Updates the number of blocks mapped in a block file. Returns the new block-file.
Updates the number of blocks mapped in a block file. Returns the new block-file.
(unmap {:keys [mapped-byte-buffers block-size nr-blocks raf] :as block-file})
Throw away mappings. This is dangerous, as it invalidates all instances. Only to be used when closing the file for good.
Throw away mappings. This is dangerous, as it invalidates all instances. Only to be used when closing the file for good.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close