Author: vgritsenko
Date: Fri Mar 16 18:34:14 2007
New Revision: 519202

URL: http://svn.apache.org/viewvc?view=rev&rev=519202
Log:
more cleanup

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java
    xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Paged.java
    xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/NameIndexer.java
    xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/ValueIndexer.java

Modified: 
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java
URL: 
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java?view=diff&rev=519202&r1=519201&r2=519202
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java 
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java Fri 
Mar 16 18:34:14 2007
@@ -150,11 +150,11 @@
     }
 
     private Page seekInsertionPage(Key key) throws IOException {
+        // Calculate hash and retrieve chain head page
         int hash = key.getHash();
-        long pageNum = hash % fileHeader.getPageCount();
+        Page p = getPage(hash % fileHeader.getPageCount());
 
         // Synchronize by chain head page
-        Page p = getPage(pageNum);
         synchronized (p) {
             HashPageHeader ph;
             while (true) {
@@ -165,7 +165,7 @@
                     break;
                 }
 
-                pageNum = ph.getNextCollision();
+                long pageNum = ph.getNextCollision();
                 if (pageNum == NO_PAGE) {
                     // Reached end of chain, add new page
                     Page np = getFreePage();
@@ -419,6 +419,11 @@
         public synchronized long getTotalBytes() {
             return totalBytes;
         }
+
+        /** Adjust total number of bytes in use by the file */
+        public synchronized void addTotalBytes(int count) {
+            totalBytes += count;
+        }
     }
 
     /**
@@ -456,7 +461,7 @@
         }
 
         public synchronized void setRecordLen(int recordLen) {
-            fileHeader.setTotalBytes((fileHeader.totalBytes - getRecordLen()) 
+ recordLen);
+            fileHeader.addTotalBytes(recordLen - getRecordLen());
             super.setRecordLen(recordLen);
         }
 

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?view=diff&rev=519202&r1=519201&r2=519202
==============================================================================
--- 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 Fri Mar 
16 18:34:14 2007
@@ -1097,7 +1097,7 @@
         private int keyHash;
         private int dataLen;
         private int recordLen;
-        private long nextPage = -1;
+        private long nextPage = NO_PAGE;
 
         public PageHeader() {
         }
@@ -1339,11 +1339,11 @@
         }
 
         public synchronized Key getKey() {
-            if (header.keyLen > 0) {
-                return new Key(this.data, this.keyPos, header.keyLen);
+            if (header.keyLen == 0) {
+                return null;
             }
 
-            return null;
+            return new Key(this.data, this.keyPos, header.keyLen);
         }
 
         public synchronized void streamTo(OutputStream os) throws IOException {
@@ -1365,7 +1365,7 @@
 
         // No synchronization: pageNum is final.
         public int compareTo(Object o) {
-            return (int) (this.pageNum.longValue() - ((Page) 
o).pageNum.longValue());
+            return (int) (pageNum.longValue() - ((Page) 
o).pageNum.longValue());
         }
     }
 }

Modified: 
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/NameIndexer.java
URL: 
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/NameIndexer.java?view=diff&rev=519202&r1=519201&r2=519202
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/NameIndexer.java 
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/NameIndexer.java 
Fri Mar 16 18:34:14 2007
@@ -57,7 +57,7 @@
 
     private String name;
     private String pattern;
-    private boolean wildcard = false;
+    private boolean wildcard;
 
 
     public NameIndexer() {
@@ -121,10 +121,6 @@
         } catch (IOException e) {
             throw new BTreeCorruptException("Corruption detected on add", e);
         }
-    }
-
-    public void flush() throws DBException {
-        super.flush();
     }
 
     public IndexMatch[] queryMatches(final IndexQuery query) throws 
DBException {

Modified: 
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/ValueIndexer.java
URL: 
http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/ValueIndexer.java?view=diff&rev=519202&r1=519201&r2=519202
==============================================================================
--- 
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/ValueIndexer.java 
(original)
+++ 
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/ValueIndexer.java 
Fri Mar 16 18:34:14 2007
@@ -398,10 +398,6 @@
         }
     }
 
-    public void flush() throws DBException {
-        super.flush();
-    }
-
     public IndexMatch[] queryMatches(final IndexQuery query) throws 
DBException {
         // Pre-process the value-set for typing and trimming
         if (type != STRING) {


Reply via email to