joafip-svn Mailing List for java data object persistence in file (Page 10)
Brought to you by:
luc_peuvrier
You can subscribe to this list here.
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(102) |
Nov
(52) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2012 |
Jan
(4) |
Feb
|
Mar
(14) |
Apr
(116) |
May
(100) |
Jun
(14) |
Jul
|
Aug
|
Sep
(30) |
Oct
|
Nov
(108) |
Dec
(2) |
|
From: <luc...@us...> - 2012-05-04 16:19:04
|
Revision: 3067
http://joafip.svn.sourceforge.net/joafip/?rev=3067&view=rev
Author: luc_peuvrier
Date: 2012-05-04 16:18:55 +0000 (Fri, 04 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : update crc32 change
Modified Paths:
--------------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-04 05:07:37
|
Revision: 3066
http://joafip.svn.sourceforge.net/joafip/?rev=3066&view=rev
Author: luc_peuvrier
Date: 2012-05-04 05:07:30 +0000 (Fri, 04 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : fixed arrays
Modified Paths:
--------------
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/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
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 04:01:29 UTC (rev 3065)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-05-04 05:07:30 UTC (rev 3066)
@@ -23,8 +23,6 @@
*/
package net.sf.joafip.btreeplus.entity;
-import java.util.Arrays;
-
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
@@ -44,10 +42,19 @@
/**/4/* int size for crc32 */+
/**/8/* for next */;
- private long[] dataBlockPosition;
+ private static int MAX_NUMBER_OF_ENTRIES =
+ /**/(int) ((PageConstant.PAGE_SIZE - HEAD_TAIL_SIZE) / (8/*
+ * long size for
+ * pointer
+ */+ 8/*
+ * long size for
+ * value
+ */));
- private DataRecordIdentifier[] keys;
+ private final long[] dataBlockPosition = new long[MAX_NUMBER_OF_ENTRIES];
+ private final DataRecordIdentifier[] keys = new DataRecordIdentifier[MAX_NUMBER_OF_ENTRIES];
+
private int numberOfKeyEntries;
private int byteSize;
@@ -68,23 +75,9 @@
public LeafPage(final int numberOfKeyEntries, final boolean longKey) {
super(longKey);
this.numberOfKeyEntries = numberOfKeyEntries;
- keys = new DataRecordIdentifier[numberOfKeyEntries];
- dataBlockPosition = new long[numberOfKeyEntries];
byteSize = 0;
}
- public LeafPage(final int numberOfKeyEntries,
- final long[] dataBlockPosition, final DataRecordIdentifier[] keys,
- final boolean longKey) {
- super(longKey);
- assert numberOfKeyEntries == dataBlockPosition.length
- && numberOfKeyEntries == keys.length;
- this.numberOfKeyEntries = numberOfKeyEntries;
- this.dataBlockPosition = dataBlockPosition;
- this.keys = keys;
- updateByteSize();
- }
-
@Override
public EnumRecordType getRecordType() {
return EnumRecordType.LEAF_PAGE;
@@ -227,25 +220,15 @@
final int insertBeforeIndex = computeInsertBeforeIndex(dataRecordIdentifier);
final int afterLength = numberOfKeyEntries - insertBeforeIndex;
numberOfKeyEntries++;
- final long[] newDataBlockPosition = new long[numberOfKeyEntries];
- final DataRecordIdentifier[] newKeys = new DataRecordIdentifier[numberOfKeyEntries];
- if (insertBeforeIndex != 0) {
- System.arraycopy(dataBlockPosition, 0, newDataBlockPosition, 0,
- insertBeforeIndex);
- System.arraycopy(keys, 0, newKeys, 0, insertBeforeIndex);
- }
- newDataBlockPosition[insertBeforeIndex] = dataBlock
- .getPositionInFile();
- newKeys[insertBeforeIndex] = dataRecordIdentifier;
if (afterLength != 0) {
System.arraycopy(dataBlockPosition, insertBeforeIndex,
- newDataBlockPosition, insertBeforeIndex + 1,
- afterLength);
- System.arraycopy(keys, insertBeforeIndex, newKeys,
+ dataBlockPosition, insertBeforeIndex + 1, afterLength);
+ System.arraycopy(keys, insertBeforeIndex, keys,
insertBeforeIndex + 1, afterLength);
}
- dataBlockPosition = newDataBlockPosition;
- keys = newKeys;
+ dataBlockPosition[insertBeforeIndex] = dataBlock
+ .getPositionInFile();
+ keys[insertBeforeIndex] = dataRecordIdentifier;
byteSize += entrySize;
// ASSERTX
assert byteSize == computeByteSize() : byteSize + " for "
@@ -262,21 +245,16 @@
final int newLeafPageNumberOfKeyEntries = numberOfKeyEntries
- newNumberOfKeyEntries;
- final long[] newDataBlockPosition = Arrays.copyOf(dataBlockPosition,
- newNumberOfKeyEntries);
- final DataRecordIdentifier[] newKeys = Arrays.copyOf(keys,
- newNumberOfKeyEntries);
- final long[] newLeafPageDataBlockPosition = Arrays.copyOfRange(
- dataBlockPosition, newNumberOfKeyEntries, numberOfKeyEntries);
- final DataRecordIdentifier[] newLeafPageKeys = Arrays.copyOfRange(keys,
- newNumberOfKeyEntries, numberOfKeyEntries);
-
final LeafPage newLeafPage = new LeafPage(
- newLeafPageNumberOfKeyEntries, newLeafPageDataBlockPosition,
- newLeafPageKeys, longKey);
+ newLeafPageNumberOfKeyEntries, longKey);
+ System.arraycopy(dataBlockPosition, newNumberOfKeyEntries,
+ newLeafPage.dataBlockPosition, 0, newLeafPageNumberOfKeyEntries);
+ System.arraycopy(keys, newNumberOfKeyEntries, newLeafPage.keys, 0,
+ newLeafPageNumberOfKeyEntries);
+
+ newLeafPage.updateByteSize();
+
newLeafPage.setParentPage(getParentPage(), getInParentIndex() + 1);
- dataBlockPosition = newDataBlockPosition;
- keys = newKeys;
numberOfKeyEntries = newNumberOfKeyEntries;
updateByteSize();
if (insertBeforeIndex >= newNumberOfKeyEntries) {
@@ -299,20 +277,11 @@
assert byteSize != 0 : "unknow current byte size";
final int afterLength = numberOfKeyEntries - (index + 1);
numberOfKeyEntries--;
- final long[] newDataBlockPosition = new long[numberOfKeyEntries];
- final DataRecordIdentifier[] newKeys = new DataRecordIdentifier[numberOfKeyEntries];
- if (index != 0) {
- System.arraycopy(dataBlockPosition, 0, newDataBlockPosition, 0,
- index);
- System.arraycopy(keys, 0, newKeys, 0, index);
- }
if (afterLength != 0) {
- System.arraycopy(dataBlockPosition, index + 1,
- newDataBlockPosition, index, afterLength);
- System.arraycopy(keys, index + 1, newKeys, index, afterLength);
+ System.arraycopy(dataBlockPosition, index + 1, dataBlockPosition,
+ index, afterLength);
+ System.arraycopy(keys, index + 1, keys, index, afterLength);
}
- keys = newKeys;
- dataBlockPosition = newDataBlockPosition;
byteSize -= entrySize;
// ASSERTX
assert byteSize == computeByteSize() : byteSize + " for "
@@ -366,9 +335,6 @@
final boolean merged;
if (byteSize + leafPageByteSize - HEAD_TAIL_SIZE <= PageConstant.PAGE_SIZE) {
merged = true;
- dataBlockPosition = Arrays.copyOf(dataBlockPosition,
- totalNumberOfEntries);
- keys = Arrays.copyOf(keys, totalNumberOfEntries);
System.arraycopy(leafPage.dataBlockPosition, 0, dataBlockPosition,
numberOfKeyEntries, leafPageNumberOfKeyEntries);
System.arraycopy(leafPage.keys, 0, keys, numberOfKeyEntries,
@@ -385,42 +351,37 @@
final int newLeafPageNumberOfEntries = totalNumberOfEntries
- newNumberOfEntries;
if (newNumberOfEntries > numberOfKeyEntries) {
- dataBlockPosition = Arrays.copyOf(dataBlockPosition,
- newNumberOfEntries);
- keys = Arrays.copyOf(keys, newNumberOfEntries);
final int length = newNumberOfEntries - numberOfKeyEntries;
System.arraycopy(leafPage.dataBlockPosition, 0,
dataBlockPosition, numberOfKeyEntries, length);
System.arraycopy(leafPage.keys, 0, keys, numberOfKeyEntries,
length);
- leafPage.dataBlockPosition = Arrays.copyOfRange(
- leafPage.dataBlockPosition, length,
+
+ System.arraycopy(leafPage.dataBlockPosition, length,
+ leafPage.dataBlockPosition, 0,
leafPageNumberOfKeyEntries);
- leafPage.keys = Arrays.copyOfRange(leafPage.keys, length,
+ System.arraycopy(leafPage.keys, length, leafPage.keys, 0,
leafPageNumberOfKeyEntries);
+
numberOfKeyEntries = newNumberOfEntries;
leafPage.numberOfKeyEntries = newLeafPageNumberOfEntries;
updateByteSize();
leafPage.updateByteSize();
} else if (newLeafPageNumberOfEntries > leafPageNumberOfKeyEntries) {
- long[] newLeafPageDataBlockPosition = new long[newLeafPageNumberOfEntries];
- DataRecordIdentifier[] newLeafPageKeys = new DataRecordIdentifier[newLeafPageNumberOfEntries];
final int length = newLeafPageNumberOfEntries
- leafPageNumberOfKeyEntries;
- System.arraycopy(dataBlockPosition, newNumberOfEntries,
- newLeafPageDataBlockPosition, 0, length);
- System.arraycopy(keys, newNumberOfEntries, newLeafPageKeys, 0,
- length);
+
System.arraycopy(leafPage.dataBlockPosition, 0,
- newLeafPageDataBlockPosition, length,
+ leafPage.dataBlockPosition, length,
leafPageNumberOfKeyEntries);
- System.arraycopy(leafPage.keys, 0, newLeafPageKeys, length,
+ System.arraycopy(leafPage.keys, 0, leafPage.keys, length,
leafPageNumberOfKeyEntries);
- dataBlockPosition = Arrays.copyOf(dataBlockPosition,
- newNumberOfEntries);
- keys = Arrays.copyOf(keys, newNumberOfEntries);
- leafPage.dataBlockPosition = newLeafPageDataBlockPosition;
- leafPage.keys = newLeafPageKeys;
+
+ System.arraycopy(dataBlockPosition, newNumberOfEntries,
+ leafPage.dataBlockPosition, 0, length);
+ System.arraycopy(keys, newNumberOfEntries, leafPage.keys, 0,
+ length);
+
numberOfKeyEntries = newNumberOfEntries;
leafPage.numberOfKeyEntries = newLeafPageNumberOfEntries;
updateByteSize();
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 04:01:29 UTC (rev 3065)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-05-04 05:07:30 UTC (rev 3066)
@@ -23,8 +23,7 @@
*/
package net.sf.joafip.btreeplus.entity;
-import java.util.Arrays;
-
+import net.sf.joafip.Fortest;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
@@ -45,10 +44,21 @@
/**/4/* int size for crc32 */+
/**/8/* last pointer long size */;
- private long[] pagePositions;
+ private static int MAX_NUMBER_OF_ENTRIES =
+ /**/(int) ((PageConstant.PAGE_SIZE - HEAD_TAIL_SIZE) / (8/*
+ * long size for
+ * pointer
+ */+ 8/*
+ * long size for
+ * value
+ */));
- private DataRecordIdentifier[] keys;
+ /** +1 for last pointer and +1 for add before split */
+ private final long[] pagePositions = new long[MAX_NUMBER_OF_ENTRIES + 1 + 1];
+ /** +1 for add before split */
+ private final DataRecordIdentifier[] keys = new DataRecordIdentifier[MAX_NUMBER_OF_ENTRIES + 1];
+
private int numberOfKeyEntries;
private int byteSize;
@@ -67,11 +77,10 @@
public NonTerminalPage(final int numberOfKeyEntries, final boolean longKey) {
super(longKey);
this.numberOfKeyEntries = numberOfKeyEntries;
- keys = new DataRecordIdentifier[numberOfKeyEntries];
- pagePositions = new long[numberOfKeyEntries + 1];
byteSize = 0;
}
+ @Fortest
public NonTerminalPage(final int numberOfKeyEntries,
final DataRecordIdentifier[] keys, final long[] pagePosition,
final boolean longKey) {
@@ -79,8 +88,9 @@
assert numberOfKeyEntries == keys.length
&& numberOfKeyEntries + 1 == pagePosition.length;
this.numberOfKeyEntries = numberOfKeyEntries;
- this.keys = keys;
- this.pagePositions = pagePosition;
+ System.arraycopy(keys, 0, this.keys, 0, numberOfKeyEntries);
+ System.arraycopy(pagePosition, 0, this.pagePositions, 0,
+ numberOfKeyEntries + 1);
updateByteSize();
}
@@ -222,22 +232,14 @@
final int entrySize = entrySize(key);
final int afterLength = numberOfKeyEntries - index;
numberOfKeyEntries++;
- DataRecordIdentifier[] newKeys = new DataRecordIdentifier[numberOfKeyEntries];
- long[] newPagePosition = new long[numberOfKeyEntries + 1];
- if (index != 0) {
- System.arraycopy(keys, 0, newKeys, 0, index);
- }
- System.arraycopy(pagePositions, 0, newPagePosition, 0, index + 1);
- newKeys[index] = key;
- newPagePosition[index + 1] = newRightILeafPage.getPositionInFile();
- System.arraycopy(pagePositions, index + 1, newPagePosition, index + 2,
+ System.arraycopy(pagePositions, index + 1, pagePositions, index + 2,
afterLength);
if (afterLength != 0) {
- System.arraycopy(keys, index, newKeys, index + 1, afterLength);
+ System.arraycopy(keys, index, keys, index + 1, afterLength);
}
- keys = newKeys;
- pagePositions = newPagePosition;
+ keys[index] = key;
+ pagePositions[index + 1] = newRightILeafPage.getPositionInFile();
// ASSERTX
assert byteSize != 0 : "unknow current byte size";
byteSize += entrySize;
@@ -263,23 +265,14 @@
final int entrySize = entrySize(middleKey);
final int afterLength = numberOfKeyEntries - index;
numberOfKeyEntries++;
- DataRecordIdentifier[] newKeys = new DataRecordIdentifier[numberOfKeyEntries];
- long[] newPagePositions = new long[numberOfKeyEntries + 1];
- if (index != 0) {
- System.arraycopy(keys, 0, newKeys, 0, index);
- }
- System.arraycopy(pagePositions, 0, newPagePositions, 0, index + 1);
- newKeys[index] = middleKey;
- newPagePositions[index + 1] = rightSonNonTerminalPage
- .getPositionInFile();
-
if (afterLength != 0) {
- System.arraycopy(keys, index, newKeys, index + 1, afterLength);
- System.arraycopy(pagePositions, index + 1, newPagePositions,
+ System.arraycopy(keys, index, keys, index + 1, afterLength);
+ System.arraycopy(pagePositions, index + 1, pagePositions,
index + 2, afterLength);
}
- keys = newKeys;
- pagePositions = newPagePositions;
+ keys[index] = middleKey;
+ pagePositions[index + 1] = rightSonNonTerminalPage.getPositionInFile();
+
// ASSERTX
assert byteSize != 0 : "unknow current byte size";
byteSize += entrySize;
@@ -295,19 +288,15 @@
final int newNumberOfKeyEntries = splitIndex;
final int newNonTerminalPageNumberOfKeyEntries = numberOfKeyEntries
- (splitIndex + 1);
- final DataRecordIdentifier[] newKeys = Arrays.copyOf(keys,
+
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(
+ newNonTerminalPageNumberOfKeyEntries, longKey);
+ System.arraycopy(keys, splitIndex + 1, nonTerminalPage.keys, 0,
newNumberOfKeyEntries);
- final long[] newPagePosition = Arrays.copyOf(pagePositions,
- newNumberOfKeyEntries + 1);
- final DataRecordIdentifier[] newNonTerminalKeys = Arrays.copyOfRange(
- keys, splitIndex + 1, numberOfKeyEntries);
- final long[] newNonTerminalPagePosition = Arrays.copyOfRange(
- pagePositions, splitIndex + 1, numberOfKeyEntries + 1);
- final INonTerminalPage nonTerminalPage = new NonTerminalPage(
- newNonTerminalPageNumberOfKeyEntries, newNonTerminalKeys,
- newNonTerminalPagePosition, longKey);
- keys = newKeys;
- pagePositions = newPagePosition;
+ System.arraycopy(pagePositions, splitIndex + 1,
+ nonTerminalPage.pagePositions, 0, newNumberOfKeyEntries + 1);
+
+ nonTerminalPage.updateByteSize();
numberOfKeyEntries = newNumberOfKeyEntries;
updateByteSize();
setValueIsChangedValueToSave();
@@ -328,22 +317,13 @@
public void remove(int leafPageInParentIndex) {
final DataRecordIdentifier key = keys[leafPageInParentIndex];
numberOfKeyEntries--;
- DataRecordIdentifier[] newKeys = new DataRecordIdentifier[numberOfKeyEntries];
- long[] newPagePositions = new long[numberOfKeyEntries + 1];
- if (leafPageInParentIndex != 0) {
- System.arraycopy(keys, 0, newKeys, 0, leafPageInParentIndex);
- System.arraycopy(pagePositions, 0, newPagePositions, 0,
- leafPageInParentIndex);
- }
final int length = numberOfKeyEntries - leafPageInParentIndex;
if (length != 0) {
- System.arraycopy(keys, leafPageInParentIndex + 1, newKeys,
+ System.arraycopy(keys, leafPageInParentIndex + 1, keys,
leafPageInParentIndex, length);
}
System.arraycopy(pagePositions, leafPageInParentIndex + 1,
- newPagePositions, leafPageInParentIndex, length + 1);
- keys = newKeys;
- pagePositions = newPagePositions;
+ pagePositions, leafPageInParentIndex, length + 1);
// ASSERTX
assert byteSize != 0 : "unknow current byte size";
byteSize -= entrySize(key);
@@ -377,9 +357,6 @@
if (byteSize + middleKeySize + rightPageByteSize - HEAD_TAIL_SIZE <= PageConstant.PAGE_SIZE) {
// can merge
merged = true;
- pagePositions = Arrays.copyOf(pagePositions,
- totalNumberOfEntries + 1 + 1);
- keys = Arrays.copyOf(keys, totalNumberOfEntries + 1);
System.arraycopy(rightNonTerminalPage.pagePositions, 0,
pagePositions, numberOfKeyEntries + 1,
rightPageNumberOfKeyEntries + 1);
@@ -398,11 +375,8 @@
- newNumberOfEntries;
if (newNumberOfEntries > numberOfKeyEntries) {
int length = newNumberOfEntries - numberOfKeyEntries;
- pagePositions = Arrays.copyOf(pagePositions,
- newNumberOfEntries + 1);
System.arraycopy(rightNonTerminalPage.pagePositions, 0,
pagePositions, numberOfKeyEntries + 1, length);
- keys = Arrays.copyOf(keys, newNumberOfEntries);
keys[numberOfKeyEntries] = middleKey;
System.arraycopy(rightNonTerminalPage.keys, 0, keys,
numberOfKeyEntries + 1, length - 1);
@@ -411,41 +385,36 @@
updateByteSize();
length = rightPageNumberOfKeyEntries
- newRightPageNumberOfEntries;
- rightNonTerminalPage.pagePositions = Arrays.copyOfRange(
- rightNonTerminalPage.pagePositions, length,
+ System.arraycopy(rightNonTerminalPage.pagePositions, length,
+ rightNonTerminalPage.pagePositions, 0,
rightPageNumberOfKeyEntries + 1);
- rightNonTerminalPage.keys = Arrays.copyOfRange(
- rightNonTerminalPage.keys, length,
+ System.arraycopy(rightNonTerminalPage.keys, length,
+ rightNonTerminalPage.keys, 0,
rightPageNumberOfKeyEntries);
rightNonTerminalPage.numberOfKeyEntries = newRightPageNumberOfEntries;
rightNonTerminalPage.updateByteSize();
} else if (newRightPageNumberOfEntries > rightPageNumberOfKeyEntries) {
final int length = newRightPageNumberOfEntries
- rightPageNumberOfKeyEntries;
- long[] newPagePositions = Arrays.copyOf(pagePositions,
- newNumberOfEntries + 1);
- DataRecordIdentifier[] newKeys = Arrays.copyOf(keys,
- newNumberOfEntries);
this.middleKey = keys[newNumberOfEntries];
- long[] newRightPagePositions = new long[newRightPageNumberOfEntries + 1];
- DataRecordIdentifier[] newRightKeys = new DataRecordIdentifier[newRightPageNumberOfEntries];
- System.arraycopy(pagePositions, newNumberOfEntries + 1,
- newRightPagePositions, 0, length);
- System.arraycopy(keys, newNumberOfEntries + 1, newRightKeys, 0,
- length - 1);
- newRightKeys[length - 1] = middleKey;
+
System.arraycopy(rightNonTerminalPage.pagePositions, 0,
- newRightPagePositions, length,
+ rightNonTerminalPage.pagePositions, length,
rightPageNumberOfKeyEntries + 1);
- System.arraycopy(rightNonTerminalPage.keys, 0, newRightKeys,
- length, rightPageNumberOfKeyEntries);
+ System.arraycopy(rightNonTerminalPage.keys, 0,
+ rightNonTerminalPage.keys, length,
+ rightPageNumberOfKeyEntries);
+
+ System.arraycopy(pagePositions, newNumberOfEntries + 1,
+ rightNonTerminalPage.pagePositions, 0, length);
+ System.arraycopy(keys, newNumberOfEntries + 1,
+ rightNonTerminalPage.keys, 0, length - 1);
+
+ rightNonTerminalPage.keys[length - 1] = middleKey;
+
rightNonTerminalPage.numberOfKeyEntries = newRightPageNumberOfEntries;
- rightNonTerminalPage.keys = newRightKeys;
- rightNonTerminalPage.pagePositions = newRightPagePositions;
rightNonTerminalPage.updateByteSize();
numberOfKeyEntries = newNumberOfEntries;
- keys = newKeys;
- pagePositions = newPagePositions;
updateByteSize();
}
}
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 04:01:29 UTC (rev 3065)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-05-04 05:07:30 UTC (rev 3066)
@@ -460,13 +460,15 @@
public void testEquilibrateLeftToRight() throws HeapException {
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();
+
+ final NonTerminalPage rightPage = new NonTerminalPage(128 + 32, true);
addToNonTerminalPage(rightPage, createKeys(2 + 128 + 64, 128 + 32),
createPointers(1 + 128 + 64 + 1, 128 + 32 + 1));
rightPage.updateByteSize();
+
assertFalse("must not merge", leftPage.equilibrate(
new DataRecordIdentifier(1 + 128 + 64), rightPage));
checkState(leftPage, createKeys(1, 176), createPointers(1, 177));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-04 05:07:37
|
Revision: 3066
http://joafip.svn.sourceforge.net/joafip/?rev=3066&view=rev
Author: luc_peuvrier
Date: 2012-05-04 05:07:30 +0000 (Fri, 04 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : fixed arrays
Modified Paths:
--------------
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/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-03 04:01:35
|
Revision: 3065
http://joafip.svn.sourceforge.net/joafip/?rev=3065&view=rev
Author: luc_peuvrier
Date: 2012-05-03 04:01:29 +0000 (Thu, 03 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : dichotomic search to speed up
Modified Paths:
--------------
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/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-03 04:01:35
|
Revision: 3065
http://joafip.svn.sourceforge.net/joafip/?rev=3065&view=rev
Author: luc_peuvrier
Date: 2012-05-03 04:01:29 +0000 (Thu, 03 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : dichotomic search to speed up
Modified Paths:
--------------
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/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
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:37:42 UTC (rev 3064)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-05-03 04:01:29 UTC (rev 3065)
@@ -160,7 +160,6 @@
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]);
}
@@ -176,13 +175,27 @@
*/
public long getDataBlockPosition(
final DataRecordIdentifier dataRecordIdentifier) {
- // FIXMELUC _________________LONG dichotomic search
long position = -1;
- for (index = 0; position == -1L && index < numberOfKeyEntries; index++) {
- if (keys[index].compareTo(dataRecordIdentifier) == 0) {
- position = dataBlockPosition[index];
+ int begin = 0;
+ int end = numberOfKeyEntries - 1;
+ while (position == -1 && end >= begin) {
+ final int middle = (begin + end) >> 1;
+ final int compareto = dataRecordIdentifier.compareTo(keys[middle]);
+ if (compareto < 0) {
+ end = middle - 1;
+ } else if (compareto > 0) {
+ begin = middle + 1;
+ } else {
+ position = dataBlockPosition[middle];
}
}
+ // below was "simpler" implementation
+ // for (index = 0; position == -1L && index < numberOfKeyEntries;
+ // index++) {
+ // if (keys[index].compareTo(dataRecordIdentifier) == 0) {
+ // position = dataBlockPosition[index];
+ // }
+ // }
return position;
}
@@ -315,12 +328,23 @@
private int computeInsertBeforeIndex(
final DataRecordIdentifier dataRecordIdentifier) {
- // FIXMELUC _________________LONG
- int index;
- for (index = 0; index < numberOfKeyEntries
- && dataRecordIdentifier.compareTo(keys[index]) > 0; index++)
- ;
- return index;
+ int begin = 0;
+ int end = numberOfKeyEntries - 1;
+ while (end >= begin) {
+ final int middle = (begin + end) >> 1;
+ final int compareto = dataRecordIdentifier.compareTo(keys[middle]);
+ if (compareto <= 0) {
+ end = middle - 1;
+ } else {
+ begin = middle + 1;
+ }
+ }
+ return begin;
+ // below was "simpler" implementation
+ // for (index = 0; index < numberOfKeyEntries
+ // && dataRecordIdentifier.compareTo(keys[index]) > 0; index++)
+ // ;
+ // return index;
}
public DataRecordIdentifier getLastKey() {
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:37:42 UTC (rev 3064)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-05-03 04:01:29 UTC (rev 3065)
@@ -158,7 +158,6 @@
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]);
}
@@ -187,14 +186,26 @@
* @return sub page index for data record identifier
*/
public int getIndex(final DataRecordIdentifier dataRecordIdentifier) {
- // FIXMELUC _________dichotomic search
- int index;
- for (index = 0; index < numberOfKeyEntries; index++) {
- if (keys[index].compareTo(dataRecordIdentifier) >= 0) {
- return index;
+ int begin = 0;
+ int end = numberOfKeyEntries - 1;
+ while (end >= begin) {
+ final int middle = (begin + end) >> 1;
+ final int compareto = dataRecordIdentifier.compareTo(keys[middle]);
+ if (compareto <= 0) {
+ end = middle - 1;
+ } else {
+ begin = middle + 1;
}
}
- return index;
+ return begin;
+ // below was "simpler" implementation
+ // int index;
+ // for (index = 0; index < numberOfKeyEntries; index++) {
+ // if (keys[index].compareTo(dataRecordIdentifier) >= 0) {
+ // return index;
+ // }
+ // }
+ // return index;
}
/**
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:37:42 UTC (rev 3064)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-05-03 04:01:29 UTC (rev 3065)
@@ -546,7 +546,6 @@
/**/4/* int size for crc32 */+
/**/numberOfKeyEntries * 8/* key entries */+
/**/(numberOfKeyEntries + 1) * 8/* pointers entries */;
- // FIXMELUC ________speedup if long value key
return xbyteSize;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-03 03:36:57
|
Revision: 3063
http://joafip.svn.sourceforge.net/joafip/?rev=3063&view=rev
Author: luc_peuvrier
Date: 2012-05-03 03:36:50 +0000 (Thu, 03 May 2012)
Log Message:
-----------
refactoring best name
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMemoryDataManagerMock.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMultiFileDataManager.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-03 03:36:57
|
Revision: 3063
http://joafip.svn.sourceforge.net/joafip/?rev=3063&view=rev
Author: luc_peuvrier
Date: 2012-05-03 03:36:50 +0000 (Thu, 03 May 2012)
Log Message:
-----------
refactoring best name
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMemoryDataManagerMock.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMultiFileDataManager.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -1093,7 +1093,7 @@
}
@Override
- public void setDataRecordKeyComparator(
+ public void setDataRecordKeyManager(
final IDataRecordKeyManager dataRecordKeyComparator) {
heapElementManager.setDataRecordKeyManager(dataRecordKeyComparator);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -338,7 +338,7 @@
}
@Override
- public void setDataRecordKeyComparator(
+ public void setDataRecordKeyManager(
final IDataRecordKeyManager dataRecordKeyComparator) {
throw new UnsupportedOperationException(
"works only with long data record identifier");
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -259,8 +259,8 @@
*/
void clearStandbyModification() throws HeapException;
- void setDataRecordKeyComparator(
- IDataRecordKeyManager dataRecordKeyComparator) throws HeapException;
+ void setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyComparator)
+ throws HeapException;
/**
* get number of data record in heap file.<br>
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -50,7 +50,7 @@
final DataRecordKeyManager keyManager = DataRecordKeyManager
.getInstance();
createFileHeapDataManager(true);
- heapDataManager.setDataRecordKeyComparator(keyManager);
+ heapDataManager.setDataRecordKeyManager(keyManager);
final DataRecordIdentifier keyA = keyManager.createKey("A");
assertFalse("must not found 'A'", heapDataManager.hasDataRecord(keyA));
final byte[] dataA = "valueA".getBytes();
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -484,7 +484,7 @@
}
@Override
- public void setDataRecordKeyComparator(
+ public void setDataRecordKeyManager(
final IDataRecordKeyManager dataRecordKeyComparator) {
throw new UnsupportedOperationException(
"works only with long data record identifier");
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -361,10 +361,10 @@
}
@Override
- public void setDataRecordKeyComparator(
+ public void setDataRecordKeyManager(
final IDataRecordKeyManager dataRecordKeyComparator)
throws HeapException {
- firstDataManager.setDataRecordKeyComparator(dataRecordKeyComparator);
- secondDataManager.setDataRecordKeyComparator(dataRecordKeyComparator);
+ firstDataManager.setDataRecordKeyManager(dataRecordKeyComparator);
+ secondDataManager.setDataRecordKeyManager(dataRecordKeyComparator);
}
}
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMemoryDataManagerMock.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMemoryDataManagerMock.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMemoryDataManagerMock.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -297,7 +297,7 @@
}
@Override
- public void setDataRecordKeyComparator(
+ public void setDataRecordKeyManager(
final IDataRecordKeyManager dataRecordKeyComparator) {
throw new UnsupportedOperationException(
"works only with long data record identifier");
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMultiFileDataManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMultiFileDataManager.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/HeapMultiFileDataManager.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -468,7 +468,7 @@
}
@Override
- public void setDataRecordKeyComparator(
+ public void setDataRecordKeyManager(
final IDataRecordKeyManager dataRecordKeyComparator) {
throw new UnsupportedOperationException(
"works only with long data record identifier");
Modified: trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
===================================================================
--- trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java 2012-05-03 02:48:57 UTC (rev 3062)
+++ trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java 2012-05-03 03:36:50 UTC (rev 3063)
@@ -100,7 +100,7 @@
true/* manageNodeindex */, autoSaveMaxRecord.intValue());
}
keyManager = new FileTreeMapKeyMgr(comparator);
- heapDataManager.setDataRecordKeyComparator(keyManager);
+ heapDataManager.setDataRecordKeyManager(keyManager);
this.comparator = comparator;
this.descending = false;
this.fromKey = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-03 02:49:04
|
Revision: 3062
http://joafip.svn.sourceforge.net/joafip/?rev=3062&view=rev
Author: luc_peuvrier
Date: 2012-05-03 02:48:57 +0000 (Thu, 03 May 2012)
Log Message:
-----------
optimization
Modified Paths:
--------------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-03 02:49:03
|
Revision: 3062
http://joafip.svn.sourceforge.net/joafip/?rev=3062&view=rev
Author: luc_peuvrier
Date: 2012-05-03 02:48:57 +0000 (Thu, 03 May 2012)
Log Message:
-----------
optimization
Modified Paths:
--------------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java 2012-05-02 06:14:15 UTC (rev 3061)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java 2012-05-03 02:48:57 UTC (rev 3062)
@@ -192,20 +192,23 @@
private void updateCrc32(final byte[] buffer, final int start,
final int length) {
- for (int i = 0; i < length; i++) {
- final byte byteValue = buffer[start + i];
+ int index = start;
+ for (int count = 0; count < length; count++) {
+ final byte byteValue = buffer[index++];
updateCrc32(byteValue);
}
}
private void updateCrc32(final byte byteValue) {
+ int value = byteValue;
for (int j = 0; j < 8; j++) {
- final int testbit = ((crc32 >> 31) & 1) ^ ((byteValue >> j) & 1);
+ final int testbit = ((crc32 >> 31) & 1) ^ (value & 1);
crc32 <<= 2;
if (testbit != 0) {
crc32 ^= 0x8005; /* 32 bit crc */
}
+ value >>= 1;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-02 06:14:21
|
Revision: 3061
http://joafip.svn.sourceforge.net/joafip/?rev=3061&view=rev
Author: luc_peuvrier
Date: 2012-05-02 06:14:15 +0000 (Wed, 02 May 2012)
Log Message:
-----------
todo update
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2012-05-02 05:26:05 UTC (rev 3060)
+++ trunk/joafip/doc/_todo.txt 2012-05-02 06:14:15 UTC (rev 3061)
@@ -102,10 +102,6 @@
- replace HeapDataFileManager direct use and option for main joafip storage
- replace internal use of HeapFileDataManager by BtreePlusDataManager
-file cache:
-when save, do not clear read cache (if file not closed and externally accessible), move wrote to read cache.
-
-
changes for garbage management because of autosave
- tests to add
- test for state machine
@@ -116,6 +112,8 @@
alternative is to create list of record attached to root and then clear detached data records
for detached clearing take care of #0 #1 and used for class name and garbage
+? alternative to garbage: remove object by program
+
export:
- no more static field management
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-02 06:14:21
|
Revision: 3061
http://joafip.svn.sourceforge.net/joafip/?rev=3061&view=rev
Author: luc_peuvrier
Date: 2012-05-02 06:14:15 +0000 (Wed, 02 May 2012)
Log Message:
-----------
todo update
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-02 05:26:13
|
Revision: 3060
http://joafip.svn.sourceforge.net/joafip/?rev=3060&view=rev
Author: luc_peuvrier
Date: 2012-05-02 05:26:05 +0000 (Wed, 02 May 2012)
Log Message:
-----------
file cache optimization tests
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
Added Paths:
-----------
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap2.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ICacheMap.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator2.java
Added: trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap.java (rev 0)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap.java 2012-05-02 05:26:05 UTC (rev 3060)
@@ -0,0 +1,73 @@
+/*
+ * 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.file.entity;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class CacheMap implements ICacheMap {
+
+ private final Map<Long, PageNode> cacheMap = new TreeMap<Long, PageNode>();
+
+ @Override
+ public void initialize(final int maxPage) {
+ // no implementation
+ }
+
+ @Override
+ public Iterator<PageNode> toWriteIterator() {
+ return new ToWriteIterator(cacheMap.values().iterator());
+ }
+
+ @Override
+ public void clear() {
+ cacheMap.clear();
+ }
+
+ @Override
+ public PageNode get(final long pagePositionInFile) {
+ return cacheMap.get(pagePositionInFile);
+ }
+
+ @Override
+ public void put(final long pagePositionInFile, final PageNode pageNode) {
+ cacheMap.put(pagePositionInFile, pageNode);
+ }
+
+ @Override
+ public PageNode remove(long removedPosition) {
+ return cacheMap.remove(removedPosition);
+ }
+
+ @Override
+ public boolean contains(final PageNode pageNode) {
+ return cacheMap.containsKey(pageNode.positionInFile);
+ }
+}
Added: trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap2.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap2.java (rev 0)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap2.java 2012-05-02 05:26:05 UTC (rev 3060)
@@ -0,0 +1,138 @@
+/*
+ * 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.file.entity;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class CacheMap2 implements ICacheMap {
+
+ private PageNode[] pageNodes;
+
+ private int size;
+
+ @Override
+ public void initialize(final int maxPage) {
+ pageNodes = new PageNode[maxPage];
+ size = 0;
+ }
+
+ @Override
+ public Iterator<PageNode> toWriteIterator() {
+ return new ToWriteIterator2(pageNodes, size);
+ }
+
+ @Override
+ public void clear() {
+ size = 0;
+ Arrays.fill(pageNodes, null);
+ }
+
+ @Override
+ public PageNode get(final long pagePositionInFile) {
+ int begin = 0;
+ int end = size - 1;
+ PageNode found = null;
+ while (found == null && end >= begin) {
+ final int middle = (begin + end) / 2;
+ final PageNode pageNode = pageNodes[middle];
+ final long positionInFile = pageNode.positionInFile;
+ if (pagePositionInFile > positionInFile) {
+ begin = middle + 1;
+ } else if (pagePositionInFile < positionInFile) {
+ end = middle - 1;
+ } else {
+ found = pageNode;
+ }
+ }
+ return found;
+ }
+
+ @Override
+ public void put(long pagePositionInFile, PageNode pPageNode) {
+ int begin = 0;
+ int end = size - 1;
+ PageNode found = null;
+ int middle = -1;
+ while (found == null && end >= begin) {
+ middle = (begin + end) / 2;
+ final PageNode pageNode = pageNodes[middle];
+ final long positionInFile = pageNode.positionInFile;
+ if (pagePositionInFile > positionInFile) {
+ begin = middle + 1;
+ } else if (pagePositionInFile < positionInFile) {
+ end = middle - 1;
+ } else {
+ found = pageNode;
+ }
+ }
+ if (found == null) {
+ if (begin < size) {
+ System.arraycopy(pageNodes, begin, pageNodes, begin + 1, size
+ - begin);
+ }
+ pageNodes[begin] = pPageNode;
+ size++;
+ } else {
+ pageNodes[middle] = pPageNode;
+ }
+ }
+
+ @Override
+ public PageNode remove(long pagePositionInFile) {
+ int begin = 0;
+ int end = size - 1;
+ PageNode found = null;
+ int middle = -1;
+ while (found == null && end >= begin) {
+ middle = (begin + end) / 2;
+ final PageNode pageNode = pageNodes[middle];
+ final long positionInFile = pageNode.positionInFile;
+ if (pagePositionInFile > positionInFile) {
+ begin = middle + 1;
+ } else if (pagePositionInFile < positionInFile) {
+ end = middle - 1;
+ } else {
+ found = pageNode;
+ }
+ }
+ if (found != null) {
+ System.arraycopy(pageNodes, middle + 1, pageNodes, middle, size
+ - middle - 1);
+ size--;
+ }
+ return found;
+ }
+
+ @Override
+ public boolean contains(PageNode pageNode) {
+ return get(pageNode.positionInFile) != null;
+ }
+
+}
Added: trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ICacheMap.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ICacheMap.java (rev 0)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ICacheMap.java 2012-05-02 05:26:05 UTC (rev 3060)
@@ -0,0 +1,49 @@
+/*
+ * 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.file.entity;
+
+import java.util.Iterator;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface ICacheMap {
+
+ void initialize(int maxPage);
+
+ Iterator<PageNode> toWriteIterator();
+
+ void clear();
+
+ PageNode get(long pagePositionInFile);
+
+ void put(long pagePositionInFile, PageNode pageNode);
+
+ PageNode remove(long removedPosition);
+
+ boolean contains(PageNode pageNode);
+
+}
Added: trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator.java (rev 0)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator.java 2012-05-02 05:26:05 UTC (rev 3060)
@@ -0,0 +1,75 @@
+/*
+ * 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.file.entity;
+
+import java.util.Iterator;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class ToWriteIterator implements Iterator<PageNode> {
+
+ private final Iterator<PageNode> iterator;
+
+ private PageNode next;
+
+ public ToWriteIterator(final Iterator<PageNode> iterator) {
+ super();
+ this.iterator = iterator;
+ setNext();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return next != null;
+ }
+
+ @Override
+ public PageNode next() {
+ final PageNode result = next;
+ setNext();
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setNext() {
+ if (iterator.hasNext()) {
+ do {
+ if (iterator.hasNext()) {
+ next = iterator.next();
+ } else {
+ next = null;
+ }
+ } while (next != null && !next.toWrite);
+ } else {
+ next = null;
+ }
+ }
+}
Added: trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator2.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator2.java (rev 0)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator2.java 2012-05-02 05:26:05 UTC (rev 3060)
@@ -0,0 +1,71 @@
+/*
+ * 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.file.entity;
+
+import java.util.Iterator;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class ToWriteIterator2 implements Iterator<PageNode> {
+
+ private int nextIndex;
+
+ private final PageNode[] pageNodes;
+
+ private final int size;
+
+ public ToWriteIterator2(final PageNode[] pageNodes, final int size) {
+ super();
+ this.pageNodes = pageNodes;
+ this.size = size;
+ nextIndex = -1;
+ setNext();
+ }
+
+ @Override
+ public boolean hasNext() {
+ return nextIndex < size;
+ }
+
+ @Override
+ public PageNode next() {
+ final PageNode result = pageNodes[nextIndex];
+ setNext();
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ private void setNext() {
+ do {
+ nextIndex++;
+ } while (nextIndex < size && !pageNodes[nextIndex].toWrite);
+ }
+}
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2012-05-01 21:55:15 UTC (rev 3059)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2012-05-02 05:26:05 UTC (rev 3060)
@@ -20,13 +20,12 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.SortedMap;
-import java.util.TreeMap;
import net.sf.joafip.Fortest;
import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.file.entity.CacheMap;
+import net.sf.joafip.file.entity.ICacheMap;
import net.sf.joafip.file.entity.PageNode;
/**
@@ -57,11 +56,15 @@
private final IRandomAccessFile randomAccessFileDelegate;
/**
- * read/write cache is a map of pages, can not be cleared until write in
- * file
+ * read/write cache is a map of pages, can not be cleared until to be write
+ * are write in file
*/
- private final Map<Long, PageNode> cacheMap = new TreeMap<Long, PageNode>();
+ // private final Map<Long, PageNode> cacheMap = new TreeMap<Long,
+ // PageNode>();
+ private final ICacheMap cacheMap = new CacheMap();
+ // private final Set<Long> toWriteSet=new TreeSet<E>();
+
/** current position in file */
private long positionInFile = 0;
@@ -189,25 +192,21 @@
}
private void writeModified() throws FileIOException {
- final Iterator<Entry<Long, PageNode>> iterator = cacheMap.entrySet()
- .iterator();
+ final Iterator<PageNode> iterator = cacheMap.toWriteIterator();
long previousPagePositionInfile = Long.MIN_VALUE;
while (iterator.hasNext()) {
- final Entry<Long, PageNode> entry = iterator.next();
- final PageNode pageNode = entry.getValue();
- if (pageNode.toWrite) {
- final long pagePositionInfile = entry.getKey();
- if (previousPagePositionInfile + pageSize != pagePositionInfile) {
- randomAccessFileDelegate.seek(pagePositionInfile);
- }
- randomAccessFileDelegate.write(pageNode.data);
- if (haveReadCache) {
- pageNode.toWrite = false;
- } else {
- freePage(pageNode);
- }
- previousPagePositionInfile = pagePositionInfile;
+ final PageNode pageNode = iterator.next();
+ final long pagePositionInfile = pageNode.positionInFile;
+ if (previousPagePositionInfile + pageSize != pagePositionInfile) {
+ randomAccessFileDelegate.seek(pagePositionInfile);
}
+ randomAccessFileDelegate.write(pageNode.data);
+ if (haveReadCache) {
+ pageNode.toWrite = false;
+ } else {
+ freePage(pageNode);
+ }
+ previousPagePositionInfile = pagePositionInfile;
}
if (!haveReadCache) {
cacheMap.clear();
@@ -459,6 +458,7 @@
}
private void initializeCache() {
+ cacheMap.initialize(maxPage);
readBuffer = new byte[pageSize];
PageNode previous = null;
for (int page = 0; page < maxPage; page++) {
@@ -498,7 +498,7 @@
PageNode current = usedPageFirstNode;
while (current != null) {
assert current.positionInFile != -1;
- assert cacheMap.containsKey(current.positionInFile);
+ assert cacheMap.contains(current);
// if (current.toWrite) {
pageSet.add(current.positionInFile);
// }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-02 05:26:12
|
Revision: 3060
http://joafip.svn.sourceforge.net/joafip/?rev=3060&view=rev
Author: luc_peuvrier
Date: 2012-05-02 05:26:05 +0000 (Wed, 02 May 2012)
Log Message:
-----------
file cache optimization tests
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
Added Paths:
-----------
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/CacheMap2.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ICacheMap.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/ToWriteIterator2.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 21:55:22
|
Revision: 3059
http://joafip.svn.sourceforge.net/joafip/?rev=3059&view=rev
Author: luc_peuvrier
Date: 2012-05-01 21:55:15 +0000 (Tue, 01 May 2012)
Log Message:
-----------
refactoring
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 21:55:22
|
Revision: 3059
http://joafip.svn.sourceforge.net/joafip/?rev=3059&view=rev
Author: luc_peuvrier
Date: 2012-05-01 21:55:15 +0000 (Tue, 01 May 2012)
Log Message:
-----------
refactoring
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java 2012-05-01 21:05:38 UTC (rev 3058)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java 2012-05-01 21:55:15 UTC (rev 3059)
@@ -116,21 +116,6 @@
this.numberOfChild = numberOfChild;
}
- // /**
- // * construct a Red Black Tree node mirrored in heap file
- // *
- // * @param heapElementManager
- // * the heap element manager
- // * @param heapRecord
- // * associated heap record
- // */
- // public AbstractHeapRBTNode(final IHeapElementManager heapElementManager,
- // final long positionInFile) {
- // super();
- // this.heapElementManager = heapElementManager;
- // this.positionInFile = positionInFile;
- // }
-
public HeapRecord getHeapRecord() throws HeapException {
return readHeapFileDataRecord(positionInFile);
}
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java 2012-05-01 21:05:38 UTC (rev 3058)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java 2012-05-01 21:55:15 UTC (rev 3059)
@@ -516,8 +516,9 @@
public void clear() throws HeapException {
// ASSERTX
assert assertTransactionOpened();
- heapRecordToWriteMap.clear();
- readHeapRecordMap.clear();
+
+ clearHeaprecordMaps();
+
if (clearResizeFile) {
try {
setStartSaveFlagFile();
@@ -562,7 +563,7 @@
starterTrace = new Exception("starter trace");
serviceStarted = true;
if (!fileOpenedInTransaction) {
- openFile();
+ openFiles();
}
}
@@ -618,10 +619,11 @@
// ASSERTX
assert assertServiceStartedAndTransactionClosed();
if (fileOpenedInTransaction) {
- openFile();
+ openFiles();
}
- clearHeaprecordToWriteMap();
- readHeapRecordMap.clear();
+
+ clearHeaprecordMaps();
+
try {
final long fileSize = getFileSize();
header.clear();
@@ -632,7 +634,7 @@
flushOnFile();
if (fileOpenedInTransaction) {
closeFiles();
- openFile();
+ openFiles();
}
} else {
header.readFromFile();
@@ -666,7 +668,7 @@
return true;
}
- private void openFile() throws HeapException {
+ private void openFiles() throws HeapException {
if (openFileTraceFile != null) {
try {
final PrintStream printStream = new PrintStream(
@@ -713,8 +715,8 @@
updateBackup(toBackupList);
- clearHeaprecordToWriteMap();
- readHeapRecordMap.clear();
+ clearHeaprecordMaps();
+
if (crashSafeMode) {
flushOnFile();
}
@@ -728,16 +730,26 @@
public void closeTransactionDiscardChange() throws HeapException {
// ASSERTX
assert assertTransactionOpened();
- clearHeaprecordToWriteMap();
- readHeapRecordMap.clear();
+
+ clearHeaprecordMaps();
+
if (fileOpenedInTransaction) {
closeFiles();
}
openedTransaction = false;
}
- private void clearHeaprecordToWriteMap() {
+ // private void clearHeaprecordReadMap() {
+ // readHeapRecordMap.clear();
+ // }
+ //
+ // private void clearHeaprecordToWriteMap() {
+ // heapRecordToWriteMap.clear();
+ // }
+
+ private void clearHeaprecordMaps() {
heapRecordToWriteMap.clear();
+ readHeapRecordMap.clear();
}
private void closeFiles() throws HeapException {
@@ -1064,10 +1076,12 @@
// ASSERTX
assert assertNoPreviousOrPreviousSameAsCurrent(previous, heapRecord);
if (previous == null) {
+ // may be in read cache
previous = readHeapRecordMap.remove(positionInFile);
// ASSERTX
assert assertNoPreviousOrPreviousSameAsCurrent(previous, heapRecord);
} else {
+ // is not in read cache because already in write cache
// ASSERTX
assert !readHeapRecordMap.containsKey(positionInFile) : "heap record must not be in read cache";
}
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java 2012-05-01 21:05:38 UTC (rev 3058)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java 2012-05-01 21:55:15 UTC (rev 3059)
@@ -76,8 +76,8 @@
/* no read cache on backup copy, not used for read */
fileForStorableBackup = new FileForStorable(
setup.getBackupDataFile(), setup.getPageSize(),
- setup.getMaxPage(), false/*no read cache*/, maxFileOperationRetry,
- fileOperationRetryMsDelay);
+ setup.getMaxPage(), false/* no read cache */,
+ maxFileOperationRetry, fileOperationRetryMsDelay);
stateOkFlagFile = setup.getStateOkFlagFile();
} else {
fileForStorable = new FileForStorable(setup.getDataFile(),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 21:05:45
|
Revision: 3058
http://joafip.svn.sourceforge.net/joafip/?rev=3058&view=rev
Author: luc_peuvrier
Date: 2012-05-01 21:05:38 +0000 (Tue, 01 May 2012)
Log Message:
-----------
file cache optimization
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 21:05:45
|
Revision: 3058
http://joafip.svn.sourceforge.net/joafip/?rev=3058&view=rev
Author: luc_peuvrier
Date: 2012-05-01 21:05:38 +0000 (Tue, 01 May 2012)
Log Message:
-----------
file cache optimization
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2012-05-01 20:02:42 UTC (rev 3057)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2012-05-01 21:05:38 UTC (rev 3058)
@@ -209,6 +209,9 @@
previousPagePositionInfile = pagePositionInfile;
}
}
+ if (!haveReadCache) {
+ cacheMap.clear();
+ }
}
@Override
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java 2012-05-01 20:02:42 UTC (rev 3057)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java 2012-05-01 21:05:38 UTC (rev 3058)
@@ -197,27 +197,43 @@
+ randomFileAccess.getPageSet().toString());
}
- assertEquals(BAD_READ_ACCESS + '\n' + probe.readLogToString(), 5,
- probe.readLogSize());
- assertEquals(BAD_WRITE_ACCESS, 0, probe.writeLogSize());
+ if (flushMode) {
+ // data kept in cache
+ assertEquals(BAD_READ_ACCESS + '\n' + probe.readLogToString(), 2,
+ probe.readLogSize());
+ assertEquals(BAD_WRITE_ACCESS, 0, probe.writeLogSize());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 3 * PAGE_SIZE,
+ record.getPositionInFile());
+ assertEquals(BAD_DATA, createStrPageData('3'), record.getStrData());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 4 * PAGE_SIZE,
+ record.getPositionInFile());
+ assertEquals(BAD_DATA, createStrPageData('4'), record.getStrData());
+ } else {
+ // cache was cleared, so check read 5 records
+ assertEquals(BAD_READ_ACCESS + '\n' + probe.readLogToString(), 5,
+ probe.readLogSize());
+ assertEquals(BAD_WRITE_ACCESS, 0, probe.writeLogSize());
- record = probe.pollFirstRead();
- assertEquals(BAD_POSITION_IN_FILE, 0 * PAGE_SIZE,
- record.getPositionInFile());
- record = probe.pollFirstRead();
- assertEquals(BAD_POSITION_IN_FILE, 1 * PAGE_SIZE,
- record.getPositionInFile());
- record = probe.pollFirstRead();
- assertEquals(BAD_POSITION_IN_FILE, 2 * PAGE_SIZE,
- record.getPositionInFile());
- record = probe.pollFirstRead();
- assertEquals(BAD_POSITION_IN_FILE, 3 * PAGE_SIZE,
- record.getPositionInFile());
- assertEquals(BAD_DATA, createStrPageData('3'), record.getStrData());
- record = probe.pollFirstRead();
- assertEquals(BAD_POSITION_IN_FILE, 4 * PAGE_SIZE,
- record.getPositionInFile());
- assertEquals(BAD_DATA, createStrPageData('4'), record.getStrData());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 0 * PAGE_SIZE,
+ record.getPositionInFile());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 1 * PAGE_SIZE,
+ record.getPositionInFile());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 2 * PAGE_SIZE,
+ record.getPositionInFile());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 3 * PAGE_SIZE,
+ record.getPositionInFile());
+ assertEquals(BAD_DATA, createStrPageData('3'), record.getStrData());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 4 * PAGE_SIZE,
+ record.getPositionInFile());
+ assertEquals(BAD_DATA, createStrPageData('4'), record.getStrData());
+ }
randomFileAccess.close();
}
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java 2012-05-01 20:02:42 UTC (rev 3057)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java 2012-05-01 21:05:38 UTC (rev 3058)
@@ -76,7 +76,7 @@
/* no read cache on backup copy, not used for read */
fileForStorableBackup = new FileForStorable(
setup.getBackupDataFile(), setup.getPageSize(),
- setup.getMaxPage(), false, maxFileOperationRetry,
+ setup.getMaxPage(), false/*no read cache*/, maxFileOperationRetry,
fileOperationRetryMsDelay);
stateOkFlagFile = setup.getStateOkFlagFile();
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 20:02:49
|
Revision: 3057
http://joafip.svn.sourceforge.net/joafip/?rev=3057&view=rev
Author: luc_peuvrier
Date: 2012-05-01 20:02:42 +0000 (Tue, 01 May 2012)
Log Message:
-----------
javadoc update, clearCache no more public, must not be public
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/PageNode.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/TestRandomAccessFileCache.java
Added Paths:
-----------
trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecordForTests.java
Removed Paths:
-------------
trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/PageNode.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/PageNode.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/PageNode.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -44,7 +44,7 @@
/** previous page node, null if this is the first node */
public PageNode previous;
- /** next page node, null if this is the last node */
+ /** next free page node, null if this is the last node */
public PageNode next;
public PageNode(final byte[] data) { // NOPMD
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -86,14 +86,6 @@
void setLength(final long newSize) throws FileIOException;
/**
- * clear the cache<br>
- * this can be done independently to file opened state or closed<br>
- *
- * @throws FileIOException
- */
- void clearCache() throws FileIOException;
-
- /**
* make copy of this file in other file
*
* @param fileName
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -269,11 +269,6 @@
}
@Override
- public void clearCache() {
- // nothing to do
- }
-
- @Override
public void copy(final String fileName) throws FileIOException {
final long savedCurrentPositionInFile = currentPositionInFile;
if (opened) {
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -322,11 +322,6 @@
}
@Override
- public void clearCache() {
- // nothing to do
- }
-
- @Override
public void copy(final String fileName) throws FileIOException {
try {
if (opened) {
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -68,6 +68,7 @@
/** true if use read cache */
private boolean haveReadCache;// NOPMD
+ /** first free page node */
private PageNode freePageRootNode;
/** first of used page (less acceded) */
@@ -178,6 +179,7 @@
public void closeImpl() throws FileIOException {
writeModified();
randomAccessFileDelegate.close();
+ clearCache();
}
@Override
@@ -221,8 +223,8 @@
randomAccessFileDelegate.deleteIfExistsRenaming();
}
- @Override
- public void clearCache() {
+ // @Override
+ private void clearCache() {
cacheMap.clear();
while (usedPageFirstNode != null) {
freePage(usedPageFirstNode);
Deleted: trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2010 Luc Peuvrier
- *
- * 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.file.entity;
-
-import java.util.Arrays;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class FileAccessRecord {
-
- private final long positionInFile;
-
- private final byte[] data;
-
- public FileAccessRecord(final long positionInFile, final byte[] data,
- final int offset, final int length) {
- super();
- this.positionInFile = positionInFile;
- this.data = Arrays.copyOfRange(data, offset, offset + length);
- }
-
- public long getPositionInFile() {
- return positionInFile;
- }
-
- public byte[] getData() {
- return data;// NOPMD
- }
-
- public String getStrData() {
- return new String(data);
- }
-}
Copied: trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecordForTests.java (from rev 3024, trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java)
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecordForTests.java (rev 0)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecordForTests.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2010 Luc Peuvrier
+ *
+ * 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.file.entity;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class FileAccessRecordForTests {
+
+ private final long positionInFile;
+
+ private final byte[] data;
+
+ public FileAccessRecordForTests(final long positionInFile,
+ final byte[] data, final int offset, final int length) {
+ super();
+ this.positionInFile = positionInFile;
+ this.data = Arrays.copyOfRange(data, offset, offset + length);
+ }
+
+ public long getPositionInFile() {
+ return positionInFile;
+ }
+
+ public byte[] getData() {
+ return data;// NOPMD
+ }
+
+ public String getStrData() {
+ return new String(data);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("FileAccessRecordForTests [positionInFile=");
+ builder.append(positionInFile);
+ builder.append(", data.length=");
+ builder.append(data.length);
+ builder.append("]");
+ return builder.toString();
+ }
+}
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -75,13 +75,6 @@
}
@Override
- public void clearCache() throws FileIOException {
- randomFileDirect.clearCache();
- randomFileDirectNio.clearCache();
- randomFileReadWriteCache.clearCache();
- }
-
- @Override
public void deleteIfExists() throws FileIOException {
randomFileDirect.deleteIfExists();
randomFileDirectNio.deleteIfExists();
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -27,7 +27,7 @@
import java.util.LinkedList;
import java.util.SortedMap;
-import net.sf.joafip.file.entity.FileAccessRecord;
+import net.sf.joafip.file.entity.FileAccessRecordForTests;
/**
* probe of read write operation
@@ -39,9 +39,9 @@
private final IRandomAccessFile delegate;
- private final Deque<FileAccessRecord> readLog = new LinkedList<FileAccessRecord>();
+ private final Deque<FileAccessRecordForTests> readLog = new LinkedList<FileAccessRecordForTests>();
- private final Deque<FileAccessRecord> writeLog = new LinkedList<FileAccessRecord>();
+ private final Deque<FileAccessRecordForTests> writeLog = new LinkedList<FileAccessRecordForTests>();
public RandomAccessFileProbeForTest(final File file) {
super();
@@ -58,7 +58,7 @@
final long positionInFile = delegate.currentPositionInFile();
final int read = delegate.read(data);
if (read > 0) {
- final FileAccessRecord fileAccessRecord = new FileAccessRecord(
+ final FileAccessRecordForTests fileAccessRecord = new FileAccessRecordForTests(
positionInFile, data, 0, data.length);
readLog.add(fileAccessRecord);
}
@@ -71,7 +71,7 @@
final long positionInFile = delegate.currentPositionInFile();
final int read = delegate.read(data, offset, length);
if (read > 0) {
- final FileAccessRecord fileAccessRecord = new FileAccessRecord(
+ final FileAccessRecordForTests fileAccessRecord = new FileAccessRecordForTests(
positionInFile, data, offset, length);
readLog.add(fileAccessRecord);
}
@@ -81,7 +81,7 @@
@Override
public void write(final byte[] data) throws FileIOException {
final long positionInFile = delegate.currentPositionInFile();
- final FileAccessRecord fileAccessRecord = new FileAccessRecord(
+ final FileAccessRecordForTests fileAccessRecord = new FileAccessRecordForTests(
positionInFile, data, 0, data.length);
delegate.write(data);
writeLog.add(fileAccessRecord);
@@ -91,7 +91,7 @@
public void write(final byte[] data, final int length)
throws FileIOException {
final long positionInFile = delegate.currentPositionInFile();
- final FileAccessRecord fileAccessRecord = new FileAccessRecord(
+ final FileAccessRecordForTests fileAccessRecord = new FileAccessRecordForTests(
positionInFile, data, 0, length);
delegate.write(data);
writeLog.add(fileAccessRecord);
@@ -101,7 +101,7 @@
public void write(final byte[] data, final int offset, final int length)
throws FileIOException {
final long positionInFile = delegate.currentPositionInFile();
- final FileAccessRecord fileAccessRecord = new FileAccessRecord(
+ final FileAccessRecordForTests fileAccessRecord = new FileAccessRecordForTests(
positionInFile, data, offset, length);
delegate.write(data);
writeLog.add(fileAccessRecord);
@@ -112,7 +112,7 @@
writeLog.clear();
}
- public FileAccessRecord pollFirstRead() {
+ public FileAccessRecordForTests pollFirstRead() {
return readLog.pollFirst();
}
@@ -120,7 +120,7 @@
return readLog.size();
}
- public FileAccessRecord pollFirstWrote() {
+ public FileAccessRecordForTests pollFirstWrote() {
return writeLog.pollFirst();
}
@@ -128,6 +128,15 @@
return writeLog.size();
}
+ public String readLogToString() {
+ final StringBuilder stringBuilder = new StringBuilder();
+ for (FileAccessRecordForTests fileAccessRecord : readLog) {
+ stringBuilder.append(fileAccessRecord.toString());
+ stringBuilder.append('\n');
+ }
+ return stringBuilder.toString();
+ }
+
@Override
public void seek(final long positionInFile) throws FileIOException {
delegate.seek(positionInFile);
@@ -139,11 +148,6 @@
}
@Override
- public void clearCache() throws FileIOException {
- delegate.clearCache();
- }
-
- @Override
public void close() throws FileIOException {
delegate.close();
}
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -29,7 +29,7 @@
import net.sf.joafip.DoNotTransform;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
-import net.sf.joafip.file.entity.FileAccessRecord;
+import net.sf.joafip.file.entity.FileAccessRecordForTests;
import net.sf.joafip.logger.JoafipLogger;
/**
@@ -138,7 +138,7 @@
// check page 0 wrote
assertEquals(BAD_READ_ACCESS, 0, probe.readLogSize());
assertEquals(BAD_WRITE_ACCESS, 1, probe.writeLogSize());
- FileAccessRecord record = probe.pollFirstWrote();
+ FileAccessRecordForTests record = probe.pollFirstWrote();
assertNotNull("must write at 3*PAGE_SIZE", record);
assertEquals(BAD_POSITION_IN_FILE, 3 * PAGE_SIZE,
record.getPositionInFile());
@@ -197,10 +197,20 @@
+ randomFileAccess.getPageSet().toString());
}
- assertEquals(BAD_READ_ACCESS, 2, probe.readLogSize());
+ assertEquals(BAD_READ_ACCESS + '\n' + probe.readLogToString(), 5,
+ probe.readLogSize());
assertEquals(BAD_WRITE_ACCESS, 0, probe.writeLogSize());
record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 0 * PAGE_SIZE,
+ record.getPositionInFile());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 1 * PAGE_SIZE,
+ record.getPositionInFile());
+ record = probe.pollFirstRead();
+ assertEquals(BAD_POSITION_IN_FILE, 2 * PAGE_SIZE,
+ record.getPositionInFile());
+ record = probe.pollFirstRead();
assertEquals(BAD_POSITION_IN_FILE, 3 * PAGE_SIZE,
record.getPositionInFile());
assertEquals(BAD_DATA, createStrPageData('3'), record.getStrData());
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/TestRandomAccessFileCache.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/TestRandomAccessFileCache.java 2012-05-01 18:43:45 UTC (rev 3056)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/TestRandomAccessFileCache.java 2012-05-01 20:02:42 UTC (rev 3057)
@@ -94,7 +94,7 @@
public void testWroteInFile() throws FileIOException {
writeData();
fileCache.close();
- fileCache.clearCache();
+ // fileCache.clearCache();
fileCache.open();
assertWroteReading();
}
@@ -102,7 +102,7 @@
public void testRandomBlock() throws FileIOException {
writeData();
fileCache.close();
- fileCache.clearCache();
+ // fileCache.clearCache();
fileCache.open();
writeBlock(25, 200);
@@ -133,7 +133,7 @@
}
fileCache.flush();
fileCache.close();
- fileCache.clearCache();
+ // fileCache.clearCache();
/*
* change value in first page, when read enough to activate old page
@@ -150,7 +150,7 @@
}
fileCache.flush();
fileCache.close();
- fileCache.clearCache();
+ // fileCache.clearCache();
/*
* check if first page wrote
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 20:02:49
|
Revision: 3057
http://joafip.svn.sourceforge.net/joafip/?rev=3057&view=rev
Author: luc_peuvrier
Date: 2012-05-01 20:02:42 +0000 (Tue, 01 May 2012)
Log Message:
-----------
javadoc update, clearCache no more public, must not be public
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/entity/PageNode.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCacheTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/TestRandomAccessFileCache.java
Added Paths:
-----------
trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecordForTests.java
Removed Paths:
-------------
trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 18:44:08
|
Revision: 3056
http://joafip.svn.sourceforge.net/joafip/?rev=3056&view=rev
Author: luc_peuvrier
Date: 2012-05-01 18:43:45 +0000 (Tue, 01 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : integrations tests changed, comparison with heap file and btree plus using random key insertion
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainMemGraphDraw.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Searcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java
trunk/joafip-4test/src/main/resources/log4j.properties
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CheckRandomList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateRandomList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithoutCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithoutCache.java
trunk/joafip-4test/src/main/resources/all.txt
trunk/joafip-4test/src/main/resources/firstHalf.txt
trunk/joafip-4test/src/main/resources/secondHalf.txt
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -38,7 +38,6 @@
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
import net.sf.joafip.service.IDataAccessSession;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
/**
*
@@ -47,31 +46,15 @@
*/
public class AbstractDeleter extends AbstractPerfService {
- public AbstractDeleter(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- public AbstractDeleter(final String pathName)
+ protected void run(final String pathName,
+ final IHeapDataManager dataManager, final Boolean useCache)
throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
- }
-
- protected void run() throws FilePersistenceException,
- FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
FilePersistenceDataCorruptedException,
FilePersistenceNotSerializableException,
FilePersistenceTooBigForSerializationException, IOException {
+ initialize(pathName, dataManager, useCache);
final IDataAccessSession session = filePersistence
.createDataAccessSession();
session.open();
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -22,11 +22,14 @@
*/
package net.sf.joafip.performance.items.service;
+import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
@@ -56,7 +59,6 @@
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
import net.sf.joafip.service.IDataAccessSession;
import net.sf.joafip.service.MemInspectorJoafipSetup;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
import net.sf.joafip.store.service.StoreException;
import net.sf.joafip.store.service.proxy.StaticProxyCallBack;
@@ -95,26 +97,26 @@
private int usedPageRootNodeSize;
- public AbstractInserter(final String pathName)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
+ protected void clearDirectory(final String pathName) {
+ /* remove existing data */
+ final File dataDirectory = new File(pathName);
+ if (dataDirectory.exists()) {
+ if (dataDirectory.isDirectory()) {
+ for (final File file : dataDirectory.listFiles()) {
+ file.delete();
+ }
+ } else {
+ dataDirectory.delete();
+ dataDirectory.mkdirs();
+ }
+ } else {
+ dataDirectory.mkdirs();
+ }
}
- public AbstractInserter(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- protected void run(final int numberOfItem) throws FilePersistenceException,
+ protected void run(final String pathName,
+ final IHeapDataManager dataManager, final Boolean useCache,
+ final int numberOfItem) throws FilePersistenceException,
StoreException, FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
FilePersistenceDataCorruptedException,
@@ -122,6 +124,7 @@
IOException, SecurityException, IllegalArgumentException,
NoSuchFieldException, IllegalAccessException,
FilePersistenceTooBigForSerializationException {
+ initialize(pathName, dataManager, useCache);
final Runtime runtime = Runtime.getRuntime();
final MemInspector memInspectorForMemory = new MemInspector();
addTemplate();
@@ -137,9 +140,16 @@
initMemInspector();
session.open();
initializeByItemDuration();
- boolean added = false;
+ boolean objectAddedInMemory = false;
long duration = 0;
- for (int identifier = 0; !added && identifier < numberOfItem + 1; identifier++) {
+ final InputStream inputStream = getClass().getResourceAsStream(
+ "/all.txt");
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(
+ inputStream));
+ final long insertStartTime = System.currentTimeMillis();
+ int count;
+ for (count = 0; (System.currentTimeMillis() - insertStartTime) < 5 * 60 * 1000
+ && !objectAddedInMemory && count < numberOfItem + 1; count++) {
// final ItemTemplateList itemTemplateList =
// getItemTemplateList(session);
// final ItemTemplate itemTemplate;
@@ -156,17 +166,19 @@
// default:
// itemTemplate = null;
// }
+ final int identifier = Integer.parseInt(reader.readLine());
+
addItem(session, identifier);
- if (identifier % BATCH_SIZE == BATCH_SIZE - 1) {
+ if (count % BATCH_SIZE == BATCH_SIZE - 1) {
final long startTime = System.currentTimeMillis();
session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
final long currentTime = System.currentTimeMillis();
System.gc();
- added = checkAdded(byItemIndex);
+ objectAddedInMemory = checkObjectAddedInMemory(byItemIndex);
duration += (currentTime - startTime);
- final long byItem = duration * 1000 / (identifier + 1);
+ final long byItem = duration * 1000 / (count + 1);
final long memUse = runtime.totalMemory()
- runtime.freeMemory();
byItemMem[byItemIndex] = (int) (memUse / 1024);
@@ -178,7 +190,7 @@
builder.append('\n');
builder.append(duration);
builder.append(" mS ");
- builder.append(identifier + 1);
+ builder.append(count + 1);
builder.append(" appened, by item ");
builder.append(byItem);
builder.append(" µS\nmem used=");
@@ -197,7 +209,7 @@
builder.append("\nmax= ");
builder.append(mem(maxMemUse2));
}
- if (FILE_CACHE) {
+ if (useCache != null && useCache.booleanValue()) {
builder.append("\npageSet size=");
builder.append(pageSetSize);
builder.append('/');
@@ -219,7 +231,7 @@
session.open();
}
}
-
+ reader.close();
session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
session.open();
@@ -229,7 +241,7 @@
FILE_FOR_LUC.delete();
- logSize(-1, duration);
+ logSize(count, -1, duration);
// startTime = System.currentTimeMillis();
// final int numberGarbaged = filePersistence.garbageSweep();
@@ -255,7 +267,7 @@
objectOutputStream.close();
}
- if (added) {
+ if (objectAddedInMemory) {
ShowObjectTree.show("runtime/mem.bin");
}
}
@@ -274,7 +286,7 @@
}
@SuppressWarnings("unchecked")
- private boolean checkAdded(final int byItemIndex)
+ private boolean checkObjectAddedInMemory(final int byItemIndex)
throws MemInspectorException, SecurityException,
NoSuchFieldException, IllegalArgumentException,
IllegalAccessException {
@@ -291,7 +303,7 @@
markNew = byItemIndex >= 2;
added = false;
}
- if (FILE_CACHE) {
+ if (useCache != null && useCache.booleanValue()) {
final List<Object> list = memInspector
.getInstanceOfClass("net.sf.joafip.file.service.RandomAccessFileReadWriteCache");
if (list.size() != 1) {
@@ -340,13 +352,15 @@
}
/**
+ * @param numberOfItem
* @param numberGarbaged
* @param duration
* @throws FilePersistenceException
* @throws FileNotFoundException
*/
- private void logSize(final int numberGarbaged, final long duration)
- throws FilePersistenceException, FileNotFoundException {
+ private void logSize(final int numberOfItem, final int numberGarbaged,
+ final long duration) throws FilePersistenceException,
+ FileNotFoundException {
PrintWriter writer;
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(FILE_FOR_LUC, true))));
@@ -354,7 +368,7 @@
message = "-----------------------";
printMessage(writer, message);
- message = "nb of item=" + NUMBER_OF_ITEM;
+ message = "nb of item=" + numberOfItem;
printMessage(writer, message);
message = "batch size=" + BATCH_SIZE;
printMessage(writer, message);
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -36,11 +36,10 @@
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
import net.sf.joafip.service.IDataAccessSession;
import net.sf.joafip.service.IFilePersistence;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
@NotStorableClass
@StorableAccess
-public class AbstractPerfService {
+public abstract class AbstractPerfService {
private static final String FAILED_DELETE = "failed delete ";
@@ -59,8 +58,6 @@
private static final boolean GARBAGE = false;
- protected static final boolean FILE_CACHE = true;
-
protected static final int PAGE_SIZE = 4 * 1024;
protected static final int NUMBER_OF_PAGE = 4 * 1024;
@@ -80,44 +77,23 @@
protected int byItemIndex;
- private final String pathName;
+ protected Boolean useCache;
- private final IHeapDataManager dataManager;
-
- public AbstractPerfService(final String pathName)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super();
- this.pathName = pathName;
- this.dataManager = null;// NOPMD
- initialize();
- }
-
- public AbstractPerfService(final IHeapDataManager dataManager)
+ protected void initialize(final String pathName,
+ final IHeapDataManager dataManager, final Boolean useCache)
throws FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException, FilePersistenceException,
FilePersistenceTooBigForSerializationException {
- super();
- this.dataManager = dataManager;
- this.pathName = null;// NOPMD
- initialize();
- }
-
- private void initialize() throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
+ this.useCache = useCache;
final FilePersistenceBuilder builder = new FilePersistenceBuilder();
try {
if (dataManager == null) {
builder.setPathName(pathName);
+ if (useCache) {
+ builder.setFileCache(PAGE_SIZE, NUMBER_OF_PAGE);
+ }
} else {
builder.setDataManager(dataManager);
}
@@ -125,27 +101,6 @@
builder.setProxyMode(true);
builder.setCrashSafeMode(CRASH_SAFE_MODE);
builder.setGarbageManagement(GARBAGE);
- if (FILE_CACHE) {
- // filePersistence = new FilePersistence(1, null, RUNTIME_DIR,
- // /**/false/* do not remove files */,
- // /**/PAGE_SIZE, NUMBER_OF_PAGE,
- // /**/GARBAGE,
- // /**/CRASH_SAFE_MODE);
- builder.setFileCache(PAGE_SIZE, NUMBER_OF_PAGE);
- }
- // else {
- // if (CRASH_SAFE_MODE) {
- // filePersistence = new FilePersistence(1, null, RUNTIME_DIR,
- // /**/false/* do not remove files */,
- // /**/GARBAGE);
- // } else {
- // filePersistence = new FilePersistence(1, null, RUNTIME_DIR,
- // /**/true/* proxyMode */,
- // /**/false/* removeFiles */,
- // /**/GARBAGE/* garbageManagement */,
- // /**/CRASH_SAFE_MODE);
- // }
- // }
filePersistence = builder.build();
} catch (final FilePersistenceException exception) {
final EnumFileState fileState = FilePersistence
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -41,7 +41,6 @@
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
import net.sf.joafip.service.IDataAccessSession;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
/**
*
@@ -52,32 +51,15 @@
private final JoafipLogger logger = JoafipLogger.getLogger(getClass());
- public AbstractSearcher(final String pathName)
+ protected void run(final String pathName,
+ final IHeapDataManager dataManager, final Boolean useCache)
throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
- }
-
- public AbstractSearcher(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- protected void run() throws FilePersistenceException,
- FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
FilePersistenceDataCorruptedException,
FilePersistenceNotSerializableException, FileNotFoundException,
IOException, FilePersistenceTooBigForSerializationException {
-
+ initialize(pathName, dataManager, useCache);
long maxSearchTime = Long.MIN_VALUE;
long minSearchTime = Long.MAX_VALUE;
final long startTime = System.currentTimeMillis();
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CheckRandomList.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CheckRandomList.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CheckRandomList.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -0,0 +1,62 @@
+/*
+ * 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.performance.items.service;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class CheckRandomList {
+
+ public static void main(final String[] args) {
+ try {
+ final Set<Integer> set = new TreeSet<Integer>();
+ final InputStream inputStream = CheckRandomList.class
+ .getResourceAsStream("/all.txt");
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(inputStream));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ final int identifier = Integer.parseInt(line);
+ if (!set.add(identifier)) {
+ throw new Exception(identifier + " is duplicate");
+ }
+ }
+ reader.close();
+ if (set.size() != AbstractPerfService.NUMBER_OF_ITEM) {
+ throw new Exception(set.size() + " for "
+ + AbstractPerfService.NUMBER_OF_ITEM + " expected");
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -1,63 +0,0 @@
-/*
- * 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.performance.items.service;
-
-import java.io.PrintWriter;
-import java.util.List;
-import java.util.Random;
-
-import net.sf.joafip.java.util.PTreeList;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class CreateDeleteList {
-
- public static void main(String[] args) {
- try {
- final List<Integer> list = new PTreeList<Integer>();
- for (int identifier = 0; identifier < AbstractPerfService.NUMBER_OF_ITEM; identifier++) {
- list.add(identifier);
- }
- PrintWriter writer = new PrintWriter("runtime_perf/toDelete.txt");
- final Random random = new Random(System.currentTimeMillis());
- for (int count = 0; count < AbstractPerfService.NUMBER_OF_ITEM / 2; count++) {
- final int upperBound = list.size();
- final int index = random.nextInt(upperBound);
- int identifier = list.remove(index);
- writer.println(identifier);
- }
- writer.close();
- writer = new PrintWriter("runtime_perf/toSearch.txt");
- for (int identifier : list) {
- writer.println(identifier);
- }
- writer.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateRandomList.java (from rev 3053, trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateRandomList.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateRandomList.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -0,0 +1,73 @@
+/*
+ * 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.performance.items.service;
+
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.Random;
+
+import net.sf.joafip.java.util.PTreeList;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class CreateRandomList {
+
+ public static void main(String[] args) {
+ try {
+ final List<Integer> list = new PTreeList<Integer>();
+ for (int identifier = 0; identifier < AbstractPerfService.NUMBER_OF_ITEM; identifier++) {
+ list.add(identifier);
+ }
+ PrintWriter allWriter = new PrintWriter(
+ "src/main/resources/all.txt");
+ PrintWriter writer = new PrintWriter(
+ "src/main/resources/firstHalf.txt");
+ final Random random = new Random(System.currentTimeMillis());
+ int count;
+ for (count = 0; count < AbstractPerfService.NUMBER_OF_ITEM / 2; count++) {
+ final int upperBound = list.size();
+ final int index = random.nextInt(upperBound);
+ int identifier = list.remove(index);
+ writer.println(identifier);
+ allWriter.println(identifier);
+ }
+ writer.close();
+ writer = new PrintWriter("src/main/resources/secondHalf.txt");
+ for (; count < AbstractPerfService.NUMBER_OF_ITEM; count++) {
+ final int upperBound = list.size();
+ final int index = random.nextInt(upperBound);
+ int identifier = list.remove(index);
+ writer.println(identifier);
+ allWriter.println(identifier);
+ }
+ writer.close();
+ allWriter.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -24,9 +24,11 @@
package net.sf.joafip.performance.items.service;
import java.io.File;
+import java.io.IOException;
import net.sf.joafip.btreeplus.service.BtreePlusDataManager;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
@@ -35,7 +37,6 @@
import net.sf.joafip.service.FilePersistenceInvalidClassException;
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
/**
*
@@ -47,42 +48,31 @@
private final static JoafipLogger LOGGER = JoafipLogger
.getLogger(DeleterBtreePlus.class);
- public DeleterBtreePlus(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
+ private void run() throws HeapException, FilePersistenceException,
FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- public DeleterBtreePlus(final String pathName)
- throws FilePersistenceException,
FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
+ FilePersistenceTooBigForSerializationException, IOException {
+ final String dataFilePath = RUNTIME_DIR + "/block.data";
+ final File dataFile = new File(dataFilePath);
+ final HeapFileSetup setup = new HeapFileSetup(dataFile,
+ CRASH_SAFE_MODE/* crashSafeMode */,
+ false/* FILE_CACHE *//* useCacheMode */,
+ false/* deleteRenaming */, false/* clearResizeFile */,
+ 0/* maxFileOperationRetry */, 0/* fileOperationRetryMsDelay */,
+ null/* openFileTraceFile */);
+ // if (FILE_CACHE) {
+ // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
+ // }
+ final IHeapDataManager dataManager =
+ /**/new BtreePlusDataManager(setup);
+ run(null, dataManager, true);
}
public static void main(final String[] args) {
- final String dataFilePath = RUNTIME_DIR + "/block.data";
- final File dataFile = new File(dataFilePath);
- DeleterBtreePlus deleter;
try {
- final HeapFileSetup setup = new HeapFileSetup(dataFile,
- CRASH_SAFE_MODE/* crashSafeMode */,
- false/* FILE_CACHE *//* useCacheMode */,
- false/* deleteRenaming */, false/* clearResizeFile */,
- 0/* maxFileOperationRetry */,
- 0/* fileOperationRetryMsDelay */, null/* openFileTraceFile */);
- // if (FILE_CACHE) {
- // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
- // }
- final IHeapDataManager dataManager =
- /**/new BtreePlusDataManager(setup);
- deleter = new DeleterBtreePlus(dataManager);
+ DeleterBtreePlus deleter = new DeleterBtreePlus();
deleter.run();
} catch (final Throwable throwable) {// NOPMD catch all
LOGGER.fatal("error", throwable);
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -26,7 +26,6 @@
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
import net.sf.joafip.store.service.IGarbageListener;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
@NotStorableClass
@StorableAccess
@@ -38,25 +37,22 @@
public static void main(final String[] args) {
Garbage garbage;
try {
- garbage = new Garbage(RUNTIME_DIR);
+ garbage = new Garbage();
garbage.execute();
} catch (final Throwable throwable) {// NOPMD catch all
LOGGER.fatal("error", throwable);
}
}
- public Garbage(final String pathName) throws FilePersistenceException,
+ private long displayTime;
+
+ private void execute() throws FilePersistenceException,
FilePersistenceInvalidClassException,
FilePersistenceNotSerializableException,
FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceDataCorruptedException,
FilePersistenceTooBigForSerializationException {
- super(pathName);
- }
-
- private long displayTime;
-
- private void execute() throws FilePersistenceException {
+ initialize(RUNTIME_DIR, null, true);
final long startTime = System.currentTimeMillis();
displayTime = startTime - 2000;
filePersistence.setGarbageListener(this);
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -16,6 +16,9 @@
*/
package net.sf.joafip.performance.items.service;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.logger.JoafipLogger;
@@ -25,7 +28,6 @@
import net.sf.joafip.service.FilePersistenceInvalidClassException;
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
@NotStorableClass
@StorableAccess
@@ -34,20 +36,19 @@
private static final JoafipLogger LOGGER = JoafipLogger
.getLogger(ImportSearcher.class);
- public ImportSearcher(final String pathName)
- throws FilePersistenceException,
+ private void run() throws FileNotFoundException, FilePersistenceException,
+ FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, IOException,
FilePersistenceTooBigForSerializationException {
- super(pathName);
+ run("runtime_perf/from_import", null, true);
}
public static void main(final String[] args) {
ImportSearcher searcher;
try {
- searcher = new ImportSearcher("runtime_perf/from_import");
+ searcher = new ImportSearcher();
searcher.run();
} catch (final Throwable throwable) {// NOPMD catch all
LOGGER.fatal("error", throwable);
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -1,65 +0,0 @@
-/*
- * Copyright 2011 Luc Peuvrier
- *
- * 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
- *
- * 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.performance.items.service;//NOPMD
-
-import java.io.File;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.StorableAccess;
-import net.sf.joafip.logger.JoafipLogger;
-import net.sf.joafip.service.FilePersistenceClassNotFoundException;
-import net.sf.joafip.service.FilePersistenceDataCorruptedException;
-import net.sf.joafip.service.FilePersistenceException;
-import net.sf.joafip.service.FilePersistenceInvalidClassException;
-import net.sf.joafip.service.FilePersistenceNotSerializableException;
-import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
-
-@SuppressWarnings("PMD")
-@NotStorableClass
-@StorableAccess
-public class Inserter extends AbstractInserter {
-
- private static final JoafipLogger LOGGER = JoafipLogger
- .getLogger(Inserter.class);
-
- public Inserter(final String pathName) throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
- }
-
- public static void main(final String[] args) {
- /* remove existing data */
- final File dataDirectory = new File(RUNTIME_DIR);
- for (final File file : dataDirectory.listFiles()) {
- file.delete();
- }
- dataDirectory.mkdirs();
- Inserter inserter;
- try {
- inserter = new Inserter(RUNTIME_DIR);
- inserter.run(NUMBER_OF_ITEM);
- inserter.close();
- } catch (final Throwable throwable) {// NOPMD catch all
- LOGGER.fatal("error", throwable);
- }
- }
-}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -16,20 +16,22 @@
*/
package net.sf.joafip.performance.items.service;//NOPMD
-import java.io.File;
+import java.io.IOException;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.kvstore.service.BlockDataManager;
+import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.meminspector.service.MemInspectorException;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
import net.sf.joafip.service.FilePersistenceDataCorruptedException;
import net.sf.joafip.service.FilePersistenceException;
import net.sf.joafip.service.FilePersistenceInvalidClassException;
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
+import net.sf.joafip.store.service.StoreException;
@SuppressWarnings("PMD")
@NotStorableClass
@@ -39,35 +41,25 @@
private static final JoafipLogger LOGGER = JoafipLogger
.getLogger(InserterBKM.class);
- private InserterBKM(final String pathName) throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
+ private void run() throws SecurityException, IllegalArgumentException,
+ FilePersistenceException, StoreException,
FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, NoSuchFieldException, IllegalAccessException,
+ FilePersistenceTooBigForSerializationException, HeapException {
+ final String dataFile = RUNTIME_DIR + "/block.data";
+ clearDirectory(RUNTIME_DIR);
+ final IHeapDataManager dataManager =
+ /**/new BlockDataManager(dataFile, 1024);
+ run(null, dataManager, null, NUMBER_OF_ITEM);
}
- private InserterBKM(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
public static void main(final String[] args) {
- final String dataFile = RUNTIME_DIR + "/block.data";
- /* remove existing data */
- new File(dataFile).delete();
- new File(RUNTIME_DIR).mkdirs();
- InserterBKM inserter;
try {
- final IHeapDataManager dataManager =
- /**/new BlockDataManager(dataFile, 1024);
- inserter = new InserterBKM(dataManager);
- inserter.run(NUMBER_OF_ITEM);
+ final InserterBKM inserter = new InserterBKM();
+ inserter.run();
inserter.close();
} catch (final Throwable throwable) {// NOPMD catch all
LOGGER.fatal("error", throwable);
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -1,93 +0,0 @@
-/*
- * Copyright 2011 Luc Peuvrier
- *
- * 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
- *
- * 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.performance.items.service;//NOPMD
-
-import java.io.File;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.StorableAccess;
-import net.sf.joafip.btreeplus.service.BtreePlusDataManager;
-import net.sf.joafip.kvstore.entity.HeapFileSetup;
-import net.sf.joafip.kvstore.service.IHeapDataManager;
-import net.sf.joafip.logger.JoafipLogger;
-import net.sf.joafip.service.FilePersistenceClassNotFoundException;
-import net.sf.joafip.service.FilePersistenceDataCorruptedException;
-import net.sf.joafip.service.FilePersistenceException;
-import net.sf.joafip.service.FilePersistenceInvalidClassException;
-import net.sf.joafip.service.FilePersistenceNotSerializableException;
-import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
-
-@SuppressWarnings("PMD")
-@NotStorableClass
-@StorableAccess
-public final class InserterBtreePlus extends AbstractInserter {
-
- private static final JoafipLogger LOGGER = JoafipLogger
- .getLogger(InserterBtreePlus.class);
-
- private InserterBtreePlus(final String pathName)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(pathName);
- }
-
- private InserterBtreePlus(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- public static void main(final String[] args) {
- /* remove existing data */
- final File dataDirectory = new File(RUNTIME_DIR);
- for (final File file : dataDirectory.listFiles()) {
- file.delete();
- }
- dataDirectory.mkdirs();
- final String dataFilePath = RUNTIME_DIR + "/block.data";
- /* remove existing data */
- final File dataFile = new File(dataFilePath);
- dataFile.delete();
- InserterBtreePlus inserter;
- try {
- final HeapFileSetup setup = new HeapFileSetup(dataFile,
- CRASH_SAFE_MODE/* crashSafeMode */,
- false/* FILE_CACHE *//* useCacheMode */,
- false/* deleteRenaming */, false/* clearResizeFile */,
- 0/* maxFileOperationRetry */,
- 0/* fileOperationRetryMsDelay */, null/* openFileTraceFile */);
- // if (FILE_CACHE) {
- // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
- // }
- final IHeapDataManager dataManager =
- /**/new BtreePlusDataManager(setup);
- inserter = new InserterBtreePlus(dataManager);
- inserter.run(NUMBER_OF_ITEM);
- inserter.close();
- } catch (final Throwable throwable) {// NOPMD catch all
- LOGGER.fatal("error", throwable);
- }
- }
-}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithCache.java (from rev 3053, trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithCache.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithCache.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * 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
+ *
+ * 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.performance.items.service;//NOPMD
+
+import java.io.File;
+import java.io.IOException;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.btreeplus.service.BtreePlusDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.meminspector.service.MemInspectorException;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreException;
+
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public final class InserterBtreePlusWhithCache extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterBtreePlusWhithCache.class);
+
+ private void run() throws HeapException, SecurityException,
+ IllegalArgumentException, FilePersistenceException, StoreException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, NoSuchFieldException, IllegalAccessException,
+ FilePersistenceTooBigForSerializationException {
+ /* remove existing data */
+ clearDirectory(RUNTIME_DIR);
+ final String dataFilePath = RUNTIME_DIR + "/block.data";
+ /* remove existing data */
+ final File dataFile = new File(dataFilePath);
+ dataFile.delete();
+ final HeapFileSetup setup = new HeapFileSetup(dataFile,
+ CRASH_SAFE_MODE/* crashSafeMode */, true/* useCacheMode */,
+ false/* deleteRenaming */, false/* clearResizeFile */,
+ 0/* maxFileOperationRetry */, 0/* fileOperationRetryMsDelay */,
+ null/* openFileTraceFile */);
+ setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
+ final IHeapDataManager dataManager =
+ /**/new BtreePlusDataManager(setup);
+
+ run(null, dataManager, true, NUMBER_OF_ITEM);
+ }
+
+ public static void main(final String[] args) {
+ try {
+ InserterBtreePlusWhithCache inserter = new InserterBtreePlusWhithCache();
+ inserter.run();
+ inserter.close();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithoutCache.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithoutCache.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithoutCache.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * 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
+ *
+ * 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.performance.items.service;//NOPMD
+
+import java.io.File;
+import java.io.IOException;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.btreeplus.service.BtreePlusDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.meminspector.service.MemInspectorException;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreException;
+
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public final class InserterBtreePlusWhithoutCache extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterBtreePlusWhithoutCache.class);
+
+ private void run() throws HeapException, SecurityException,
+ IllegalArgumentException, FilePersistenceException, StoreException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, NoSuchFieldException, IllegalAccessException,
+ FilePersistenceTooBigForSerializationException {
+ /* remove existing data */
+ clearDirectory(RUNTIME_DIR);
+ final String dataFilePath = RUNTIME_DIR + "/block.data";
+ /* remove existing data */
+ final File dataFile = new File(dataFilePath);
+ dataFile.delete();
+ final HeapFileSetup setup = new HeapFileSetup(dataFile,
+ CRASH_SAFE_MODE/* crashSafeMode */,
+ false/* FILE_CACHE *//* useCacheMode */,
+ false/* deleteRenaming */, false/* clearResizeFile */,
+ 0/* maxFileOperationRetry */, 0/* fileOperationRetryMsDelay */,
+ null/* openFileTraceFile */);
+ // if (FILE_CACHE) {
+ // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
+ // }
+ final IHeapDataManager dataManager =
+ /**/new BtreePlusDataManager(setup);
+
+ run(null, dataManager, true, NUMBER_OF_ITEM);
+ }
+
+ public static void main(final String[] args) {
+ try {
+ InserterBtreePlusWhithoutCache inserter = new InserterBtreePlusWhithoutCache();
+ inserter.run();
+ inserter.close();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java 2012-05-01 17:58:39 UTC (rev 3055)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -22,18 +22,19 @@
*/
package net.sf.joafip.performance.items.service;//NOPMD
-import java.io.File;
+import java.io.IOException;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.meminspector.service.MemInspectorException;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
import net.sf.joafip.service.FilePersistenceDataCorruptedException;
import net.sf.joafip.service.FilePersistenceException;
import net.sf.joafip.service.FilePersistenceInvalidClassException;
import net.sf.joafip.service.FilePersistenceNotSerializableException;
import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
-import net.sf.joafip.store.service.StoreClassNotFoundException;
+import net.sf.joafip.store.service.StoreException;
/**
*
@@ -48,27 +49,23 @@
private static final JoafipLogger LOGGER = JoafipLogger
.getLogger(InserterFewInsertAndExport.class);
- public InserterFewInsertAndExport(final String pathName)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
+ private void run() throws SecurityException, IllegalArgumentException,
+ FilePersistenceException, StoreException,
FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, NoSuchFieldException, IllegalAccessException,
FilePersistenceTooBigForSerializationException {
- super(pathName);
+ clearDirectory("runtime");
+ run("runtime", null, true, 1);
}
public static void main(final String[] args) {
- /* remove existing data */
- final File dataDirectory = new File("runtime");
- for (final File file : dataDirectory.listFiles()) {
- file.delete();
- }
- dataDirectory.mkdirs();
InserterFewInsertAndExport inserter;
try {
- inserter = new InserterFewInsertAndExport("runtime");
- inserter.run(1);
+ inserter = new InserterFewInsertAndExport();
+ inserter.run();
inserter.export("runtime");
inserter.close();
} catch (final Throwable throwable) {// NOPMD catch all
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithCache.java (from rev 3045, trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithCache.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithCache.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * 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
+ *
+ * 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.performance.items.service;//NOPMD
+
+import java.io.IOException;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.meminspector.service.MemInspectorException;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreException;
+
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public class InserterHeapFileWithCache extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterHeapFileWithCache.class);
+
+ private void run() throws SecurityException, IllegalArgumentException,
+ FilePersistenceException, StoreException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, NoSuchFieldException, IllegalAccessException,
+ FilePersistenceTooBigForSerializationException {
+ clearDirectory(RUNTIME_DIR);
+ run(RUNTIME_DIR, null, true, NUMBER_OF_ITEM);
+ close();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ InserterHeapFileWithCache inserter = new InserterHeapFileWithCache();
+ inserter.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithoutCache.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithoutCache.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithoutCache.java 2012-05-01 18:43:45 UTC (rev 3056)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * 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
+ *
+ * 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.performance.items.service;//NOPMD
+
+import java.io.IOException;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.meminspector.service.MemInspectorException;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreException;
+
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public class InserterHeapFileWithoutCache extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterHeapFileWithoutCache.class);
+
+ private void run() throws SecurityException, IllegalArgumentException,
+ FilePersistenceException, StoreException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException, MemInspectorException,
+ IOException, NoSuch...
[truncated message content] |
|
From: <luc...@us...> - 2012-05-01 18:44:06
|
Revision: 3056
http://joafip.svn.sourceforge.net/joafip/?rev=3056&view=rev
Author: luc_peuvrier
Date: 2012-05-01 18:43:45 +0000 (Tue, 01 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization : integrations tests changed, comparison with heap file and btree plus using random key insertion
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Garbage.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ImportSearcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterFewInsertAndExport.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainMemGraphDraw.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Searcher.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java
trunk/joafip-4test/src/main/resources/log4j.properties
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CheckRandomList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateRandomList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlusWhithoutCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterHeapFileWithoutCache.java
trunk/joafip-4test/src/main/resources/all.txt
trunk/joafip-4test/src/main/resources/firstHalf.txt
trunk/joafip-4test/src/main/resources/secondHalf.txt
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Inserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 17:58:46
|
Revision: 3055
http://joafip.svn.sourceforge.net/joafip/?rev=3055&view=rev
Author: luc_peuvrier
Date: 2012-05-01 17:58:39 +0000 (Tue, 01 May 2012)
Log Message:
-----------
todo update
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 17:58:46
|
Revision: 3055
http://joafip.svn.sourceforge.net/joafip/?rev=3055&view=rev
Author: luc_peuvrier
Date: 2012-05-01 17:58:39 +0000 (Tue, 01 May 2012)
Log Message:
-----------
todo update
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2012-05-01 15:44:39 UTC (rev 3054)
+++ trunk/joafip/doc/_todo.txt 2012-05-01 17:58:39 UTC (rev 3055)
@@ -91,7 +91,6 @@
-------------------------------------------------------------------------------------
btree+ implementation
-- problems with previous data record
- management of leaf page link
- add to header first leaf page position
- check link to leaf page to next
@@ -103,6 +102,10 @@
- replace HeapDataFileManager direct use and option for main joafip storage
- replace internal use of HeapFileDataManager by BtreePlusDataManager
+file cache:
+when save, do not clear read cache (if file not closed and externally accessible), move wrote to read cache.
+
+
changes for garbage management because of autosave
- tests to add
- test for state machine
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|