db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r557507 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree: BTreeLockingPolicy.java BTreeMaxScan.java BTreeRowPosition.java BTreeScan.java OpenBTree.java index/B2INoLocking.java index/B2IRowLocking3.java
Date Thu, 19 Jul 2007 07:19:14 GMT
Author: kahatlen
Date: Thu Jul 19 00:19:13 2007
New Revision: 557507

URL: http://svn.apache.org/viewvc?view=rev&rev=557507
Log:
DERBY-2878: Scan protection handle could be cached in BasePage

Don't allocate a new RecordHandle and PageKey in unlockScan().

  1) Replaced the field current_scan_pageno (a long) in
     BTreeRowPosition with current_scan_protectionHandle (a
     RecordHandle which is cached in BasePage)

  2) Changed the signature of BTreeLockingPolicy.unlockScan() to take
     a RecordHandle

  3) Removed unused method OpenBTree.makeRecordHandle()

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeLockingPolicy.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeMaxScan.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeRowPosition.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScan.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2INoLocking.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeLockingPolicy.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeLockingPolicy.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeLockingPolicy.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeLockingPolicy.java
Thu Jul 19 00:19:13 2007
@@ -24,6 +24,7 @@
 import org.apache.derby.iapi.error.StandardException; 
 
 import org.apache.derby.iapi.store.raw.FetchDescriptor;
+import org.apache.derby.iapi.store.raw.RecordHandle;
 
 import org.apache.derby.iapi.types.DataValueDescriptor;
 import org.apache.derby.iapi.types.RowLocation;
@@ -253,10 +254,12 @@
      * end of transaction.
      * <p>
      *
-     * @param page_number   page number of page that lockScan was called on.
+     * @param protectionHandle a <code>RecordHandle</code> that, when locked,
+     * protects all the record ids on a page
+     * @see RecordHandle#RECORD_ID_PROTECTION_HANDLE
      *
      **/
-    abstract public void unlockScan(long page_number);
+    abstract public void unlockScan(RecordHandle protectionHandle);
 
 
     /**************************************************************************

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeMaxScan.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeMaxScan.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeMaxScan.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeMaxScan.java
Thu Jul 19 00:19:13 2007
@@ -285,7 +285,7 @@
             SanityManager.ASSERT(this.scan_state          == SCAN_INIT);
             SanityManager.ASSERT(pos.current_rh          == null);
             SanityManager.ASSERT(pos.current_positionKey         == null);
-            SanityManager.ASSERT(pos.current_scan_pageno == 0);
+            SanityManager.ASSERT(pos.current_scan_protectionHandle == null);
         }
 
         // Loop until you can lock the row previous to the first row to be
@@ -363,7 +363,8 @@
         }
 
         this.scan_state          = SCAN_INPROGRESS;
-        pos.current_scan_pageno = pos.current_leaf.page.getPageNumber();
+        pos.current_scan_protectionHandle =
+            pos.current_leaf.page.getProtectionRecordHandle();
 
         if (SanityManager.DEBUG)
             SanityManager.ASSERT(pos.current_leaf != null);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeRowPosition.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeRowPosition.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeRowPosition.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeRowPosition.java
Thu Jul 19 00:19:13 2007
@@ -25,6 +25,7 @@
 import org.apache.derby.iapi.services.sanity.SanityManager;
 
 import org.apache.derby.iapi.store.raw.Page;
+import org.apache.derby.iapi.store.raw.RecordHandle;
 
 import org.apache.derby.iapi.store.access.RowUtil;
 
@@ -45,7 +46,7 @@
      **************************************************************************
      */
     public    DataValueDescriptor[] current_positionKey;
-    public    long                  current_scan_pageno;
+    public    RecordHandle          current_scan_protectionHandle;
     public    LeafControlRow        current_leaf;
     protected LeafControlRow        next_leaf;
     public    DataValueDescriptor[] current_lock_template;
