summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-04-10 15:04:40 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-04-10 15:04:40 +0000
commit4a3fcb78f11e4b1a29bb790e4c9c13e104505cfe (patch)
treeda1f92f109f48fa0eecd8ac67c029ce75b1a1a0d
parenta384c7f87e826891249b2e0f4630b35c5f289460 (diff)
downloadjackcess-4a3fcb78f11e4b1a29bb790e4c9c13e104505cfe.tar.gz
jackcess-4a3fcb78f11e4b1a29bb790e4c9c13e104505cfe.zip
add code to dump page cache to string
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@321 f203690c-595d-4dc9-a70b-905162fa7fd2
-rwxr-xr-xsrc/java/com/healthmarketscience/jackcess/BigIndex.java5
-rw-r--r--src/java/com/healthmarketscience/jackcess/IndexPageCache.java33
2 files changed, 37 insertions, 1 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/BigIndex.java b/src/java/com/healthmarketscience/jackcess/BigIndex.java
index c4bc60d..20310e6 100755
--- a/src/java/com/healthmarketscience/jackcess/BigIndex.java
+++ b/src/java/com/healthmarketscience/jackcess/BigIndex.java
@@ -70,5 +70,10 @@ public class BigIndex extends Index {
{
return _pageCache.getCacheDataPage(pageNumber);
}
+
+ @Override
+ public String toString() {
+ return super.toString() + "\n" + _pageCache.toString();
+ }
}
diff --git a/src/java/com/healthmarketscience/jackcess/IndexPageCache.java b/src/java/com/healthmarketscience/jackcess/IndexPageCache.java
index e7ada2e..e5faa5c 100644
--- a/src/java/com/healthmarketscience/jackcess/IndexPageCache.java
+++ b/src/java/com/healthmarketscience/jackcess/IndexPageCache.java
@@ -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>
{