Fairport
v1.0.38
|
Heap-on-Node implementation. More...
#include <heap.h>
Public Member Functions | |
heap (const node &n) | |
Open a heap object on a node. | |
heap (const node &n, byte client_sig) | |
Open a heap object on the specified node, and validate the client sig. | |
heap (const heap &other) | |
Copy constructor. | |
heap (heap &&other) | |
Move constructor. | |
size_t | size (heap_id id) const |
heap_id | get_root_id () const |
byte | get_client_signature () const |
size_t | read (std::vector< byte > &buffer, heap_id id, ulong offset) const |
std::vector< byte > | read (heap_id id) const |
hid_stream_device | open_stream (heap_id id) |
const node & | get_node () const |
node & | get_node () |
template<typename K , typename V > | |
std::tr1::shared_ptr< bth_node < K, V > > | open_bth (heap_id root) |
Heap-on-Node implementation.
The HN is the first concept built on top of the node abstraction exposed by the NDB. It treats the node similar to how a memory heap is treated, allowing the client to allocate memory up to 3.8k and free those allocations from inside the node. To faciliate this, metadata is kept at the start and end of each block in the HN node (which are confusingly sometimes called pages in this context). So the HN has detailed knowledge of how blocks and extended_blocks work in order to do it's book keeping, and find the appropriate block (..page) to satisfy a given allocation request.
Note a heap completely controls a node - you can not have multiple heaps per node. You can not use a node which has a heap on it for any other purpose beyond the heap interface.
fairport::heap::heap | ( | const node & | n | ) | [inline, explicit] |
Open a heap object on the specified node, and validate the client sig.
sig_mismatch | If the specified client_sig doesn't match what is in the node |
[in] | n | The node to open on top of. |
[in] | client_sig | Validate the heap has this value for the client sig |
fairport::heap::heap | ( | const heap & | other | ) | [inline] |
fairport::heap::heap | ( | heap && | other | ) | [inline] |
byte fairport::heap::get_client_signature | ( | ) | const [inline] |
const node& fairport::heap::get_node | ( | ) | const [inline] |
node& fairport::heap::get_node | ( | ) | [inline] |
heap_id fairport::heap::get_root_id | ( | ) | const [inline] |
Returns the client root allocation out of this heap.
This value has specific meaning to the owner of the heap. It may point to a special structure which contains information about the data structures implemented in this heap or the larger node and subnodes (such as the table). Or, it could just point to the root BTH allocation (such as the property_bag). In any event, the heap itself gives no special meaning to this value.
hid_stream_device fairport::heap::open_stream | ( | heap_id | id | ) | [inline] |
Creates a stream device over a specified heap allocation.
The returned stream device can be used to construct a proper stream:
heap h; hid_stream hstream(h.open_stream(0x30));
Which can then be used as any iostream would be.
[in] | id | The heap allocation to open a stream on |
size_t fairport::heap::read | ( | std::vector< byte > & | buffer, |
heap_id | id, | ||
ulong | offset | ||
) | const [inline] |
Read data out of a specified allocation at the specified offset.
length_error | (FAIRPORT_VALIDATION_LEVEL_WEAK) If the page, index, or size of the allocation are out of bounds |
[in] | buffer | The location to store the data. The size of the buffer indicates the amount of data to read |
[in] | id | The heap allocation to read from |
[in] | offset | The offset into id to read starting at |
Read an entire allocation.
length_error | (FAIRPORT_VALIDATION_LEVEL_WEAK) If the page or index of the allocation as indicated by the id are out of bounds for this node |
[in] | id | The allocation to read |
size_t fairport::heap::size | ( | heap_id | id | ) | const [inline] |
Get the size of the given allocation.
[in] | id | The heap allocation to get the size of |
length_error | (FAIRPORT_VALIDATION_LEVEL_WEAK) If the page or index of the allocation as indicated by the id are out of bounds for this node |