001: /*
002:
003: Derby - Class org.apache.derby.impl.store.access.btree.index.B2INoLocking
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.store.access.btree.index;
023:
024: import org.apache.derby.iapi.services.sanity.SanityManager;
025:
026: import org.apache.derby.iapi.error.StandardException;
027:
028: import org.apache.derby.iapi.store.access.ConglomerateController;
029: import org.apache.derby.iapi.types.RowLocation;
030: import org.apache.derby.iapi.store.access.TransactionController;
031:
032: import org.apache.derby.iapi.store.raw.FetchDescriptor;
033: import org.apache.derby.iapi.store.raw.LockingPolicy;
034: import org.apache.derby.iapi.store.raw.Page;
035: import org.apache.derby.iapi.store.raw.RecordHandle;
036: import org.apache.derby.iapi.store.raw.Transaction;
037:
038: import org.apache.derby.iapi.types.DataValueDescriptor;
039:
040: import org.apache.derby.impl.store.access.btree.BTree;
041: import org.apache.derby.impl.store.access.btree.BTreeLockingPolicy;
042: import org.apache.derby.impl.store.access.btree.ControlRow;
043: import org.apache.derby.impl.store.access.btree.LeafControlRow;
044: import org.apache.derby.impl.store.access.btree.OpenBTree;
045: import org.apache.derby.impl.store.access.btree.BTreeRowPosition;
046: import org.apache.derby.impl.store.access.btree.WaitError;
047:
048: /**
049:
050: Secondary index locking policy that does no locking.
051: <p>
052: This is used when the caller knows that logical locks are already obtained
053: so need not be requested again. For instance when inserting a row into
054: an index, a X row lock has already been obtained when the row was inserted
055: into the base table, so there is no need to get another lock in the
056: secondary index.
057: <p>
058: This class overrides all interfaces of BTreeLockingPolicy making them
059: no-ops.
060:
061: **/
062:
063: public class B2INoLocking implements BTreeLockingPolicy {
064:
065: /**************************************************************************
066: * Constructors for This class:
067: **************************************************************************
068: */
069: public B2INoLocking(Transaction rawtran, int lock_level,
070: LockingPolicy locking_policy,
071: ConglomerateController base_cc, OpenBTree open_btree) {
072: }
073:
074: protected B2INoLocking() {
075: }
076:
077: /**************************************************************************
078: * Public Methods of This class:
079: **************************************************************************
080: */
081:
082: /**************************************************************************
083: * Abstract Protected lockScan*() locking methods of BTree:
084: * lockScan - lock the scan page
085: * lockScanForReclaimSpace - lock page for reclaiming deleted rows.
086: * lockScanRow - lock row and possibly the scan page
087: * unlockScan - unlock the scan page
088: * unlockScanRecordAfterRead- unlock the scan record
089: **************************************************************************
090: */
091:
092: /**
093: * Lock a control row page for scan.
094: * <p>
095: * See BTree.lockScan() for more info.
096: *
097: * @exception StandardException Standard exception policy.
098: **/
099: public boolean lockScan(LeafControlRow current_leaf,
100: ControlRow aux_control_row, boolean forUpdate,
101: int lock_operation) throws StandardException {
102: return (true);
103: }
104:
105: /**
106: * Lock a control row page for reclaiming deleted rows.
107: * <p>
108: * When reclaiming deleted rows during split need to get an exclusive
109: * scan lock on the page, which will mean there are no other scans
110: * positioned on the page. If there are other scans positioned, just
111: * give up on reclaiming space now.
112: *
113: * @return true if lock was granted nowait, else false and not lock was
114: * granted.
115: *
116: * @exception StandardException Standard exception policy.
117: **/
118: public boolean lockScanForReclaimSpace(LeafControlRow current_leaf)
119: throws StandardException {
120: // if doing no locking don't allow reclaiming space.
121: return (false);
122: }
123:
124: /**
125: * Lock a btree row to determine if it is a committed deleted row.
126: * <p>
127: * Request an exclusive lock on the row located at the given slot, NOWAIT.
128: * Return true if the lock is granted, otherwise false.
129: * <p>
130: *
131: * @param open_btree The conglomerate we are locking.
132: * @param leaf The leaf page with the row to lock.
133: * @param template A scratch area to use to read in RowLocation.
134: * @param slot_no The slot of row on "current_leaf"
135: *
136: * @exception StandardException Standard exception policy.
137: **/
138: public boolean lockScanCommittedDeletedRow(OpenBTree open_btree,
139: LeafControlRow leaf, DataValueDescriptor[] template,
140: FetchDescriptor lock_fetch_desc, int slot_no)
141: throws StandardException {
142: return (true);
143: }
144:
145: /**
146: * Lock a row as part of doing the scan.
147: * <p>
148: * Lock the row at the given slot (or the previous row if slot is 0).
149: * Get the scan lock on the page if "request_scan_lock" is true.
150: * <p>
151: * If this routine returns true all locks were acquired while maintaining
152: * the latch on leaf. If this routine returns false, locks may or may
153: * not have been acquired, and the routine should be called again after
154: * the client has researched the tree to reget the latch on the
155: * appropriate page.
156: * (p>
157: * As a sided effect stores the value of the record handle of the current
158: * scan lock.
159: *
160: * @return Whether locks were acquired without releasing latch on leaf.
161: *
162: * @param pos The position of the row to lock.
163: * @param request_scan_lock Whether to request the page scan lock, should
164: * only be requested once per page in the scan.
165: *
166: * @exception StandardException Standard exception policy.
167: **/
168: public boolean lockScanRow(OpenBTree open_btree, BTree btree,
169: BTreeRowPosition pos, boolean request_scan_lock,
170: FetchDescriptor lock_fetch_desc,
171: DataValueDescriptor[] lock_template,
172: RowLocation lock_row_loc, boolean previous_key_lock,
173: boolean forUpdate, int lock_operation)
174: throws StandardException {
175: return (true);
176: }
177:
178: /**
179: * Release read lock on a row.
180: *
181: * @param forUpdate Is the scan for update or for read only.
182: *
183: * @exception StandardException Standard exception policy.
184: **/
185: public void unlockScanRecordAfterRead(BTreeRowPosition pos,
186: boolean forUpdate) throws StandardException {
187: return;
188: }
189:
190: /**
191: * Unlock the lock gotten by lockScan().
192: * <p>
193: * See BTree.unlockScan() for more info.
194: *
195: **/
196: public void unlockScan(long page_number) {
197: }
198:
199: /**************************************************************************
200: * Abstract Protected lockNonScan*() locking methods of BTree:
201: *
202: * lockNonScanPreviousRow - lock the row previous to the current
203: * lockNonScanRow - lock the input row
204: **************************************************************************
205: */
206:
207: /**
208: * Lock the row previous to the input row.
209: * <p>
210: * See BTree.lockPreviousRow() for more info.
211: *
212: * @exception StandardException Standard exception policy.
213: **/
214: public boolean lockNonScanPreviousRow(BTree btree,
215: LeafControlRow current_leaf, int current_slot,
216: FetchDescriptor lock_fetch_desc,
217: DataValueDescriptor[] lock_template,
218: RowLocation lock_row_loc, OpenBTree open_btree,
219: int lock_operation, int lock_duration)
220: throws StandardException {
221: return (true);
222: }
223:
224: /**
225: * Lock the in memory row.
226: * <p>
227: * See BTree.lockRow() for more info.
228: *
229: * @exception StandardException Standard exception policy.
230: **/
231: public boolean lockNonScanRow(BTree btree,
232: LeafControlRow current_leaf, LeafControlRow aux_leaf,
233: DataValueDescriptor[] current_row, int lock_operation)
234: throws StandardException {
235: return (true);
236: }
237:
238: public boolean lockNonScanRowOnPage(BTree btree,
239: LeafControlRow current_leaf, int current_slot,
240: FetchDescriptor lock_fetch_desc,
241: DataValueDescriptor[] lock_template,
242: RowLocation lock_row_loc, int lock_operation)
243: throws StandardException {
244: return (true);
245: }
246: }
|