KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > access > btree > index > B2INoLocking


1 /*
2
3    Derby - Class org.apache.derby.impl.store.access.btree.index.B2INoLocking
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.store.access.btree.index;
23
24 import org.apache.derby.iapi.services.sanity.SanityManager;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import org.apache.derby.iapi.store.access.ConglomerateController;
29 import org.apache.derby.iapi.types.RowLocation;
30 import org.apache.derby.iapi.store.access.TransactionController;
31
32 import org.apache.derby.iapi.store.raw.FetchDescriptor;
33 import org.apache.derby.iapi.store.raw.LockingPolicy;
34 import org.apache.derby.iapi.store.raw.Page;
35 import org.apache.derby.iapi.store.raw.RecordHandle;
36 import org.apache.derby.iapi.store.raw.Transaction;
37
38 import org.apache.derby.iapi.types.DataValueDescriptor;
39
40 import org.apache.derby.impl.store.access.btree.BTree;
41 import org.apache.derby.impl.store.access.btree.BTreeLockingPolicy;
42 import org.apache.derby.impl.store.access.btree.ControlRow;
43 import org.apache.derby.impl.store.access.btree.LeafControlRow;
44 import org.apache.derby.impl.store.access.btree.OpenBTree;
45 import org.apache.derby.impl.store.access.btree.BTreeRowPosition;
46 import org.apache.derby.impl.store.access.btree.WaitError;
47
48
49 /**
50
51 Secondary index locking policy that does no locking.
52 <p>
53 This is used when the caller knows that logical locks are already obtained
54 so need not be requested again. For instance when inserting a row into
55 an index, a X row lock has already been obtained when the row was inserted
56 into the base table, so there is no need to get another lock in the
57 secondary index.
58 <p>
59 This class overrides all interfaces of BTreeLockingPolicy making them
60 no-ops.
61
62 **/

