KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > tree > INDeleteInfo


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: INDeleteInfo.java,v 1.30 2006/10/30 21:14:26 bostic Exp $
7  */

8
9 package com.sleepycat.je.tree;
10
11 import java.nio.ByteBuffer JavaDoc;
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 /**
25  * INDeleteInfo encapsulates the information logged about the removal of a
26  * child from an IN during IN compression.
27  */

28 public class INDeleteInfo
29     implements LoggableObject, LogReadable, LogWritable {
30
31     private long deletedNodeId;
32     private byte[] deletedIdKey;
33     private DatabaseId dbId;
34
35     /**
36      * Create a new delete info entry.
37      */

38     public INDeleteInfo(long deletedNodeId,
39             byte[] deletedIdKey,
40             DatabaseId dbId) {
41         this.deletedNodeId = deletedNodeId;
42         this.deletedIdKey = deletedIdKey;
43         this.dbId = dbId;
44     }
45
46     /**
47      * Used by logging system only.
48      */

49     public INDeleteInfo() {
50         dbId = new DatabaseId();
51     }
52
53     /*
54      * Accessors.
55      */

56     public long getDeletedNodeId() {
57         return deletedNodeId;
58     }
59
60     public byte[] getDeletedIdKey() {
61         return deletedIdKey;
62     }
63     
64     public DatabaseId getDatabaseId() {
65         return dbId;
66     }
67
68     /*
69      * Logging support for writing.
70      */

71     public void optionalLog(LogManager logManager,
72                             DatabaseImpl dbImpl)
73         throws DatabaseException {
74
75         if (!dbImpl.isDeferredWrite()) {
76             logManager.log(this);
77         }
78     }
79
80     /**
81      * @see LoggableObject#getLogType
82      */

83     public LogEntryType getLogType() {
84         return LogEntryType.LOG_IN_DELETE_INFO;
85     }
86
87     /**
88      * @see LoggableObject#marshallOutsideWriteLatch
89      * Can be marshalled outside the log write latch.
90      */

91     public boolean marshallOutsideWriteLatch() {
92         return true;
93     }
94
95     /**
96      * @see LoggableObject#countAsObsoleteWhenLogged
97      */

98     public boolean countAsObsoleteWhenLogged() {
99         return false;
100     }
101
102     /**
103      * @see LoggableObject#postLogWork
104      */

105     public void postLogWork(long justLoggedLsn) {
106     }
107
108     /**
109      * @see LoggableObject#getLogSize
110      */

111     public int getLogSize() {
112         return LogUtils.LONG_BYTES +
113             LogUtils.getByteArrayLogSize(deletedIdKey) +
114             dbId.getLogSize();
115     }
116
117     /**
118      * @see LogWritable#writeToLog
119      */

120     public void writeToLog(ByteBuffer JavaDoc logBuffer) {
121
122         LogUtils.writeLong(logBuffer, deletedNodeId);
123         LogUtils.writeByteArray(logBuffer, deletedIdKey);
124         dbId.writeToLog(logBuffer);
125     }
126
127     /**
128      * @see LogReadable#readFromLog
129      */

130     public void readFromLog(ByteBuffer JavaDoc itemBuffer, byte entryTypeVersion)
131     throws LogException {
132
133         deletedNodeId = LogUtils.readLong(itemBuffer);
134         deletedIdKey = LogUtils.readByteArray(itemBuffer);
135         dbId.readFromLog(itemBuffer, entryTypeVersion);
136     }
137
138     /**
139      * @see LogReadable#dumpLog
140      */

141     public void dumpLog(StringBuffer JavaDoc sb, boolean verbose) {
142         sb.append("<INDeleteEntry node=\"").append(deletedNodeId);
143         sb.append("\">");
144         sb.append(Key.dumpString(deletedIdKey, 0));
145         dbId.dumpLog(sb, verbose);
146         sb.append("</INDeleteEntry>");
147     }
148
149     /**
150      * @see LogReadable#logEntryIsTransactional
151      */

152     public boolean logEntryIsTransactional() {
153     return false;
154     }
155
156     /**
157      * @see LogReadable#getTransactionId
158      */

159     public long getTransactionId() {
160     return 0;
161     }
162 }
163
Popular Tags