@@ -97,7 +98,8 @@
                 super.toString() + 
                 "current_positionKey = " + current_positionKey + 
                 ";key = " + RowUtil.toString(current_positionKey) + 
-                ";current_scan_pageno" + current_scan_pageno + 
+                ";current_scan_protectionHandle" +
+                current_scan_protectionHandle +
                 ";next_leaf" + next_leaf + 
                 ";current_leaf" + current_leaf;
         }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScan.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScan.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScan.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/BTreeScan.java
Thu Jul 19 00:19:13 2007
@@ -348,7 +348,7 @@
                 (scan_state == SCAN_INIT) || (scan_state == SCAN_HOLD_INIT));
             SanityManager.ASSERT(pos.current_rh          == null);
             SanityManager.ASSERT(pos.current_positionKey == null);
-            SanityManager.ASSERT(pos.current_scan_pageno == 0);
+            SanityManager.ASSERT(pos.current_scan_protectionHandle == null);
         }
 
         // Loop until you can lock the row previous to the first row to be
@@ -481,7 +481,8 @@
         }
 
         this.scan_state         = SCAN_INPROGRESS;
-        pos.current_scan_pageno = pos.current_leaf.page.getPageNumber();
+        pos.current_scan_protectionHandle =
+            pos.current_leaf.page.getProtectionRecordHandle();
 		pos.current_slot        = pos.current_slot;
 
         if (SanityManager.DEBUG)
@@ -514,7 +515,7 @@
 
             SanityManager.ASSERT(pos.current_rh          == null);
             SanityManager.ASSERT(pos.current_positionKey         == null);
-            SanityManager.ASSERT(pos.current_scan_pageno == 0);
+            SanityManager.ASSERT(pos.current_scan_protectionHandle == null);
         }
 
         // Loop until you can lock the row previous to the first row to be
@@ -639,7 +640,8 @@
         }
 
         this.scan_state          = SCAN_INPROGRESS;
-        pos.current_scan_pageno = pos.current_leaf.page.getPageNumber();
+        pos.current_scan_protectionHandle =
+            pos.current_leaf.page.getProtectionRecordHandle();
 
         if (SanityManager.DEBUG)
             SanityManager.ASSERT(pos.current_leaf != null);
@@ -668,7 +670,7 @@
         // assert may not be true, but for now we always have the scan
         // lock when we call this routine.
         if (SanityManager.DEBUG)
