ssm_sort::skey_t Class Reference
[Sorting]

Collaboration diagram for ssm_sort::skey_t:

Collaboration graph
[legend]
List of all members.

Detailed Description

The result of a CSKF function.

This is a handle on a key. The key might reside in scratch memory or in the buffer pool. This class provides a generic API for using such a key.

The attributes are:

Generally only the constructor is used by a CSKF callback function, and the idiom used (indeed, the only way it can be populated) is placement new as follows:

using namespace ssm_sort;
w_rc_t 
exampleCSKF(
    const rid_t&         rid,
    const object_t&      obj,
    key_cookie_t         ,  
    factory_t&           f,
    skey_t*              out
)
{
    {
    // this shows how to create an skey_t from the entire header of the
    // incoming object_t, whether the object is in the buffer pool or
    // in scratch memory:
    smsize_t length = obj.hdr_size();
    smsize_t offset = 0;
    bool     in_hdr = true;
    new(out) skey_t(obj, offset, length, in_hdr);
    }

    {
    // this shows how to create an skey_t from the last 3 bytes of the
    // body of the incoming object_t, whether the 
    // object is in the buffer pool or in scratch memory:
    smsize_t length = 3;
    smsize_t offset = obj.body_size() - length;
    bool     in_hdr = false;
    new(out) skey_t(obj, offset, length, in_hdr);
    }

    {
    // this shows how to create an skey_t derived from the record id
    int val = rid.pid.page;
    smsize_t length = sizeof(val);
    smsize_t offset = 0;
    void *buf = f.allocfunc(length);
    memcpy(&buf, &val, sizeof(val));
    new(out) skey_t(buf, offset, length, f);
    }

    return RCOK;
}

Definition at line 502 of file sort_s.h.

Public Member Functions

NORET skey_t (const object_t &o, smsize_t offset, smsize_t len, bool in_hdr)
 Construct from a key in the buffer pool.
NORET skey_t (void *buf, smsize_t offset, smsize_t len, factory_t &f)
 Construct from a key in scratch memory.
NORET ~skey_t ()
smsize_t size () const
 Length of entire key.
bool is_valid () const
 True if this structure is populated (points to a key).
bool is_in_obj () const
 True if key is in the buffer pool.
bool consistent_with_object (const object_t &o) const
 True unless this key is for an object other than o.
bool is_in_hdr () const
 True if key is in buffer pool and is in record header.
const void * ptr (smsize_t offset) const
 Pointer into byte at offset in key.
void freespace ()
 Using its factory, free space allocated for the in-scratch-memory buffer.
void assert_nobuffers () const
 Asserts that no heap memory is held by this or its object_t.
smsize_t contig_length () const
 Pinned amount of the key.
w_rc_t copy_out (vec_t &dest) const
 Copies key into vector (which must have pre-allocated space).

Protected Member Functions

NORET skey_t ()
void _construct (const object_t *o, smsize_t off, smsize_t l, bool h)
void _construct (const void *buf, smsize_t off, smsize_t l, factory_t *f)

Protected Attributes

const object_t_obj
smsize_t _offset


Constructor & Destructor Documentation

NORET ssm_sort::skey_t::skey_t ( const object_t o,
smsize_t  offset,
smsize_t  len,
bool  in_hdr 
) [inline]

Construct from a key in the buffer pool.

Parameters:
[in] o structure describing the key location
[in] offset offset from record header or body where key starts
[in] len length of entire key
[in] in_hdr true if key is in record header, false if in body

Definition at line 513 of file sort_s.h.

NORET ssm_sort::skey_t::skey_t ( void *  buf,
smsize_t  offset,
smsize_t  len,
factory_t f 
) [inline]

Construct from a key in scratch memory.

Parameters:
[in] buf scratch memory buffer
[in] offset offset from buf where key starts
[in] len length of entire key
[in] f factory used to allocate the buffer

Definition at line 532 of file sort_s.h.


Member Function Documentation

bool ssm_sort::skey_t::consistent_with_object ( const object_t o  )  const [inline]

True unless this key is for an object other than o.

Used for assertions in sort code.

Definition at line 562 of file sort_s.h.

References _obj.


The documentation for this class was generated from the following file:
Generated on Wed Jul 7 17:22:44 2010 for Shore Storage Manager by  doxygen 1.4.7