2004-07-06 20:59:36 +00:00
|
|
|
/**
|
2009-08-22 00:01:02 +00:00
|
|
|
@file
|
2004-07-06 20:59:36 +00:00
|
|
|
|
2005-01-20 21:19:47 +00:00
|
|
|
Allocates and deallocates records.
|
|
|
|
|
2004-07-06 20:59:36 +00:00
|
|
|
@ingroup OPERATIONS
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
2005-01-20 21:19:47 +00:00
|
|
|
|
|
|
|
#ifndef __ALLOC_H
|
|
|
|
#define __ALLOC_H 1
|
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
#include <stasis/operations.h>
|
2009-08-22 21:29:27 +00:00
|
|
|
#include <stasis/allocationPolicy.h>
|
2009-03-31 05:02:54 +00:00
|
|
|
stasis_operation_impl stasis_op_impl_alloc();
|
|
|
|
stasis_operation_impl stasis_op_impl_dealloc();
|
|
|
|
stasis_operation_impl stasis_op_impl_realloc();
|
2006-07-29 00:56:54 +00:00
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
typedef struct stasis_alloc_t stasis_alloc_t;
|
|
|
|
|
|
|
|
void stasis_alloc_aborted(stasis_alloc_t* alloc, int xid);
|
|
|
|
void stasis_alloc_committed(stasis_alloc_t* alloc, int xid);
|
2004-07-06 20:59:36 +00:00
|
|
|
|
2009-08-22 21:29:27 +00:00
|
|
|
stasis_alloc_t* stasis_alloc_init(stasis_allocation_policy_t * allocPolicy);
|
|
|
|
void stasis_alloc_post_init(stasis_alloc_t* alloc);
|
|
|
|
void stasis_alloc_deinit(stasis_alloc_t* alloc);
|
2009-08-22 00:01:02 +00:00
|
|
|
/**
|
|
|
|
Allocate a record.
|
2004-07-06 20:59:36 +00:00
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
@param xid The transaction responsible for the allocation
|
2005-01-21 02:13:17 +00:00
|
|
|
@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.
|
2005-01-20 21:19:47 +00:00
|
|
|
|
|
|
|
@return the recordid of the new record.
|
2004-07-06 20:59:36 +00:00
|
|
|
*/
|
2006-06-17 00:25:09 +00:00
|
|
|
compensated_function recordid Talloc(int xid, unsigned long size);
|
2004-07-06 20:59:36 +00:00
|
|
|
|
2008-10-03 02:42:25 +00:00
|
|
|
compensated_function recordid TallocFromPage(int xid, pageid_t page, unsigned long size);
|
2005-01-28 03:32:17 +00:00
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
/**
|
|
|
|
Free a record.
|
2005-01-20 21:19:47 +00:00
|
|
|
*/
|
2005-02-24 21:12:36 +00:00
|
|
|
compensated_function void Tdealloc(int xid, recordid rid);
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2005-01-20 21:19:47 +00:00
|
|
|
/**
|
2009-08-22 00:01:02 +00:00
|
|
|
Obtain the type of a record, as returned by getRecordType.
|
2005-01-28 03:32:17 +00:00
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
@param xid the transaction id.
|
2005-01-28 03:32:17 +00:00
|
|
|
|
|
|
|
@param rid the record of interest. The size field will be ignored,
|
|
|
|
allowing this function to be used to probe for records in pages.
|
2009-08-22 00:01:02 +00:00
|
|
|
|
2005-01-28 03:32:17 +00:00
|
|
|
@return UNINITIALIZED_RECORD, BLOB_RECORD, SLOTTED_RECORD, or FIXED_RECORD.
|
|
|
|
|
|
|
|
@see getRecordType
|
2005-01-20 21:19:47 +00:00
|
|
|
|
|
|
|
*/
|
2005-02-24 21:12:36 +00:00
|
|
|
compensated_function int TrecordType(int xid, recordid rid);
|
2004-12-01 01:26:25 +00:00
|
|
|
|
2005-01-28 03:32:17 +00:00
|
|
|
/**
|
|
|
|
Obtain the length of the data stored in a record.
|
|
|
|
|
2009-08-22 00:01:02 +00:00
|
|
|
@param xid the transaction id.
|
2005-01-28 03:32:17 +00:00
|
|
|
|
|
|
|
@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.
|
|
|
|
*/
|
2005-02-24 21:12:36 +00:00
|
|
|
compensated_function int TrecordSize(int xid, recordid rid);
|
2005-01-28 03:32:17 +00:00
|
|
|
|
|
|
|
/** Return the number of records stored in page pageid */
|
2008-10-03 02:42:25 +00:00
|
|
|
compensated_function int TrecordsInPage(int xid, pageid_t page);
|
2005-01-28 03:32:17 +00:00
|
|
|
|
2004-06-24 21:10:31 +00:00
|
|
|
#endif
|