-            SanityManager.ASSERT(pos.current_scan_pageno != 0);
+            SanityManager.ASSERT(pos.current_scan_protectionHandle != null);
 
         while (true)
         {
@@ -705,10 +707,13 @@
         // there is no next leaf we can release scan and latch on current page.
         if (SanityManager.DEBUG)
         {
-			if (pos.current_scan_pageno != pos.current_leaf.page.getPageNumber())
+			if (pos.current_scan_protectionHandle.getPageNumber() !=
+                         pos.current_leaf.page.getPageNumber()) {
 				SanityManager.THROWASSERT(
-                "pos.current_scan_pageno = " + pos.current_scan_pageno +
+                "pos.current_scan_protectionHandle = " +
+                pos.current_scan_protectionHandle +
                 "pos.current_leaf = " + pos.current_leaf);
+            }
         }
 
         // unlock the previous row if doing read.
@@ -722,8 +727,9 @@
         pos.current_leaf.release();
         pos.current_leaf        = pos.next_leaf;
 
-        pos.current_scan_pageno = 
-            (pos.next_leaf == null) ? 0 : pos.next_leaf.page.getPageNumber();
+        pos.current_scan_protectionHandle =
+            (pos.current_leaf == null) ?
+            null : pos.current_leaf.page.getProtectionRecordHandle();
 
         // set up for scan to continue at beginning of next page.
         pos.current_slot        = Page.FIRST_SLOT_NUMBER;
@@ -1065,7 +1071,7 @@
         {
             // Reposition to remembered spot on page.
             if (SanityManager.DEBUG)
-                SanityManager.ASSERT(pos.current_scan_pageno != 0);
+                SanityManager.ASSERT(pos.current_scan_protectionHandle != null);
 
             pos.current_leaf = (LeafControlRow)
                 ControlRow.get(this, pos.current_rh.getPageNumber());
@@ -1078,7 +1084,7 @@
             // assert may not be true, but for now we always release the 
             // scan lock when we save the row away as the current position.
             if (SanityManager.DEBUG)
-                SanityManager.ASSERT(pos.current_scan_pageno == 0);
+                SanityManager.ASSERT(pos.current_scan_protectionHandle == null);
 
             SearchParameters sp =
                 new SearchParameters(
@@ -1136,7 +1142,8 @@
 
             } while (latch_released);
 
-            pos.current_scan_pageno = pos.current_leaf.page.getPageNumber();
+            pos.current_scan_protectionHandle =
+                pos.current_leaf.page.getProtectionRecordHandle();
             pos.current_slot        = sp.resultSlot;
             pos.current_positionKey = null;
         }
@@ -1150,9 +1157,9 @@
      * @param pos position of the scan
      */
     private void unlockCurrentScan(BTreeRowPosition pos) {
-        if (pos.current_scan_pageno != 0L) {
-            getLockingPolicy().unlockScan(pos.current_scan_pageno);
-            pos.current_scan_pageno = 0L;
+        if (pos.current_scan_protectionHandle != null) {
+            getLockingPolicy().unlockScan(pos.current_scan_protectionHandle);
+            pos.current_scan_protectionHandle = null;
         }
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/OpenBTree.java
Thu Jul 19 00:19:13 2007
@@ -577,16 +577,6 @@
         }
     }
 
-    public RecordHandle makeRecordHandle(
-    long    page_number,
-    int     rec_id)
-        throws StandardException
-    {
-        return(
-            container.makeRecordHandle(
-                page_number, rec_id));
-    }
-
     /**
      * Dump information about tree into the log.
      * <p>
@@ -656,7 +646,7 @@
                     if (release_scan_lock)
                     {
                         btree_locking_policy.unlockScan(
-                            leaf.page.getPageNumber());
+                            leaf.page.getProtectionRecordHandle());
                     }
                     leaf.release();
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2INoLocking.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2INoLocking.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2INoLocking.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2INoLocking.java
Thu Jul 19 00:19:13 2007
@@ -28,6 +28,7 @@
 
 import org.apache.derby.iapi.store.raw.FetchDescriptor;
 import org.apache.derby.iapi.store.raw.LockingPolicy;
+import org.apache.derby.iapi.store.raw.RecordHandle;
 import org.apache.derby.iapi.store.raw.Transaction;
 
 import org.apache.derby.iapi.types.DataValueDescriptor;
@@ -215,8 +216,7 @@
      * See BTree.unlockScan() for more info.
      *
      **/
-    public void unlockScan(
-    long    page_number)
+    public void unlockScan(RecordHandle protectionHandle)
     {
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java?view=diff&rev=557507&r1=557506&r2=557507
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java
Thu Jul 19 00:19:13 2007
@@ -861,17 +861,12 @@
      * See BTree.unlockScan() for more info.
      *
      **/
-    public void unlockScan(
-    long            page_number)
+    public void unlockScan(RecordHandle scan_lock_rh)
     {
         // This is first row in table, lock the special key that 
         // represents the key previous to the first key of the table.
         try
         {
-            RecordHandle scan_lock_rh = 
-                open_btree.makeRecordHandle(
-                    page_number, RecordHandle.RECORD_ID_PROTECTION_HANDLE);
-
             scan_locking_policy.unlockRecordAfterRead(
                 rawtran, open_btree.getContainerHandle(), 
                 scan_lock_rh, false, true);



Mime
View raw message