Addded "interpretRid" which knows how to call the "dereference*" functions.
This commit is contained in:
parent
33ca0d3254
commit
7dada65a13
3 changed files with 40 additions and 37 deletions
|
@ -88,6 +88,8 @@ terms specified in this license.
|
||||||
#include <lladd/compensations.h>
|
#include <lladd/compensations.h>
|
||||||
#include "page/slotted.h"
|
#include "page/slotted.h"
|
||||||
#include "page/fixed.h"
|
#include "page/fixed.h"
|
||||||
|
#include "page/indirect.h"
|
||||||
|
#include <lladd/operations/arrayList.h>
|
||||||
#include <lladd/bufferPool.h>
|
#include <lladd/bufferPool.h>
|
||||||
#include <lladd/truncation.h>
|
#include <lladd/truncation.h>
|
||||||
void pageWriteLSN(int xid, Page * page, lsn_t lsn) {
|
void pageWriteLSN(int xid, Page * page, lsn_t lsn) {
|
||||||
|
@ -263,3 +265,31 @@ void writeRecordUnlocked(int xid, Page * p, lsn_t lsn, recordid rid, const void
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recordid interpretRidUnlocked(int xid, recordid rid, Page * p) {
|
||||||
|
int page_type = *page_type_ptr(p);
|
||||||
|
if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) {
|
||||||
|
|
||||||
|
} else if(page_type == INDIRECT_PAGE) {
|
||||||
|
rid = dereferenceRIDUnlocked(xid, rid);
|
||||||
|
} else if(page_type == ARRAY_LIST_PAGE) {
|
||||||
|
rid = dereferenceArrayListRidUnlocked(p, rid.slot);
|
||||||
|
} else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return rid;
|
||||||
|
}
|
||||||
|
recordid interpretRid(int xid, recordid rid, Page * p) {
|
||||||
|
int page_type = *page_type_ptr(p);
|
||||||
|
if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) {
|
||||||
|
|
||||||
|
} else if(page_type == INDIRECT_PAGE) {
|
||||||
|
rid = dereferenceRID(xid, rid);
|
||||||
|
} else if(page_type == ARRAY_LIST_PAGE) {
|
||||||
|
rid = dereferenceArrayListRid(p, rid.slot);
|
||||||
|
} else {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return rid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,9 @@ int getRecordTypeUnlocked(int xid, Page * p, recordid rid);
|
||||||
*/
|
*/
|
||||||
int getRecordLength(int xid, Page * p, recordid rid);
|
int getRecordLength(int xid, Page * p, recordid rid);
|
||||||
|
|
||||||
|
recordid interpretRid(int xid, recordid rid, Page * p);
|
||||||
|
recordid interpretRidUnlocked(int xid, recordid rid, Page * p);
|
||||||
|
|
||||||
END_C_DECLS
|
END_C_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -214,7 +214,7 @@ compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op
|
||||||
rid = dereferenceRID(xid, rid);
|
rid = dereferenceRID(xid, rid);
|
||||||
p = loadPage(xid, rid.page);
|
p = loadPage(xid, rid.page);
|
||||||
} end;
|
} end;
|
||||||
/** @todo Kludge! Shouldn't special case operations in transactional2. */
|
// @todo Kludge! Shouldn't special case operations in transactional2.
|
||||||
} else if(*page_type_ptr(p) == ARRAY_LIST_PAGE &&
|
} else if(*page_type_ptr(p) == ARRAY_LIST_PAGE &&
|
||||||
op != OPERATION_LINEAR_INSERT &&
|
op != OPERATION_LINEAR_INSERT &&
|
||||||
op != OPERATION_UNDO_LINEAR_INSERT &&
|
op != OPERATION_UNDO_LINEAR_INSERT &&
|
||||||
|
@ -240,25 +240,11 @@ void TreadUnlocked(int xid, recordid rid, void * dat) {
|
||||||
try {
|
try {
|
||||||
p = loadPage(xid, rid.page);
|
p = loadPage(xid, rid.page);
|
||||||
} end;
|
} end;
|
||||||
int page_type = *page_type_ptr(p);
|
|
||||||
if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) {
|
|
||||||
|
|
||||||
} else if(page_type == INDIRECT_PAGE) {
|
rid = interpretRidUnlocked(xid, rid, p);
|
||||||
|
if(rid.page != p->id) {
|
||||||
releasePage(p);
|
releasePage(p);
|
||||||
|
|
||||||
try {
|
|
||||||
rid = dereferenceRIDUnlocked(xid, rid);
|
|
||||||
p = loadPage(xid, rid.page);
|
p = loadPage(xid, rid.page);
|
||||||
} end;
|
|
||||||
} else if(page_type == ARRAY_LIST_PAGE) {
|
|
||||||
rid = dereferenceArrayListRidUnlocked(p, rid.slot);
|
|
||||||
releasePage(p);
|
|
||||||
try {
|
|
||||||
p = loadPage(xid, rid.page);
|
|
||||||
} end;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
readRecordUnlocked(xid, p, rid, dat);
|
readRecordUnlocked(xid, p, rid, dat);
|
||||||
releasePage(p);
|
releasePage(p);
|
||||||
|
@ -269,27 +255,11 @@ compensated_function void Tread(int xid, recordid rid, void * dat) {
|
||||||
try {
|
try {
|
||||||
p = loadPage(xid, rid.page);
|
p = loadPage(xid, rid.page);
|
||||||
} end;
|
} end;
|
||||||
int page_type = *page_type_ptr(p);
|
|
||||||
if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) {
|
|
||||||
|
|
||||||
} else if(page_type == INDIRECT_PAGE) {
|
rid = interpretRid(xid, rid, p);
|
||||||
|
if(rid.page != p->id) {
|
||||||
releasePage(p);
|
releasePage(p);
|
||||||
try {
|
|
||||||
rid = dereferenceRID(xid, rid);
|
|
||||||
} end;
|
|
||||||
try {
|
|
||||||
p = loadPage(xid, rid.page);
|
p = loadPage(xid, rid.page);
|
||||||
} end;
|
|
||||||
|
|
||||||
} else if(page_type == ARRAY_LIST_PAGE) {
|
|
||||||
rid = dereferenceArrayListRid(p, rid.slot);
|
|
||||||
releasePage(p);
|
|
||||||
try {
|
|
||||||
p = loadPage(xid, rid.page);
|
|
||||||
} end;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
readRecord(xid, p, rid, dat);
|
readRecord(xid, p, rid, dat);
|
||||||
releasePage(p);
|
releasePage(p);
|
||||||
|
|
Loading…
Reference in a new issue