2004-06-24 21:10:31 +00:00
|
|
|
/*---
|
|
|
|
This software is copyrighted by the Regents of the University of
|
|
|
|
California, and other parties. The following terms apply to all files
|
|
|
|
associated with the software unless explicitly disclaimed in
|
|
|
|
individual files.
|
|
|
|
|
|
|
|
The authors hereby grant permission to use, copy, modify, distribute,
|
|
|
|
and license this software and its documentation for any purpose,
|
|
|
|
provided that existing copyright notices are retained in all copies
|
|
|
|
and that this notice is included verbatim in any distributions. No
|
|
|
|
written agreement, license, or royalty fee is required for any of the
|
|
|
|
authorized uses. Modifications to this software may be copyrighted by
|
|
|
|
their authors and need not follow the licensing terms described here,
|
|
|
|
provided that the new terms are clearly indicated on the first page of
|
|
|
|
each file where they apply.
|
|
|
|
|
|
|
|
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
|
|
|
|
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
|
|
|
|
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
|
|
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
|
|
|
NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND
|
|
|
|
THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
|
|
|
|
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
|
|
|
|
GOVERNMENT USE: If you are acquiring this software on behalf of the
|
|
|
|
U.S. government, the Government shall have only "Restricted Rights" in
|
|
|
|
the software and related documentation as defined in the Federal
|
|
|
|
Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are
|
|
|
|
acquiring the software on behalf of the Department of Defense, the
|
|
|
|
software shall be classified as "Commercial Computer Software" and the
|
|
|
|
Government shall have only "Restricted Rights" as defined in Clause
|
|
|
|
252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
|
|
|
|
authors grant the U.S. Government and others acting in its behalf
|
|
|
|
permission to use and distribute the software in accordance with the
|
|
|
|
terms specified in this license.
|
|
|
|
---*/
|
|
|
|
|
2004-07-31 00:27:55 +00:00
|
|
|
/**
|
|
|
|
|
|
|
|
@file
|
|
|
|
|
|
|
|
Generic page interface. This file handles updates to the LSN, but
|
|
|
|
leaves finer grained concurrency to the implementor of each of the
|
|
|
|
page types. This interface's primary purpose is to wrap common
|
|
|
|
functionality together, and to delegate responsibility for page
|
|
|
|
handling to other modules.
|
|
|
|
|
|
|
|
Latching summary:
|
|
|
|
|
|
|
|
Each page has an associated read/write lock. This lock only
|
|
|
|
protects the internal layout of the page, and the members of the
|
|
|
|
page struct. Here is how it is held in various circumstances:
|
|
|
|
|
|
|
|
Record allocation: Write lock
|
|
|
|
Record read: Read lock
|
|
|
|
Read LSN Read lock
|
|
|
|
Record write *READ LOCK*
|
|
|
|
Write LSN Write lock
|
|
|
|
|
|
|
|
Any circumstance where these locks are held during an I/O operation
|
|
|
|
is a bug.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-07-27 22:04:59 +00:00
|
|
|
/* _XOPEN_SOURCE is needed for posix_memalign */
|
|
|
|
#define _XOPEN_SOURCE 600
|
|
|
|
#include <stdlib.h>
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-13 23:48:20 +00:00
|
|
|
#include <config.h>
|
2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/common.h>
|
2008-04-13 04:02:57 +00:00
|
|
|
#include <stasis/latches.h>
|
|
|
|
#include <stasis/page.h>
|
2004-07-13 23:48:20 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/constants.h>
|
2004-07-21 02:13:28 +00:00
|
|
|
#include <assert.h>
|
2008-04-13 04:02:57 +00:00
|
|
|
#include <stasis/blobManager.h>
|
2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/lockManager.h>
|
|
|
|
#include <stasis/compensations.h>
|
2008-04-13 04:02:57 +00:00
|
|
|
#include <stasis/page/slotted.h>
|
|
|
|
#include <stasis/page/fixed.h>
|
|
|
|
#include <stasis/page/indirect.h>
|
2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/operations/arrayList.h>
|
|
|
|
#include <stasis/bufferPool.h>
|
|
|
|
#include <stasis/truncation.h>
|
2007-06-07 21:53:09 +00:00
|
|
|
|
2007-07-19 16:35:11 +00:00
|
|
|
static page_impl page_impls[MAX_PAGE_TYPE];
|
2007-06-07 21:53:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
XXX latching for pageWriteLSN...
|
|
|
|
*/
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_page_lsn_write(int xid, Page * page, lsn_t lsn) {
|
2008-09-28 03:11:24 +00:00
|
|
|
assertlocked(page->rwlatch);
|
2007-06-07 21:53:09 +00:00
|
|
|
|
2004-07-31 00:27:55 +00:00
|
|
|
if(page->LSN < lsn) {
|
|
|
|
page->LSN = lsn;
|
2007-06-07 21:53:09 +00:00
|
|
|
}
|
2006-04-14 03:45:26 +00:00
|
|
|
dirtyPages_add(page);
|
2005-02-14 02:49:59 +00:00
|
|
|
return;
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
2007-06-07 21:53:09 +00:00
|
|
|
/**
|
|
|
|
XXX latching for pageReadLSN...
|
|
|
|
*/
|
2007-10-02 00:18:33 +00:00
|
|
|
lsn_t stasis_page_lsn_read(const Page * page) {
|
2008-09-28 03:11:24 +00:00
|
|
|
assertlocked(page->rwlatch);
|
2007-06-07 21:53:09 +00:00
|
|
|
return page->LSN;
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
2004-07-23 20:21:44 +00:00
|
|
|
/* ----- (de)initialization functions. Do not need to support multithreading. -----*/
|
|
|
|
|
|
|
|
/**
|
2007-10-02 00:18:33 +00:00
|
|
|
* initializes all the important variables needed in
|
2004-07-23 20:21:44 +00:00
|
|
|
* all the functions dealing with pages.
|
|
|
|
*/
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_page_init() {
|
2004-08-17 01:46:17 +00:00
|
|
|
slottedPageInit();
|
2007-06-07 21:53:09 +00:00
|
|
|
fixedPageInit();
|
|
|
|
|
2007-10-02 00:18:33 +00:00
|
|
|
stasis_page_impl_register(slottedImpl());
|
|
|
|
stasis_page_impl_register(fixedImpl());
|
|
|
|
stasis_page_impl_register(boundaryTagImpl());
|
|
|
|
stasis_page_impl_register(arrayListImpl());
|
|
|
|
stasis_page_impl_register(blobImpl());
|
|
|
|
stasis_page_impl_register(indirectImpl());
|
|
|
|
stasis_page_impl_register(lsmRootImpl());
|
2004-07-27 01:04:35 +00:00
|
|
|
}
|
|
|
|
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_page_deinit() {
|
2007-07-19 23:47:06 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < MAX_PAGE_TYPE; i++) {
|
|
|
|
page_impl p = { 0 };
|
|
|
|
page_impls[i] = p;
|
|
|
|
}
|
|
|
|
|
2007-06-07 21:53:09 +00:00
|
|
|
fixedPageDeinit();
|
|
|
|
slottedPageDeinit();
|
2004-07-23 20:21:44 +00:00
|
|
|
}
|
|
|
|
|
2007-10-02 00:18:33 +00:00
|
|
|
int stasis_page_impl_register(page_impl p) {
|
2007-07-19 23:47:06 +00:00
|
|
|
assert(page_impls[p.page_type].page_type == 0);
|
2007-06-07 21:53:09 +00:00
|
|
|
page_impls[p.page_type] = p;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_write(int xid, Page * p, lsn_t lsn, recordid rid, const byte *dat) {
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2007-06-07 21:53:09 +00:00
|
|
|
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
2006-06-17 00:25:09 +00:00
|
|
|
|
2007-06-07 21:53:09 +00:00
|
|
|
readlock(p->rwlatch, 225);
|
2008-09-28 03:11:24 +00:00
|
|
|
assert(rid.size <= BLOB_THRESHOLD_SIZE);
|
|
|
|
|
|
|
|
byte * buf = stasis_record_write_begin(xid, p, rid);
|
|
|
|
memcpy(buf, dat, stasis_record_length_read(xid, p, rid));
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
|
2007-06-07 21:53:09 +00:00
|
|
|
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
2004-07-30 01:28:39 +00:00
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
int stasis_record_read(int xid, Page * p, recordid rid, byte *buf) {
|
2007-06-07 21:53:09 +00:00
|
|
|
assert(rid.page == p->id);
|
2004-10-19 21:16:37 +00:00
|
|
|
|
2008-09-28 03:11:24 +00:00
|
|
|
assert(rid.size <= BLOB_THRESHOLD_SIZE);
|
|
|
|
|
|
|
|
readlock(p->rwlatch, 0);
|
|
|
|
const byte * dat = stasis_record_read_begin(xid,p,rid);
|
|
|
|
memcpy(buf, dat, stasis_record_length_read(xid,p,rid));
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
return 0;
|
|
|
|
|
2004-10-19 21:16:37 +00:00
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
/**
|
|
|
|
@todo stasis_record_dereference should dispatch via page_impl...
|
|
|
|
*/
|
|
|
|
recordid stasis_record_dereference(int xid, Page * p, recordid rid) {
|
|
|
|
int page_type = *stasis_page_type_ptr(p);
|
|
|
|
if(page_type == INDIRECT_PAGE) {
|
|
|
|
rid = dereferenceIndirectRID(xid, rid);
|
2006-08-11 02:24:01 +00:00
|
|
|
} else if(page_type == ARRAY_LIST_PAGE) {
|
2007-06-07 21:53:09 +00:00
|
|
|
rid = dereferenceArrayListRid(xid, p, rid.slot);
|
2006-08-11 02:24:01 +00:00
|
|
|
}
|
|
|
|
return rid;
|
|
|
|
}
|
|
|
|
|
2007-06-07 21:53:09 +00:00
|
|
|
/// -------------- Dispatch functions
|
|
|
|
|
|
|
|
static int recordWarnedAboutPageTypeKludge = 0;
|
2007-10-02 00:18:33 +00:00
|
|
|
const byte * stasis_record_read_begin(int xid, Page * p, recordid rid) {
|
|
|
|
int page_type = *stasis_page_type_ptr(p);
|
2007-06-07 21:53:09 +00:00
|
|
|
if(!page_type) {
|
|
|
|
page_type = FIXED_PAGE;
|
|
|
|
if(!recordWarnedAboutPageTypeKludge) {
|
|
|
|
recordWarnedAboutPageTypeKludge = 1;
|
|
|
|
printf("page.c: MAKING USE OF TERRIBLE KLUDGE AND IGNORING ASSERT FAILURE! FIX ARRAY LIST ASAP!!!\n");
|
2007-11-11 17:18:57 +00:00
|
|
|
abort();
|
2007-06-07 21:53:09 +00:00
|
|
|
}
|
2006-08-11 02:24:01 +00:00
|
|
|
}
|
2008-02-19 21:26:31 +00:00
|
|
|
return page_impls[page_type].recordRead(xid, p, rid);
|
2007-06-07 21:53:09 +00:00
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
byte * stasis_record_write_begin(int xid, Page * p, recordid rid) {
|
|
|
|
int page_type = *stasis_page_type_ptr(p);
|
2007-06-07 21:53:09 +00:00
|
|
|
if(!page_type) {
|
|
|
|
page_type = FIXED_PAGE;
|
|
|
|
if(!recordWarnedAboutPageTypeKludge) {
|
|
|
|
recordWarnedAboutPageTypeKludge = 1;
|
|
|
|
printf("page.c: MAKING USE OF TERRIBLE KLUDGE AND IGNORING ASSERT FAILURE! FIX ARRAY LIST ASAP!!!\n");
|
2007-11-11 17:24:44 +00:00
|
|
|
abort();
|
2007-06-07 21:53:09 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-19 21:26:31 +00:00
|
|
|
assert(stasis_record_length_read(xid, p, rid) == stasis_record_type_to_size(rid.size));
|
2007-06-07 21:53:09 +00:00
|
|
|
return page_impls[page_type].recordWrite(xid, p, rid);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_read_done(int xid, Page *p, recordid rid, const byte *b) {
|
|
|
|
int page_type = *stasis_page_type_ptr(p);
|
2007-07-18 20:09:14 +00:00
|
|
|
if(page_impls[page_type].recordReadDone) {
|
|
|
|
page_impls[page_type].recordReadDone(xid,p,rid,b);
|
|
|
|
}
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_write_done(int xid, Page *p, recordid rid, byte *b) {
|
|
|
|
int page_type = *stasis_page_type_ptr(p);
|
2007-07-18 20:09:14 +00:00
|
|
|
if(page_impls[page_type].recordWriteDone) {
|
|
|
|
page_impls[page_type].recordWriteDone(xid,p,rid,b);
|
|
|
|
}
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
int stasis_record_type_read(int xid, Page *p, recordid rid) {
|
2008-02-19 21:26:31 +00:00
|
|
|
if(page_impls[*stasis_page_type_ptr(p)].recordGetType)
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)].recordGetType(xid, p, rid);
|
|
|
|
else
|
|
|
|
return INVALID_SLOT;
|
2007-06-07 21:53:09 +00:00
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_type_write(int xid, Page *p, recordid rid, int type) {
|
|
|
|
page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordSetType(xid, p, rid, type);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
int stasis_record_length_read(int xid, Page *p, recordid rid) {
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordGetLength(xid,p,rid);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
recordid stasis_record_first(int xid, Page * p){
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordFirst(xid,p);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
recordid stasis_record_next(int xid, Page * p, recordid prev){
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordNext(xid,p,prev);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
recordid stasis_record_alloc_begin(int xid, Page * p, int size){
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordPreAlloc(xid,p,size);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_alloc_done(int xid, Page * p, recordid rid){
|
|
|
|
page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordPostAlloc(xid, p, rid);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_free(int xid, Page * p, recordid rid){
|
|
|
|
page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.recordFree(xid, p, rid);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
int stasis_block_supported(int xid, Page * p){
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.isBlockSupported(xid, p);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
block_t * stasis_block_first(int xid, Page * p){
|
|
|
|
int t = *stasis_page_type_ptr(p);
|
2007-07-18 20:09:14 +00:00
|
|
|
return page_impls[t]
|
|
|
|
.blockFirst(xid, p);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
block_t * stasis_block_next(int xid, Page * p, block_t * prev){
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-07-18 20:09:14 +00:00
|
|
|
.blockNext(xid, p,prev);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_block_done(int xid, Page * p, block_t * done){
|
|
|
|
page_impls[*stasis_page_type_ptr(p)]
|
2007-07-18 20:09:14 +00:00
|
|
|
.blockDone(xid, p,done);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
int stasis_record_freespace(int xid, Page * p){
|
|
|
|
return page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.pageFreespace(xid, p);
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_record_compact(Page * p){
|
|
|
|
page_impls[*stasis_page_type_ptr(p)]
|
2007-06-07 21:53:09 +00:00
|
|
|
.pageCompact(p);
|
|
|
|
}
|
2007-07-18 20:09:14 +00:00
|
|
|
/** @todo How should the LSN of pages without a page_type be handled?
|
|
|
|
|
|
|
|
This only works because we don't have LSN-free pages yet. With
|
|
|
|
LSN-free pages, we'll need special "loadPageForAlloc(), and
|
|
|
|
loadPageOfType() methods (or something...)
|
|
|
|
*/
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_page_loaded(Page * p){
|
|
|
|
short type = *stasis_page_type_ptr(p);
|
2007-07-18 20:09:14 +00:00
|
|
|
if(type) {
|
2007-07-19 16:35:11 +00:00
|
|
|
assert(page_impls[type].page_type == type);
|
2007-07-18 20:09:14 +00:00
|
|
|
page_impls[type].pageLoaded(p);
|
|
|
|
} else {
|
2007-10-02 00:18:33 +00:00
|
|
|
p->LSN = *stasis_page_lsn_ptr(p); // XXX kluge - shouldn't special-case UNINITIALIZED_PAGE
|
2007-07-18 20:09:14 +00:00
|
|
|
}
|
2007-06-07 21:53:09 +00:00
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_page_flushed(Page * p){
|
|
|
|
short type = *stasis_page_type_ptr(p);
|
2007-07-18 20:09:14 +00:00
|
|
|
if(type) {
|
2007-07-19 16:35:11 +00:00
|
|
|
assert(page_impls[type].page_type == type);
|
2007-10-02 00:18:33 +00:00
|
|
|
page_impls[type].pageFlushed(p);
|
2007-07-18 20:09:14 +00:00
|
|
|
} else {
|
2007-10-02 00:18:33 +00:00
|
|
|
*stasis_page_lsn_ptr(p) = p->LSN;
|
2007-07-18 20:09:14 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_page_cleanup(Page * p) {
|
|
|
|
short type = *stasis_page_type_ptr(p);
|
2007-08-20 21:58:20 +00:00
|
|
|
if(type) {
|
|
|
|
assert(page_impls[type].page_type == type);
|
|
|
|
page_impls[type].pageCleanup(p);
|
|
|
|
}
|
|
|
|
}
|
2007-07-18 20:09:14 +00:00
|
|
|
|
|
|
|
/// Generic block implementations
|
|
|
|
|
|
|
|
static int blkTrue(block_t *b) { return 1; }
|
|
|
|
static int blkFalse(block_t *b) { return 0; }
|
|
|
|
|
|
|
|
typedef struct genericBlockImpl {
|
|
|
|
Page * p;
|
|
|
|
recordid pos;
|
|
|
|
} genericBlockImpl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
@todo The block API should pass around xids.
|
|
|
|
*/
|
|
|
|
static const byte * blkFirst(block_t * b) {
|
|
|
|
genericBlockImpl * impl = b->impl;
|
2007-10-02 00:18:33 +00:00
|
|
|
impl->pos = stasis_record_first(-1, impl->p);
|
2007-07-18 20:09:14 +00:00
|
|
|
if(! memcmp(&(impl->pos), &(NULLRID), sizeof(recordid))) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
2007-10-02 00:18:33 +00:00
|
|
|
return stasis_record_read_begin(-1, impl->p, impl->pos);
|
2007-07-18 20:09:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
static const byte * blkNext(block_t * b) {
|
|
|
|
genericBlockImpl * impl = b->impl;
|
2007-10-02 00:18:33 +00:00
|
|
|
impl->pos = stasis_record_next(-1, impl->p, impl->pos);
|
2007-07-18 20:09:14 +00:00
|
|
|
if(! memcmp(&(impl->pos), &NULLRID, sizeof(recordid))) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
2007-10-02 00:18:33 +00:00
|
|
|
return stasis_record_read_begin(-1, impl->p, impl->pos);
|
2007-07-18 20:09:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
static int blkSize(block_t * b) {
|
|
|
|
genericBlockImpl * impl = b->impl;
|
2007-10-03 01:53:51 +00:00
|
|
|
return stasis_record_type_to_size(impl->pos.size);
|
2007-07-18 20:09:14 +00:00
|
|
|
}
|
|
|
|
static void blkRelease(block_t * b) {
|
|
|
|
free(b->impl);
|
|
|
|
free(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
block_t genericBlock = {
|
|
|
|
blkTrue, // isValid
|
|
|
|
blkFalse, //isOneValue
|
|
|
|
blkFalse, //isValueSorted
|
|
|
|
blkFalse, //isPosContig
|
|
|
|
blkFirst,
|
|
|
|
blkNext,
|
|
|
|
blkSize,
|
|
|
|
0, //recordCount
|
|
|
|
0, //ptrArray can't do pointer array efficiently...
|
|
|
|
0, //sizePtrArray
|
|
|
|
blkFalse, //recordFixedLen
|
|
|
|
0, //packedArray
|
|
|
|
blkRelease,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2007-10-02 00:18:33 +00:00
|
|
|
block_t* stasis_block_first_default_impl(int xid, Page * p) {
|
2007-07-18 20:09:14 +00:00
|
|
|
block_t* ret = malloc(sizeof(block_t));
|
|
|
|
*ret = genericBlock;
|
|
|
|
genericBlockImpl impl = { p, NULLRID };
|
|
|
|
ret->impl = malloc(sizeof(genericBlockImpl));
|
|
|
|
*(genericBlockImpl*)(ret->impl) = impl;
|
|
|
|
return ret;
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
block_t* stasis_block_next_default_impl(int xid, Page *p, block_t *prev) {
|
|
|
|
stasis_block_done_default_impl(xid, p, prev);
|
2007-07-18 20:09:14 +00:00
|
|
|
return 0; // definitely done.
|
|
|
|
}
|
2007-10-02 00:18:33 +00:00
|
|
|
void stasis_block_done_default_impl(int xid, Page *p, block_t *b) {
|
2007-07-18 20:09:14 +00:00
|
|
|
free(b->impl);
|
|
|
|
free(b);
|
2006-08-11 02:24:01 +00:00
|
|
|
}
|