1 5 package org.h2.store; 6 7 import java.sql.SQLException ; 8 9 import org.h2.util.CacheObject; 10 11 14 public abstract class Record extends CacheObject { 15 private boolean deleted; 16 private int storageId; 17 private int lastLog = LogSystem.LOG_WRITTEN; 18 private int lastPos = LogSystem.LOG_WRITTEN; 19 20 public abstract int getByteCount(DataPage dummy) throws SQLException ; 21 22 28 public void prepareWrite() throws SQLException { 29 } 30 31 public abstract void write(DataPage buff) throws SQLException ; 32 33 public boolean isEmpty() { 34 return false; 35 } 36 37 public void setDeleted(boolean deleted) { 38 this.deleted = deleted; 39 } 40 41 public boolean getDeleted() { 42 return deleted; 43 } 44 45 public void setStorageId(int storageId) { 46 this.storageId = storageId; 47 } 48 49 public int getStorageId() { 50 return storageId; 51 } 52 53 public void setLastLog(int log, int pos) { 54 lastLog = log; 55 lastPos = pos; 56 } 57 58 public void setLogWritten(int log, int pos) { 59 if(log < lastLog) { 60 return; 61 } 62 if(log > lastLog || pos >= lastPos) { 63 lastLog = LogSystem.LOG_WRITTEN; 64 lastPos = LogSystem.LOG_WRITTEN; 65 } 66 } 67 68 public boolean canRemove() { 69 if((isChanged() && !isLogWritten()) || isPinned()) { 70 return false; 71 } 72 return true; 73 } 74 75 public boolean isLogWritten() { 76 return lastLog == LogSystem.LOG_WRITTEN; 77 } 78 79 } 80 | Popular Tags |