stasis-aries-wal/stasis/operations/alloc.h

75 lines
1.9 KiB
C

/**
@file
Allocates and deallocates records.
@ingroup OPERATIONS
$Id: alloc.h 1517 2011-06-12 08:13:34Z sears.russell@gmail.com $
*/
#ifndef __ALLOC_H
#define __ALLOC_H 1
#include <stasis/operations.h>
#include <stasis/allocationPolicy.h>
BEGIN_C_DECLS
stasis_operation_impl stasis_op_impl_alloc();
stasis_operation_impl stasis_op_impl_dealloc();
stasis_operation_impl stasis_op_impl_realloc();
typedef struct stasis_alloc_t stasis_alloc_t;
stasis_alloc_t* stasis_alloc_init(stasis_transaction_table_t * tbl, stasis_allocation_policy_t * allocPolicy);
void stasis_alloc_post_init(stasis_alloc_t* alloc);
void stasis_alloc_deinit(stasis_alloc_t* alloc);
/**
Allocate a record.
@param xid The transaction responsible for the allocation
@param size The size of the new record to be allocated. Talloc will allocate a
blob if the record will not easily fit on a page.
@return the recordid of the new record.
*/
recordid Talloc(int xid, unsigned long size);
recordid TallocFromPage(int xid, pageid_t page, unsigned long size);
/**
Free a record.
*/
void Tdealloc(int xid, recordid rid);
/**
Obtain the type of a record, as returned by getRecordType.
@param xid the transaction id.
@param rid the record of interest. The size field will be ignored,
allowing this function to be used to probe for records in pages.
@return UNINITIALIZED_RECORD, BLOB_RECORD, SLOTTED_RECORD, or FIXED_RECORD.
@see getRecordType
*/
int TrecordType(int xid, recordid rid);
/**
Obtain the length of the data stored in a record.
@param xid the transaction id.
@param rid the record of interest. The size field will be ignored,
allowing this function to be used to probe for records in pages.
@return -1 if the record does not exist, the size of the record otherwise.
*/
int TrecordSize(int xid, recordid rid);
/** Return the number of records stored in page pageid */
int TrecordsInPage(int xid, pageid_t page);
END_C_DECLS
#endif