Cleaned up Tupdate() by adding TupdateRaw(); removed *_RAW and updated linear hash accordingly.
This commit is contained in:
parent
6df9f538f4
commit
4c8466555c
8 changed files with 43 additions and 118 deletions
|
@ -144,8 +144,8 @@ terms specified in this license.
|
|||
#define OPERATION_LINEAR_HASH_INSERT 31
|
||||
#define OPERATION_LINEAR_HASH_REMOVE 32
|
||||
|
||||
#define OPERATION_SET_RAW 33
|
||||
#define OPERATION_INSTANT_SET_RAW 34
|
||||
//#define OPERATION_SET_RAW 33
|
||||
//#define OPERATION_INSTANT_SET_RAW 34
|
||||
|
||||
#define OPERATION_ALLOC_BOUNDARY_TAG 35
|
||||
|
||||
|
|
|
@ -368,8 +368,12 @@ int Tbegin();
|
|||
*
|
||||
* @see operations.h set.h
|
||||
*/
|
||||
compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op);
|
||||
|
||||
compensated_function void Tupdate(int xid, recordid rid,
|
||||
const void *dat, int op);
|
||||
compensated_function void TupdateRaw(int xid, recordid rid,
|
||||
const void *dat, int op);
|
||||
compensated_function void TupdateDeferred(int xid, recordid rid,
|
||||
const void *dat, int op);
|
||||
/**
|
||||
* @param xid transaction ID
|
||||
* @param rid reference to page/slot
|
||||
|
|
|
@ -166,30 +166,25 @@ static compensated_function int TarrayListExtendInternal(int xid, recordid rid,
|
|||
DEBUG("block %d\n", i);
|
||||
/* We used to call OPERATION_INITIALIZE_FIXED_PAGE on each page in current indirection block. */
|
||||
tmp.slot = i + FIRST_DATA_PAGE_OFFSET;
|
||||
// alTupdate(xid, tmp, &newFirstPage, op);
|
||||
|
||||
/**
|
||||
@XXX the calls to Tupdate in arrayList.c are bypassing operation implementations.
|
||||
*/
|
||||
Tupdate(xid, tmp, &newFirstPage, op);
|
||||
TupdateRaw(xid, tmp, &newFirstPage, op);
|
||||
DEBUG("Tset: {%d, %d, %d} = %d\n", tmp.page, tmp.slot, tmp.size, newFirstPage);
|
||||
}
|
||||
|
||||
tmp.slot = MAX_OFFSET_POSITION;
|
||||
|
||||
int newMaxOffset = tlp.maxOffset+slots;
|
||||
// alTupdate(xid, tmp, &newMaxOffset, op);
|
||||
Tupdate(xid, tmp, &newMaxOffset, op);
|
||||
TupdateRaw(xid, tmp, &newMaxOffset, op);
|
||||
} end_ret(compensation_error());
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
compensated_function int TarrayListInstantExtend(int xid, recordid rid, int slots) {
|
||||
return TarrayListExtendInternal(xid, rid, slots, OPERATION_INSTANT_SET_RAW);
|
||||
return TarrayListExtendInternal(xid, rid, slots, OPERATION_INSTANT_SET);
|
||||
}
|
||||
compensated_function int TarrayListExtend(int xid, recordid rid, int slots) {
|
||||
return TarrayListExtendInternal(xid, rid, slots, OPERATION_SET_RAW);
|
||||
return TarrayListExtendInternal(xid, rid, slots, OPERATION_SET);
|
||||
}
|
||||
compensated_function int TarrayListLength(int xid, recordid rid) {
|
||||
Page * p = loadPage(xid, rid.page);
|
||||
|
@ -198,39 +193,6 @@ compensated_function int TarrayListLength(int xid, recordid rid) {
|
|||
return tlp.maxOffset+1;
|
||||
}
|
||||
|
||||
/*static int operateInitFixed(int xid, Page * p, lsn_t lsn, recordid rid, const void * dat) {
|
||||
|
||||
fixedPageInitialize(p, rid.size, recordsPerPage(rid.size));
|
||||
pageWriteLSN(xid, p, lsn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int operateUnInitPage(int xid, Page * p, lsn_t lsn, recordid rid, const void * dat) {
|
||||
*page_type_ptr(p) = UNINITIALIZED_PAGE;
|
||||
pageWriteLSN(xid, p, lsn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Operation getInitFixed() {
|
||||
Operation o = {
|
||||
OPERATION_INITIALIZE_FIXED_PAGE,
|
||||
0, // The necessary parameters are hidden in the rid
|
||||
//OPERATION_UNINITIALIZE_PAGE,
|
||||
OPERATION_NOOP,
|
||||
&operateInitFixed
|
||||
};
|
||||
return o;
|
||||
}
|
||||
Operation getUnInitPage() {
|
||||
Operation o = {
|
||||
OPERATION_UNINITIALIZE_PAGE,
|
||||
PAGE_SIZE,
|
||||
NO_INVERSE_WHOLE_PAGE, //OPERATION_NOOP,
|
||||
&operateUnInitPage
|
||||
};
|
||||
return o;
|
||||
}*/
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
/** @todo locking for arrayLists */
|
||||
|
|
|
@ -51,7 +51,6 @@ terms specified in this license.
|
|||
|
||||
static int operate(int xid, Page *p, lsn_t lsn, recordid rid, const void *dat) {
|
||||
writeRecord(xid, p, lsn, rid, dat);
|
||||
//writeRecordUnlocked(xid, p, lsn, rid, dat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -64,14 +63,3 @@ Operation getInstantSet() {
|
|||
};
|
||||
return o;
|
||||
}
|
||||
Operation getInstantSetRaw() {
|
||||
Operation o = {
|
||||
OPERATION_INSTANT_SET_RAW, /* id */
|
||||
SIZEOF_RECORD, /* use the size of the record as size of arg */
|
||||
OPERATION_NOOP,
|
||||
&operate /* Function */
|
||||
};
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void TlogicalHashInsert(int xid, recordid hashRid, void * key, int keySize, void
|
|||
|
||||
hashRid.slot = valSize;
|
||||
hashRid.size = keySize;
|
||||
Tupdate(xid, hashRid, key, OPERATION_LINEAR_INSERT);
|
||||
TupdateRaw(xid, hashRid, key, OPERATION_LINEAR_INSERT);
|
||||
|
||||
/* Perform redo-only insert. */
|
||||
hashRid.size = sizeof(hashEntry) + keySize + valSize;
|
||||
|
@ -157,7 +157,7 @@ int TlogicalHashDelete(int xid, recordid hashRid, void * key, int keySize, void
|
|||
|
||||
hashRid.size = sizeof(undoDeleteArg) + keySize + valSize;
|
||||
|
||||
Tupdate(xid, hashRid, arg, OPERATION_LINEAR_DELETE);
|
||||
TupdateRaw(xid, hashRid, arg, OPERATION_LINEAR_DELETE);
|
||||
hashRid.size = sizeof(hashEntry) + keySize + valSize;
|
||||
free(arg);
|
||||
/* hashRid.size = sizeof(recordid); */
|
||||
|
|
|
@ -140,15 +140,6 @@ Operation getSet() {
|
|||
};
|
||||
return o;
|
||||
}
|
||||
Operation getSetRaw() {
|
||||
Operation o = {
|
||||
OPERATION_SET_RAW, /* id */
|
||||
SIZEOF_RECORD, /* use the size of the record as size of arg */
|
||||
NO_INVERSE,
|
||||
&operate /* Function */
|
||||
};
|
||||
return o;
|
||||
}
|
||||
|
||||
Operation getSetRange() {
|
||||
Operation o = {
|
||||
|
|
|
@ -128,6 +128,9 @@ void pageDeinit() {
|
|||
slottedPageDeInit();
|
||||
}
|
||||
|
||||
/**
|
||||
@todo this updates the LSN of the page that points to blob, even if the page is otherwise untouched!!
|
||||
*/
|
||||
void writeRecord(int xid, Page * p, lsn_t lsn, recordid rid, const void *dat) {
|
||||
|
||||
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
||||
|
|
|
@ -43,6 +43,7 @@ pthread_mutex_t transactional_2_mutex;
|
|||
|
||||
void setupOperationsTable() {
|
||||
memset(XactionTable, INVALID_XTABLE_XID, sizeof(TransactionLog)*MAX_TRANSACTIONS);
|
||||
// @todo clean out unused constants...
|
||||
operationsTable[OPERATION_SET] = getSet();
|
||||
operationsTable[OPERATION_INCREMENT] = getIncrement();
|
||||
operationsTable[OPERATION_DECREMENT] = getDecrement();
|
||||
|
@ -85,8 +86,8 @@ void setupOperationsTable() {
|
|||
operationsTable[OPERATION_LINEAR_HASH_INSERT] = getLinearHashInsert();
|
||||
operationsTable[OPERATION_LINEAR_HASH_REMOVE] = getLinearHashRemove();
|
||||
|
||||
operationsTable[OPERATION_SET_RAW] = getSetRaw();
|
||||
operationsTable[OPERATION_INSTANT_SET_RAW] = getInstantSetRaw();
|
||||
//operationsTable[OPERATION_SET_RAW] = getSetRaw();
|
||||
//operationsTable[OPERATION_INSTANT_SET_RAW] = getInstantSetRaw();
|
||||
|
||||
operationsTable[OPERATION_ALLOC_BOUNDARY_TAG] = getAllocBoundaryTag();
|
||||
|
||||
|
@ -95,15 +96,6 @@ void setupOperationsTable() {
|
|||
operationsTable[OPERATION_ALLOC_REGION] = getAllocRegion();
|
||||
operationsTable[OPERATION_DEALLOC_REGION] = getDeallocRegion();
|
||||
|
||||
/*
|
||||
int i;
|
||||
|
||||
for(i = 0; i <= OPERATION_LINEAR_HASH_REMOVE; i++) {
|
||||
if(operationsTable[i].id != i) {
|
||||
printf("mismatch %d -> %d\n", i, operationsTable[i].id);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// @todo this factory stuff doesn't really belong here...
|
||||
|
@ -228,43 +220,28 @@ static compensated_function void TupdateHelper(int xid, recordid rid, const void
|
|||
FreeLogEntry(e);
|
||||
}
|
||||
|
||||
compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op) {
|
||||
Page * p;
|
||||
compensated_function void TupdateRaw(int xid, recordid rid,
|
||||
const void * dat, int op) {
|
||||
assert(xid >= 0);
|
||||
#ifdef DEBUGGING
|
||||
pthread_mutex_lock(&transactional_2_mutex);
|
||||
assert(numActiveXactions <= MAX_TRANSACTIONS);
|
||||
pthread_mutex_unlock(&transactional_2_mutex);
|
||||
#endif
|
||||
try {
|
||||
p = loadPage(xid, rid.page);
|
||||
} end;
|
||||
if(op != OPERATION_SET_RAW && op != OPERATION_INSTANT_SET_RAW) {
|
||||
if(*page_type_ptr(p) == INDIRECT_PAGE) {
|
||||
releasePage(p);
|
||||
try {
|
||||
rid = dereferenceRID(xid, rid);
|
||||
p = loadPage(xid, rid.page);
|
||||
} end;
|
||||
// @todo Kludge! Shouldn't special case operations in transactional2.
|
||||
} else if(*page_type_ptr(p) == ARRAY_LIST_PAGE &&
|
||||
op != OPERATION_LINEAR_INSERT &&
|
||||
op != OPERATION_UNDO_LINEAR_INSERT &&
|
||||
op != OPERATION_LINEAR_DELETE &&
|
||||
op != OPERATION_UNDO_LINEAR_DELETE ) {
|
||||
rid = dereferenceArrayListRid(p, rid.slot);
|
||||
releasePage(p);
|
||||
try {
|
||||
p = loadPage(xid, rid.page);
|
||||
} end;
|
||||
}
|
||||
Page * p = loadPage(xid, rid.page);
|
||||
TupdateHelper(xid, rid, dat, op, p);
|
||||
releasePage(p);
|
||||
}
|
||||
|
||||
compensated_function void Tupdate(int xid, recordid rid,
|
||||
const void *dat, int op) {
|
||||
Page * p = loadPage(xid, rid.page);
|
||||
if(*page_type_ptr(p) == INDIRECT_PAGE) {
|
||||
rid = dereferenceRID(xid, rid);
|
||||
} else if(*page_type_ptr(p) == ARRAY_LIST_PAGE) {
|
||||
rid = dereferenceArrayListRid(p, rid.slot);
|
||||
}
|
||||
|
||||
/** @todo For logical undo logs, grabbing a lock makes no sense! */
|
||||
begin_action(releasePage, p) {
|
||||
TupdateHelper(xid, rid, dat, op, p);
|
||||
} compensate;
|
||||
|
||||
if(p->id != rid.page) {
|
||||
releasePage(p);
|
||||
p = loadPage(xid, rid.page);
|
||||
}
|
||||
TupdateHelper(xid, rid, dat, op, p);
|
||||
releasePage(p);
|
||||
}
|
||||
|
||||
void TreadUnlocked(int xid, recordid rid, void * dat) {
|
||||
|
@ -327,10 +304,10 @@ int Tabort(int xid) {
|
|||
|
||||
TransactionLog * t =&XactionTable[xid%MAX_TRANSACTIONS];
|
||||
|
||||
lsn = LogTransAbort(t /*&XactionTable[xid%MAX_TRANSACTIONS]*/);
|
||||
lsn = LogTransAbort(t);
|
||||
|
||||
/** @todo is the order of the next two calls important? */
|
||||
undoTrans(*t/*XactionTable[xid%MAX_TRANSACTIONS]*/);
|
||||
undoTrans(*t);
|
||||
if(globalLockManager.abort) { globalLockManager.abort(xid); }
|
||||
|
||||
allocTransactionAbort(xid);
|
||||
|
@ -395,7 +372,7 @@ void TsetXIDCount(int xid) {
|
|||
}
|
||||
|
||||
lsn_t transactions_minRecLSN() {
|
||||
lsn_t minRecLSN = LSN_T_MAX; // LogFlushedLSN()
|
||||
lsn_t minRecLSN = LSN_T_MAX;
|
||||
pthread_mutex_lock(&transactional_2_mutex);
|
||||
for(int i = 0; i < MAX_TRANSACTIONS; i++) {
|
||||
if(XactionTable[i].xid != INVALID_XTABLE_XID) {
|
||||
|
|
Loading…
Reference in a new issue