[Joafip-svn] SF.net SVN: joafip:[2993] trunk
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2012-03-06 08:44:21
|
Revision: 2993
http://joafip.svn.sourceforge.net/joafip/?rev=2993&view=rev
Author: luc_peuvrier
Date: 2012-03-06 08:44:06 +0000 (Tue, 06 Mar 2012)
Log Message:
-----------
file tree map project added
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/src/main/java/net/sf/joafip/store/entity/heaprecordable/AbstractHeapRecordableRBTNode.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestRuntime310Garbage.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java
trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeSubSet.java
trunk/joafip-heapfile/pom.xml
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/AbstractFileStorable.java
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/DataRecordIdentifier.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapIdNode.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/IDataRecordKey.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/NullDataRecordKey.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractHeapDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java
trunk/joafip-pmap/pom.xml
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/entity/IRBTNode.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/entity/RBTSentinel.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/entity/RBTNode.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/service/RedBlackTree.java
trunk/joafip-rbtree/src/test/java/net/sf/joafip/redblacktree/service/AbstractTestByPosition.java
trunk/joafip-rbtree/src/test/java/net/sf/joafip/redblacktree/service/AbstractTestDelete.java
trunk/joafip-rbtree/src/test/java/net/sf/joafip/redblacktree/service/TestDeleteDuplicate.java
trunk/joafip-testsuite/pom.xml
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/redblacktree/RedBlackTreeTests.java
Added Paths:
-----------
trunk/joafip/doc/class_comment_header_lgpl.txt
trunk/joafip/doc/licences.txt
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyManager.java
trunk/joafip-pmap/src/main/java/net/
trunk/joafip-pmap/src/main/java/net/sf/
trunk/joafip-pmap/src/main/java/net/sf/joafip/
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMapEntrySet.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMapKeyMgr.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMapKeySet.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMapValues.java
trunk/joafip-pmap/src/test/java/net/
trunk/joafip-pmap/src/test/java/net/sf/
trunk/joafip-pmap/src/test/java/net/sf/joafip/
trunk/joafip-pmap/src/test/java/net/sf/joafip/pmap/
trunk/joafip-pmap/src/test/java/net/sf/joafip/pmap/TestFileTreeMap.java
trunk/joafip-rbtree/src/test/java/net/sf/joafip/redblacktree/service/TestIndexMultipleValue.java
trunk/joafip-rbtree/src/test/java/net/sf/joafip/redblacktree/service/TestIndexUniqueValue.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/pmap/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/pmap/FileTreeMapTests.java
Removed Paths:
-------------
trunk/joafip/doc/class_comment_header.txt
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyComparator.java
trunk/joafip-rbtree/src/test/java/net/sf/joafip/redblacktree/service/TestIndex.java
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/doc/_todo.txt 2012-03-06 08:44:06 UTC (rev 2993)
@@ -109,6 +109,9 @@
a java agent to change "new Xxx" to call to newInstance proxied object factory for auto save
+sub set/map/list
+- add/check test contains, remove, add must failed if not in range
+
collection apache and google
BlockDataManger
Deleted: trunk/joafip/doc/class_comment_header.txt
===================================================================
--- trunk/joafip/doc/class_comment_header.txt 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/doc/class_comment_header.txt 2012-03-06 08:44:06 UTC (rev 2993)
@@ -1,22 +0,0 @@
-/*
- * Copyright 2011 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.
- */
Copied: trunk/joafip/doc/class_comment_header_lgpl.txt (from rev 2989, trunk/joafip/doc/class_comment_header.txt)
===================================================================
--- trunk/joafip/doc/class_comment_header_lgpl.txt (rev 0)
+++ trunk/joafip/doc/class_comment_header_lgpl.txt 2012-03-06 08:44:06 UTC (rev 2993)
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
Added: trunk/joafip/doc/licences.txt
===================================================================
--- trunk/joafip/doc/licences.txt (rev 0)
+++ trunk/joafip/doc/licences.txt 2012-03-06 08:44:06 UTC (rev 2993)
@@ -0,0 +1,124 @@
+LGPL:
+-----
+
+/*
+ * 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.
+ */
+
+APACHE:
+-------
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+
+ 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.
+
+A LESS RESTRICTIVE LICENCE (asm objectweb)
+------------------------------------------
+
+/*
+ * 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 "LGPL License");
+ * you may not use this file except in compliance with the "LGPL License" extended with here below additional permissions.
+ * You may obtain a copy of the "LGPL License" at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Additional permissions extensions for this file:
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted under the the Apache License, Version 2.0 (the "Apache License") instead of the "LGPL License"
+ * and if following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * You may obtain a copy of the "Apache License" at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ */
+
+
+Copyright (c) 2007-2012 Luc Peuvrier
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+
\ No newline at end of file
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/heaprecordable/AbstractHeapRecordableRBTNode.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/heaprecordable/AbstractHeapRecordableRBTNode.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/heaprecordable/AbstractHeapRecordableRBTNode.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -410,6 +410,16 @@
}
@Override
+ public void setIndex(final int index) {
+ node.setIndex(index);
+ }
+
+ @Override
+ public int getIndex() {
+ return node.getIndex();
+ }
+
+ @Override
public void decrementNumberOfChild() throws RBTException {
node.decrementNumberOfChild();
try {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -128,7 +128,7 @@
if (useCacheMode) {
setup.cacheSetup(pageSize, maxPage);
}
- this.dataManager = new HeapFileDataManager(setup);
+ this.dataManager = new HeapFileDataManager(setup, false);
} catch (HeapException exception) {
logger.fatal(CREATION_FAILED, exception);
throw new StoreException(CREATION_FAILED, exception);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -60,7 +60,7 @@
1/* maxFileOperationRetry */, 0/* fileOperationRetryMsDelay */,
null/* openFileTraceFile */);
setup.cacheSetup(1024/* pageSize */, 1024/* maxPage */);
- heapDataManagerForSet = new AutoSaveHeapFileDataManager(setup,
+ heapDataManagerForSet = new AutoSaveHeapFileDataManager(setup, false,
MAX_RECORDS);
minusOne = longToBinary(-1);
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -54,7 +54,7 @@
/**/false/* delete renaming */, false/* clearResizeFile */, 1, 0,
/**/openFileTraceFile);
setup.cacheSetup(16 * 1024, 100);
- dataManager = new HeapFileDataManager(setup);
+ dataManager = new HeapFileDataManager(setup, false);
super.setUp();
}
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestRuntime310Garbage.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestRuntime310Garbage.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestRuntime310Garbage.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -75,6 +75,7 @@
builder.setCrashSafeMode(false);
filePersistence = (FilePersistence) builder.build();
joafipMutex = filePersistence.getMutex();
+ filePersistence.addToNotCheckMethod(Bob1.class);
}
@Override
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -65,7 +65,7 @@
+ "/backup.ok"),
/**/new File(TestConstant.getWinRamDiskRuntimeDir()
+ "/global.ok"));
- dataManager = new HeapFileDataManager(setup);
+ dataManager = new HeapFileDataManager(setup, false);
dataManager.startService(true);
} catch (HeapException exception) {
if (dataManager == null) {
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -61,7 +61,8 @@
false/* clearResizeFile */, 0/* maxFileOperationRetry */,
0/* fileOperationRetryMsDelay */, new File(
"runtime/openFileTraceFile.txt"));
- final IHeapDataManager fileDataManager = new HeapFileDataManager(setup);
+ final IHeapDataManager fileDataManager = new HeapFileDataManager(setup,
+ false);
builder.setDataManager(new DualWrapDataManager(fileDataManager,
blockDataManager));
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -57,7 +57,7 @@
final File dataFile = new File(storageFileName);
final HeapFileSetup setup = new HeapFileSetup(dataFile, false,
false, false, false, 1, 0, null);
- dataManager = new HeapFileDataManager(setup);
+ dataManager = new HeapFileDataManager(setup, false);
final HeapRecordableManager heapRecordableManager = new HeapRecordableManager(
dataManager);
final HelperBinaryConversion helperBinaryConversion = new HelperBinaryConversion();
Modified: trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeSubSet.java
===================================================================
--- trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeSubSet.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-collection/src/main/java/net/sf/joafip/java/util/PTreeSubSet.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -134,12 +134,24 @@
}
}
if (outOfRange) {
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("element out of range");
}
return super.add(element);
}
+ // FIXMELUC ____________must be override
@Override
+ public boolean contains(final Object object) {// NOPMD
+ return super.contains(object);
+ }
+
+ // FIXMELUC ____________must be override
+ @Override
+ public boolean remove(final Object object) {// NOPMD
+ return super.remove(object);
+ }
+
+ @Override
public ListIterator<E> listIterator() {
return treeSupport.iterator(fromElement, fromInclusive, toElement,
toInclusive);
Modified: trunk/joafip-heapfile/pom.xml
===================================================================
--- trunk/joafip-heapfile/pom.xml 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/pom.xml 2012-03-06 08:44:06 UTC (rev 2993)
@@ -35,6 +35,14 @@
<dependency>
<groupId>net.sf.joafip</groupId>
+ <artifactId>joafip-collection</artifactId>
+ <version>4.0.0b8</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.joafip</groupId>
<artifactId>joafip-file</artifactId>
<version>4.0.0b8</version>
</dependency>
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/AbstractFileStorable.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/AbstractFileStorable.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/AbstractFileStorable.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -16,6 +16,8 @@
*/
package net.sf.joafip.heapfile.entity;
+import java.util.Arrays;
+
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.heapfile.service.FileForStorable;
import net.sf.joafip.heapfile.service.HeapException;
@@ -67,6 +69,8 @@
/** input output buffer */
private transient byte[] ioBuffer;
+ private transient int readInIoBuffer;
+
/**
* true if this value changed, creation implies no value to save since not
* read and not write
@@ -223,12 +227,33 @@
protected int readFileToIoBuffer(final int size) throws HeapException {
ioBuffer = new byte[size];
- final int readInIoBuffer = fileForStorable.read(ioBuffer);
+ readInIoBuffer = fileForStorable.read(ioBuffer);
numberOfByteReadWrote = 0;
return readInIoBuffer;
}
/**
+ * read extending ioBuffer
+ *
+ * @param newSize
+ * ioBuffer new size
+ * @throws HeapException
+ */
+ protected void readFileAppendToIoBuffer(final int newSize)
+ throws HeapException {
+ if (newSize > ioBuffer.length) {
+ ioBuffer = Arrays.copyOf(ioBuffer, newSize);
+ final int appendSize = newSize - readInIoBuffer;
+ final byte[] tempBuffer = new byte[appendSize];
+ // FIXMELUC _________________use of additional read
+ // read(iobuffer,readInIoBuffer/*offset*/,appendSize/*length*/);
+ fileForStorable.read(tempBuffer);
+ System.arraycopy(tempBuffer, 0, ioBuffer, readInIoBuffer,
+ appendSize);
+ }
+ }
+
+ /**
* read and check CRC32
*
* @throws HeapException
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-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -92,6 +92,8 @@
*/
public int numberOfChild = 0;
+ public int index;
+
/**
* heap elements manager for access to {@link HeapRecord}, null for sentinel
* node
@@ -437,6 +439,16 @@
}
@Override
+ public void setIndex(final int index) {
+ this.index = index;
+ }
+
+ @Override
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
public void decrementNumberOfChild() throws RBTException {
numberOfChild--;
heapRecordValueIsChanged(true);
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -45,6 +45,8 @@
private final IDataRecordKey dataRecordKey;
+ private int index;
+
/**
* create the first data record identifier: #0
*
@@ -114,6 +116,18 @@
return dataRecordKey.getKeyData();
}
+ public Object getKey() throws HeapException {
+ return dataRecordKey.getKey();
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(final int index) {
+ this.index = index;
+ }
+
public int compareTo(final DataRecordIdentifier dataRecordIdentifier) {
final int compareTo;
final long otherLong1 = dataRecordIdentifier.value;
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -23,7 +23,7 @@
package net.sf.joafip.heapfile.record.entity;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.heapfile.record.service.IDataRecordKeyComparator;
+import net.sf.joafip.heapfile.record.service.IDataRecordKeyManager;
import net.sf.joafip.heapfile.service.HeapException;
/**
@@ -34,16 +34,16 @@
@NotStorableClass
public class DataRecordKey implements IDataRecordKey {
- private final IDataRecordKeyComparator comparator;
+ private final IDataRecordKeyManager dataRecordKeyManager;
private final byte[] data;
private transient Object key;
- public DataRecordKey(final IDataRecordKeyComparator comparator,
+ public DataRecordKey(final IDataRecordKeyManager dataRecordKeyManager,
final byte[] data) {// NOPMD
super();
- this.comparator = comparator;
+ this.dataRecordKeyManager = dataRecordKeyManager;
this.data = data;
}
@@ -55,7 +55,7 @@
@Override
public int compareTo(final IDataRecordKey dataRecordKey)
throws HeapException {
- return comparator.compareDataRecordKey(this, dataRecordKey);
+ return dataRecordKeyManager.compareDataRecordKey(this, dataRecordKey);
}
@Override
@@ -69,11 +69,13 @@
}
@Override
- public Object getKey() {
+ public Object getKey() throws HeapException {
+ if (key == null) {
+ key = dataRecordKeyManager.unmarshall(data);
+ }
return key;
}
- @Override
public void setKey(final Object key) {
this.key = key;
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapIdNode.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapIdNode.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapIdNode.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -59,6 +59,7 @@
}
public DataRecordIdentifier getElement() {
+ nodeIdentifier.setIndex(index);
return nodeIdentifier;
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -92,9 +92,10 @@
/**/COMMON_FOR_HEADER_SIZE + 4 + 3 * 8 + 1 + 4 + 8;
@SuppressWarnings("all")
+ // add 4 to DATA_RECORD_HEADER_SIZE for key data length storage
public static final int MAX_RECORD_HEADER_SIZE =
- /**/DATA_RECORD_HEADER_SIZE > FREE_RECORD_HEADER_SIZE ?
- /**/DATA_RECORD_HEADER_SIZE
+ /**/(DATA_RECORD_HEADER_SIZE + 4) > FREE_RECORD_HEADER_SIZE ?
+ /**/(DATA_RECORD_HEADER_SIZE + 4)
/**/: FREE_RECORD_HEADER_SIZE;
/**
@@ -131,6 +132,8 @@
/** the area size in file ( record header size + data size ) */
private Integer areaSize;
+ private int dataRecordHeaderSize;
+
/** data size of data associated to this record, null if free data area */
private Integer dataAssociatedSize;
@@ -189,13 +192,6 @@
assert assertAreaSizeForData(freeRecord, nodeIdentifier,
dataAssociatedSize, areaSize);
this.areaSize = areaSize;
- // if (freeRecord) {
- // freeNode = new HeapFreeNode(heapElementManager, positionInFile,
- // areaSize);
- // } else {
- // idNode = new HeapIdNode(heapElementManager, positionInFile,
- // nodeIdentifier);
- // }
this.nodeIdentifier = nodeIdentifier;
clearNodeData();
// ASSERTX
@@ -206,9 +202,11 @@
final DataRecordIdentifier nodeIdentifier,
final Integer dataAssociatedSize, final Integer areaSize)
throws HeapException {
+ // if (!freeRecord && areaSize != null
+ // && areaSize < MAX_RECORD_HEADER_SIZE + dataAssociatedSize + 4) {
if (!freeRecord
&& areaSize != null
- && areaSize < MAX_RECORD_HEADER_SIZE
+ && areaSize < DATA_RECORD_HEADER_SIZE
+ nodeIdentifier.getKeyDataSize() + dataAssociatedSize
+ 4) {
logger.fatal(AREA_SIZE_TO_SMALL_FOR_DATA);
@@ -272,8 +270,6 @@
dataAssociated = null;// NOPMD no more data
dataAssociatedSize = null;// NOPMD no more data
idNode = null;// NOPMD no more data
- // freeNode = new HeapFreeNode(heapElementManager, positionInFile,
- // areaSize);
clearNodeData();
}
@@ -327,8 +323,6 @@
final DataRecordIdentifier nodeIdentifier) {
freeRecord = false;
freeNode = null;// NOPMD no more free
- // idNode = new HeapIdNode(heapElementManager, positionInFile,
- // nodeIdentifier);
this.nodeIdentifier = nodeIdentifier;
this.dataAssociatedSize = dataAssociatedSize;
clearNodeData();
@@ -345,7 +339,12 @@
toMarshallSize = areaSize;
} else {
// only header will be write
- toMarshallSize = DATA_RECORD_HEADER_SIZE;
+ final byte[] keyData = nodeIdentifier.getKeyData();
+ if (keyData == null) {
+ toMarshallSize = DATA_RECORD_HEADER_SIZE;
+ } else {
+ toMarshallSize = DATA_RECORD_HEADER_SIZE + keyData.length + 4;
+ }
}
return toMarshallSize;
}
@@ -501,15 +500,10 @@
// ASSERTX
assert read >= FREE_RECORD_HEADER_SIZE : "expected a minimum of "
+ FREE_RECORD_HEADER_SIZE + " but read " + read;
- // idNode = null;// NOPMD have no id node
- // freeNode = new HeapFreeNode(heapElementManager, positionInFile,
- // areaSize);
} else {
// ASSERTX
assert read >= DATA_RECORD_HEADER_SIZE : "expected a minimum of "
+ DATA_RECORD_HEADER_SIZE + " but read " + read;
- // freeNode = null;// NOPMD have no free node
- // idNode = new HeapIdNode(heapElementManager, positionInFile);
}
try {
if (freeRecord) {
@@ -549,11 +543,14 @@
final long long1 = readLong();
if (long1 == -1) {
final int keySize = readInteger();
+ dataRecordHeaderSize = DATA_RECORD_HEADER_SIZE + 4 + keySize;
+ readFileAppendToIoBuffer(dataRecordHeaderSize);
final byte[] keyData = readBytes(keySize);
final IDataRecordKey dataRecordKey = new DataRecordKey(
- heapElementManager.getDataRecordKeyComparator(), keyData);
+ heapElementManager.getDataRecordKeyManager(), keyData);
nodeIdentifier = new DataRecordIdentifier(dataRecordKey);
} else {
+ dataRecordHeaderSize = DATA_RECORD_HEADER_SIZE;
nodeIdentifier = new DataRecordIdentifier(long1);
}
readAndCheckCrc32();
@@ -754,7 +751,8 @@
private void readData() throws HeapException {
// ASSERTX
assert headerRead : "can not read data if header not read";
- fileForStorable.seek(positionInFile + DATA_RECORD_HEADER_SIZE);
+ fileForStorable
+ .seek(positionInFile + dataRecordHeaderSize/* DATA_RECORD_HEADER_SIZE */);
unmarshallDataArea();
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/IDataRecordKey.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/IDataRecordKey.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/IDataRecordKey.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -39,7 +39,5 @@
byte[] getKeyData();
- Object getKey();
-
- void setKey(Object key);
+ Object getKey() throws HeapException;
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/NullDataRecordKey.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/NullDataRecordKey.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/NullDataRecordKey.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -75,8 +75,8 @@
return null;
}
- @Override
- public void setKey(final Object key) {
- // no implementation
- }
+ // @Override
+ // public void setKey(final Object key) {
+ // // no implementation
+ // }
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -22,6 +22,8 @@
*/
package net.sf.joafip.heapfile.record.service;
+import java.util.Comparator;
+
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.heapfile.record.entity.IDataRecordKey;
import net.sf.joafip.heapfile.service.HeapException;
@@ -34,27 +36,23 @@
*/
@NotStorableClass
public abstract class AbstractDataRecordKeyComparator<K extends Comparable<K>>
- implements IDataRecordKeyComparator {
+ implements IDataRecordKeyManager {
+ private final Comparator<? super K> comparator;
+
+ public AbstractDataRecordKeyComparator(
+ final Comparator<? super K> comparator) {
+ super();
+ this.comparator = comparator;
+ }
+
+ @SuppressWarnings("unchecked")
@Override
public int compareDataRecordKey(final IDataRecordKey dataRecordKey1,
final IDataRecordKey dataRecordKey2) throws HeapException {
- final K key1 = getObject(dataRecordKey1);
- final K key2 = getObject(dataRecordKey2);
- return key1.compareTo(key2);
+ final K key1 = (K) dataRecordKey1.getKey();
+ final K key2 = (K) dataRecordKey2.getKey();
+ return comparator == null ? key1.compareTo(key2) : comparator.compare(
+ key1, key2);
}
-
- @SuppressWarnings("unchecked")
- private K getObject(final IDataRecordKey dataRecordKey)
- throws HeapException {
- K key = (K) dataRecordKey.getKey();
- if (key == null) {
- key = unmarshall(dataRecordKey.getKeyData());
- dataRecordKey.setKey(key);
- }
- return key;
- }
-
- protected abstract K unmarshall(byte[] keyData) throws HeapException;
-
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -26,6 +26,7 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.Comparator;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
@@ -39,7 +40,7 @@
*/
@NotStorableClass
@SuppressWarnings("rawtypes")
-public final class DataRecordKeyManager extends AbstractDataRecordKeyComparator {
+public class DataRecordKeyManager extends AbstractDataRecordKeyComparator {
private static final DataRecordKeyManager INSTANCE = new DataRecordKeyManager();
@@ -47,13 +48,18 @@
return INSTANCE;
}
+ @SuppressWarnings("unchecked")
private DataRecordKeyManager() {
- super();
+ super(null);
}
+ @SuppressWarnings("unchecked")
+ protected DataRecordKeyManager(final Comparator comparator) {
+ super(comparator);
+ }
+
@Override
- protected Comparable<?> unmarshall(final byte[] keyData)
- throws HeapException {
+ public Comparable<?> unmarshall(final byte[] keyData) throws HeapException {
try {
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
keyData);
@@ -67,6 +73,7 @@
}
}
+ @Override
public DataRecordIdentifier createKey(final Object key)
throws HeapException {
try {
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -219,7 +219,7 @@
private final int fileOperationRetryMsDelay;
- private IDataRecordKeyComparator dataRecordKeyComparator;
+ private IDataRecordKeyManager dataRecordKeyManager;
/**
* construction for crash safe mode disabled<br>
@@ -1190,13 +1190,13 @@
}
@Override
- public void setDataRecordKeyComparator(
- final IDataRecordKeyComparator dataRecordKeyComparator) {
- this.dataRecordKeyComparator = dataRecordKeyComparator;
+ public void setDataRecordKeyManager(
+ final IDataRecordKeyManager dataRecordKeyManager) {
+ this.dataRecordKeyManager = dataRecordKeyManager;
}
@Override
- public IDataRecordKeyComparator getDataRecordKeyComparator() {
- return dataRecordKeyComparator;
+ public IDataRecordKeyManager getDataRecordKeyManager() {
+ return dataRecordKeyManager;
}
}
Deleted: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyComparator.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyComparator.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyComparator.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -1,37 +0,0 @@
-/*
- * Copyright 2012 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.heapfile.record.service;
-
-import net.sf.joafip.heapfile.record.entity.IDataRecordKey;
-import net.sf.joafip.heapfile.service.HeapException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public interface IDataRecordKeyComparator {
-
- int compareDataRecordKey(IDataRecordKey dataRecordKey1,
- IDataRecordKey dataRecordKey2) throws HeapException;
-}
Copied: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyManager.java (from rev 2988, trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyComparator.java)
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyManager.java (rev 0)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IDataRecordKeyManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012 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.heapfile.record.service;
+
+import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
+import net.sf.joafip.heapfile.record.entity.IDataRecordKey;
+import net.sf.joafip.heapfile.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface IDataRecordKeyManager {
+
+ int compareDataRecordKey(IDataRecordKey dataRecordKey1,
+ IDataRecordKey dataRecordKey2) throws HeapException;
+
+ Comparable<?> unmarshall(byte[] keyData) throws HeapException;
+
+ DataRecordIdentifier createKey(Object key) throws HeapException;
+}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -208,8 +208,7 @@
int getNumberOfHeaprecordInMemory();
- void setDataRecordKeyComparator(
- IDataRecordKeyComparator dataRecordKeyComparator);
+ void setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyComparator);
- IDataRecordKeyComparator getDataRecordKeyComparator();
+ IDataRecordKeyManager getDataRecordKeyManager();
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractHeapDataManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractHeapDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -33,6 +33,8 @@
public abstract class AbstractHeapDataManager implements IHeapDataManager,
Serializable {
+ private static final String UNSUPPORTED_OPERATION = "unsupported operation";
+
/**
*
*/
@@ -371,6 +373,139 @@
throws HeapException;
@Override
+ public DataRecordIdentifier firstDataRecordIdentifier()
+ throws HeapException {
+ try {
+ // ASSERTX
+ assert assertStarted();
+ return firstDataRecordIdentifierImpl();
+ } catch (HeapException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ } catch (RuntimeException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ }
+ }
+
+ protected DataRecordIdentifier firstDataRecordIdentifierImpl()
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public DataRecordIdentifier lastDataRecordIdentifier() throws HeapException {
+ try {
+ // ASSERTX
+ assert assertStarted();
+ return lastDataRecordIdentifierImpl();
+ } catch (HeapException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ } catch (RuntimeException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ }
+ }
+
+ protected DataRecordIdentifier lastDataRecordIdentifierImpl()
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public DataRecordIdentifier lowerDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ // ASSERTX
+ assert assertStarted();
+ return lowerDataRecordIdentifierImpl(dataRecordIdentifier);
+ } catch (HeapException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ } catch (RuntimeException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ }
+ }
+
+ protected DataRecordIdentifier lowerDataRecordIdentifierImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public DataRecordIdentifier floorDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ // ASSERTX
+ assert assertStarted();
+ return floorDataRecordIdentifierImpl(dataRecordIdentifier);
+ } catch (HeapException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ } catch (RuntimeException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ }
+ }
+
+ protected DataRecordIdentifier floorDataRecordIdentifierImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public DataRecordIdentifier ceilingDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ // ASSERTX
+ assert assertStarted();
+ return ceilingDataRecordIdentifierImpl(dataRecordIdentifier);
+ } catch (HeapException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ } catch (RuntimeException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ }
+ }
+
+ protected DataRecordIdentifier ceilingDataRecordIdentifierImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED_OPERATION);
+ }
+
+ @Override
+ public DataRecordIdentifier higherDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ // ASSERTX
+ assert assertStarted();
+ return higherDataRecordIdentifierImpl(dataRecordIdentifier);
+ } catch (HeapException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ } catch (RuntimeException exception) {
+ closeHeapManagerAfterException();
+ throw exception;
+ }
+ }
+
+ protected DataRecordIdentifier higherDataRecordIdentifierImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED_OPERATION);
+ }
+
+ @Override
public DataRecordIdentifier removeFirstDataRecord() throws HeapException {
// ASSERTX
try {
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -42,8 +42,9 @@
private final int maxRecord;
public AutoSaveHeapFileDataManager(final HeapFileSetup setup,
- final int maxRecord) throws HeapException {
- super(setup);
+ final boolean manageNodeIndex, final int maxRecord)
+ throws HeapException {
+ super(setup, manageNodeIndex);
this.maxRecord = maxRecord;
}
@@ -98,5 +99,4 @@
flushImp();
}
}
-
}
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-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -37,7 +37,7 @@
import net.sf.joafip.heapfile.record.service.HeapElementManager;
import net.sf.joafip.heapfile.record.service.HeapFreeNodeManager;
import net.sf.joafip.heapfile.record.service.HeapIdNodeManager;
-import net.sf.joafip.heapfile.record.service.IDataRecordKeyComparator;
+import net.sf.joafip.heapfile.record.service.IDataRecordKeyManager;
import net.sf.joafip.heapfile.record.service.IHeapElementManager;
import net.sf.joafip.redblacktree.entity.IRBTNode;
import net.sf.joafip.redblacktree.service.IRBTVisitor;
@@ -55,6 +55,8 @@
// FIXMELUC ______HeapFileDataManager not accept empty data
+ private static final String IDENTIFIER2 = ", identifier=";
+
/**
*
*/
@@ -129,7 +131,8 @@
/** file name for backup logging */
private String backupFileName;
- public HeapFileDataManager(final HeapFileSetup setup) throws HeapException {
+ public HeapFileDataManager(final HeapFileSetup setup,
+ final boolean manageNodeIndex) throws HeapException {
super();
final boolean deleteRenaming = setup.isDeleteRenaming();
final boolean clearResizeFile = setup.isClearResizeFile();
@@ -193,7 +196,7 @@
final HeapIdNodeManager heapIdNodeManager = new HeapIdNodeManager(
heapElementManager);
idNodeTree = new RedBlackTree<DataRecordIdentifier>(heapIdNodeManager,
- false, true);
+ manageNodeIndex, true);
if (crashSafeMode && heapElementManager.wasBadFileStableState()) {
logger.warn(RESTART_FROM_STABLE_BACKUP);
/* validate the stable state */
@@ -637,8 +640,8 @@
try {
heapIdNode = (HeapIdNode) idNodeTree.search(identifier);
} catch (RBTException e) {
- final String message = SEARCH_FOR_IDENTIFIER_FAILED
- + ", identifier=" + identifier;
+ final String message = SEARCH_FOR_IDENTIFIER_FAILED + IDENTIFIER2
+ + identifier;
logger.fatal(message);
throw new HeapException(message, e);
}
@@ -822,6 +825,94 @@
return haveDataRecord;
}
+ @Override
+ protected DataRecordIdentifier firstDataRecordIdentifierImpl()
+ throws HeapException {
+ try {
+ final HeapIdNode firstHeapIdNode = (HeapIdNode) idNodeTree.first();
+ return firstHeapIdNode == null ? null : firstHeapIdNode
+ .getElement();
+ } catch (RBTException exception) {
+ final String message = "failed get first node";
+ logger.fatal(message);
+ throw new HeapException(message, exception);
+ }
+ }
+
+ @Override
+ protected DataRecordIdentifier lastDataRecordIdentifierImpl()
+ throws HeapException {
+ try {
+ final HeapIdNode firstHeapIdNode = (HeapIdNode) idNodeTree.last();
+ return firstHeapIdNode == null ? null : firstHeapIdNode
+ .getElement();
+ } catch (RBTException exception) {
+ final String message = "failed get first node";
+ logger.fatal(message);
+ throw new HeapException(message, exception);
+ }
+ }
+
+ @Override
+ protected DataRecordIdentifier lowerDataRecordIdentifierImpl(
+ final DataRecordIdentifier identifier) throws HeapException {
+ try {
+ final HeapIdNode heapIdNode = (HeapIdNode) idNodeTree
+ .strictlyLess(identifier);
+ return heapIdNode == null ? null : heapIdNode.getElement();
+ } catch (RBTException e) {
+ final String message = SEARCH_FOR_IDENTIFIER_FAILED + IDENTIFIER2
+ + identifier;
+ logger.fatal(message);
+ throw new HeapException(message, e);
+ }
+ }
+
+ @Override
+ protected DataRecordIdentifier floorDataRecordIdentifierImpl(
+ final DataRecordIdentifier identifier) throws HeapException {
+ try {
+ final HeapIdNode heapIdNode = (HeapIdNode) idNodeTree
+ .closestLessOrEqual(identifier);
+ return heapIdNode == null ? null : heapIdNode.getElement();
+ } catch (RBTException e) {
+ final String message = SEARCH_FOR_IDENTIFIER_FAILED + IDENTIFIER2
+ + identifier;
+ logger.fatal(message);
+ throw new HeapException(message, e);
+ }
+ }
+
+ @Override
+ protected DataRecordIdentifier ceilingDataRecordIdentifierImpl(
+ final DataRecordIdentifier identifier) throws HeapException {
+ try {
+ final HeapIdNode heapIdNode = (HeapIdNode) idNodeTree
+ .closestGreaterOrEqual(identifier);
+ return heapIdNode == null ? null : heapIdNode.getElement();
+ } catch (RBTException e) {
+ final String message = SEARCH_FOR_IDENTIFIER_FAILED + IDENTIFIER2
+ + identifier;
+ logger.fatal(message);
+ throw new HeapException(message, e);
+ }
+ }
+
+ @Override
+ protected DataRecordIdentifier higherDataRecordIdentifierImpl(
+ final DataRecordIdentifier identifier) throws HeapException {
+ try {
+ final HeapIdNode heapIdNode = (HeapIdNode) idNodeTree
+ .strictlyGreater(identifier);
+ return heapIdNode == null ? null : heapIdNode.getElement();
+ } catch (RBTException e) {
+ final String message = SEARCH_FOR_IDENTIFIER_FAILED + IDENTIFIER2
+ + identifier;
+ logger.fatal(message);
+ throw new HeapException(message, e);
+ }
+ }
+
/**
* To obtain a free record for an area size<br>
* The free record obtained may have greater area size than size asked for<br>
@@ -1126,8 +1217,8 @@
@Override
public void setDataRecordKeyComparator(
- final IDataRecordKeyComparator dataRecordKeyComparator) {
- heapElementManager.setDataRecordKeyComparator(dataRecordKeyComparator);
+ final IDataRecordKeyManager dataRecordKeyComparator) {
+ heapElementManager.setDataRecordKeyManager(dataRecordKeyComparator);
}
/**
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -21,7 +21,7 @@
import net.sf.joafip.Fortest;
import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
-import net.sf.joafip.heapfile.record.service.IDataRecordKeyComparator;
+import net.sf.joafip.heapfile.record.service.IDataRecordKeyManager;
/**
* data management on heap file<br>
@@ -170,6 +170,64 @@
throws HeapException;
/**
+ *
+ * @return first data record identifier, null if none (heap empty)
+ * @throws HeapException
+ */
+ DataRecordIdentifier firstDataRecordIdentifier() throws HeapException;
+
+ /**
+ *
+ * @return last data record identifier, null if none (heap empty)
+ * @throws HeapException
+ */
+ DataRecordIdentifier lastDataRecordIdentifier() throws HeapException;
+
+ /**
+ *
+ * @param dataRecordIdentifier
+ * the key
+ * @return the greatest key strictly less than the given key, or
+ * {@code null} if there is no such key.
+ * @throws HeapException
+ */
+ DataRecordIdentifier lowerDataRecordIdentifier(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException;
+
+ /**
+ *
+ * @param dataRecordIdentifier
+ * the key
+ * @return the greatest key less than or equal to {@code key}, or
+ * {@code null} if there is no such key
+ * @throws HeapException
+ */
+ DataRecordIdentifier floorDataRecordIdentifier(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException;
+
+ /**
+ *
+ * @param dataRecordIdentifier
+ * the key
+ * @return a key with the least key greater than or equal to {@code key}, or
+ * {@code null} if there is no such key
+ * @throws HeapException
+ */
+ DataRecordIdentifier ceilingDataRecordIdentifier(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException;
+
+ /**
+ *
+ * @param dataRecordIdentifier
+ * the key
+ * @return the least key greater than {@code key}, or {@code null} if there
+ * is no such key
+ * @throws HeapException
+ */
+ DataRecordIdentifier higherDataRecordIdentifier(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException;
+
+ /**
* remove first data record and return its data record identifier.<br>
* {@link #flush()} must be call to store the modification.<br>
* service must be started.
@@ -295,5 +353,5 @@
long getLastRecordPositionInFile() throws HeapException;
void setDataRecordKeyComparator(
- IDataRecordKeyComparator dataRecordKeyComparator);
+ IDataRecordKeyManager dataRecordKeyComparator);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -332,13 +332,13 @@
}
@Override
- public void setDataRecordKeyComparator(
- final IDataRecordKeyComparator dataRecordKeyComparator) {
+ public void setDataRecordKeyManager(
+ final IDataRecordKeyManager dataRecordKeyComparator) {
throw new UnsupportedOperationException("not implemented");
}
@Override
- public IDataRecordKeyComparator getDataRecordKeyComparator() {
+ public IDataRecordKeyManager getDataRecordKeyManager() {
throw new UnsupportedOperationException("not implemented");
}
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -124,7 +124,7 @@
openFileTraceFile);
setup.crashSafeSetup(backupFile, stateDataFile, stateDataBackupFile,
globalStateFile);
- heapDataManager = new HeapFileDataManager(setup);
+ heapDataManager = new HeapFileDataManager(setup, false);
heapDataManager.startService(removeFile);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2012-03-03 02:24:47 UTC (rev 2992)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2012-03-06 08:44:06 UTC (rev 2993)
@@ -36,7 +36,7 @@
import net.sf.joafi...
[truncated message content] |