1 8 9 package com.sleepycat.je.tree; 10 11 import java.nio.ByteBuffer ; 12 13 import com.sleepycat.je.DatabaseException; 14 import com.sleepycat.je.dbi.DatabaseId; 15 import com.sleepycat.je.dbi.DatabaseImpl; 16 import com.sleepycat.je.log.LogEntryType; 17 import com.sleepycat.je.log.LogException; 18 import com.sleepycat.je.log.LogManager; 19 import com.sleepycat.je.log.LogReadable; 20 import com.sleepycat.je.log.LogUtils; 21 import com.sleepycat.je.log.LogWritable; 22 import com.sleepycat.je.log.LoggableObject; 23 24 28 public class INDupDeleteInfo 29 implements LoggableObject, LogReadable, LogWritable { 30 31 private long deletedNodeId; 32 private byte[] deletedMainKey; 33 private byte[] deletedDupKey; 34 private DatabaseId dbId; 35 36 39 public INDupDeleteInfo(long deletedNodeId, 40 byte[] deletedMainKey, 41 byte[] deletedDupKey, 42 DatabaseId dbId) { 43 this.deletedNodeId = deletedNodeId; 44 this.deletedMainKey = deletedMainKey; 45 this.deletedDupKey = deletedDupKey; 46 this.dbId = dbId; 47 } 48 49 52 public INDupDeleteInfo() { 53 dbId = new DatabaseId(); 54 } 55 56 59 public long getDeletedNodeId() { 60 return deletedNodeId; 61 } 62 63 public byte[] getDeletedMainKey() { 64 return deletedMainKey; 65 } 66 67 public byte[] getDeletedDupKey() { 68 return deletedDupKey; 69 } 70 71 public DatabaseId getDatabaseId() { 72 return dbId; 73 } 74 75 78 79 82 public void optionalLog(LogManager logManager, 83 DatabaseImpl dbImpl) 84 throws DatabaseException { 85 86 if (!dbImpl.isDeferredWrite()) { 87 logManager.log(this); 88 } 89 } 90 91 94 public LogEntryType getLogType() { 95 return LogEntryType.LOG_IN_DUPDELETE_INFO; 96 } 97 98 102 public boolean marshallOutsideWriteLatch() { 103 return true; 104 } 105 106 109 public boolean countAsObsoleteWhenLogged() { 110 return false; 111 } 112 113 116 public void postLogWork(long justLoggedLsn) { 117 } 118 119 122 public int getLogSize() { 123 return LogUtils.LONG_BYTES + 124 LogUtils.getByteArrayLogSize(deletedMainKey) + 125 LogUtils.getByteArrayLogSize(deletedDupKey) + 126 dbId.getLogSize(); 127 } 128 129 132 public void writeToLog(ByteBuffer logBuffer) { 133 134 LogUtils.writeLong(logBuffer, deletedNodeId); 135 LogUtils.writeByteArray(logBuffer, deletedMainKey); 136 LogUtils.writeByteArray(logBuffer, deletedDupKey); 137 dbId.writeToLog(logBuffer); 138 } 139 140 143 public void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion) 144 throws LogException { 145 146 deletedNodeId = LogUtils.readLong(itemBuffer); 147 deletedMainKey = LogUtils.readByteArray(itemBuffer); 148 deletedDupKey = LogUtils.readByteArray(itemBuffer); 149 dbId.readFromLog(itemBuffer, entryTypeVersion); 150 } 151 152 155 public void dumpLog(StringBuffer sb, boolean verbose) { 156 sb.append("<INDupDeleteEntry node=\"").append(deletedNodeId); 157 sb.append("\">"); 158 sb.append(Key.dumpString(deletedMainKey, 0)); 159 sb.append(Key.dumpString(deletedDupKey, 0)); 160 dbId.dumpLog(sb, verbose); 161 sb.append("</INDupDeleteEntry>"); 162 } 163 164 167 public boolean logEntryIsTransactional() { 168 return false; 169 } 170 171 174 public long getTransactionId() { 175 return 0; 176 } 177 } 178 | Popular Tags |