From 209a6916e5905997c29e6f5b481ff3278a5a9b07 Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Fri, 16 Jun 2006 00:27:02 +0000 Subject: [PATCH] Updated some comments. --- lladd/operations/alloc.h | 2 ++ src/apps/readOnlyHash/buildTable.c | 5 ++++- src/lladd/operations/alloc.c | 23 +++++++++++++++++----- src/lladd/page/slotted.c | 31 ------------------------------ 4 files changed, 24 insertions(+), 37 deletions(-) diff --git a/lladd/operations/alloc.h b/lladd/operations/alloc.h index c20682d..7d1062e 100644 --- a/lladd/operations/alloc.h +++ b/lladd/operations/alloc.h @@ -28,6 +28,8 @@ void TallocInit(); @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. + @todo need to obtain (transaction-level) write locks _before_ writing log entries. Otherwise, we can deadlock at recovery. + @return the recordid of the new record. */ compensated_function recordid Talloc(int xid, long size); diff --git a/src/apps/readOnlyHash/buildTable.c b/src/apps/readOnlyHash/buildTable.c index c79c9f2..f16fd3b 100644 --- a/src/apps/readOnlyHash/buildTable.c +++ b/src/apps/readOnlyHash/buildTable.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include int main(int argc, char** argv) { @@ -26,7 +28,8 @@ int main(int argc, char** argv) { gettimeofday(&start,0); int count = 0; - while(EOF != (ret=scanf("%as\t%as\n", &key, &value))) { + // bleah; gcc would warn without the casts, since it doesn't understand that %as = Allocate String + while(EOF != (ret=scanf("%as\t%as\n", (float*)&key, (float*)&value))) { if(!ret) { printf("Could not parse input!\n"); Tabort(xid); diff --git a/src/lladd/operations/alloc.c b/src/lladd/operations/alloc.c index cd9b494..7863656 100644 --- a/src/lladd/operations/alloc.c +++ b/src/lladd/operations/alloc.c @@ -152,6 +152,12 @@ void TallocInit() { compensated_function recordid Talloc(int xid, long size) { recordid rid; + + // @todo How should blobs be handled? Should Talloc do it? If not, + // it's hard for apps to to use it... Similarly, with hints, Talloc + // may need to route certain sizes to certain types of pages (eg; + // small sizes go to fixed page implementations...) + int isBlob = size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT; if(isBlob) { @@ -161,6 +167,8 @@ compensated_function recordid Talloc(int xid, long size) { } end_ret(NULLRID); } else { + + Page * p = NULL; begin_action_ret(pthread_mutex_unlock, &talloc_mutex, NULLRID) { @@ -193,9 +201,8 @@ compensated_function recordid Talloc(int xid, long size) { slottedPageInitialize(p); } - // rid = slottedPreRalloc(xid, size, &p); - rid = slottedRawRalloc(p, size); - Tupdate(xid, rid, NULL, OPERATION_ALLOC); + rid = slottedRawRalloc(p, size); // <--- Important part. + Tupdate(xid, rid, NULL, OPERATION_ALLOC); // <--- This hardcodes "slotted" Should we use TallocFromPage() instead? /** @todo does releasePage do the correct error checking? <- Why is this comment here?*/ releasePage(p); } compensate_ret(NULLRID); @@ -208,9 +215,13 @@ compensated_function recordid Talloc(int xid, long size) { compensated_function recordid TallocFromPage(int xid, long page, unsigned long size) { recordid rid; + // Does TallocFromPage need to understand blobs? This function + // seems to be too complex; all it does it delegate the allocation + // request to the page type's implementation. (Does it really need + // to check for freespace?) if(size >= BLOB_THRESHOLD_SIZE && size != BLOB_SLOT) { try_ret(NULLRID) { - rid = preAllocBlobFromPage(xid, page, size); + rid = preAllocBlobFromPage(xid, page, size); // <--- ICK!!! Kill this function. Tupdate(xid,rid, NULL, OPERATION_ALLOC); } end_ret(NULLRID); } else { @@ -226,7 +237,7 @@ compensated_function recordid TallocFromPage(int xid, long page, unsigned long s } else { rid = slottedRawRalloc(p, size); assert(rid.size == size); - Tupdate(xid, rid, NULL, OPERATION_ALLOC); + Tupdate(xid, rid, NULL, OPERATION_ALLOC); } releasePage(p); } compensate_ret(NULLRID); @@ -235,6 +246,8 @@ compensated_function recordid TallocFromPage(int xid, long page, unsigned long s } compensated_function void Tdealloc(int xid, recordid rid) { + + // @todo this needs to garbage collect emptry pages / storage regions. void * preimage = malloc(rid.size); Page * p; try { diff --git a/src/lladd/page/slotted.c b/src/lladd/page/slotted.c index 888fe58..852f77c 100644 --- a/src/lladd/page/slotted.c +++ b/src/lladd/page/slotted.c @@ -183,37 +183,6 @@ size_t slottedFreespace(Page * page) { } -/** @todo slottedPreRalloc ignores it's xid parameter; change the - interface? (The xid is there for now, in case it allows some - optimizations later. Perhaps it's better to cluster allocations - from the same xid on the same page, or something...) - - @todo slottedPreRalloc should understand deadlock, and try another page if deadlock occurs. - - @todo need to obtain (transaction-level) write locks _before_ writing log entries. Otherwise, we can deadlock at recovery. -*/ -/*compensated_function recordid slottedPreRalloc(int xid, unsigned long size, Page ** pp) { - recordid ret; - // int isBlob = 0; - //if(size == BLOB_SLOT) { - // isBlob = 1; - // size = sizeof(blob_record_t); - // } - // assert(size < BLOB_THRESHOLD_SIZE); - - // assert(*page_type_ptr(*pp) == SLOTTED_PAGE); - ret = slottedRawRalloc(*pp, size); - // assert(ret.size == size); - - // if(isBlob) { - // *slot_length_ptr(*pp, ret.slot) = BLOB_SLOT; - // } - - DEBUG("alloced rid = {%d, %d, %ld}\n", ret.page, ret.slot, ret.size); - - return ret; -}*/ - recordid slottedRawRalloc(Page * page, int size) {