svn commit: r712683 - /xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java

[email protected]
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
Author: natalia
Date: Mon Nov 10 07:54:38 2008
New Revision: 712683

URL: http://svn.apache.org/viewvc?rev=712683&view=rev
Log:
Do not read page from disk when getting new free page

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java

Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java?rev=712683&r1=712682&r2=712683&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java Mon Nov 10 07:54:38 2008
@@ -338,6 +338,14 @@
      * @throws IOException if an Exception occurs
      */
     protected final Page getPage(long pageNum) throws IOException {
+        Page p = updateIdentityMap(pageNum);
+
+        // Load the page from disk if necessary
+        p.read();
+        return p;
+    }
+
+    private Page updateIdentityMap(long pageNum) {
         final PageKey k = new PageKey(pageNum);
         Page p = null;
         synchronized (pagesLock) {
@@ -357,8 +365,6 @@
             }
         }
 
-        // Load the page from disk if necessary
-        p.read();
         return p;
     }
 
@@ -544,7 +550,12 @@
 
         if (p == null) {
             // No deleted pages, grow the file
-            p = getPage(fileHeader.incTotalCount());
+            p = updateIdentityMap(fileHeader.incTotalCount());
+
+            // initialize page
+            p.data = new byte[fileHeader.pageSize];
+            p.keyPos = fileHeader.pageHeaderSize;
+            p.dataPos = p.keyPos + p.header.keyLen;
         }
 
         // Initialize The Page Header (Cleanly)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.