Fairport  v1.0.38
fairport::heap Class Reference

Heap-on-Node implementation. More...

#include <heap.h>

List of all members.

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< byteread (heap_id id) const
hid_stream_device open_stream (heap_id id)
const nodeget_node () const
nodeget_node ()
template<typename K , typename V >
std::tr1::shared_ptr< bth_node
< K, V > > 
open_bth (heap_id root)

Detailed Description

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.

See also:
[MS-PST 2.3.1]

Definition at line 195 of file heap.h.


Constructor & Destructor Documentation

fairport::heap::heap ( const node n) [inline, explicit]

Open a heap object on a node.

Parameters:
[in]nThe node to open on top of.

Definition at line 200 of file heap.h.

fairport::heap::heap ( const node n,
byte  client_sig 
) [inline]

Open a heap object on the specified node, and validate the client sig.

Exceptions:
sig_mismatchIf the specified client_sig doesn't match what is in the node
Parameters:
[in]nThe node to open on top of.
[in]client_sigValidate the heap has this value for the client sig

Definition at line 206 of file heap.h.

fairport::heap::heap ( const heap other) [inline]

Copy constructor.

Parameters:
[in]otherThe heap to copy

Definition at line 210 of file heap.h.

fairport::heap::heap ( heap &&  other) [inline]

Move constructor.

Parameters:
[in]otherThe heap to move from

Definition at line 216 of file heap.h.


Member Function Documentation

byte fairport::heap::get_client_signature ( ) const [inline]

Returns the client signature of the heap.

Each heap is stamped with a signature byte by it's creator. This value is used mostly for validation purposes by the client when opening the heap.

See also:
heap_client_signature returns The client sig byte

Definition at line 227 of file heap.h.

const node& fairport::heap::get_node ( ) const [inline]

Get the node underlying this heap.

Returns:
The node

Definition at line 240 of file heap.h.

node& fairport::heap::get_node ( ) [inline]

Get the node underlying this heap.

Returns:
The node

Definition at line 243 of file heap.h.

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.

Returns:
The client's root allocation

Definition at line 224 of file heap.h.

template<typename K , typename V >
std::tr1::shared_ptr<bth_node<K,V> > fairport::heap::open_bth ( heap_id  root) [inline]

Opens a BTH from this heap with the given root id.

Template Parameters:
KThe key type of this BTH
VThe value type of this BTH
Parameters:
[in]rootThe root allocation of this BTH
Returns:
The BTH object

Definition at line 248 of file heap.h.

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.

Parameters:
[in]idThe heap allocation to open a stream on
Returns:
A heap allocation stream device

Definition at line 236 of file heap.h.

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.

Exceptions:
length_error(FAIRPORT_VALIDATION_LEVEL_WEAK) If the page, index, or size of the allocation are out of bounds
Parameters:
[in]bufferThe location to store the data. The size of the buffer indicates the amount of data to read
[in]idThe heap allocation to read from
[in]offsetThe offset into id to read starting at
Returns:
The number of bytes read

Definition at line 230 of file heap.h.

std::vector<byte> fairport::heap::read ( heap_id  id) const [inline]

Read an entire allocation.

Exceptions:
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
Parameters:
[in]idThe allocation to read
Returns:
The entire allocation

Definition at line 233 of file heap.h.

size_t fairport::heap::size ( heap_id  id) const [inline]

Get the size of the given allocation.

Parameters:
[in]idThe heap allocation to get the size of
Exceptions:
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
Returns:
The size of the allocation

Definition at line 221 of file heap.h.


The documentation for this class was generated from the following file: