stasis-aries-wal/src/lladd/blobManager.c

78 lines
2 KiB
C
Raw Normal View History

#include <string.h>
#include <lladd/transactional.h>
#include "page/raw.h"
#include <assert.h>
2004-07-27 21:30:54 +00:00
2004-07-26 20:37:04 +00:00
void allocBlob(int xid, recordid rid) {
assert(rid.size>0);
int pageCount = (rid.size / USABLE_SIZE_OF_PAGE) + ((rid.size % USABLE_SIZE_OF_PAGE) ? 1 : 0);
long startPage = TpageAllocMany(xid, pageCount);
blob_record_t rec;
rec.offset = startPage;
rec.size = rid.size;
recordid rid2 = rid;
rid2.size = BLOB_SLOT;
Tset(xid, rid2, &rec);
// printf("Page start = %d, count = %d, rid.size=%d\n", rec.offset, pageCount, rid.size);
// printf("rid = {%d %d %d}\n", rid.page, rid.slot, rid.size);
}
2004-06-25 18:59:24 +00:00
void openBlobStore() {
2004-06-25 18:59:24 +00:00
}
void closeBlobStore() {
}
void readBlob(int xid, Page * p2, recordid rid, byte * buf) {
int chunk;
recordid rawRid = rid;
rawRid.size = BLOB_SLOT;
byte * pbuf = alloca(PAGE_SIZE);
blob_record_t rec;
readRecord(xid, p2, rawRid, &rec);
for(chunk = 0; (chunk+1) * USABLE_SIZE_OF_PAGE < rid.size; chunk++) {
TpageGet(xid, rec.offset+chunk, pbuf);
memcpy(buf + (chunk * USABLE_SIZE_OF_PAGE), pbuf, USABLE_SIZE_OF_PAGE);
}
TpageGet(xid, rec.offset+chunk, pbuf);
memcpy(buf + (chunk * USABLE_SIZE_OF_PAGE), pbuf, rid.size % USABLE_SIZE_OF_PAGE);
// printf("Chunk = %d\n", chunk);
2004-07-27 21:30:54 +00:00
}
void writeBlob(int xid, Page * p2, lsn_t lsn, recordid rid, const byte * buf) {
int chunk;
recordid rawRid = rid;
rawRid.size = BLOB_SLOT;
byte * pbuf = alloca(PAGE_SIZE);
2004-07-27 21:30:54 +00:00
blob_record_t rec;
readRecord(xid, p2, rawRid, &rec);
2004-07-27 21:30:54 +00:00
assert(rec.offset);
2004-07-27 21:30:54 +00:00
for(chunk = 0; (chunk+1) * USABLE_SIZE_OF_PAGE < rid.size; chunk++) {
TpageGet(xid, rec.offset+chunk, pbuf);
memcpy(pbuf, buf + (chunk * USABLE_SIZE_OF_PAGE), USABLE_SIZE_OF_PAGE);
TpageSet(xid, rec.offset+chunk, pbuf);
}
TpageGet(xid, rec.offset+chunk, pbuf);
memcpy(pbuf, buf + (chunk * USABLE_SIZE_OF_PAGE), rid.size % USABLE_SIZE_OF_PAGE);
TpageSet(xid, rec.offset+chunk, pbuf);
// printf("Write Chunk = %d (%d)\n", chunk, rec.offset+chunk);
}
void commitBlobs(int xid) {
}
2004-07-26 20:37:04 +00:00
void abortBlobs(int xid) {
2004-07-26 20:37:04 +00:00
2004-06-25 18:59:24 +00:00
}