Updated some comments.

This commit is contained in:
Sears Russell 2006-06-16 00:27:02 +00:00
parent dc8a3e5d60
commit 209a6916e5
4 changed files with 24 additions and 37 deletions

View file

@ -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);

View file

@ -5,6 +5,8 @@
#include <string.h>
#include <lladd/transactional.h>
#include <lladd/truncation.h>
#include <sys/time.h>
#include <time.h>
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);

View file

@ -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 {
@ -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 {

View file

@ -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) {