Author: vgritsenko Date: Tue Oct 24 19:24:31 2006 New Revision: 467541 URL: http://svn.apache.org/viewvc?view=rev&rev=467541 Log: <action dev="VG" type="fix"> HashFiler did not allocate root page correctly. </action> <action dev="VG" type="fix"> BTreeFiler did not use first pagecount pages due to bug introduced in 1.1b4. </action>
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java 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/status.xml Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java?view=diff&rev=467541&r1=467540&r2=467541 ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTree.java Tue Oct 24 19:24:31 2006 @@ -114,11 +114,15 @@ try { // Don't call this.open() as it will try to read rootNode from the disk super.open(); - long p = fileHeader.getRootPage(); - rootInfo = new BTreeRootInfo(p); + + Page p = getFreePage(); + long pn = p.getPageNum().longValue(); + fileHeader.setRootPage(pn); + + rootInfo = new BTreeRootInfo(pn); // Initialize root node - rootNode = new BTreeNode(getPage(p), null, new Value[0], new long[0]); + rootNode = new BTreeNode(p, null, new Value[0], new long[0]); rootNode.ph.setStatus(LEAF); rootNode.write(); synchronized (cache) { 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=467541&r1=467540&r2=467541 ============================================================================== --- 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 Tue Oct 24 19:24:31 2006 @@ -44,8 +44,7 @@ * quite a bit more flexibility in its ability to retreive blocks of * data and allocate Record space. * - * @deprecated This class has been temporarily (maybe indefinitely) - * deprecated by BTreeFiler. + * @deprecated This class has been temporarily deprecated by BTreeFiler. * @version CVS $Revision$, $Date$ */ public final class HashFiler extends Paged implements Filer { @@ -80,7 +79,9 @@ } public boolean create() throws DBException { - fileHeader.setPageCount(getConfig().getLongAttribute(PAGECOUNT, fileHeader.getPageCount())); + fileHeader.setPageCount(getConfig().getLongAttribute(PAGECOUNT, + fileHeader.getPageCount())); + fileHeader.setTotalCount(fileHeader.getPageCount()); return super.create(); } @@ -89,9 +90,8 @@ long pageNum = hash % fileHeader.getPageCount(); Page p = getPage(pageNum); synchronized (p) { - HashPageHeader ph = null; while (true) { - ph = (HashPageHeader) p.getPageHeader(); + HashPageHeader ph = (HashPageHeader) p.getPageHeader(); if (ph.getStatus() == RECORD && ph.getKeyHash() == key.getHash() && p.getKey().equals(key)) { return p; } @@ -226,7 +226,7 @@ Page page = getPage(pageNum); synchronized(page) { HashPageHeader prevHead = null; - HashPageHeader pageHead = null; + HashPageHeader pageHead; Page prev = null; while (true) { @@ -288,13 +288,11 @@ public HashFilerRecordSet() { try { - Page p = null; - HashPageHeader ph = null; long pageNum = 0; while (pageNum < fileHeader.getTotalCount()) { - p = getPage(pageNum); - ph = (HashPageHeader) p.getPageHeader(); + Page p = getPage(pageNum); + HashPageHeader ph = (HashPageHeader) p.getPageHeader(); if (ph.getStatus() == RECORD) { keys.add(p.getKey()); } 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=467541&r1=467540&r2=467541 ============================================================================== --- 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 Tue Oct 24 19:24:31 2006 @@ -586,7 +586,7 @@ RandomAccessFile raf = null; try { raf = getDescriptor(); - long o = fileHeader.headerSize + (fileHeader.totalCount + 1) * fileHeader.pageSize - 1; + long o = fileHeader.headerSize + (fileHeader.pageCount + 1) * fileHeader.pageSize - 1; raf.seek(o); raf.write(0); } finally { @@ -904,7 +904,7 @@ public FileHeader(long pageCount, int pageSize) { this.pageSize = pageSize; this.pageCount = pageCount; - this.totalCount = pageCount; + this.totalCount = 0; this.headerSize = (short) 4096; calculateWorkSize(); } Modified: xml/xindice/trunk/status.xml URL: http://svn.apache.org/viewvc/xml/xindice/trunk/status.xml?view=diff&rev=467541&r1=467540&r2=467541 ============================================================================== --- xml/xindice/trunk/status.xml (original) +++ xml/xindice/trunk/status.xml Tue Oct 24 19:24:31 2006 @@ -74,10 +74,17 @@ <changes> <release version="1.1b5-dev" date="Oct 24 2006"> + <action dev="VG" type="fix"> + HashFiler did not allocate root page correctly. + </action> + <action dev="VG" type="fix"> + BTreeFiler did not use first pagecount pages due to bug + introduced in 1.1b4. + </action> <action dev="VG" type="update"> Implement DOM3 API compatibility. </action> - <action dev="VG" type="fix" fixes-bug="31159"> + <action dev="VG" type="fix"> Data files were created 6Mb in size instead of 4Mb (default value). </action> <action dev="VG" type="fix" fixes-bug="37383" due-to="Terry Rosenbaum">