diff --git a/lladd/logger/logger2.h b/lladd/logger/logger2.h index f4b8533..8a7798a 100644 --- a/lladd/logger/logger2.h +++ b/lladd/logger/logger2.h @@ -91,6 +91,9 @@ extern int loggerType; int LogInit(int logType); int LogDeinit(); void LogForce(lsn_t lsn); +/** + @param lsn The first lsn that will be available after truncation. +*/ void LogTruncate(lsn_t lsn); /** This function is guaranteed to return the LSN of the most recent @@ -161,6 +164,11 @@ lsn_t LogCLR(int xid, lsn_t LSN, recordid rid, lsn_t prevLSN); */ void LogEnd (TransactionLog * l); +/** + Needed by sizeofLogEntry +*/ +long LoggerSizeOfInternalLogEntry(const LogEntry * e); + /** For internal use only... This would be static, but it is called by the test cases. */ diff --git a/src/lladd/logger/inMemoryLog.c b/src/lladd/logger/inMemoryLog.c index 27aa32f..05bca33 100644 --- a/src/lladd/logger/inMemoryLog.c +++ b/src/lladd/logger/inMemoryLog.c @@ -123,3 +123,6 @@ LogEntry * readLSNEntry_InMemoryLog(lsn_t lsn) { //printf("lsn: %ld prevlsn: %ld\n", ptr->LSN, ptr->prevLSN); return ret; } +long sizeofInternalLogEntry_InMemoryLog(const LogEntry * e) { + abort(); +} diff --git a/src/lladd/logger/inMemoryLog.h b/src/lladd/logger/inMemoryLog.h index 8c3044b..5ceb5da 100644 --- a/src/lladd/logger/inMemoryLog.h +++ b/src/lladd/logger/inMemoryLog.h @@ -10,6 +10,7 @@ void syncLog_InMemoryLog(); int truncateLog_InMemoryLog(lsn_t lsn); lsn_t firstLogEntry_InMemoryLog(); void close_InMemoryLog(); +long sizeofInternalLogEntry_InMemoryLog(const LogEntry * e); LogEntry * readLSNEntry_InMemoryLog(lsn_t lsn); lsn_t nextEntry_InMemoryLog(const LogEntry * e); #endif diff --git a/src/lladd/logger/logEntry.c b/src/lladd/logger/logEntry.c index 04d0edd..fd431a5 100644 --- a/src/lladd/logger/logEntry.c +++ b/src/lladd/logger/logEntry.c @@ -48,7 +48,7 @@ terms specified in this license. #include #include - +#include LogEntry * allocCommonLogEntry(lsn_t prevLSN, int xid, unsigned int type) { LogEntry * ret = malloc(sizeof(struct __raw_log_entry)); ret->LSN = -1; @@ -132,6 +132,8 @@ long sizeofLogEntry(const LogEntry * log) { return sizeof(struct __raw_log_entry) + sizeof(UpdateLogEntry) + log->contents.update.argSize + ((operationsTable[log->contents.update.funcID].undo == NO_INVERSE) ? physical_slot_length(log->contents.update.rid.size) : 0) + ((operationsTable[log->contents.update.funcID].undo == NO_INVERSE_WHOLE_PAGE) ? PAGE_SIZE : 0) ; + case INTERNALLOG: + return LoggerSizeOfInternalLogEntry(log); default: return sizeof(struct __raw_log_entry); } diff --git a/src/lladd/logger/logger2.c b/src/lladd/logger/logger2.c index 244d34b..6042fca 100644 --- a/src/lladd/logger/logger2.c +++ b/src/lladd/logger/logger2.c @@ -61,6 +61,16 @@ terms specified in this license. int loggerType = LOG_TO_FILE; +long LoggerSizeOfInternalLogEntry(const LogEntry * e) { + if(loggerType == LOG_TO_FILE) { + return sizeofInternalLogEntry_LogWriter(e); + } else if (loggerType == LOG_TO_MEMORY) { + return sizeofInternalLogEntry_InMemoryLog(e); + } else { + abort(); // we dont have an appropriate implementation, or weren't initialized... + } +} + void LogWrite(LogEntry * e) { if(loggerType == LOG_TO_FILE) { writeLogEntry(e);