Browse Source

continuing minor refactoring

git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@318 f203690c-595d-4dc9-a70b-905162fa7fd2
tags/rel_1_1_14
James Ahlborn 16 years ago
parent
commit
2c480d7a1b
1 changed files with 51 additions and 30 deletions
  1. 51
    30
      src/java/com/healthmarketscience/jackcess/IndexPageCache.java

+ 51
- 30
src/java/com/healthmarketscience/jackcess/IndexPageCache.java View File

@@ -320,32 +320,12 @@ public class IndexPageCache
}

// remove this page from it's parent page
removeFromParent(cacheDataPage);
removeParentEntry(cacheDataPage);

// remove this page from any next/prev pages
removeFromPeers(cacheDataPage);
}

private void removeFromParent(CacheDataPage childDataPage)
throws IOException
{
DataPageMain childMain = childDataPage._main;

CacheDataPage parentDataPage =
new CacheDataPage(childMain.getParentPage());

setModified(parentDataPage);
DataPageMain parentMain = parentDataPage._main;

if(childMain.isTail()) {
parentMain._childTailPageNumber = INVALID_INDEX_PAGE_NUMBER;
} else {
updateParentEntry(parentDataPage, childDataPage,
childMain._firstEntry, null, UpdateType.REMOVE);
}
}

private void removeFromPeers(CacheDataPage cacheDataPage)
throws IOException
{
@@ -371,18 +351,44 @@ public class IndexPageCache
throws IOException
{
DataPageMain dpMain = cacheDataPage._main;
DataPageExtra dpExtra = cacheDataPage._extra;
if(!dpMain.isRoot()) {
DataPageExtra dpExtra = cacheDataPage._extra;

Entry oldEntry = dpMain._firstEntry;
dpMain._firstEntry = dpExtra.getFirstEntry();
DataPageMain parentMain = dpMain.getParentPage();
if(parentMain != null) {
updateParentEntry(new CacheDataPage(parentMain),
cacheDataPage,
oldEntry, dpMain._firstEntry,
UpdateType.REPLACE);
Entry oldEntry = dpMain._firstEntry;
dpMain._firstEntry = dpExtra.getFirstEntry();
DataPageMain parentMain = dpMain.getParentPage();
replaceParentEntry(new CacheDataPage(parentMain),
cacheDataPage,
oldEntry, dpMain._firstEntry);
}
}

private void removeParentEntry(CacheDataPage childDataPage)
throws IOException
{
DataPageMain childMain = childDataPage._main;
updateParentEntry(new CacheDataPage(childMain.getParentPage()),
childDataPage, childMain._firstEntry,
null, UpdateType.REMOVE);
}
private void addParentEntry(CacheDataPage parentDataPage,
CacheDataPage childDataPage,
Entry newEntry)
throws IOException
{
updateParentEntry(parentDataPage, childDataPage, null, newEntry,
UpdateType.ADD);
}
private void replaceParentEntry(CacheDataPage parentDataPage,
CacheDataPage childDataPage,
Entry oldEntry, Entry newEntry)
throws IOException
{
updateParentEntry(parentDataPage, childDataPage, oldEntry, newEntry,
UpdateType.REPLACE);
}
private void updateParentEntry(CacheDataPage parentDataPage,
CacheDataPage childDataPage,
@@ -391,8 +397,23 @@ public class IndexPageCache
throws IOException
{
DataPageMain childMain = childDataPage._main;
DataPageMain parentMain = parentDataPage._main;
DataPageExtra parentExtra = parentDataPage._extra;

if(childMain.isTail()) {
int newChildTailPageNumber =
((upType == UpdateType.REMOVE) ?
INVALID_INDEX_PAGE_NUMBER :
childMain._pageNumber);
if((int)parentMain._childTailPageNumber != newChildTailPageNumber) {
setModified(parentDataPage);
parentMain._childTailPageNumber = newChildTailPageNumber;
}

// nothing more to do
return;
}
if(oldEntry != null) {
oldEntry = oldEntry.asNodeEntry(childMain._pageNumber);
}

Loading…
Cancel
Save