[Joafip-svn] SF.net SVN: joafip:[3064] trunk/joafip-btreeplus/src
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2012-05-03 03:37:49
|
Revision: 3064
http://joafip.svn.sourceforge.net/joafip/?rev=3064&view=rev
Author: luc_peuvrier
Date: 2012-05-03 03:37:42 +0000 (Thu, 03 May 2012)
Log Message:
-----------
byte size computing optimization in case of long key usage
refactoring best name
Modified Paths:
--------------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractNodePage.java
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -24,7 +24,6 @@
package net.sf.joafip.btreeplus.entity;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
/**
@@ -69,13 +68,4 @@
public long getPreviousRecordPositionInFile() throws HeapException {
return pageRecord.getPreviousRecordPositionInFile();
}
-
- protected int entrySize(final DataRecordIdentifier key) {
- int entryByteSize = 8/* long size for pointer */+ 8/* long size for value */;
- final int dataSize = key.getKeyDataSize();
- if (dataSize != 0) {
- entryByteSize += 4/* int size for data size */+ dataSize;
- }
- return entryByteSize;
- }
}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractNodePage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractNodePage.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractNodePage.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012 Luc Peuvrier
+ * All rights reserved.
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.btreeplus.entity;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public abstract class AbstractNodePage extends AbstractElement {
+
+ protected final boolean longKey;
+
+ public AbstractNodePage(final boolean longKey) {
+ super();
+ this.longKey = longKey;
+ }
+
+ protected int entrySize(final DataRecordIdentifier key) {
+ int entryByteSize = 8/* long size for pointer */+ 8/* long size for value */;
+ if (!longKey) {
+ final int dataSize = key.getKeyDataSize();
+ if (dataSize != 0) {
+ entryByteSize += 4/* int size for data size */+ dataSize;
+ }
+ }
+ return entryByteSize;
+ }
+}
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -58,14 +58,14 @@
writeByte((byte) recordType.getTypeIdentifier());
}
- private IDataRecordKeyManager dataRecordKeyManager;
-
protected DataRecordIdentifier readKey() throws HeapException {
final long value = readLong();
final DataRecordIdentifier dataRecordIdentifier;
if (value == -1) {
final int keySize = readInteger();
final byte[] keyData = readBytes(keySize);
+ final IDataRecordKeyManager dataRecordKeyManager = heapElementManager
+ .getDataRecordKeyManager();
final IDataRecordKey dataRecordKey = new DataRecordKey(
dataRecordKeyManager, keyData);
dataRecordIdentifier = new DataRecordIdentifier(dataRecordKey);
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -35,7 +35,7 @@
*
*/
@NotStorableClass
-public class LeafPage extends AbstractElement implements ILeafPage {
+public class LeafPage extends AbstractNodePage implements ILeafPage {
public static int HEAD_TAIL_SIZE =
/**/8/* byte size for previous record position */+
@@ -60,13 +60,13 @@
private int index;
- public LeafPage() {
- this(0);
+ public LeafPage(final boolean longKey) {
+ this(0, longKey);
updateByteSize();
}
- public LeafPage(final int numberOfKeyEntries) {
- super();
+ public LeafPage(final int numberOfKeyEntries, final boolean longKey) {
+ super(longKey);
this.numberOfKeyEntries = numberOfKeyEntries;
keys = new DataRecordIdentifier[numberOfKeyEntries];
dataBlockPosition = new long[numberOfKeyEntries];
@@ -74,8 +74,9 @@
}
public LeafPage(final int numberOfKeyEntries,
- final long[] dataBlockPosition, final DataRecordIdentifier[] keys) {
- super();
+ final long[] dataBlockPosition, final DataRecordIdentifier[] keys,
+ final boolean longKey) {
+ super(longKey);
assert numberOfKeyEntries == dataBlockPosition.length
&& numberOfKeyEntries == keys.length;
this.numberOfKeyEntries = numberOfKeyEntries;
@@ -153,10 +154,16 @@
}
private int computeByteSize() {
- int xbyteSize = HEAD_TAIL_SIZE;
- // FIXMELUC ________speedup if long value key
- for (int index = 0; index < numberOfKeyEntries; index++) {
- xbyteSize += entrySize(keys[index]);
+ int xbyteSize;
+ if (longKey) {
+ // <<4 for *16: 8 (long size for pointer) + 8 (long size for value)
+ xbyteSize = HEAD_TAIL_SIZE + (numberOfKeyEntries << 4);
+ } else {
+ xbyteSize = HEAD_TAIL_SIZE;
+ // FIXMELUC ________speedup if long value key
+ for (int index = 0; index < numberOfKeyEntries; index++) {
+ xbyteSize += entrySize(keys[index]);
+ }
}
return xbyteSize;
}
@@ -253,7 +260,7 @@
final LeafPage newLeafPage = new LeafPage(
newLeafPageNumberOfKeyEntries, newLeafPageDataBlockPosition,
- newLeafPageKeys);
+ newLeafPageKeys, longKey);
newLeafPage.setParentPage(getParentPage(), getInParentIndex() + 1);
dataBlockPosition = newDataBlockPosition;
keys = newKeys;
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -35,7 +35,7 @@
*
*/
@NotStorableClass
-public class NonTerminalPage extends AbstractElement implements
+public class NonTerminalPage extends AbstractNodePage implements
INonTerminalPage {
public static int HEAD_TAIL_SIZE =
@@ -59,13 +59,13 @@
private DataRecordIdentifier middleKey;
- public NonTerminalPage() {
- this(0);
+ public NonTerminalPage(final boolean longKey) {
+ this(0, longKey);
updateByteSize();
}
- public NonTerminalPage(final int numberOfKeyEntries) {
- super();
+ public NonTerminalPage(final int numberOfKeyEntries, final boolean longKey) {
+ super(longKey);
this.numberOfKeyEntries = numberOfKeyEntries;
keys = new DataRecordIdentifier[numberOfKeyEntries];
pagePositions = new long[numberOfKeyEntries + 1];
@@ -73,8 +73,9 @@
}
public NonTerminalPage(final int numberOfKeyEntries,
- final DataRecordIdentifier[] keys, final long[] pagePosition) {
- super();
+ final DataRecordIdentifier[] keys, final long[] pagePosition,
+ final boolean longKey) {
+ super(longKey);
assert numberOfKeyEntries == keys.length
&& numberOfKeyEntries + 1 == pagePosition.length;
this.numberOfKeyEntries = numberOfKeyEntries;
@@ -151,10 +152,16 @@
}
private int computeByteSize() {
- int xbyteSize = HEAD_TAIL_SIZE;
- // FIXMELUC ________speedup if long value key
- for (int index = 0; index < numberOfKeyEntries; index++) {
- xbyteSize += entrySize(keys[index]);
+ int xbyteSize;
+ if (longKey) {
+ // <<4 for *16: 8 (long size for pointer) + 8 (long size for value)
+ xbyteSize = HEAD_TAIL_SIZE + (numberOfKeyEntries << 4);
+ } else {
+ xbyteSize = HEAD_TAIL_SIZE;
+ // FIXMELUC ________speedup if long value key
+ for (int index = 0; index < numberOfKeyEntries; index++) {
+ xbyteSize += entrySize(keys[index]);
+ }
}
return xbyteSize;
}
@@ -287,7 +294,7 @@
pagePositions, splitIndex + 1, numberOfKeyEntries + 1);
final INonTerminalPage nonTerminalPage = new NonTerminalPage(
newNonTerminalPageNumberOfKeyEntries, newNonTerminalKeys,
- newNonTerminalPagePosition);
+ newNonTerminalPagePosition, longKey);
keys = newKeys;
pagePositions = newPagePosition;
numberOfKeyEntries = newNumberOfKeyEntries;
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -44,6 +44,8 @@
private long previousRecordPositionInFile;
+ private final boolean longKey;
+
/**
* creation for reading
*
@@ -55,6 +57,7 @@
super(heapElementManager, pageNumber << PageConstant.PAGE_BITS);
this.pageNumber = pageNumber;
this.previousRecordPositionInFile = -1L;
+ longKey = heapElementManager.getDataRecordKeyManager() == null;
}
public PageRecord(final IHeapElementManager heapElementManager,
@@ -65,6 +68,7 @@
this.pageNumber = pageNumber;
this.pageRecordable = pageRecordable;
this.recordType = pageRecordable.getRecordType();
+ longKey = heapElementManager.getDataRecordKeyManager() == null;
}
@Override
@@ -206,7 +210,7 @@
private void unmarshallNonTerminalPage() throws HeapException {
final int numberOfKeyEntries = readInteger();
final NonTerminalPage nonTerminalPage = new NonTerminalPage(
- numberOfKeyEntries);
+ numberOfKeyEntries, longKey);
nonTerminalPage.setPageRecord(this);
for (int index = 0; index < numberOfKeyEntries; index++) {
final long pagePointer = readLong();
@@ -235,7 +239,7 @@
private void unmarshallLeafPage() throws HeapException {
final int numberOfKeyEntries = readInteger();
- final LeafPage leafPage = new LeafPage(numberOfKeyEntries);
+ final LeafPage leafPage = new LeafPage(numberOfKeyEntries, longKey);
leafPage.setPageRecord(this);
for (int index = 0; index < numberOfKeyEntries; index++) {
final DataRecordIdentifier key = readKey();
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -85,9 +85,9 @@
}
@Override
- public void setDataRecordKeyComparator(
- IDataRecordKeyManager dataRecordKeyComparator) throws HeapException {
- btreePlusElementMgr.setDataRecordKeyManager(dataRecordKeyComparator);
+ public void setDataRecordKeyManager(
+ IDataRecordKeyManager dataRecordKeyManager) throws HeapException {
+ btreePlusElementMgr.setDataRecordKeyManager(dataRecordKeyManager);
}
@Override
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -63,6 +63,8 @@
private final IFileForStorable fileForStorable;
+ private final boolean longKey;
+
public BtreePlusElementMgr(final IHeapElementManager heapElementManager)
throws HeapException {
super();
@@ -77,6 +79,7 @@
+ " and file cache page size is "
+ fileForStorable.getCachePageSize());
}
+ longKey = heapElementManager.getDataRecordKeyManager() == null;
}
public void setDataRecordKeyManager(
@@ -228,7 +231,7 @@
public void newRootLeafPage(
final DataRecordIdentifier dataRecordIdentifier,
final IDataBlock dataBlock) throws HeapException {
- final LeafPage leafPage = new LeafPage(1);
+ final LeafPage leafPage = new LeafPage(1, longKey);
appendPageRecordable(leafPage);
// leafPage.setDataBlock(0, dataBlock);
leafPage.setEntry(0, dataBlock.getPositionInFile(),
@@ -241,7 +244,7 @@
public void newRootNonTerminalPage(final LeafPage leftLeafPage,
final LeafPage rightLeafPage) throws HeapException {
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1, longKey);
nonTerminalPage.setEntry(0, leftLeafPage.getPositionInFile(),
leftLeafPage.getLastKey());
nonTerminalPage.setEntry(1, rightLeafPage.getPositionInFile(), null);
@@ -255,7 +258,7 @@
final INonTerminalPage leftNonTerminalPage,
final DataRecordIdentifier middleKey,
final INonTerminalPage rightNonTerminalPage) throws HeapException {
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1, longKey);
nonTerminalPage.setEntry(0, leftNonTerminalPage.getPositionInFile(),
middleKey);
nonTerminalPage.setEntry(1, rightNonTerminalPage.getPositionInFile(),
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -53,7 +53,7 @@
}
public void testCreation() {
- LeafPage leafPage = new LeafPage();
+ LeafPage leafPage = new LeafPage(true);
leafPage.setPageRecord(PAGE_RECORD);
assertEquals("must be empty", 0, leafPage.getNumberOfKeyEntries());
assertEquals("must be one page", 1, leafPage.getNumberOfPage());
@@ -63,7 +63,7 @@
}
public void testAdd() throws HeapException {
- LeafPage leafPage = new LeafPage();
+ LeafPage leafPage = new LeafPage(true);
leafPage.setPageRecord(PAGE_RECORD);
addToLeafPage(leafPage, 1000/* position */, 10/* key value */, 10, 1);
checkContent(leafPage,
@@ -118,7 +118,7 @@
}
public void testSetDataBlock() throws HeapException {
- final LeafPage leafPage = new LeafPage(1);
+ final LeafPage leafPage = new LeafPage(1, true);
leafPage.setPageRecord(PAGE_RECORD);
final MockDataBlock dataBlock = new MockDataBlock();
final long position = 1000;
@@ -130,7 +130,7 @@
}
public void testSetEntry() throws HeapException {
- final LeafPage leafPage = new LeafPage(1);
+ final LeafPage leafPage = new LeafPage(1, true);
leafPage.setPageRecord(PAGE_RECORD);
final int index = 0;
final long pagePointer = 2000;
@@ -144,7 +144,7 @@
}
public void testSetParentPage() throws HeapException {
- final LeafPage leafPage = new LeafPage();
+ final LeafPage leafPage = new LeafPage(true);
leafPage.setPageRecord(PAGE_RECORD);
final IPageRecordable parentPage = new MockPageRecordable();
final int inParentIndex = 5;
@@ -155,7 +155,7 @@
}
public void testSetNext() throws HeapException {
- final LeafPage leafPage = new LeafPage();
+ final LeafPage leafPage = new LeafPage(true);
leafPage.setPageRecord(PAGE_RECORD);
final long next = 5000;
leafPage.setNext(next);
@@ -163,7 +163,7 @@
}
public void testSplit1() throws HeapException {
- final LeafPage leafPage = new LeafPage();
+ final LeafPage leafPage = new LeafPage(true);
leafPage.setPageRecord(PAGE_RECORD);
final int maxNumberOfEntries = maxNumberOfEntries();
int count = 0;
@@ -182,7 +182,7 @@
}
public void testSplit2() throws HeapException {
- final LeafPage leafPage = new LeafPage();
+ final LeafPage leafPage = new LeafPage(true);
leafPage.setPageRecord(PAGE_RECORD);
final int maxNumberOfEntries = maxNumberOfEntries();
int count = 1;
@@ -223,7 +223,7 @@
}
public void testRemove() throws HeapException {
- final LeafPage leafPage = new LeafPage();
+ final LeafPage leafPage = new LeafPage(true);
addToLeafPage(leafPage,
/**/new int[] { 5, 7, 10, 15, 17 },
/**/new long[] { 2000, 4000, 1000, 3000, 5000 });
@@ -245,8 +245,8 @@
}
public void testEquilibrateMerge() throws HeapException {
- final LeafPage leftLeafPage = new LeafPage();
- final LeafPage rightLeafPage = new LeafPage();
+ final LeafPage leftLeafPage = new LeafPage(true);
+ final LeafPage rightLeafPage = new LeafPage(true);
addToLeafPage(leftLeafPage,
/**/new int[] { 5, 7, 10, 15, 17 },
/**/new long[] { 2000, 4000, 1000, 3000, 5000 });
@@ -261,10 +261,10 @@
}
public void testEquilibrateRightToLeft() throws HeapException {
- final LeafPage leftLeafPage = new LeafPage();
+ final LeafPage leftLeafPage = new LeafPage(true);
addToLeafPage(leftLeafPage, createKeys(1, 128 + 32),
createPointers(1000, 128 + 32));
- final LeafPage rightLeafPage = new LeafPage();
+ final LeafPage rightLeafPage = new LeafPage(true);
addToLeafPage(rightLeafPage, createKeys(1 + 128 + 32, 128 + 64),
createPointers(1000 + 128 + 32, 128 + 64));
assertFalse("must not merge", leftLeafPage.equilibrate(rightLeafPage));
@@ -275,10 +275,10 @@
}
public void testEquilibrateLeftToRight() throws HeapException {
- final LeafPage leftLeafPage = new LeafPage();
+ final LeafPage leftLeafPage = new LeafPage(true);
addToLeafPage(leftLeafPage, createKeys(1, 128 + 64),
createPointers(1000, 128 + 64));
- final LeafPage rightLeafPage = new LeafPage();
+ final LeafPage rightLeafPage = new LeafPage(true);
addToLeafPage(rightLeafPage, createKeys(1 + 128 + 64, 128 + 32),
createPointers(1000 + 128 + 64, 128 + 32));
assertFalse("must not merge", leftLeafPage.equilibrate(rightLeafPage));
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -53,7 +53,7 @@
}
public void testCreation() {
- final NonTerminalPage nonTerminalPage = new NonTerminalPage();
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(true);
assertEquals("must be empty", 0,
nonTerminalPage.getNumberOfKeyEntries());
assertEquals("must be one page", 1, nonTerminalPage.getNumberOfPage());
@@ -65,7 +65,7 @@
public void testAddLeafPage() throws HeapException {
// A 10 B
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1, true);
nonTerminalPage.setPageRecord(PAGE_RECORD);
final MockLeafPage leafPageA = newMockLeafPage();
final long pageAPositionInFile = 1000;
@@ -172,7 +172,7 @@
public void testAddLeafPageNeedSplit() throws HeapException {
// A 10 B
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1, true);
nonTerminalPage.setPageRecord(PAGE_RECORD);
final MockLeafPage leafPageA = newMockLeafPage();
final long pageAPositionInFile = 1000;
@@ -203,7 +203,7 @@
public void testAddNonTerminalPage() throws HeapException {
// A 10 B
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1, true);
nonTerminalPage.setPageRecord(PAGE_RECORD);
final MockNonTerminalPage pageA = newMockNonTerminalPage();
final long pageAPositionInFile = 1000;
@@ -307,7 +307,7 @@
public void testAddNonTerminalPageNeedSplit() throws HeapException {
// A 10 B
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1, true);
nonTerminalPage.setPageRecord(PAGE_RECORD);
final MockNonTerminalPage pageA = newMockNonTerminalPage();
final long pageAPositionInFile = 1000;
@@ -382,7 +382,7 @@
private NonTerminalPage createFilledNonterminalPage(
final int numberOfEntries) throws HeapException {
final NonTerminalPage nonTerminalPage = new NonTerminalPage(
- numberOfEntries);
+ numberOfEntries, true);
nonTerminalPage.setPageRecord(PAGE_RECORD);
for (int index = 0; index < numberOfEntries; index++) {
nonTerminalPage.setEntry(index, index * 1000,
@@ -393,8 +393,8 @@
}
public void testSetParentPage() throws HeapException {
- final NonTerminalPage nonTerminalPage = new NonTerminalPage();
- final IPageRecordable parentPage = new NonTerminalPage();
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(true);
+ final IPageRecordable parentPage = new NonTerminalPage(true);
nonTerminalPage.setParentPage(parentPage, 10);
assertSame("bad parent page", parentPage,
nonTerminalPage.getParentPage());
@@ -423,8 +423,8 @@
}
public void testEquilibrateMerge() throws HeapException {
- final NonTerminalPage leftPage = new NonTerminalPage(5);
- final NonTerminalPage rightPage = new NonTerminalPage(5);
+ final NonTerminalPage leftPage = new NonTerminalPage(5, true);
+ final NonTerminalPage rightPage = new NonTerminalPage(5, true);
addToNonTerminalPage(leftPage,
/**/new int[] { 5, 7, 10, 15, 17 },
/**/new long[] { 2000, 4000, 1000, 3000, 5000, 6000 });
@@ -442,8 +442,8 @@
}
public void testEquilibrateRightToLeft() throws HeapException {
- final NonTerminalPage leftPage = new NonTerminalPage(128 + 32);
- final NonTerminalPage rightPage = new NonTerminalPage(128 + 64);
+ final NonTerminalPage leftPage = new NonTerminalPage(128 + 32, true);
+ final NonTerminalPage rightPage = new NonTerminalPage(128 + 64, true);
addToNonTerminalPage(leftPage, createKeys(1, 128 + 32),
createPointers(1, 128 + 32 + 1));
leftPage.updateByteSize();
@@ -459,8 +459,8 @@
}
public void testEquilibrateLeftToRight() throws HeapException {
- final NonTerminalPage leftPage = new NonTerminalPage(128 + 64);
- final NonTerminalPage rightPage = new NonTerminalPage(128 + 32);
+ final NonTerminalPage leftPage = new NonTerminalPage(128 + 64, true);
+ final NonTerminalPage rightPage = new NonTerminalPage(128 + 32, true);
addToNonTerminalPage(leftPage, createKeys(1, 128 + 64),
createPointers(1, 128 + 64 + 1));
leftPage.updateByteSize();
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java 2012-05-03 03:36:50 UTC (rev 3063)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java 2012-05-03 03:37:42 UTC (rev 3064)
@@ -99,7 +99,7 @@
public void testAppendPageRecordable() throws HeapException {
btreePlusElementMgr.openTransaction();
- IPageRecordable pageRecordable = new LeafPage();
+ IPageRecordable pageRecordable = new LeafPage(true);
assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
@@ -110,7 +110,7 @@
assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
btreePlusElementMgr.getLastRecordPositionInFile());
- pageRecordable = new NonTerminalPage();
+ pageRecordable = new NonTerminalPage(true);
assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
@@ -130,7 +130,7 @@
0) };
final long[] pagePosition = new long[] { 0, 1 };
pageRecordable = new NonTerminalPage(numberOfKeyEntries, keys,
- pagePosition);
+ pagePosition, true);
assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
@@ -169,14 +169,14 @@
btreePlusElementMgr.openTransaction();
assertEquals("must not has free page", -1, getHeapHeader()
.getPageNumberOfFirstFreePage());
- IPageRecordable pageRecordable = new LeafPage();
+ IPageRecordable pageRecordable = new LeafPage(true);
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
- pageRecordable = new LeafPage();
+ pageRecordable = new LeafPage(true);
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
final long pageNumber = pageRecordable.getPageRecord().getPageNumber();
- pageRecordable = new LeafPage();
+ pageRecordable = new LeafPage(true);
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
btreePlusElementMgr.closeTransaction();
@@ -193,7 +193,7 @@
btreePlusElementMgr.openTransaction();
assertEquals("must has free page", pageNumber, getHeapHeader()
.getPageNumberOfFirstFreePage());
- pageRecordable = new LeafPage();
+ pageRecordable = new LeafPage(true);
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
final long pageNumber2 = pageRecordable.getPageRecord().getPageNumber();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|