Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 35407 invoked from network); 29 Jun 2007 16:03:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Jun 2007 16:03:44 -0000 Received: (qmail 7948 invoked by uid 500); 29 Jun 2007 16:03:47 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 7908 invoked by uid 500); 29 Jun 2007 16:03:47 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 7879 invoked by uid 99); 29 Jun 2007 16:03:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jun 2007 09:03:47 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jun 2007 09:03:42 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 28F7A1A981A; Fri, 29 Jun 2007 09:03:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r551933 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/store/raw/Page.java impl/store/access/btree/index/B2IRowLocking3.java impl/store/raw/data/BasePage.java Date: Fri, 29 Jun 2007 16:03:21 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070629160322.28F7A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Fri Jun 29 09:03:21 2007 New Revision: 551933 URL: http://svn.apache.org/viewvc?view=rev&rev=551933 Log: DERBY-2878 (partial) Scan protection handle could be cached in BasePage This patch is the first step towards eliminating the allocation of protection handles. It adds a method to Page/BasePage called getProtectionRecordHandle(). This method creates a new record handle if it hasn't been called before and returns a cached value otherwise. B2IRowLocking3.lockScan() and lockScanForReclaimSpace() have been modified to use the new method. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Page.java db/derby/code/trunk/java/engine/org/apache/derby/impl/store/access/btree/index/B2IRowLocking3.java db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Page.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Page.java?view=diff&rev=551933&r1=551932&r2=551933 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Page.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/raw/Page.java Fri Jun 29 09:03:21 2007 @@ -139,6 +139,14 @@ public RecordHandle getInvalidRecordHandle(); /** + * Get a record id protection handle. + * + * @return a record id protection handle + * @see RecordHandle#RECORD_ID_PROTECTION_HANDLE + */ + public RecordHandle getProtectionRecordHandle(); + + /** * Return a record handle for the given constant record id. *

* Return a record handle that doesn't represent a record but rather has 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=551933&r1=551932&r2=551933 ============================================================================== --- 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 Fri Jun 29 09:03:21 2007 @@ -665,8 +665,7 @@ // The scan page lock is implemented as a row lock on the reserved // row id on the page (RecordHandle.RECORD_ID_PROTECTION_HANDLE). RecordHandle scan_lock_rh = - current_leaf.getPage().makeRecordHandle( - RecordHandle.RECORD_ID_PROTECTION_HANDLE); + current_leaf.getPage().getProtectionRecordHandle(); // First try to get the lock NOWAIT, while latch is held. boolean ret_status = @@ -730,8 +729,7 @@ // The scan page lock is implemented as a row lock on the reserved // row id on the page (RecordHandle.RECORD_ID_PROTECTION_HANDLE). RecordHandle scan_lock_rh = - current_leaf.getPage().makeRecordHandle( - RecordHandle.RECORD_ID_PROTECTION_HANDLE); + current_leaf.getPage().getProtectionRecordHandle(); // First try to get the lock NOWAIT, while latch is held. return( Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java?view=diff&rev=551933&r1=551932&r2=551933 ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/BasePage.java Fri Jun 29 09:03:21 2007 @@ -106,6 +106,13 @@ private int recordCount; /** + * A record handle that, when locked, protects all the record ids on the + * page. + * @see RecordHandle#RECORD_ID_PROTECTION_HANDLE + */ + private RecordId protectionHandle; + + /** Page owner during exclusive access. MT - mutable : single thread required, provided by Lockable single thread required. @@ -219,6 +226,7 @@ { setAuxObject(null); identity = null; + protectionHandle = null; recordCount = 0; clearLastLogInstant(); @@ -260,6 +268,7 @@ protected void fillInIdentity(PageKey key) { if (SanityManager.DEBUG) { SanityManager.ASSERT(identity == null); + SanityManager.ASSERT(protectionHandle == null); } identity = key; @@ -283,6 +292,7 @@ protected void cleanPageForReuse() { setAuxObject(null); + protectionHandle = null; recordCount = 0; } @@ -309,6 +319,29 @@ // a static invalid record handle return InvalidRecordHandle; } + + /** + * Get the record id protection handle for the page. + * + * @return protection handle + * @see RecordHandle#RECORD_ID_PROTECTION_HANDLE + */ + public final RecordHandle getProtectionRecordHandle() { + // only allocate a new handle the first time the method is called + if (protectionHandle == null) { + protectionHandle = + new RecordId(getPageId(), + RecordHandle.RECORD_ID_PROTECTION_HANDLE); + } + + if (SanityManager.DEBUG) { + SanityManager.ASSERT( + getPageId().equals(protectionHandle.getPageId()), + "PageKey for cached protection handle doesn't match identity"); + } + + return protectionHandle; + } public static final RecordHandle MakeRecordHandle(PageKey pkey, int recordHandleConstant) throws StandardException