2006-06-21 00:45:18 +00:00
|
|
|
#include <string.h>
|
2004-06-28 21:10:10 +00:00
|
|
|
#include <lladd/transactional.h>
|
2006-06-21 00:45:18 +00:00
|
|
|
#include "page/raw.h"
|
|
|
|
#include <assert.h>
|
2004-07-27 21:30:54 +00:00
|
|
|
|
2004-07-26 20:37:04 +00:00
|
|
|
|
2006-06-21 00:45:18 +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-28 21:10:10 +00:00
|
|
|
}
|
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
void openBlobStore() {
|
2004-07-06 01:22:18 +00:00
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void closeBlobStore() {
|
2004-08-21 00:03:30 +00:00
|
|
|
|
2004-06-26 02:05:24 +00:00
|
|
|
}
|
|
|
|
|
2006-06-21 00:45:18 +00:00
|
|
|
void readBlob(int xid, Page * p2, recordid rid, byte * buf) {
|
|
|
|
int chunk;
|
|
|
|
recordid rawRid = rid;
|
|
|
|
rawRid.size = BLOB_SLOT;
|
|
|
|
byte * pbuf = alloca(PAGE_SIZE);
|
2004-06-28 21:10:10 +00:00
|
|
|
blob_record_t rec;
|
2006-06-21 00:45:18 +00:00
|
|
|
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);
|
2004-06-26 02:05:24 +00:00
|
|
|
}
|
2004-06-28 21:10:10 +00:00
|
|
|
|
2006-06-21 00:45:18 +00:00
|
|
|
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-06-28 21:10:10 +00:00
|
|
|
|
2004-07-27 21:30:54 +00:00
|
|
|
}
|
2004-08-21 00:03:30 +00:00
|
|
|
|
2006-06-21 00:45:18 +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;
|
2006-06-21 00:45:18 +00:00
|
|
|
readRecord(xid, p2, rawRid, &rec);
|
2004-07-27 21:30:54 +00:00
|
|
|
|
2006-06-21 00:45:18 +00:00
|
|
|
assert(rec.offset);
|
2004-07-27 21:30:54 +00:00
|
|
|
|
2006-06-21 00:45:18 +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);
|
|
|
|
|
2004-06-26 02:05:24 +00:00
|
|
|
|
|
|
|
}
|
2004-08-21 00:03:30 +00:00
|
|
|
|
2004-06-28 21:10:10 +00:00
|
|
|
void commitBlobs(int xid) {
|
2004-06-26 02:05:24 +00:00
|
|
|
|
2006-06-21 00:45:18 +00:00
|
|
|
}
|
2004-07-26 20:37:04 +00:00
|
|
|
|
2006-06-21 00:45:18 +00:00
|
|
|
void abortBlobs(int xid) {
|
2004-07-26 20:37:04 +00:00
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
}
|