63
64 public class B2INoLocking implements BTreeLockingPolicy
65 {
66
67     /**************************************************************************
68      * Constructors for This class:
69      **************************************************************************
70      */

71     public B2INoLocking(
72     Transaction rawtran,
73     int lock_level,
74     LockingPolicy locking_policy,
75     ConglomerateController base_cc,
76     OpenBTree open_btree)
77     {
78     }
79
80     protected B2INoLocking()
81     {
82     }
83
84     /**************************************************************************
85      * Public Methods of This class:
86      **************************************************************************
87      */

88
89
90     /**************************************************************************
91      * Abstract Protected lockScan*() locking methods of BTree:
92      * lockScan - lock the scan page
93      * lockScanForReclaimSpace - lock page for reclaiming deleted rows.
94      * lockScanRow - lock row and possibly the scan page
95      * unlockScan - unlock the scan page
96      * unlockScanRecordAfterRead- unlock the scan record
97      **************************************************************************
98      */

99
100
101     /**
102      * Lock a control row page for scan.
103      * <p>
104      * See BTree.lockScan() for more info.
105      *
106      * @exception StandardException Standard exception policy.
107      **/

108     public boolean lockScan(
109     LeafControlRow current_leaf,
110     ControlRow aux_control_row,
111     boolean forUpdate,
112     int lock_operation)
113         throws StandardException
114     {
115         return(true);
116     }
117
118     /**
119      * Lock a control row page for reclaiming deleted rows.
120      * <p>
121      * When reclaiming deleted rows during split need to get an exclusive
122      * scan lock on the page, which will mean there are no other scans
123      * positioned on the page. If there are other scans positioned, just
124      * give up on reclaiming space now.
125      *
126      * @return true if lock was granted nowait, else false and not lock was
127      * granted.
128      *
129      * @exception StandardException Standard exception policy.
130      **/

131     public boolean lockScanForReclaimSpace(
132     LeafControlRow current_leaf)
133         throws StandardException
134     {
135         // if doing no locking don't allow reclaiming space.
136
return(false);
137     }
138
139     /**
140      * Lock a btree row to determine if it is a committed deleted row.
141      * <p>
142      * Request an exclusive lock on the row located at the given slot, NOWAIT.
143      * Return true if the lock is granted, otherwise false.
144      * <p>
145      *
146      * @param open_btree The conglomerate we are locking.
147      * @param leaf The leaf page with the row to lock.
148      * @param template A scratch area to use to read in RowLocation.
149      * @param slot_no The slot of row on "current_leaf"
150      *
151      * @exception StandardException Standard exception policy.
152      **/

153     public boolean lockScanCommittedDeletedRow(
154     OpenBTree open_btree,
155     LeafControlRow leaf,
156     DataValueDescriptor[] template,
157     FetchDescriptor lock_fetch_desc,
158     int slot_no)
159         throws StandardException
160     {
161         return(true);
162     }
163
164     /**
165      * Lock a row as part of doing the scan.
166      * <p>
167      * Lock the row at the given slot (or the previous row if slot is 0).
168      * Get the scan lock on the page if "request_scan_lock" is true.
169      * <p>
170      * If this routine returns true all locks were acquired while maintaining
171      * the latch on leaf. If this routine returns false, locks may or may
172      * not have been acquired, and the routine should be called again after
173      * the client has researched the tree to reget the latch on the
174      * appropriate page.
175      * (p>
176      * As a sided effect stores the value of the record handle of the current
177      * scan lock.
178      *
179      * @return Whether locks were acquired without releasing latch on leaf.
180      *
181      * @param pos The position of the row to lock.
182      * @param request_scan_lock Whether to request the page scan lock, should
183      * only be requested once per page in the scan.
184      *
185      * @exception StandardException Standard exception policy.
186      **/

187     public boolean lockScanRow(
188     OpenBTree open_btree,
189     BTree btree,
190     BTreeRowPosition pos,
191     boolean request_scan_lock,
192     FetchDescriptor lock_fetch_desc,
193     DataValueDescriptor[] lock_template,
194     RowLocation lock_row_loc,
195     boolean previous_key_lock,
196     boolean forUpdate,
197     int lock_operation)
198         throws StandardException
199     {
200         return(true);
201     }
202
203     /**
204      * Release read lock on a row.
205      *
206      * @param forUpdate Is the scan for update or for read only.
207      *
208      * @exception StandardException Standard exception policy.
209      **/

210     public void unlockScanRecordAfterRead(
211     BTreeRowPosition pos,
212     boolean forUpdate)
213         throws StandardException
214     {
215         return;
216     }
217
218
219     /**
220      * Unlock the lock gotten by lockScan().
221      * <p>
222      * See BTree.unlockScan() for more info.
223      *
224      **/

225     public void unlockScan(
226     long page_number)
227     {
228     }
229
230     /**************************************************************************
231      * Abstract Protected lockNonScan*() locking methods of BTree:
232      *
233      * lockNonScanPreviousRow - lock the row previous to the current
234      * lockNonScanRow - lock the input row
235      **************************************************************************
236      */

237
238     /**
239      * Lock the row previous to the input row.
240      * <p>
241      * See BTree.lockPreviousRow() for more info.
242      *
243      * @exception StandardException Standard exception policy.
244      **/

245     public boolean lockNonScanPreviousRow(
246     BTree btree,
247     LeafControlRow current_leaf,
248     int current_slot,
249     FetchDescriptor lock_fetch_desc,
250     DataValueDescriptor[] lock_template,
251     RowLocation lock_row_loc,
252     OpenBTree open_btree,
253     int lock_operation,
254     int lock_duration)
255         throws StandardException
256     {
257         return(true);
258     }
259
260
261     /**
262      * Lock the in memory row.
263      * <p>
264      * See BTree.lockRow() for more info.
265      *
266      * @exception StandardException Standard exception policy.
267      **/

268     public boolean lockNonScanRow(
269     BTree btree,
270     LeafControlRow current_leaf,
271     LeafControlRow aux_leaf,
272     DataValueDescriptor[] current_row,
273     int lock_operation)
274         throws StandardException
275     {
276         return(true);
277     }
278
279     public boolean lockNonScanRowOnPage(
280     BTree btree,
281     LeafControlRow current_leaf,
282     int current_slot,
283     FetchDescriptor lock_fetch_desc,
284     DataValueDescriptor[] lock_template,
285     RowLocation lock_row_loc,
286     int lock_operation)
287         throws StandardException
288     {
289         return(true);
290     }
291 }
292
Popular Tags