Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 39418 invoked from network); 4 Apr 2008 22:25:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Apr 2008 22:25:14 -0000 Received: (qmail 62300 invoked by uid 500); 4 Apr 2008 22:25:14 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 62132 invoked by uid 500); 4 Apr 2008 22:25:13 -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 62105 invoked by uid 99); 4 Apr 2008 22:25:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Apr 2008 15:25:13 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED 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, 04 Apr 2008 22:24:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6ABEB1A983A; Fri, 4 Apr 2008 15:24:46 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r644961 - in /db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data: AllocPage.java CachedPage.java FileContainer.java PageCreationArgs.java StoredPage.java Date: Fri, 04 Apr 2008 22:24:43 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080404222446.6ABEB1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Fri Apr 4 15:24:41 2008 New Revision: 644961 URL: http://svn.apache.org/viewvc?rev=644961&view=rev Log: DERBY-3589: AllocPage.createPage() doesn't initialize minimumRecordSize correctly Merged fix from trunk (revision 644620). Added: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/PageCreationArgs.java - copied unchanged from r644620, db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/PageCreationArgs.java Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java?rev=644961&r1=644960&r2=644961&view=diff ============================================================================== --- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java (original) +++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/AllocPage.java Fri Apr 4 15:24:41 2008 @@ -270,22 +270,13 @@ * * @exception StandardException Standard exception policy. **/ - protected void createPage(PageKey newIdentity, int[] args) + protected void createPage(PageKey newIdentity, PageCreationArgs args) throws StandardException { super.createPage(newIdentity, args); - // args[0] is the format id - // args[1] is whether to sync the page to disk or not - // args[2] is the pagesize (used by StoredPage) - // args[3] is the spareSize (used by StoredPage) - // args[4] is the number of bytes to reserve for container header - // args[5] is the minimumRecordSize - // NOTE: the arg list here must match the one in FileContainer - int pageSize = args[2]; - int minimumRecordSize = args[5]; - borrowedSpace = args[4]; + borrowedSpace = args.containerInfoSize; if (SanityManager.DEBUG) { @@ -321,7 +312,7 @@ // the pages this extent is going to manage starts from pageNum+1 // starting physical offset is pageSize*(pageNum+1) since we have // no logical to physical mapping yet... - extent = createExtent(newIdentity.getPageNumber()+1, pageSize, 0 /* pagesAlloced */, maxSpace); + extent = createExtent(newIdentity.getPageNumber()+1, getPageSize(), 0 /* pagesAlloced */, maxSpace); } private AllocExtent createExtent(long pageNum, int pageSize, int pagesAlloced, int availspace) Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java?rev=644961&r1=644960&r2=644961&view=diff ============================================================================== --- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java (original) +++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/CachedPage.java Fri Apr 4 15:24:41 2008 @@ -256,9 +256,10 @@ PageKey newIdentity = (PageKey) key; - int[] createArgs = (int[]) createParameter; + PageCreationArgs createArgs = (PageCreationArgs) createParameter; + int formatId = createArgs.formatId; - if (createArgs[0] == -1) + if (formatId == -1) { throw StandardException.newException( SQLState.DATA_UNKNOWN_PAGE_FORMAT, newIdentity); @@ -267,10 +268,10 @@ // createArgs[0] contains the integer form of the formatId // if it is not the same as this instance's formatId, instantiate the // real page object - if (createArgs[0] != getTypeFormatId()) + if (formatId != getTypeFormatId()) { return( - changeInstanceTo(createArgs[0], newIdentity).createIdentity( + changeInstanceTo(formatId, newIdentity).createIdentity( key, createParameter)); } @@ -296,22 +297,23 @@ * will be a SYNC call after all the pages are preallocated * 0 means creating a page that has already been preallocated. */ - if ((createArgs[1] & WRITE_SYNC) != 0 || - (createArgs[1] & WRITE_NO_SYNC) != 0) - writePage(newIdentity, (createArgs[1] & WRITE_SYNC) != 0); + int syncFlag = createArgs.syncFlag; + if ((syncFlag & WRITE_SYNC) != 0 || + (syncFlag & WRITE_NO_SYNC) != 0) + writePage(newIdentity, (syncFlag & WRITE_SYNC) != 0); if (SanityManager.DEBUG) { if (SanityManager.DEBUG_ON(FileContainer.SPACE_TRACE)) { - String syncFlag = - ((createArgs[1] & WRITE_SYNC) != 0) ? "Write_Sync" : - (((createArgs[1] & WRITE_NO_SYNC) != 0) ? "Write_NO_Sync" : + String sync = + ((syncFlag & WRITE_SYNC) != 0) ? "Write_Sync" : + (((syncFlag & WRITE_NO_SYNC) != 0) ? "Write_NO_Sync" : "No_write"); SanityManager.DEBUG( FileContainer.SPACE_TRACE, - "creating new page " + newIdentity + " with " + syncFlag); + "creating new page " + newIdentity + " with " + sync); } } @@ -900,7 +902,7 @@ // create the page - protected abstract void createPage(PageKey id, int[] args) + protected abstract void createPage(PageKey id, PageCreationArgs args) throws StandardException; // page is about to be written, write everything to pageData array Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java?rev=644961&r1=644960&r2=644961&view=diff ============================================================================== --- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java (original) +++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/FileContainer.java Fri Apr 4 15:24:41 2008 @@ -290,12 +290,6 @@ CONTAINER_FORMAT_ID_SIZE+4+4+4+4+2+2+8+8+8+8+CHECKSUM_SIZE+8+8; /** - the number of arguments we need to pass to alloc page for create - */ - protected static final int STORED_PAGE_ARG_NUM = 5; - protected static final int ALLOC_PAGE_ARG_NUM = 6; - - /** * where the first alloc page is located - * the logical page number and the physical page offset * NOTE if it is not 0 this is not going to work for Stream @@ -1768,13 +1762,13 @@ // 2'nd element is pagesize // 3'rd element is spareSpace - int[] createPageArgs = new int[STORED_PAGE_ARG_NUM]; - createPageArgs[0] = StoredPage.FORMAT_NUMBER; - createPageArgs[1] = prealloced ? - 0 : (noIO ? 0 : CachedPage.WRITE_SYNC); - createPageArgs[2] = pageSize; - createPageArgs[3] = spareSpace; - createPageArgs[4] = minimumRecordSize; + PageCreationArgs createPageArgs = new PageCreationArgs( + StoredPage.FORMAT_NUMBER, + prealloced ? 0 : (noIO ? 0 : CachedPage.WRITE_SYNC), + pageSize, + spareSpace, + minimumRecordSize, + 0 /* containerInfoSize - unused for StoredPage */); // RESOLVE: right now, there is no re-mapping of pages, so // pageOffset = pageNumber*pageSize @@ -1797,7 +1791,7 @@ SanityManager.DEBUG_PRINT("FileContainer", "got exception from initPage:" + "\nreuse = " + reuse + - "\ncreatePageArgs[1] = " + createPageArgs[1] + + "\nsyncFlag = " + createPageArgs.syncFlag + "\nallocPage = " + allocPage ); } @@ -2223,13 +2217,13 @@ boolean noIO = (handle.getMode() & ContainerHandle.MODE_UNLOGGED) == ContainerHandle.MODE_UNLOGGED; - int[] createAllocPageArgs = new int[ALLOC_PAGE_ARG_NUM]; - createAllocPageArgs[0] = AllocPage.FORMAT_NUMBER; - createAllocPageArgs[1] = noIO ? 0 : CachedPage.WRITE_SYNC; - createAllocPageArgs[2] = pageSize; - createAllocPageArgs[3] = 0; // allocation page has no need for spare - createAllocPageArgs[4] = containerInfoSize; - createAllocPageArgs[5] = minimumRecordSize; + PageCreationArgs createAllocPageArgs = new PageCreationArgs( + AllocPage.FORMAT_NUMBER, + noIO ? 0 : CachedPage.WRITE_SYNC, + pageSize, + 0, // allocation page has no need for spare + minimumRecordSize, + containerInfoSize); if (SanityManager.DEBUG) { @@ -2271,7 +2265,7 @@ @param allochandle the contianer handle to initialize the page with - the ntt @param pkey the page number of the page to be initialized - @param createArgs the int array for page creation + @param createArgs the arguments for page creation @param reuse is true if we are reusing a page that has already been initialized once @@ -2279,7 +2273,7 @@ */ protected BasePage initPage(BaseContainerHandle allochandle, PageKey pkey, - int[] createArgs, + PageCreationArgs createArgs, long pageOffset, boolean reuse, boolean overflow) throws StandardException @@ -2553,20 +2547,20 @@ // no address translation necessary PageKey pkey = new PageKey(identity, pageNumber); - int[] reCreatePageArgs = null; + PageCreationArgs reCreatePageArgs; if (pageFormat == StoredPage.FORMAT_NUMBER) { - reCreatePageArgs = new int[STORED_PAGE_ARG_NUM]; - reCreatePageArgs[0] = pageFormat; - reCreatePageArgs[1] = CachedPage.WRITE_SYNC; - reCreatePageArgs[2] = pageSize; - reCreatePageArgs[3] = spareSpace; - reCreatePageArgs[4] = minimumRecordSize; + reCreatePageArgs = new PageCreationArgs( + pageFormat, + CachedPage.WRITE_SYNC, + pageSize, + spareSpace, + minimumRecordSize, + 0 /* containerInfoSize - unused for StoredPage */); } else if (pageFormat == AllocPage.FORMAT_NUMBER) { - reCreatePageArgs = new int[ALLOC_PAGE_ARG_NUM]; // only the first allocation page have borrowed space for the // container info @@ -2579,13 +2573,14 @@ firstAllocPageOffset = pageOffset; } + reCreatePageArgs = new PageCreationArgs( + pageFormat, + CachedPage.WRITE_SYNC, + pageSize, + 0, // allocation page has no need for spare + minimumRecordSize, + containerInfoSize); - reCreatePageArgs[0] = pageFormat; - reCreatePageArgs[1] = CachedPage.WRITE_SYNC; - reCreatePageArgs[2] = pageSize; - reCreatePageArgs[3] = 0; // allocation page has no need for spare - reCreatePageArgs[4] = containerInfoSize; - reCreatePageArgs[5] = minimumRecordSize; } else { @@ -3251,12 +3246,13 @@ "how can we be Preallocating pages in a read only database?"); // initialize and a new page in cache - int[] createArgs = new int[5]; - createArgs[0] = StoredPage.FORMAT_NUMBER; // default is a stored page - createArgs[1] = CachedPage.WRITE_NO_SYNC; // write it but no sync - createArgs[2] = pageSize; - createArgs[3] = spareSpace; - createArgs[4] = minimumRecordSize; + PageCreationArgs createArgs = new PageCreationArgs( + StoredPage.FORMAT_NUMBER, // default is a stored page + CachedPage.WRITE_NO_SYNC, // write it but no sync + pageSize, + spareSpace, + minimumRecordSize, + 0 /* containerInfoSize - unused for StoredPage */); StoredPage page = new StoredPage(); page.setFactory(dataFactory); Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java?rev=644961&r1=644960&r2=644961&view=diff ============================================================================== --- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java (original) +++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java Fri Apr 4 15:24:41 2008 @@ -746,23 +746,18 @@ * * @param newIdentity The key describing page (segment,container,page). * @param args information stored about the page, once in the - * container header and passed in through the array. + * container header and passed in through the object. * * @exception StandardException Standard exception policy. **/ - protected void createPage( - PageKey newIdentity, - int[] args) + protected void createPage(PageKey newIdentity, PageCreationArgs args) throws StandardException { - // arg[0] is the formatId of the page - // arg[1] is whether to sync the page to disk or not - int pageSize = args[2]; - spareSpace = args[3]; - minimumRecordSize = args[4]; + spareSpace = args.spareSpace; + minimumRecordSize = args.minimumRecordSize; - setPageArray(pageSize); + setPageArray(args.pageSize); cleanPage(); // clean up the page array