Implemented TrecordType()
This commit is contained in:
parent
87cffd409b
commit
443a90ad7c
4 changed files with 59 additions and 3 deletions
|
@ -27,4 +27,6 @@ recordid Talloc(int xid, long size);
|
|||
/** @todo Currently, we just leak store space on dealloc. */
|
||||
void Tdealloc(int xid, recordid rid);
|
||||
|
||||
int TrecordType(int xid, recordid rid);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -138,7 +138,8 @@ pthread_mutex_t truncateLog_mutex;
|
|||
|
||||
static int sought = 1;
|
||||
int openLogWriter() {
|
||||
#define BUFSIZE 1024*96
|
||||
#define BUFSIZE (1024*96)
|
||||
//#define BUFSIZE (512)
|
||||
char * buffer ;/*= malloc(BUFSIZE);*/
|
||||
|
||||
assert(!posix_memalign((void*)&(buffer), PAGE_SIZE, BUFSIZE));
|
||||
|
@ -578,4 +579,3 @@ int truncateLog(lsn_t LSN) {
|
|||
lsn_t firstLogEntry() {
|
||||
return global_offset + sizeof(lsn_t);
|
||||
}
|
||||
|
||||
|
|
|
@ -142,3 +142,10 @@ void Tdealloc(int xid, recordid rid) {
|
|||
releasePage(p);
|
||||
free(preimage);
|
||||
}
|
||||
|
||||
int TrecordType(int xid, recordid rid) {
|
||||
Page * p = loadPage(rid.page);
|
||||
int ret = getRecordType(xid, p, rid);
|
||||
releasePage(p);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -411,6 +411,53 @@ START_TEST(pageCheckSlotTypeTest) {
|
|||
|
||||
Tdeinit();
|
||||
} END_TEST
|
||||
/**
|
||||
@test unit test for TrecordType
|
||||
*/
|
||||
START_TEST(pageTrecordTypeTest) {
|
||||
Tinit();
|
||||
|
||||
int xid = Tbegin();
|
||||
|
||||
recordid slot = Talloc(xid, sizeof(int));
|
||||
recordid fixedRoot = TarrayListAlloc(xid, 2, 10, 10);
|
||||
recordid blob = Talloc(xid, PAGE_SIZE * 2);
|
||||
|
||||
assert(TrecordType(xid, slot) == SLOTTED_RECORD);
|
||||
|
||||
/** @todo the use of the fixedRoot recordid to check getRecordType is
|
||||
a bit questionable, but should work. */
|
||||
|
||||
assert(TrecordType(xid, fixedRoot) == FIXED_RECORD);
|
||||
|
||||
fixedRoot.slot = 1;
|
||||
recordid fixedEntry = dereferenceRID(fixedRoot);
|
||||
fixedRoot.slot = 0;
|
||||
|
||||
assert(TrecordType(xid, fixedEntry) == FIXED_RECORD);
|
||||
|
||||
int type = TrecordType(xid, blob);
|
||||
assert(type == BLOB_RECORD);
|
||||
|
||||
recordid bad;
|
||||
bad.page = slot.page;
|
||||
bad.slot = slot.slot + 10;
|
||||
bad.size = 4;
|
||||
|
||||
assert(TrecordType(xid, bad) == UNINITIALIZED_RECORD);
|
||||
bad.size = 100000;
|
||||
assert(TrecordType(xid, bad) == UNINITIALIZED_RECORD);
|
||||
/** @todo this test could be better... The behavior for getRecordType in this
|
||||
case (valid slot, invalid size) is a bit ambiguous. Maybe an INVALID_RECORDID
|
||||
would be an appropriate return value... */
|
||||
bad.slot = slot.slot;
|
||||
assert(TrecordType(xid, bad) == UNINITIALIZED_RECORD);
|
||||
|
||||
Tcommit(xid);
|
||||
|
||||
Tdeinit();
|
||||
} END_TEST
|
||||
|
||||
|
||||
Suite * check_suite(void) {
|
||||
Suite *s = suite_create("page");
|
||||
|
@ -422,7 +469,7 @@ Suite * check_suite(void) {
|
|||
tcase_add_test(tc, pageCheckMacros);
|
||||
|
||||
tcase_add_test(tc, pageCheckSlotTypeTest);
|
||||
|
||||
tcase_add_test(tc, pageTrecordTypeTest);
|
||||
tcase_add_test(tc, pageNoThreadMultPageTest);
|
||||
tcase_add_test(tc, pageNoThreadTest);
|
||||
tcase_add_test(tc, pageThreadTest);
|
||||
|
|
Loading…
Reference in a new issue