]> source.dussan.org Git - jackcess.git/commitdiff
add code to dump page cache to string
authorJames Ahlborn <jtahlborn@yahoo.com>
Thu, 10 Apr 2008 15:04:40 +0000 (15:04 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Thu, 10 Apr 2008 15:04:40 +0000 (15:04 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@321 f203690c-595d-4dc9-a70b-905162fa7fd2

src/java/com/healthmarketscience/jackcess/BigIndex.java
src/java/com/healthmarketscience/jackcess/IndexPageCache.java

index c4bc60d9f8b3c89a864ce7a8c78e8f77b4685236..20310e6f313e55100dfe2cd939e63841a3c5e7b1 100755 (executable)
@@ -70,5 +70,10 @@ public class BigIndex extends Index {
   {
     return _pageCache.getCacheDataPage(pageNumber);
   }
+
+  @Override
+  public String toString() {
+    return super.toString() + "\n" + _pageCache.toString();
+  }
   
 }
index e7ada2e0b00e57c79872fc3b989bf5e67eed9e0e..e5faa5c3ce827be2b0482ef163b975a9823e511a 100644 (file)
@@ -517,8 +517,10 @@ public class IndexPageCache
 
     DataPageMain parentMain = origMain.getParentPage();
     boolean origWasTail = origMain.isTail();
+    boolean newIsTail = (origWasTail ||
+       ((int)origMain._nextPageNumber == INVALID_INDEX_PAGE_NUMBER));
     CacheDataPage newDataPage = allocateNewCacheDataPage(
-        parentMain._pageNumber, origMain._leaf, origWasTail);
+        parentMain._pageNumber, origMain._leaf, newIsTail);
     DataPageMain newMain = newDataPage._main;
     DataPageExtra newExtra = newDataPage._extra;
     
@@ -796,7 +798,36 @@ public class IndexPageCache
 
     return prefix;
   }
+
+  private void dumpPage(StringBuilder rtn, DataPageMain dpMain) {
+    try {
+      CacheDataPage cacheDataPage = new CacheDataPage(dpMain);
+      rtn.append(cacheDataPage).append("\n");
+      if(!dpMain._leaf) {
+        for(Entry e : cacheDataPage._extra._entries) {
+          DataPageMain childMain = dpMain.getChildPage(e);
+          dumpPage(rtn, childMain);
+        }
+        DataPageMain childTailMain = dpMain.getChildTailPage();
+        if(childTailMain != null) {
+          dumpPage(rtn, childTailMain);
+        }
+      }
+    } catch(IOException e) {
+      rtn.append("Page[" + dpMain._pageNumber + "]: " + e);
+    }
+  }
   
+  @Override
+  public String toString() {
+    if(_rootPage == null) {
+      return "Cache: (uninitialized)";
+    }
+    
+    StringBuilder rtn = new StringBuilder("Cache: \n");
+    dumpPage(rtn, _rootPage);
+    return rtn.toString();
+  }
 
   private class DataPageMain implements Comparable<DataPageMain>
   {