Thread: [Joafip-svn] SF.net SVN: joafip:[3021] trunk (Page 4)
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2012-04-20 01:44:03
|
Revision: 3021
http://joafip.svn.sourceforge.net/joafip/?rev=3021&view=rev
Author: luc_peuvrier
Date: 2012-04-20 01:43:56 +0000 (Fri, 20 Apr 2012)
Log Message:
-----------
data record key moved to joafip-kvstore because of common usage
Modified Paths:
--------------
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/service/DataRecordKeyManager.java
Added Paths:
-----------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/entity/DataRecordKey.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java
Deleted: 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-04-19 02:51:34 UTC (rev 3020)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java 2012-04-20 01:43:56 UTC (rev 3021)
@@ -1,83 +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.entity;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.kvstore.record.entity.IDataRecordKey;
-import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public class DataRecordKey implements IDataRecordKey {
-
- private final IDataRecordKeyManager dataRecordKeyManager;
-
- private final byte[] data;
-
- private transient Object key;
-
- public DataRecordKey(final IDataRecordKeyManager dataRecordKeyManager,
- final byte[] data) {// NOPMD
- super();
- this.dataRecordKeyManager = dataRecordKeyManager;
- this.data = data;
- }
-
- @Override
- public int getKeyHashcode() {
- return 0;
- }
-
- @Override
- public int compareTo(final IDataRecordKey dataRecordKey)
- throws HeapException {
- return dataRecordKeyManager.compareDataRecordKey(this, dataRecordKey);
- }
-
- @Override
- public int getKeyDataSize() {
- return data.length;
- }
-
- @Override
- public byte[] getKeyData() {
- return data; // NOPMD
- }
-
- @Override
- public Object getKey() throws HeapException {
- if (key == null) {
- key = dataRecordKeyManager.unmarshall(data);
- }
- return key;
- }
-
- public void setKey(final Object key) {
- this.key = key;
- }
-}
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-04-19 02:51:34 UTC (rev 3020)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2012-04-20 01:43:56 UTC (rev 3021)
@@ -22,6 +22,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.entity.AbstractFileStorable;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.entity.DataRecordKey;
import net.sf.joafip.kvstore.record.entity.IDataRecordKey;
import net.sf.joafip.kvstore.record.service.HeapElementManager;
import net.sf.joafip.kvstore.record.service.IHeapElementManager;
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-04-19 02:51:34 UTC (rev 3020)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java 2012-04-20 01:43:56 UTC (rev 3021)
@@ -29,8 +29,8 @@
import java.util.Comparator;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.heapfile.record.entity.DataRecordKey;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.entity.DataRecordKey;
import net.sf.joafip.kvstore.service.HeapException;
/**
Copied: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/entity/DataRecordKey.java (from rev 3020, trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordKey.java)
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/entity/DataRecordKey.java (rev 0)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/entity/DataRecordKey.java 2012-04-20 01:43:56 UTC (rev 3021)
@@ -0,0 +1,82 @@
+/*
+ * 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.kvstore.record.entity;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class DataRecordKey implements IDataRecordKey {
+
+ private final IDataRecordKeyManager dataRecordKeyManager;
+
+ private final byte[] data;
+
+ private transient Object key;
+
+ public DataRecordKey(final IDataRecordKeyManager dataRecordKeyManager,
+ final byte[] data) {// NOPMD
+ super();
+ this.dataRecordKeyManager = dataRecordKeyManager;
+ this.data = data;
+ }
+
+ @Override
+ public int getKeyHashcode() {
+ return 0;
+ }
+
+ @Override
+ public int compareTo(final IDataRecordKey dataRecordKey)
+ throws HeapException {
+ return dataRecordKeyManager.compareDataRecordKey(this, dataRecordKey);
+ }
+
+ @Override
+ public int getKeyDataSize() {
+ return data.length;
+ }
+
+ @Override
+ public byte[] getKeyData() {
+ return data; // NOPMD
+ }
+
+ @Override
+ public Object getKey() throws HeapException {
+ if (key == null) {
+ key = dataRecordKeyManager.unmarshall(data);
+ }
+ return key;
+ }
+
+ public void setKey(final Object key) {
+ this.key = key;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-22 04:19:28
|
Revision: 3024
http://joafip.svn.sourceforge.net/joafip/?rev=3024&view=rev
Author: luc_peuvrier
Date: 2012-04-22 04:19:21 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
btree+ entity added
Modified Paths:
--------------
trunk/joafip-btreeplus/pom.xml
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.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-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.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/FileForStorableBridge.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.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/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/FileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IFileForStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/AbstractTestHeapElementManager.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/
trunk/joafip-btreeplus/src/main/java/net/sf/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/
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/DataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IStateStored.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/PageConstant.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/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-22 05:38:28
|
Revision: 3025
http://joafip.svn.sourceforge.net/joafip/?rev=3025&view=rev
Author: luc_peuvrier
Date: 2012-04-22 05:38:20 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
added HeapElementManagerFactory
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.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/TestDataManagerCheckerFile.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip-4test/pom.xml
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/logger/MainTestLogger.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java
trunk/joafip-4test/src/test/java/net/sf/joafip/logger/TestCreateLogger.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.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/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/FileForStorableBridge.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-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/FileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IFileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
trunk/joafip-pmap/src/test/java/net/sf/joafip/pmap/TestFileTreeMap.java
Added Paths:
-----------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/HeapFileSetup.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBabuDB.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterJdbm.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherJdbm.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/HeapFileSetup.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-22 04:19:30
|
Revision: 3024
http://joafip.svn.sourceforge.net/joafip/?rev=3024&view=rev
Author: luc_peuvrier
Date: 2012-04-22 04:19:21 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
btree+ entity added
Modified Paths:
--------------
trunk/joafip-btreeplus/pom.xml
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.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-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.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/FileForStorableBridge.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.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/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/FileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IFileForStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/AbstractTestHeapElementManager.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/
trunk/joafip-btreeplus/src/main/java/net/sf/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/
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/DataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IStateStored.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/PageConstant.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/
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
Modified: trunk/joafip-btreeplus/pom.xml
===================================================================
--- trunk/joafip-btreeplus/pom.xml 2012-04-21 13:56:59 UTC (rev 3023)
+++ trunk/joafip-btreeplus/pom.xml 2012-04-22 04:19:21 UTC (rev 3024)
@@ -41,6 +41,14 @@
<dependency>
<groupId>net.sf.joafip</groupId>
+ <artifactId>joafip-kvstore</artifactId>
+ <version>4.0.0b8</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.joafip</groupId>
<artifactId>joafip-log4j</artifactId>
<version>4.0.0b8</version>
<scope>test</scope>
Added: 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 (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,56 @@
+/*
+ * 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.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public abstract class AbstractElement implements IPageRecordable {
+
+ private final PageRecord pageRecord;
+
+ public AbstractElement(final PageRecord pageRecord) {
+ super();
+ this.pageRecord = pageRecord;
+ }
+
+ @Override
+ public PageRecord getPageRecord() {
+ return pageRecord;
+ }
+
+ @Override
+ public void setValueIsChangedValueToSave() throws HeapException {
+ pageRecord.setValueIsChangedValueToSave();
+ }
+
+ @Override
+ public void setValueIsNotChanged() {
+ pageRecord.setValueIsNotChanged();
+ }
+}
Added: 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 (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,87 @@
+/*
+ * 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.kvstore.record.entity.DataRecordKey;
+import net.sf.joafip.kvstore.entity.AbstractFileStorable;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.entity.IDataRecordKey;
+import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IFileForStorable;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public abstract class AbstractPageRecord extends AbstractFileStorable {
+
+ public AbstractPageRecord(final IFileForStorable fileForStorable,
+ final long positionInFile) {
+ super(fileForStorable, positionInFile);
+ }
+
+ @Override
+ protected void valueChangedAction() throws HeapException {
+ // no implementation
+ }
+
+ protected EnumRecordType readRecordType() throws HeapException {
+ final int typeIdentifier = readByte() & 0xff;
+ return EnumRecordType.get(typeIdentifier);
+ }
+
+ protected void writeByteRecordType(final EnumRecordType recordType)
+ throws HeapException {
+ 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 IDataRecordKey dataRecordKey = new DataRecordKey(
+ dataRecordKeyManager, keyData);
+ dataRecordIdentifier = new DataRecordIdentifier(dataRecordKey);
+ } else {
+ dataRecordIdentifier = new DataRecordIdentifier(value);
+ }
+ return dataRecordIdentifier;
+ }
+
+ protected void writeKey(final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ writeLong(dataRecordIdentifier.value);
+ final int keyDataSize = dataRecordIdentifier.getKeyDataSize();
+ if (keyDataSize != 0) {
+ writeInteger(keyDataSize);
+ writeBytes(dataRecordIdentifier.getKeyData());
+ }
+ }
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -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.btreeplus.entity;
+
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DataBlock implements IStateStored {
+
+ private final DataBlockPage dataBlockPage;
+
+ private final byte[] data;
+
+ public DataBlock(final DataBlockPage dataBlockPage, final int size) {
+ super();
+ this.dataBlockPage = dataBlockPage;
+ data = new byte[size];
+ }
+
+ public byte[] getData() {
+ return data;
+ }
+
+ public int getSize() {
+ return data.length;
+ }
+
+ @Override
+ public void setValueIsChangedValueToSave() throws HeapException {
+ dataBlockPage.setValueIsChangedValueToSave();
+ }
+
+ @Override
+ public void setValueIsNotChanged() {
+ dataBlockPage.setValueIsNotChanged();
+ }
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DataBlockPage extends AbstractElement {
+
+ private static final int FIX_VALUE_SIZE =
+ /**/1/* byte size for record type */+
+ /**/1/* byte size for bits */+
+ /**/4/* int size for crc32 */;
+
+ private byte bits;
+
+ private final int numberOfPage;
+
+ private final int dataBlockDataSize;
+
+ private final DataBlock[] dataBlocks;
+
+ public DataBlockPage(final PageRecord pageRecord, final byte bits) {
+ super(pageRecord);
+ this.bits = bits;
+ dataBlockDataSize = 1 << bits;
+ // the less numberOfPageValue which for
+ // numberOfPage * PAGE_SIZE >= FIX_VALUE_SIZE + numberOfBlock *
+ // dataBlockDataSize
+ // numberOfBlock=1 if dataBlockDataSize > PAGE_SIZE - FIX_VALUE_SIZE
+ //
+ final int numberOfBlock;
+ if (dataBlockDataSize > PageConstant.PAGE_SIZE - FIX_VALUE_SIZE) {
+ // one data block on one or more pages
+ numberOfBlock = 1;
+ final int totalSize = FIX_VALUE_SIZE
+ + /* numberOfBlock* */dataBlockDataSize;
+ final int n = totalSize >> PageConstant.PAGE_BITS;
+ if ((totalSize & PageConstant.PAGE_MASK) == 0) {
+ numberOfPage = n;
+ } else {
+ numberOfPage = n + 1;
+ }
+ } else {
+ // more than one block in one page
+ numberOfPage = 1;
+ numberOfBlock = (PageConstant.PAGE_SIZE - FIX_VALUE_SIZE)
+ / dataBlockDataSize;
+ }
+ dataBlocks = new DataBlock[numberOfBlock];
+ for (int index = 0; index < numberOfBlock; index++) {
+ dataBlocks[index] = new DataBlock(this, dataBlockDataSize);
+ }
+ }
+
+ @Override
+ public EnumRecordType getRecordType() {
+ return EnumRecordType.DATA_BLOCK;
+ }
+
+ @Override
+ public int getNumberOfPage() {
+ return numberOfPage;
+ }
+
+ public byte getBits() {
+ return bits;
+ }
+
+ @Override
+ public void updateByteSize() {
+ // no implementation
+ }
+
+ @Override
+ public int getByteSize() {
+ return numberOfPage * PageConstant.PAGE_SIZE;
+ }
+
+ public DataBlock[] getDataBlocks() {
+ return dataBlocks;
+ }
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public enum EnumRecordType {
+ /**
+ *
+ */
+ HEADER_PAGE,
+ /**
+ *
+ */
+ NON_TERMINAL_PAGE,
+ /**
+ *
+ */
+ LEAF_PAGE,
+ /**
+ *
+ */
+ FREE_PAGE,
+ /**
+ *
+ */
+ DATA_BLOCK;
+
+ public int getTypeIdentifier() {
+ return ordinal();
+ }
+
+ public static EnumRecordType get(final int typeIdentifier) {
+ return values()[typeIdentifier];
+ }
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,66 @@
+/*
+ * 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;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class FreePage extends AbstractElement {
+
+ private final long nextFreePage;
+
+ public FreePage(final PageRecord pageRecord, final long nextFreePage) {
+ super(pageRecord);
+ this.nextFreePage = nextFreePage;
+ }
+
+ @Override
+ public EnumRecordType getRecordType() {
+ return EnumRecordType.FREE_PAGE;
+ }
+
+ @Override
+ public int getNumberOfPage() {
+ return 1;
+ }
+
+ @Override
+ public void updateByteSize() {
+ // no implementation
+ }
+
+ @Override
+ public int getByteSize() {
+ // return PageConstant.PAGE_SIZE;
+ return 1/* byte size for record type */+
+ /**/8/* long size for next free page */+
+ /**/4/* int size for crc32 */;
+ }
+
+ public long getNextFreePage() {
+ return nextFreePage;
+ }
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,178 @@
+/*
+ * 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 java.util.Arrays;
+
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IFileForStorable;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class HeaderPage extends AbstractPageRecord implements IPageRecordable {
+
+ private long fileSizeAsNumberOfPage = -1L;
+
+ /** page number of first free page. -1 means no free page */
+ private long pageNumberOfFirstFreePage = -1L;
+
+ private long pageNumberOfRootPage = -1L;
+
+ private long[] freeDataBlock;
+
+ public HeaderPage(final IFileForStorable fileForStorable) {
+ super(fileForStorable, 0L);
+ }
+
+ public long getFileSizeAsNumberOfPage() {
+ return fileSizeAsNumberOfPage;
+ }
+
+ public void setFileSizeAsNumberOfPage(final long fileSizeAsNumberOfPage)
+ throws HeapException {
+ setValueIsChangedValueToSave();
+ this.fileSizeAsNumberOfPage = fileSizeAsNumberOfPage;
+ }
+
+ public long getPageNumberOfFirstFreePage() {
+ return pageNumberOfFirstFreePage;
+ }
+
+ public void setPageNumberOfFirstFreePage(
+ final long pageNumberOfFirstFreePage) throws HeapException {
+ setValueIsChangedValueToSave();
+ this.pageNumberOfFirstFreePage = pageNumberOfFirstFreePage;
+ }
+
+ public long getPageNumberOfRootPage() {
+ return pageNumberOfRootPage;
+ }
+
+ public void setPageNumberOfRootPage(final long pageNumberOfRootPage)
+ throws HeapException {
+ setValueIsChangedValueToSave();
+ this.pageNumberOfRootPage = pageNumberOfRootPage;
+ }
+
+ public void setFirstFreeBlock(final long firstFreeBlockPosition,
+ final int blockBits) throws HeapException {
+ setValueIsChangedValueToSave();
+ initializeFreeDataBlock();
+ freeDataBlock[blockBits - PageConstant.MIN_DATA_BLOCK_BITS] = firstFreeBlockPosition;
+ }
+
+ public long getFirstFreeBlock(final int blockBits) {
+ initializeFreeDataBlock();
+ return freeDataBlock[blockBits - PageConstant.MIN_DATA_BLOCK_BITS];
+ }
+
+ public void clear() {
+ super.clear();
+ fileSizeAsNumberOfPage = -1L;
+ pageNumberOfFirstFreePage = -1L;
+ pageNumberOfRootPage = -1L;
+ freeDataBlock = null;
+ }
+
+ @Override
+ public int getNumberOfPage() {
+ return 1;
+ }
+
+ @Override
+ public long getPreviousRecordPositionInFile() throws HeapException {
+ return -1L;
+ }
+
+ @Override
+ public EnumRecordType getRecordType() {
+ return EnumRecordType.HEADER_PAGE;
+ }
+
+ @Override
+ public int getRecordSize() throws HeapException {
+ return PageConstant.PAGE_SIZE;
+ }
+
+ @Override
+ protected int toMarshallSize() throws HeapException {
+ return PageConstant.PAGE_SIZE;
+ }
+
+ @Override
+ protected void marshallImpl() throws HeapException {
+ writeByteRecordType(EnumRecordType.HEADER_PAGE);
+ writeLong(fileSizeAsNumberOfPage);
+ writeLong(pageNumberOfFirstFreePage);
+ writeLong(pageNumberOfRootPage);
+ initializeFreeDataBlock();
+ for (int index = 0; index < PageConstant.NUMBER_OF_BLOCK_TYPE; index++) {
+ writeLong(freeDataBlock[index]);
+ }
+ writeCrc32();
+ }
+
+ @Override
+ protected void unmarshallImpl() throws HeapException {
+ readFileToIoBuffer(PageConstant.PAGE_SIZE);
+ final EnumRecordType recordType = readRecordType();
+ if (!EnumRecordType.HEADER_PAGE.equals(recordType)) {
+ throw new HeapException(EnumRecordType.HEADER_PAGE
+ + " expected record type and is " + recordType);
+ }
+ fileSizeAsNumberOfPage = readLong();
+ pageNumberOfFirstFreePage = readLong();
+ pageNumberOfRootPage = readLong();
+ initializeFreeDataBlock();
+ for (int index = 0; index < PageConstant.NUMBER_OF_BLOCK_TYPE; index++) {
+ freeDataBlock[index] = readLong();
+ }
+ readAndCheckCrc32();
+ }
+
+ private void initializeFreeDataBlock() {
+ if (freeDataBlock == null) {
+ freeDataBlock = new long[PageConstant.NUMBER_OF_BLOCK_TYPE];
+ Arrays.fill(freeDataBlock, -1L);
+ }
+ }
+
+ @Override
+ public void updateByteSize() {
+ // no implementation
+ }
+
+ @Override
+ public int getByteSize() {
+ return PageConstant.PAGE_SIZE;
+ }
+
+ @Override
+ public PageRecord getPageRecord() throws HeapException {
+ throw new HeapException("unsupported");
+ }
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -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.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface IPageRecordable extends IStateStored {
+
+ EnumRecordType getRecordType();
+
+ /**
+ * the number of pages take is fix
+ *
+ * @return number of page take by the record
+ */
+ int getNumberOfPage();
+
+ /**
+ *
+ * @return byte size of the element
+ */
+ int getByteSize();
+
+ void updateByteSize();
+
+ PageRecord getPageRecord() throws HeapException;
+
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IStateStored.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IStateStored.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IStateStored.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,38 @@
+/*
+ * 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.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface IStateStored {
+
+ void setValueIsChangedValueToSave() throws HeapException;
+
+ void setValueIsNotChanged();
+}
Added: 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 (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-04-22 04:19:21 UTC (rev 3024)
@@ -0,0 +1,110 @@
+/*
+ * 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.kvstore.record.entity.DataRecordIdentifier;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class LeafPage extends AbstractElement {
+
+ private long[] pagePointers;
+
+ private DataRecordIdentifier[] keys;
+
+ private int numberOfKeyEntries;
+
+ private int byteSize;
+
+ private long next;
+
+ public LeafPage(final PageRecord pageRecord, final int numberOfKeyEntries) {
+ super(pageRecord);
+ this.numberOfKeyEntries = numberOfKeyEntries;
+ keys = new DataRecordIdentifier[numberOfKeyEntries];
+ pagePointers = new long[numberOfKeyEntries];
+ byteSize = 0;
...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-22 05:38:29
|
Revision: 3025
http://joafip.svn.sourceforge.net/joafip/?rev=3025&view=rev
Author: luc_peuvrier
Date: 2012-04-22 05:38:20 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
added HeapElementManagerFactory
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.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/TestDataManagerCheckerFile.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip-4test/pom.xml
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/logger/MainTestLogger.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java
trunk/joafip-4test/src/test/java/net/sf/joafip/logger/TestCreateLogger.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.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/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/FileForStorableBridge.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-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/FileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IFileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
trunk/joafip-pmap/src/test/java/net/sf/joafip/pmap/TestFileTreeMap.java
Added Paths:
-----------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/HeapFileSetup.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManagerFactory.java
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBabuDB.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterJdbm.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherJdbm.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/HeapFileSetup.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -1010,15 +1010,6 @@
}
@Override
- public String getBackupFileName() throws FilePersistenceException {
- try {
- return store.getBackupFileName();
- } catch (final StoreException exception) {
- throw new FilePersistenceException(exception);
- }
- }
-
- @Override
public String getChangeFileName() throws FilePersistenceException {
try {
return store.getChangeFileName();
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -907,13 +907,6 @@
/**
*
- * @return file name for backup logging
- * @throws FilePersistenceException
- */
- String getBackupFileName() throws FilePersistenceException;
-
- /**
- *
* @return file name for change logging
* @throws FilePersistenceException
*/
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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -19,8 +19,8 @@
import java.io.File;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@@ -138,6 +138,7 @@
}
}
+ @Override
public IHeapDataManager getDataManager() throws StoreException {
return dataManager;
}
@@ -220,6 +221,7 @@
}
}
+ @Override
public String getStorageFileName() throws StoreException {
try {
return dataManager.getStorageFileName();
@@ -228,14 +230,7 @@
}
}
- public String getBackupFileName() throws StoreException {
- try {
- return dataManager.getBackupFileName();
- } catch (HeapException exception) {
- throw new StoreException(exception);
- }
- }
-
+ @Override
public String getChangeFileName() throws StoreException {
try {
return dataManager.getChangeFileName();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -575,13 +575,6 @@
/**
*
- * @return file name for backup logging
- * @throws StoreException
- */
- String getBackupFileName() throws StoreException;
-
- /**
- *
* @return file name for change logging
* @throws StoreException
*/
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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -25,8 +25,8 @@
import java.io.File;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.AutoSaveHeapFileDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerCheckerFile.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerCheckerFile.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerCheckerFile.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -22,8 +22,8 @@
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestConstant;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.HeapFileCheckerDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
/**
*
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerHeapFile.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -22,8 +22,8 @@
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestConstant;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
/**
*
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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -23,10 +23,10 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestConstant;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
import net.sf.joafip.heapfile.service.HeapFileState;
import net.sf.joafip.kvstore.entity.EnumFileState;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -327,10 +327,6 @@
return store.getAllReferenceLink();
}
- public String getBackupFileName() throws StoreException {
- return store.getBackupFileName();
- }
-
public List<DataRecordIdentifierRBTNode> getCandidate()
throws StoreException {
return store.getCandidate();
Modified: trunk/joafip-4test/pom.xml
===================================================================
--- trunk/joafip-4test/pom.xml 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/pom.xml 2012-04-22 05:38:20 UTC (rev 3025)
@@ -51,18 +51,6 @@
<dependency>
<groupId>net.sf.joafip</groupId>
- <artifactId>joafip-jdbm</artifactId>
- <version>4.0.0b8</version>
- </dependency>
-
- <dependency>
- <groupId>net.sf.joafip</groupId>
- <artifactId>joafip-babudb</artifactId>
- <version>4.0.0b8</version>
- </dependency>
-
- <dependency>
- <groupId>net.sf.joafip</groupId>
<artifactId>joafip-rbtree</artifactId>
<version>4.0.0b8</version>
</dependency>
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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -5,10 +5,10 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.BlockDataManager;
import net.sf.joafip.heapfile.service.DualWrapDataManager;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
+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.redblacktree.service.RBTException;
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/logger/MainTestLogger.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/logger/MainTestLogger.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/logger/MainTestLogger.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -26,7 +26,8 @@
public class MainTestLogger {
public static void main(final String[] args) {
- final JoafipLogger logger=JoafipLogger.getLogger(MainTestLogger.class);
+ final JoafipLogger logger = JoafipLogger
+ .getLogger(MainTestLogger.class);
logger.fatal("fatal error 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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -229,39 +229,42 @@
}
byItemIndex = 0;
}
-
- protected static void initializeDirectory(final String rootDir) throws FilePersistenceException {
+
+ protected static void initializeDirectory(final String rootDir)
+ throws FilePersistenceException {
initializeDirectory(new File(rootDir));
}
-
- protected static void initializeDirectory(final File rootDir) throws FilePersistenceException {
- if( rootDir.exists()) {
- if( rootDir.isDirectory()) {
+
+ protected static void initializeDirectory(final File rootDir)
+ throws FilePersistenceException {
+ if (rootDir.exists()) {
+ if (rootDir.isDirectory()) {
deleteDir(rootDir);
} else {
- if( !rootDir.delete() ) {
- throw new FilePersistenceException(FAILED_DELETE+rootDir);
+ if (!rootDir.delete()) {
+ throw new FilePersistenceException(FAILED_DELETE + rootDir);
}
}
}
- if( !rootDir.mkdirs()) {
- throw new FilePersistenceException("failed create "+rootDir);
+ if (!rootDir.mkdirs()) {
+ throw new FilePersistenceException("failed create " + rootDir);
}
}
-
- private static void deleteDir(final File dir) throws FilePersistenceException {
+
+ private static void deleteDir(final File dir)
+ throws FilePersistenceException {
final File[] files = dir.listFiles();
- for(File file:files) {
- if( file.isDirectory()) {
+ for (File file : files) {
+ if (file.isDirectory()) {
deleteDir(file);
} else {
- if( !file.delete() ) {
- throw new FilePersistenceException(FAILED_DELETE+file);
+ if (!file.delete()) {
+ throw new FilePersistenceException(FAILED_DELETE + file);
}
}
}
- if( !dir.delete() ) {
- throw new FilePersistenceException(FAILED_DELETE+dir);
+ if (!dir.delete()) {
+ throw new FilePersistenceException(FAILED_DELETE + dir);
}
}
}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBabuDB.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBabuDB.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBabuDB.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -1,67 +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.babudb.service.BabudbDataManager;
-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 class InserterBabuDB extends AbstractInserter {
-
- private static final JoafipLogger LOGGER = JoafipLogger
- .getLogger(InserterBabuDB.class);
-
- public InserterBabuDB(final IHeapDataManager dataManager)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- public static void main(final String[] args) {
- try {
- /* remove existing data */
- initializeDirectory(RUNTIME_DIR);
- final File dataDirectory = new File(RUNTIME_DIR);
- InserterBabuDB inserter;
- final BabudbDataManager babudbDataManager = new BabudbDataManager(
- (new File(dataDirectory, "banana.data")).getAbsolutePath());
- inserter = new InserterBabuDB(babudbDataManager);
- inserter.run(NUMBER_OF_ITEM);
- 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/InserterJdbm.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterJdbm.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterJdbm.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -1,68 +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.jdbm.service.JdbmDataManager;
-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 class InserterJdbm extends AbstractInserter {
-
- private static final JoafipLogger LOGGER = JoafipLogger
- .getLogger(InserterJdbm.class);
-
- public InserterJdbm(final IHeapDataManager dataManager)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, StoreClassNotFoundException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
- public static void main(final String[] args) {
- try {
- final File dataDirectory = new File(RUNTIME_DIR);
- /* remove existing data */
- initializeDirectory(RUNTIME_DIR);
- dataDirectory.mkdirs();
- InserterJdbm inserter;
- final JdbmDataManager jdbmDataManager = new JdbmDataManager(
- (new File(dataDirectory, "banana.data")).getAbsolutePath());
- inserter = new InserterJdbm(jdbmDataManager);
- inserter.run(NUMBER_OF_ITEM);
- 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/SearcherJdbm.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherJdbm.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherJdbm.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -1,63 +0,0 @@
-/*
- * Copyright 2007 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;
-
-import java.io.File;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.StorableAccess;
-import net.sf.joafip.jdbm.service.JdbmDataManager;
-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;
-
-@NotStorableClass
-@StorableAccess
-public class SearcherJdbm extends AbstractSearcher {
-
- private static final JoafipLogger LOGGER = JoafipLogger
- .getLogger(SearcherJdbm.class);
-
-
- public SearcherJdbm(final IHeapDataManager dataManager)
- throws FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException, FilePersistenceException,
- FilePersistenceTooBigForSerializationException {
- super(dataManager);
- }
-
-
- public static void main(final String[] args) {
- SearcherJdbm searcher;
- try {
- final File dataDirectory = new File(RUNTIME_DIR);
- final JdbmDataManager jdbmDataManager = new JdbmDataManager(
- (new File(dataDirectory, "banana.data")).getAbsolutePath());
- searcher = new SearcherJdbm(jdbmDataManager);
- searcher.run();
- } catch (final Throwable throwable) {// NOPMD catch all
- LOGGER.fatal("error", throwable);
- }
- }
-}
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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CheckSaved.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -20,8 +20,8 @@
import java.util.Arrays;
import java.util.Map;
-import net.sf.joafip.heapfile.entity.HeapFileSetup;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -45,8 +45,6 @@
return INSTANCE;
}
- private String backupFileName;
-
private String changeFileName;
private String storageFileName;
@@ -92,8 +90,6 @@
bob1.setBob3(bob3);
session.close(EnumFilePersistenceCloseAction.SAVE);
- backupFileName = filePersistence.getBackupFileName();
-
changeFileName = filePersistence.getChangeFileName();
storageFileName = filePersistence.getStorageFileName();
@@ -105,10 +101,6 @@
return storageFileName;
}
- public String getBackupFileName() {
- return backupFileName;
- }
-
public String getChangeFileName() {
return changeFileName;
}
Modified: trunk/joafip-4test/src/test/java/net/sf/joafip/logger/TestCreateLogger.java
===================================================================
--- trunk/joafip-4test/src/test/java/net/sf/joafip/logger/TestCreateLogger.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-4test/src/test/java/net/sf/joafip/logger/TestCreateLogger.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -28,13 +28,14 @@
/**
*
* @author luc peuvrier
- *
+ *
*/
public class TestCreateLogger extends TestCase {
public void test() {
- final JoafipLogger logger=JoafipLogger.getLogger(TestCreateLogger.class);
+ final JoafipLogger logger = JoafipLogger
+ .getLogger(TestCreateLogger.class);
logger.fatal("fatal error message");
- assertTrue("logger must be set",logger.loggerIsSet());
+ assertTrue("logger must be set", logger.loggerIsSet());
}
}
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-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -24,26 +24,36 @@
package net.sf.joafip.btreeplus.service;
import net.sf.joafip.btreeplus.entity.HeaderPage;
+import net.sf.joafip.btreeplus.entity.PageConstant;
+import net.sf.joafip.btreeplus.entity.PageRecord;
+import net.sf.joafip.kvstore.entity.IFileStorable;
+import net.sf.joafip.kvstore.record.service.HeapElementManager;
import net.sf.joafip.kvstore.record.service.IHeapElementManager;
+import net.sf.joafip.kvstore.record.service.IHeapRecordFactory;
import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IFileForStorable;
/**
*
* @author luc peuvrier
*
*/
-public class BtreePlusElementMgr {
+public class BtreePlusElementMgr implements IHeapRecordFactory {
private final IHeapElementManager heapElementManager;
private final HeaderPage header;
+ private final IFileForStorable fileForStorable;
+
public BtreePlusElementMgr(final IHeapElementManager heapElementManager)
throws HeapException {
super();
this.heapElementManager = heapElementManager;
header = new HeaderPage(heapElementManager.getFileForStorable());
+ heapElementManager.setHeapRecordFactory(this);
heapElementManager.setHeapHeader(header);
+ fileForStorable = heapElementManager.getFileForStorable();
}
public void startService() throws HeapException {
@@ -73,4 +83,13 @@
public void removeFiles() throws HeapException {
heapElementManager.removeFiles();
}
+
+ @Override
+ public IFileStorable createHeapRecord(
+ final HeapElementManager heapElementManager,
+ final long positionInFile) throws HeapException {
+ assert (positionInFile & PageConstant.PAGE_MASK) == 0;
+ return new PageRecord(fileForStorable,
+ (int) (positionInFile >> PageConstant.PAGE_BITS));
+ }
}
Deleted: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/HeapFileSetup.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/HeapFileSetup.java 2012-04-22 04:19:21 UTC (rev 3024)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/entity/HeapFileSetup.java 2012-04-22 05:38:20 UTC (rev 3025)
@@ -1,286 +0,0 @@
-/*
- * Copyright ...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-22 06:43:06
|
Revision: 3026
http://joafip.svn.sourceforge.net/joafip/?rev=3026&view=rev
Author: luc_peuvrier
Date: 2012-04-22 06:42:59 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
WIP BtreeePlusDataManager created
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.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/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/FileForStorableBridge.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-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/FileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IFileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-22 06:43:06
|
Revision: 3026
http://joafip.svn.sourceforge.net/joafip/?rev=3026&view=rev
Author: luc_peuvrier
Date: 2012-04-22 06:42:59 +0000 (Sun, 22 Apr 2012)
Log Message:
-----------
WIP BtreeePlusDataManager created
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.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/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/FileForStorableBridge.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-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/FileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IFileForStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/IHeapDataManager.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/AbstractFilePersistenceDelegatingToStore.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -1010,15 +1010,6 @@
}
@Override
- public String getChangeFileName() throws FilePersistenceException {
- try {
- return store.getChangeFileName();
- } catch (final StoreException exception) {
- throw new FilePersistenceException(exception);
- }
- }
-
- @Override
@Deprecated
public Object copy(final Object sourceObject)
throws FilePersistenceException {
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -906,13 +906,6 @@
String getStorageFileName() throws FilePersistenceException;
/**
- *
- * @return file name for change logging
- * @throws FilePersistenceException
- */
- String getChangeFileName() throws FilePersistenceException;
-
- /**
* set save event listener
*
* @param saveEventListener
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractStoreDelegatingToDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -229,13 +229,4 @@
throw new StoreException(exception);
}
}
-
- @Override
- public String getChangeFileName() throws StoreException {
- try {
- return dataManager.getChangeFileName();
- } catch (HeapException exception) {
- throw new StoreException(exception);
- }
- }
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -573,13 +573,6 @@
*/
String getStorageFileName() throws StoreException;
- /**
- *
- * @return file name for change logging
- * @throws StoreException
- */
- String getChangeFileName() throws StoreException;
-
StoreSynchro getStoreSynchro();
HelperBinaryConversion getHelperBinaryConversion();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -243,14 +243,15 @@
}
boolean localChangeLogEnabled;
if (changeLogEnabled) {
- try {
- final String changeFileName = dataManager.getChangeFileName();
- objectIOManager.openChangeLog(changeFileName);
- localChangeLogEnabled = true;
- } catch (final Exception exception) {
- LOGGER.warn("change log disabled", exception);
- localChangeLogEnabled = false;
- }
+ // FIXMELUC ____change log no more usable
+ // try {
+ // final String changeFileName = dataManager.getChangeFileName();
+ // objectIOManager.openChangeLog(changeFileName);
+ // localChangeLogEnabled = true;
+ // } catch (final Exception exception) {
+ // LOGGER.warn("change log disabled", exception);
+ localChangeLogEnabled = false;
+ // }
} else {
localChangeLogEnabled = false;
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -332,10 +332,6 @@
return store.getCandidate();
}
- public String getChangeFileName() throws StoreException {
- return store.getChangeFileName();
- }
-
public int getClassIdentifier(final Class<?> clazz) throws StoreException,
StoreClassNotFoundException {
return store.getClassIdentifier(clazz);
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/service/changelog/CreateChangeLog.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -90,7 +90,7 @@
bob1.setBob3(bob3);
session.close(EnumFilePersistenceCloseAction.SAVE);
- changeFileName = filePersistence.getChangeFileName();
+ // changeFileName = filePersistence.getChangeFileName();
storageFileName = filePersistence.getStorageFileName();
Added: 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 (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -0,0 +1,246 @@
+/*
+ * 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.service;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Set;
+
+import net.sf.joafip.Fortest;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.service.HeapElementManagerFactory;
+import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
+import net.sf.joafip.kvstore.service.AbstractHeapDataManager;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IFileForStorable;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class BtreePlusDataManager extends AbstractHeapDataManager {
+
+ private final BtreePlusElementMgr btreePlusElementMgr;
+
+ public BtreePlusDataManager(final HeapFileSetup setup) throws HeapException {
+ super();
+ final IHeapElementManager heapElementManager = HeapElementManagerFactory
+ .create(setup);
+ btreePlusElementMgr = new BtreePlusElementMgr(heapElementManager);
+ }
+
+ @Override
+ public boolean isDataLost() {
+ return btreePlusElementMgr.isDataLost();
+ }
+
+ @Override
+ public String backup(long identifier, int maxBackup) throws HeapException {
+ return btreePlusElementMgr.backup(identifier, maxBackup);
+ }
+
+ @Override
+ public String getStorageFileName() throws HeapException {
+ final IFileForStorable fileForStorable = btreePlusElementMgr
+ .getFileForStorable();
+ final File file = fileForStorable.getFile();
+ return file.getAbsolutePath();
+ }
+
+ @Override
+ public void setDataRecordKeyComparator(
+ IDataRecordKeyManager dataRecordKeyComparator) throws HeapException {
+ btreePlusElementMgr.setDataRecordKeyComparator(dataRecordKeyComparator);
+ }
+
+ @Override
+ protected void removeFiles() throws HeapException {
+ btreePlusElementMgr.removeFiles();
+ }
+
+ @Override
+ protected void startServiceImpl(boolean removeFiles) throws HeapException {
+ if (removeFiles) {
+ btreePlusElementMgr.removeFiles();
+ }
+ btreePlusElementMgr.startService();
+ btreePlusElementMgr.openTransaction();
+ }
+
+ @Override
+ protected void stopServiceImpl() throws HeapException {
+ if (btreePlusElementMgr.isTransactionOpened()) {
+ btreePlusElementMgr.closeTransactionDiscardChange();
+ }
+ btreePlusElementMgr.stopService();
+ }
+
+ @Override
+ protected void clearImpl() throws HeapException {
+ btreePlusElementMgr.clear();
+ }
+
+ @Override
+ protected void flushImp() throws HeapException {
+ btreePlusElementMgr.closeTransaction();
+ btreePlusElementMgr.openTransaction();
+ }
+
+ @Override
+ protected void clearStandbyModificationImpl() throws HeapException {
+ btreePlusElementMgr.closeTransactionDiscardChange();
+ btreePlusElementMgr.openTransaction();
+ }
+
+ @Override
+ protected void closeHeapManagerAfterException() {
+ try {
+ if (btreePlusElementMgr.isTransactionOpened()) {
+ btreePlusElementMgr.closeTransactionDiscardChange();
+ }
+ } catch (Exception exception) {
+ logger.warn("closing after exception", exception);
+ }
+
+ try {
+ btreePlusElementMgr.stopService();
+ } catch (Exception exception) {
+ logger.warn("closing after exception", exception);
+ }
+ }
+
+ @Override
+ protected DataRecordIdentifier getNextFreeDataRecordIdentifierImpl()
+ throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void setNextFreeDataRecordIdentifierImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected DataRecordIdentifier getNewDataRecordIdentifierImpl()
+ throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected boolean deleteDataRecordImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected byte[] readDataRecordImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected boolean writeDataRecordImpl(
+ DataRecordIdentifier dataRecordIdentifier, byte[] data)
+ throws HeapException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected boolean hasDataRecordImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected DataRecordIdentifier removeFirstDataRecordImpl()
+ throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected int getNumberOfDataRecordImpl() throws HeapException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected int getNumberOfFreeRecordImpl() throws HeapException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ protected Set<DataRecordIdentifier> getDataRecordIdentifierSetImpl()
+ throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Iterator<DataRecordIdentifier> dataRecordIteratorImpl()
+ throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected long heapSizeImpl() throws HeapException {
+ return btreePlusElementMgr.heapSize();
+ }
+
+ @Override
+ protected long freeSizeImpl() throws HeapException {
+ return btreePlusElementMgr.freeSize();
+ }
+
+ @Override
+ protected long usedSizeImpl() throws HeapException {
+ return btreePlusElementMgr.usedSize();
+ }
+
+ @Fortest
+ @Override
+ public long getRecordPositionInfile(final DataRecordIdentifier identifier)
+ throws HeapException {
+ return btreePlusElementMgr.getRecordPositionInfile(identifier);
+ }
+
+ @Fortest
+ @Override
+ public long getLastRecordPositionInFile() throws HeapException {
+ return btreePlusElementMgr.getLastRecordPositionInFile();
+ }
+}
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -23,15 +23,19 @@
*/
package net.sf.joafip.btreeplus.service;
+import net.sf.joafip.Fortest;
import net.sf.joafip.btreeplus.entity.HeaderPage;
import net.sf.joafip.btreeplus.entity.PageConstant;
import net.sf.joafip.btreeplus.entity.PageRecord;
import net.sf.joafip.kvstore.entity.IFileStorable;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.record.service.HeapElementManager;
+import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.record.service.IHeapRecordFactory;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IFileForStorable;
+import net.sf.joafip.logger.JoafipLogger;
/**
*
@@ -40,6 +44,9 @@
*/
public class BtreePlusElementMgr implements IHeapRecordFactory {
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(BtreePlusElementMgr.class);
+
private final IHeapElementManager heapElementManager;
private final HeaderPage header;
@@ -54,8 +61,20 @@
heapElementManager.setHeapRecordFactory(this);
heapElementManager.setHeapHeader(header);
fileForStorable = heapElementManager.getFileForStorable();
+ if (fileForStorable.isUseCache()
+ && fileForStorable.getCachePageSize() != PageConstant.PAGE_SIZE) {
+ LOGGER.warn("btree+ page size is " + PageConstant.PAGE_SIZE
+ + " and file cache page size is "
+ + fileForStorable.getCachePageSize());
+ }
}
+ public void setDataRecordKeyComparator(
+ final IDataRecordKeyManager dataRecordKeyComparator)
+ throws HeapException {
+ heapElementManager.setDataRecordKeyManager(dataRecordKeyComparator);
+ }
+
public void startService() throws HeapException {
heapElementManager.startService();
}
@@ -72,6 +91,10 @@
heapElementManager.closeTransaction();
}
+ public boolean isTransactionOpened() {
+ return heapElementManager.isTransactionOpened();
+ }
+
public void closeTransactionDiscardChange() throws HeapException {
heapElementManager.closeTransactionDiscardChange();
}
@@ -92,4 +115,41 @@
return new PageRecord(fileForStorable,
(int) (positionInFile >> PageConstant.PAGE_BITS));
}
+
+ public boolean isDataLost() {
+ return heapElementManager.isDataLost();
+ }
+
+ public IFileForStorable getFileForStorable() {
+ return fileForStorable;
+ }
+
+ public long heapSize() throws HeapException {
+ return header.getFileSizeAsNumberOfPage() * PageConstant.PAGE_SIZE;
+ }
+
+ public long freeSize() throws HeapException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long usedSize() throws HeapException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String backup(final long identifier, final int maxBackup)
+ throws HeapException {
+ return heapElementManager.backup(identifier, maxBackup);
+ }
+
+ @Fortest
+ public long getRecordPositionInfile(final DataRecordIdentifier identifier) {
+ throw new UnsupportedOperationException("not implemented");
+ }
+
+ @Fortest
+ public long getLastRecordPositionInFile() throws HeapException {
+ throw new UnsupportedOperationException("not implemented");
+ }
}
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -17,16 +17,13 @@
package net.sf.joafip.heapfile.service;
import java.io.File;
-import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import java.util.TreeSet;
import net.sf.joafip.Fortest;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.file.service.FileIOException;
import net.sf.joafip.heapfile.record.entity.HeapFreeNode;
import net.sf.joafip.heapfile.record.entity.HeapHeader;
import net.sf.joafip.heapfile.record.entity.HeapIdNode;
@@ -102,7 +99,7 @@
private static final long MAX_INT = (long) Integer.MAX_VALUE;
/** the heap element manager, data record are accessible by position in file */
- protected IHeapElementManager heapElementManager;
+ protected final IHeapElementManager heapElementManager;
/** free node tree to manage free area in heap file */
private final RedBlackTree<Integer> freeNodeTree;
@@ -110,9 +107,6 @@
/** to map data record identifier to file position */
private final RedBlackTree<DataRecordIdentifier> idNodeTree;
- /** file name for change logging */
- private String changeFileName;
-
// /** file name for backup logging */
// private String backupFileName;
@@ -1049,76 +1043,12 @@
return heapHeader.getUsedSize();
}
- @NotStorableClass
- private class BackupFileFilter implements FilenameFilter {
-
- final private String nameBody;
-
- public BackupFileFilter(final String nameBody) {
- super();
- this.nameBody = nameBody;
- }
-
- @Override
- public boolean accept(final File dir, final String name) {
- return !nameBody.equals(name) && name.startsWith(nameBody);
- }
-
- }
-
@Override
public String backup(final long identifier, final int maxBackup)
throws HeapException {
- /*
- * no more than maxBackup file(s)
- */
- final IFileForStorable fileForStorable = heapElementManager
- .getFileForStorable();
- final File file = fileForStorable.getFile();
- final File parent = file.getParentFile();
- String fileNameForFilter = file.getName() + ".old";
- cleanFile(maxBackup, parent, fileNameForFilter);
- fileNameForFilter = file.getName() + ".change";
- cleanFile(maxBackup, parent, fileNameForFilter);
- /*
- * do the backup
- */
- String format = file.getAbsolutePath() + ".old.%020d";
- final Object[] args = new Object[] { identifier };
- String backupFileName = String.format(format, args);
- try {
- fileForStorable.copy(backupFileName);
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- /*
- * create file name for change
- */
- format = file.getAbsolutePath() + ".change.%020d";
- changeFileName = String.format(format, args);
- return backupFileName;
+ return heapElementManager.backup(identifier, maxBackup);
}
- private void cleanFile(final int maxBackup, final File parent,
- final String fileNameForFilter) throws HeapException {
- final FilenameFilter filter = new BackupFileFilter(fileNameForFilter);
- final File[] files = parent.listFiles(filter);
- if (files.length >= maxBackup) {
- final Set<File> set = new TreeSet<File>();
- for (File fileListed : files) {
- set.add(fileListed);
- }
- final Iterator<File> iterator = set.iterator();
- for (int count = files.length; iterator.hasNext()
- && count >= maxBackup; count--) {
- final File toDelete = iterator.next();
- if (!toDelete.delete()) {
- throw new HeapException("failed delete " + toDelete);
- }
- }
- }
- }
-
@Override
public String getStorageFileName() throws HeapException {
final IFileForStorable fileForStorable = heapElementManager
@@ -1127,11 +1057,6 @@
return file.getAbsolutePath();
}
- @Override
- public String getChangeFileName() {
- return changeFileName;
- }
-
@NotStorableClass
private class DataRecordIterator implements Iterator<DataRecordIdentifier> {
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -352,4 +352,9 @@
public IDataRecordKeyManager getDataRecordKeyManager() {
throw new UnsupportedOperationException("not implemented");
}
+
+ @Override
+ public String backup(long identifier, int maxBackup) throws HeapException {
+ throw new UnsupportedOperationException("not implemented");
+ }
}
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -428,11 +428,6 @@
throw new HeapException("not implemented");
}
- @Override
- public String getChangeFileName() throws HeapException {
- return null;
- }
-
private int read(final long position, final int offset, final byte[] data,
final boolean addToCache) throws FileIOException {
DataBlock dataBlock = cacheMap.get(position);
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -336,12 +336,6 @@
}
@Override
- public String getChangeFileName() throws HeapException {
- // no implementation
- return null;
- }
-
- @Override
public Set<DataRecordIdentifier> getDataRecordIdentifierSet()
throws HeapException {
// no implementation
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileForStorableBridge.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileForStorableBridge.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileForStorableBridge.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -93,4 +93,14 @@
public void copy(String fileName) throws FileIOException {
delegate.copy(fileName);
}
+
+ @Override
+ public boolean isUseCache() {
+ return delegate.isUseCache();
+ }
+
+ @Override
+ public int getCachePageSize() {
+ return delegate.getCachePageSize();
+ }
}
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -320,11 +320,6 @@
}
@Override
- public String getChangeFileName() {
- return heapFileDataManager.getChangeFileName();
- }
-
- @Override
public Iterator<DataRecordIdentifier> dataRecordIterator()
throws HeapException {
return heapFileDataManager.dataRecordIterator();
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -281,11 +281,6 @@
}
@Override
- public String getChangeFileName() throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
public Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
return getDataRecordIdentifierSetImpl().iterator();
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java 2012-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -452,11 +452,6 @@
}
@Override
- public String getChangeFileName() throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
public Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
throw new UnsupportedOperationException();
}
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-04-22 05:38:20 UTC (rev 3025)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/HeapElementManager.java 2012-04-22 06:42:59 UTC (rev 3026)
@@ -17,7 +17,9 @@
package net.sf.joafip.kvstore.record.service;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.PrintStream;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -1145,4 +1147,71 @@
public IFileStorable getHeapFileRecordInWriteCache(final long positionInFile) {
return heapRecordToWriteMap.get(positionInFile);
}
+
+ @Override
+ public String backup(long identifier, int maxBackup) throws HeapException {
+ /*
+ * no more than maxBackup file(s)
+ */
+ final File file = fileForStorable.getFile();
+ final File parent = file.getParentFile();
+ String fileNameForFilter = file.getName() + ".old";
+ cleanFile(maxBackup, parent, fileNameForFilter);
+ fileNameForFilter = file.getName() + ".change";
+ cleanFile(maxBackup, parent, fileNameForFilter);
+ /*
+ * do the backup
+ */
+ final String format = file.getAbsolutePath() + ".old.%020d";
+ final Object[] args = new Object[] { identifier };
+ String backupFileName = String.format(format, args);
+ try {
+ fileForStorable.copy(backupFileName);
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ /*
+ * create file name for change
+ */
+ // format = file.getAbsolutePath() + ".change.%020d";
+ // changeFileName = String.format(format, args);
+ return backupFileName;
+ }
+
+ private void cleanFile(final int maxBackup, final File parent,
+ final String fileNameForFilter) throws HeapException {
+ final FilenameFilter filter = new BackupFileFilter(f...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-24 04:44:18
|
Revision: 3029
http://joafip.svn.sourceforge.net/joafip/?rev=3029&view=rev
Author: luc_peuvrier
Date: 2012-04-24 04:44:11 +0000 (Tue, 24 Apr 2012)
Log Message:
-----------
WIP btree plus, tests in progress. LeafPage tests ok
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/DataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.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/PageConstant.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-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/IFileStorable.java
trunk/joafip-testsuite/pom.xml
trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecord.java
trunk/joafip-btreeplus/src/test/java/net/
trunk/joafip-btreeplus/src/test/java/net/sf/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/BtreePlusEntityTests.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-24 04:44:20
|
Revision: 3029
http://joafip.svn.sourceforge.net/joafip/?rev=3029&view=rev
Author: luc_peuvrier
Date: 2012-04-24 04:44:11 +0000 (Tue, 24 Apr 2012)
Log Message:
-----------
WIP btree plus, tests in progress. LeafPage tests ok
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/DataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.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/PageConstant.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-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/IFileStorable.java
trunk/joafip-testsuite/pom.xml
trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecord.java
trunk/joafip-btreeplus/src/test/java/net/
trunk/joafip-btreeplus/src/test/java/net/sf/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/BtreePlusEntityTests.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-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -23,6 +23,7 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
/**
@@ -32,15 +33,14 @@
*/
public abstract class AbstractElement implements IPageRecordable {
- private final PageRecord pageRecord;
+ private IPageRecord pageRecord;
- public AbstractElement(final PageRecord pageRecord) {
- super();
+ public void setPageRecord(IPageRecord pageRecord) {
this.pageRecord = pageRecord;
}
@Override
- public PageRecord getPageRecord() {
+ public IPageRecord getPageRecord() {
return pageRecord;
}
@@ -53,4 +53,17 @@
public void setValueIsNotChanged() {
pageRecord.setValueIsNotChanged();
}
+
+ public long getPositionInFile() {
+ return pageRecord.getPositionInFile();
+ }
+
+ 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;
+ }
}
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java 2012-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity;
+import java.util.Arrays;
+
import net.sf.joafip.kvstore.service.HeapException;
/**
@@ -30,27 +32,77 @@
* @author luc peuvrier
*
*/
-public class DataBlock implements IStateStored {
+public class DataBlock implements IDataBlock {
private final DataBlockPage dataBlockPage;
private final byte[] data;
- public DataBlock(final DataBlockPage dataBlockPage, final int size) {
+ private final int indexInDataBlockPage;
+
+ private final byte bits;
+
+ private final int minSize;
+
+ private final int maxSize;
+
+ private int size;
+
+ private long position = -1;
+
+ public DataBlock(final DataBlockPage dataBlockPage,
+ final int indexInDataBlockPage, final byte bits, final int minSize,
+ final int maxSize) {
super();
this.dataBlockPage = dataBlockPage;
- data = new byte[size];
+ this.indexInDataBlockPage = indexInDataBlockPage;
+ this.bits = bits;
+ this.minSize = minSize;
+ this.maxSize = maxSize;
+ data = new byte[maxSize];
}
- public byte[] getData() {
+ @Override
+ public int getMinSize() {
+ return minSize;
+ }
+
+ @Override
+ public int getMaxSize() {
+ return maxSize;
+ }
+
+ @Override
+ public byte getBits() {
+ return bits;
+ }
+
+ public DataBlockPage getDataBlockPage() {
+ return dataBlockPage;
+ }
+
+ @Override
+ public int getIndexInDataBlockPage() {
+ return indexInDataBlockPage;
+ }
+
+ @Override
+ public byte[] getDataHolder() {
return data;
}
- public int getSize() {
- return data.length;
+ @Override
+ public void setData(final byte[] data) throws HeapException {
+ System.arraycopy(data, 0, this.data, 0, size = data.length);
+ setValueIsChangedValueToSave();
}
@Override
+ public byte[] getData() {
+ return Arrays.copyOf(data, size);
+ }
+
+ @Override
public void setValueIsChangedValueToSave() throws HeapException {
dataBlockPage.setValueIsChangedValueToSave();
}
@@ -59,4 +111,39 @@
public void setValueIsNotChanged() {
dataBlockPage.setValueIsNotChanged();
}
+
+ @Override
+ public void setNextFreeDataBlockPosition(
+ final long nextFreeDataBlockPosition) throws HeapException {
+ data[0] = (byte) (nextFreeDataBlockPosition >> 56);
+ data[1] = (byte) (nextFreeDataBlockPosition >> 48);
+ data[2] = (byte) (nextFreeDataBlockPosition >> 40);
+ data[3] = (byte) (nextFreeDataBlockPosition >> 32);
+ data[4] = (byte) (nextFreeDataBlockPosition >> 24);
+ data[5] = (byte) (nextFreeDataBlockPosition >> 16);
+ data[6] = (byte) (nextFreeDataBlockPosition >> 8);
+ data[7] = (byte) (nextFreeDataBlockPosition);
+ setValueIsChangedValueToSave();
+ }
+
+ @Override
+ public long getNextFreeDataBlockPosition() {
+ return
+ /**/((((long) data[0]) & 0xff) << 56) |
+ /**/((((long) data[1]) & 0xff) << 48) |
+ /**/((((long) data[2]) & 0xff) << 40) |
+ /**/((((long) data[3]) & 0xff) << 32) |
+ /**/((((long) data[4]) & 0xff) << 24) |
+ /**/((((long) data[5]) & 0xff) << 16) |
+ /**/((((long) data[6]) & 0xff) << 8) |
+ /**/(((long) data[0]) & 0xff);
+ }
+
+ @Override
+ public long getPosition() {
+ if (position == -1) {
+ position = dataBlockPage.position(indexInDataBlockPage);
+ }
+ return position;
+ }
}
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.kvstore.service.HeapException;
+
/**
*
* @author luc peuvrier
@@ -41,10 +43,10 @@
private final int dataBlockDataSize;
- private final DataBlock[] dataBlocks;
+ private final IDataBlock[] dataBlocks;
- public DataBlockPage(final PageRecord pageRecord, final byte bits) {
- super(pageRecord);
+ public DataBlockPage(final byte bits) {
+ super();
this.bits = bits;
dataBlockDataSize = 1 << bits;
// the less numberOfPageValue which for
@@ -59,7 +61,7 @@
final int totalSize = FIX_VALUE_SIZE
+ /* numberOfBlock* */dataBlockDataSize;
final int n = totalSize >> PageConstant.PAGE_BITS;
- if ((totalSize & PageConstant.PAGE_MASK) == 0) {
+ if ((totalSize & PageConstant.IN_PAGE_POSITION_MASK) == 0) {
numberOfPage = n;
} else {
numberOfPage = n + 1;
@@ -67,12 +69,17 @@
} else {
// more than one block in one page
numberOfPage = 1;
- numberOfBlock = (PageConstant.PAGE_SIZE - FIX_VALUE_SIZE)
- / dataBlockDataSize;
+ // numberOfBlock = ((int)PageConstant.PAGE_SIZE - FIX_VALUE_SIZE)
+ // / dataBlockDataSize;
+ numberOfBlock = ((int) PageConstant.PAGE_SIZE - FIX_VALUE_SIZE) >> bits;
}
+ final int minSize = bits == PageConstant.MIN_DATA_BLOCK_BITS ? 0
+ : ((1 << (bits - 1)) + 1);
dataBlocks = new DataBlock[numberOfBlock];
- for (int index = 0; index < numberOfBlock; index++) {
- dataBlocks[index] = new DataBlock(this, dataBlockDataSize);
+ for (int dataBlockIndex = 0; dataBlockIndex < numberOfBlock; dataBlockIndex++) {
+ dataBlocks[dataBlockIndex] = new DataBlock(this, dataBlockIndex,
+ bits, minSize, dataBlockDataSize);
+
}
}
@@ -97,10 +104,46 @@
@Override
public int getByteSize() {
- return numberOfPage * PageConstant.PAGE_SIZE;
+ return numberOfPage * (int) PageConstant.PAGE_SIZE;
}
- public DataBlock[] getDataBlocks() {
+ public IDataBlock[] getDataBlocks() {
return dataBlocks;
}
+
+ public IDataBlock getDataBlock(final long dataBlockPosition) {
+ // >> bits as divide by data block size
+ final int index = ((int) (dataBlockPosition - getPositionInFile()) - FIX_VALUE_SIZE) >> bits;
+ return dataBlocks[index];
+ }
+
+ public long position(final int index) {
+ return getPositionInFile() + FIX_VALUE_SIZE + (index << bits);
+ }
+
+ public void setAllFree() throws HeapException {
+ long nextPosition = getPositionInFile() + FIX_VALUE_SIZE
+ + dataBlockDataSize;
+ for (int index = 0; index < dataBlocks.length - 1; index++) {
+ dataBlocks[index].setNextFreeDataBlockPosition(nextPosition);
+ nextPosition += dataBlockDataSize;
+ }
+ dataBlocks[dataBlocks.length - 1].setNextFreeDataBlockPosition(-1L);
+ }
+
+ @Override
+ public void setParentPage(final IPageRecordable parentPage,
+ final int inParentIndex) throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public IPageRecordable getParentPage() throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public int getInParentIndex() throws HeapException {
+ throw new HeapException("unsupported");
+ }
}
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java 2012-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.kvstore.service.HeapException;
+
/**
*
* @author luc peuvrier
@@ -32,8 +34,8 @@
private final long nextFreePage;
- public FreePage(final PageRecord pageRecord, final long nextFreePage) {
- super(pageRecord);
+ public FreePage(final long nextFreePage) {
+ super();
this.nextFreePage = nextFreePage;
}
@@ -63,4 +65,20 @@
public long getNextFreePage() {
return nextFreePage;
}
+
+ @Override
+ public void setParentPage(final IPageRecordable parentPage,
+ final int inParentIndex) throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public IPageRecordable getParentPage() throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public int getInParentIndex() throws HeapException {
+ throw new HeapException("unsupported");
+ }
}
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -40,9 +40,9 @@
/** page number of first free page. -1 means no free page */
private long pageNumberOfFirstFreePage = -1L;
- private long pageNumberOfRootPage = -1L;
+ private long rootPagePosition = -1L;
- private long[] freeDataBlock;
+ private long[] freeDataBlocks;
private long nextDataRecordIdentifier;
@@ -70,34 +70,35 @@
this.pageNumberOfFirstFreePage = pageNumberOfFirstFreePage;
}
- public long getPageNumberOfRootPage() {
- return pageNumberOfRootPage;
+ public long getRootPagePosition() {
+ return rootPagePosition;
}
- public void setPageNumberOfRootPage(final long pageNumberOfRootPage)
+ public void setRootPagePosition(final long rootPagePosition)
throws HeapException {
setValueIsChangedValueToSave();
- this.pageNumberOfRootPage = pageNumberOfRootPage;
+ this.rootPagePosition = rootPagePosition;
}
public void setFirstFreeBlock(final long firstFreeBlockPosition,
final int blockBits) throws HeapException {
setValueIsChangedValueToSave();
initializeFreeDataBlock();
- freeDataBlock[blockBits - PageConstant.MIN_DATA_BLOCK_BITS] = firstFreeBlockPosition;
+ freeDataBlocks[blockBits - PageConstant.MIN_DATA_BLOCK_BITS] = firstFreeBlockPosition;
}
public long getFirstFreeBlock(final int blockBits) {
initializeFreeDataBlock();
- return freeDataBlock[blockBits - PageConstant.MIN_DATA_BLOCK_BITS];
+ return freeDataBlocks[blockBits - PageConstant.MIN_DATA_BLOCK_BITS];
}
public void clear() {
super.clear();
fileSizeAsNumberOfPage = -1L;
pageNumberOfFirstFreePage = -1L;
- pageNumberOfRootPage = -1L;
- freeDataBlock = null;
+ rootPagePosition = -1L;
+ freeDataBlocks = null;
+ nextDataRecordIdentifier = 0;
}
@Override
@@ -117,12 +118,12 @@
@Override
public int getRecordSize() throws HeapException {
- return PageConstant.PAGE_SIZE;
+ return (int) PageConstant.PAGE_SIZE;
}
@Override
protected int toMarshallSize() throws HeapException {
- return PageConstant.PAGE_SIZE;
+ return (int) PageConstant.PAGE_SIZE;
}
@Override
@@ -130,18 +131,18 @@
writeByteRecordType(EnumRecordType.HEADER_PAGE);
writeLong(fileSizeAsNumberOfPage);
writeLong(pageNumberOfFirstFreePage);
- writeLong(pageNumberOfRootPage);
+ writeLong(rootPagePosition);
writeLong(nextDataRecordIdentifier);
initializeFreeDataBlock();
for (int index = 0; index < PageConstant.NUMBER_OF_BLOCK_TYPE; index++) {
- writeLong(freeDataBlock[index]);
+ writeLong(freeDataBlocks[index]);
}
writeCrc32();
}
@Override
protected void unmarshallImpl() throws HeapException {
- readFileToIoBuffer(PageConstant.PAGE_SIZE);
+ readFileToIoBuffer((int) PageConstant.PAGE_SIZE);
final EnumRecordType recordType = readRecordType();
if (!EnumRecordType.HEADER_PAGE.equals(recordType)) {
throw new HeapException(EnumRecordType.HEADER_PAGE
@@ -149,19 +150,19 @@
}
fileSizeAsNumberOfPage = readLong();
pageNumberOfFirstFreePage = readLong();
- pageNumberOfRootPage = readLong();
+ rootPagePosition = readLong();
nextDataRecordIdentifier = readLong();
initializeFreeDataBlock();
for (int index = 0; index < PageConstant.NUMBER_OF_BLOCK_TYPE; index++) {
- freeDataBlock[index] = readLong();
+ freeDataBlocks[index] = readLong();
}
readAndCheckCrc32();
}
private void initializeFreeDataBlock() {
- if (freeDataBlock == null) {
- freeDataBlock = new long[PageConstant.NUMBER_OF_BLOCK_TYPE];
- Arrays.fill(freeDataBlock, -1L);
+ if (freeDataBlocks == null) {
+ freeDataBlocks = new long[PageConstant.NUMBER_OF_BLOCK_TYPE];
+ Arrays.fill(freeDataBlocks, -1L);
}
}
@@ -172,10 +173,15 @@
@Override
public int getByteSize() {
- return PageConstant.PAGE_SIZE;
+ return (int) PageConstant.PAGE_SIZE;
}
@Override
+ public void setPageRecord(IPageRecord pageRecord) throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
public PageRecord getPageRecord() throws HeapException {
throw new HeapException("unsupported");
}
@@ -196,4 +202,32 @@
setValueIsChangedValueToSave();
return value;
}
+
+ public long getFreeDataBlockPosition(final int bits) {
+ initializeFreeDataBlock();
+ return freeDataBlocks[bits - PageConstant.MIN_DATA_BLOCK_BITS];
+ }
+
+ public void setFreeDataBlockPosition(final int bits,
+ long freeDataBlockPosition) throws HeapException {
+ initializeFreeDataBlock();
+ freeDataBlocks[bits - PageConstant.MIN_DATA_BLOCK_BITS] = freeDataBlockPosition;
+ setValueIsChangedValueToSave();
+ }
+
+ @Override
+ public void setParentPage(final IPageRecordable parentPage,
+ final int inParentIndex) throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public IPageRecordable getParentPage() throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public int getInParentIndex() throws HeapException {
+ throw new HeapException("unsupported");
+ }
}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -0,0 +1,56 @@
+/*
+ * 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.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface IDataBlock extends IStateStored {
+
+ long getPosition();
+
+ void setData(byte[] data) throws HeapException;
+
+ byte[] getData();
+
+ void setNextFreeDataBlockPosition(long nextFreeDataBlockPosition)
+ throws HeapException;
+
+ long getNextFreeDataBlockPosition();
+
+ byte[] getDataHolder();
+
+ int getMinSize();
+
+ int getMaxSize();
+
+ byte getBits();
+
+ int getIndexInDataBlockPage();
+
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecord.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecord.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecord.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -0,0 +1,60 @@
+/*
+ * 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.kvstore.entity.IFileStorable;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface IPageRecord extends IFileStorable {
+
+ /**
+ * @see IFileStorable#getPositionInFile
+ */
+ @Override
+ long getPositionInFile();
+
+ /**
+ * @see IFileStorable#setValueIsChangedValueToSave
+ */
+ @Override
+ void setValueIsChangedValueToSave() throws HeapException;
+
+ /**
+ * @see IFileStorable#setValueIsNotChanged
+ */
+ @Override
+ void setValueIsNotChanged();
+
+ /**
+ * @see IFileStorable#isValueChangedToSave
+ */
+ @Override
+ boolean isValueChangedToSave();
+
+}
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java 2012-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IPageRecordable.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -49,6 +49,14 @@
void updateByteSize();
- PageRecord getPageRecord() throws HeapException;
+ IPageRecord getPageRecord() throws HeapException;
+ void setPageRecord(IPageRecord pageRecord) throws HeapException;
+
+ void setParentPage(IPageRecordable parentPage, int inParentIndex)
+ throws HeapException;
+
+ IPageRecordable getParentPage() throws HeapException;
+
+ int getInParentIndex() throws HeapException;
}
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-04-23 01:47:15 UTC (rev 3028)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-04-24 04:44:11 UTC (rev 3029)
@@ -23,7 +23,10 @@
*/
package net.sf.joafip.btreeplus.entity;
+import java.util.Arrays;
+
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapException;
/**
*
@@ -32,7 +35,7 @@
*/
public class LeafPage extends AbstractElement {
- private long[] pagePointers;
+ private long[] dataBlockPosition;
private DataRecordIdentifier[] keys;
@@ -42,14 +45,32 @@
private long next;
- public LeafPage(final PageRecord pageRecord, final int numberOfKeyEntries) {
- super(pageRecord);
+ private IPageRecordable parentPage;
+
+ private int inParentIndex;
+
+ public LeafPage() {
+ this(0);
+ updateByteSize();
+ }
+
+ public LeafPage(final int numberOfKeyEntries) {
+ super();
this.numberOfKeyEntries = numberOfKeyEntries;
keys = new DataRecordIdentifier[numberOfKeyEntries];
- pagePointers = new long[numberOfKeyEntries];
+ dataBlockPosition = new long[numberOfKeyEntries];
byteSize = 0;
}
+ public LeafPage(final int numberOfKeyEntries,
+ final long[] dataBlockPosition, final DataRecordIdentifier[] keys) {
+ super();
+ this.numberOfKeyEntries = numberOfKeyEntries;
+ this.dataBlockPosition = dataBlockPosition;
+ this.keys = keys;
+ updateByteSize();
+ }
+
@Override
public EnumRecordType getRecordType() {
return EnumRecordType.LEAF_PAGE;
@@ -60,6 +81,23 @@
return 1;
}
+ @Override
+ public void setParentPage(final IPageRecordable parentPage,
+ final int inParentIndex) {
+ this.parentPage = parentPage;
+ this.inParentIndex = inParentIndex;
+ }
+
+ @Override
+ public IPageRecordable getParentPage() {
+ return parentPage;
+ }
+
+ @Override
+ public int getInParentIndex() throws HeapException {
+ return inParentIndex;
+ }
+
public int getNumberOfKeyEntries() {
return numberOfKeyEntries;
}
@@ -69,7 +107,7 @@
}
public long getBlockPointer(final int index) {
- return pagePointers[index];
+ return dataBlockPosition[index];
}
public long getNext() {
@@ -82,29 +120,145 @@
public void setEntry(final int index, final long pagePointer,
final DataRecordIdentifier key) {
- pagePointers[index] = pagePointer;
+ dataBlockPosition[index] = pagePointer;
keys[index] = key;
}
@Override
public int getByteSize() {
+ // ASSERTX
+ assert byteSize != 0 : "unknow current byte size";
return byteSize;
}
@Override
public void updateByteSize() {
- byteSize = 1/* byte size for record type */+
+ byteSize = computeByteSize();
+ }
+
+ private int computeByteSize() {
+ int xbyteSize = 1/* byte size for record type */+
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
- /**/(numberOfKeyEntries + 1/* for next */) * 8/*
- * long size for pointer
- */;
+ /**/8/* for next */;
for (int index = 0; index < numberOfKeyEntries; index++) {
- byteSize += 8/* long size for value */;
- final int dataSize = keys[index].getKeyDataSize();
- if (dataSize != 0) {
- byteSize += 4/* int size for data size */+ dataSize;
+ xbyteSize += entrySize(keys[index]);
+ }
+ return xbyteSize;
+ }
+
+ /**
+ *
+ * @param dataRecordIdentifier
+ * @return data block pointer on data associated to data record identifier,
+ * -1 if not found
+ */
+ public long getDataBlockPosition(
+ final DataRecordIdentifier dataRecordIdentifier) {
+ // FIXMELUC _______dichotomic search
+ long position = -1;
+ for (int index = 0; position == -1L && index < numberOfKeyEntries; index++) {
+ if (keys[index].compareTo(dataRecordIdentifier) == 0) {
+ position = dataBlockPosition[index];
}
}
+ return position;
}
+
+ public void setDataBlock(final int index, final IDataBlock dataBlock)
+ throws HeapException {
+ dataBlockPosition[index] = dataBlock.getPosition();
+ }
+
+ /**
+ *
+ * @param dataRecordIdentifier
+ * @param dataBlock
+ * @return true if added
+ * @throws HeapException
+ */
+ public boolean add(final DataRecordIdentifier dataRecordIdentifier,
+ final IDataBlock dataBlock) throws HeapException {
+ final int entrySize = entrySize(dataRecordIdentifier);
+ // ASSERTX
+ assert byteSize != 0 : "unknow current byte size";
+ final boolean canAdd = entrySize + byteSize <= PageConstant.PAGE_SIZE;
+ if (canAdd) {
+ // can add
+ 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.getPosition();
+ newKeys[insertBeforeIndex] = dataRecordIdentifier;
+ if (afterLength != 0) {
+ System.arraycopy(dataBlockPosition, insertBeforeIndex,
+ newDataBlockPosition, insertBeforeIndex + 1,
+ afterLength);
+ System.arraycopy(keys, insertBeforeIndex, newKeys,
+ insertBeforeIndex + 1, afterLength);
+ }
+ dataBlockPosition = newDataBlockPosition;
+ keys = newKeys;
+ byteSize += entrySize;
+ // ASSERTX
+ assert byteSize == computeByteSize() : byteSize + " for "
+ + computeByteSize() + " computed";
+ }
+ return canAdd;
+ }
+
+ public LeafPage split(final DataRecordIdentifier dataRecordIdentifier,
+ final IDataBlock dataBlock) throws HeapException {
+ final int insertBeforeIndex = computeInsertBeforeIndex(dataRecordIdentifier);
+ final int newNumberOfKeyEntries = numberOfKeyEntries / 2;
+ 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);
+ dataBlockPosition = newDataBlockPosition;
+ keys = newKeys;
+ numberOfKeyEntries = newNumberOfKeyEntries;
+ updateByteSize();
+ if (insertBeforeIndex >= newNumberOfKeyEntries) {
+ if (!newLeafPage.add(dataRecordIdentifier, dataBlock)) {
+ throw new HeapException("failed add in new leaf page");
+ }
+ } else {
+ if (!add(dataRecordIdentifier, dataBlock)) {
+ throw new HeapException("failed add in splitted l...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-25 04:28:36
|
Revision: 3030
http://joafip.svn.sourceforge.net/joafip/?rev=3030&view=rev
Author: luc_peuvrier
Date: 2012-04-25 04:28:28 +0000 (Wed, 25 Apr 2012)
Log Message:
-----------
WIP btree plus, tests in progress. NonTerminalPage tests ok
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/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-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/BtreePlusEntityTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/ILeafPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/INonTerminalPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/ILeafPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/ILeafPage.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/ILeafPage.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -0,0 +1,39 @@
+/*
+ * 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.kvstore.record.entity.DataRecordIdentifier;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface ILeafPage extends IPageRecordable {
+
+ DataRecordIdentifier getLastKey();
+
+ long getPositionInFile();
+
+}
Added: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/INonTerminalPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/INonTerminalPage.java (rev 0)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/INonTerminalPage.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -0,0 +1,40 @@
+/*
+ * 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.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface INonTerminalPage extends IPageRecordable {
+
+ @Override
+ int getInParentIndex() throws HeapException;
+
+ long getPositionInFile();
+
+}
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-04-24 04:44:11 UTC (rev 3029)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -33,7 +33,7 @@
* @author luc peuvrier
*
*/
-public class LeafPage extends AbstractElement {
+public class LeafPage extends AbstractElement implements ILeafPage {
private long[] dataBlockPosition;
@@ -122,6 +122,7 @@
final DataRecordIdentifier key) {
dataBlockPosition[index] = pagePointer;
keys[index] = key;
+ byteSize = 0;// unknown size because key size change
}
@Override
@@ -141,6 +142,7 @@
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
/**/8/* for next */;
+ // FIXMELUC ______speedup if long value key
for (int index = 0; index < numberOfKeyEntries; index++) {
xbyteSize += entrySize(keys[index]);
}
@@ -258,7 +260,7 @@
return index;
}
- public DataRecordIdentifier lastKey() {
+ public DataRecordIdentifier getLastKey() {
return keys[numberOfKeyEntries - 1];
}
}
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-04-24 04:44:11 UTC (rev 3029)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -33,7 +33,8 @@
* @author luc peuvrier
*
*/
-public class NonTerminalPage extends AbstractElement {
+public class NonTerminalPage extends AbstractElement implements
+ INonTerminalPage {
private long[] pagePositions;
@@ -123,6 +124,7 @@
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
/**/8/* last pointer long size */;
+ // FIXMELUC ______speedup if long value key
for (int index = 0; index < numberOfKeyEntries; index++) {
xbyteSize += entrySize(keys[index]);
}
@@ -149,39 +151,42 @@
public int getIndex(final DataRecordIdentifier dataRecordIdentifier) {
// FIXMELUC _______dichotomic search
int index;
- boolean found = false;
- for (index = 0; !found && index < numberOfKeyEntries; index++) {
- found = keys[index].compareTo(dataRecordIdentifier) <= 0;
+ for (index = 0; index < numberOfKeyEntries; index++) {
+ if (keys[index].compareTo(dataRecordIdentifier) >= 0) {
+ return index;
+ }
}
return index;
}
/**
*
- * @param existingLeftLeafPage
- * @param newRightLeafPage
+ * @param existingLeftILeafPage
+ * @param newRightILeafPage
* @return true if add not need split
* @throws HeapException
*/
- public boolean add(final LeafPage existingLeftLeafPage,
- final LeafPage newRightLeafPage) throws HeapException {
- final int index = existingLeftLeafPage.getInParentIndex();
- final DataRecordIdentifier key = existingLeftLeafPage.lastKey();
+ public boolean add(final ILeafPage existingLeftILeafPage,
+ final ILeafPage newRightILeafPage) throws HeapException {
+ final int index = existingLeftILeafPage.getInParentIndex();
+ final DataRecordIdentifier key = existingLeftILeafPage.getLastKey();
final int entrySize = entrySize(key);
- final int afterLength = numberOfKeyEntries - (index + 1);
+ 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);
}
+ System.arraycopy(pagePositions, 0, newPagePosition, 0, index + 1);
+
newKeys[index] = key;
- newPagePosition[index + 1] = newRightLeafPage.getPositionInFile();
- newKeys[index + 1] = newRightLeafPage.lastKey();
+ newPagePosition[index + 1] = newRightILeafPage.getPositionInFile();
System.arraycopy(pagePositions, index + 1, newPagePosition, index + 2,
- afterLength + 1);
- System.arraycopy(keys, index + 1, newKeys, index + 2, afterLength);
+ afterLength);
+ if (afterLength != 0) {
+ System.arraycopy(keys, index, newKeys, index + 1, afterLength);
+ }
keys = newKeys;
pagePositions = newPagePosition;
// ASSERTX
@@ -192,34 +197,48 @@
return byteSize < PageConstant.PAGE_SIZE;
}
- public boolean add(final NonTerminalPage leftSonNonTerminalPage,
+ /**
+ *
+ * @param leftSonNonTerminalPage
+ * @param middleKey
+ * @param rightSonNonTerminalPage
+ * @return true if add not need split
+ * @throws HeapException
+ */
+ public boolean add(final INonTerminalPage leftSonNonTerminalPage,
final DataRecordIdentifier middleKey,
- final NonTerminalPage rightSonNonTerminalPage) throws HeapException {
+ final INonTerminalPage rightSonNonTerminalPage)
+ throws HeapException {
final int index = leftSonNonTerminalPage.getInParentIndex();
final int entrySize = entrySize(middleKey);
- final int afterLength = numberOfKeyEntries - (index + 1);
+ final int afterLength = numberOfKeyEntries - index;
numberOfKeyEntries++;
DataRecordIdentifier[] newKeys = new DataRecordIdentifier[numberOfKeyEntries];
- long[] newPagePosition = new long[numberOfKeyEntries + 1];
- System.arraycopy(pagePositions, 0, newPagePosition, 0, index + 1);
+ long[] newPagePositions = new long[numberOfKeyEntries + 1];
if (index != 0) {
System.arraycopy(keys, 0, newKeys, 0, index);
}
- DataRecordIdentifier k = keys[index];
+ System.arraycopy(pagePositions, 0, newPagePositions, 0, index + 1);
newKeys[index] = middleKey;
- newKeys[index + 1] = k;
- System.arraycopy(pagePositions, index + 1, newPagePosition, index + 2,
- afterLength + 1);
- System.arraycopy(keys, index + 2, newKeys, index + 2, afterLength);
+ newPagePositions[index + 1] = rightSonNonTerminalPage
+ .getPositionInFile();
+
+ if (afterLength != 0) {
+ System.arraycopy(keys, index, newKeys, index + 1, afterLength);
+ System.arraycopy(pagePositions, index + 1, newPagePositions,
+ index + 2, afterLength);
+ }
+ keys = newKeys;
+ pagePositions = newPagePositions;
// ASSERTX
assert byteSize != 0 : "unknow current byte size";
- byteSize += entrySize + 8;
+ byteSize += entrySize;
// ASSERTX
assert byteSize == computeByteSize();
return byteSize < PageConstant.PAGE_SIZE;
}
- public NonTerminalPage split() {
+ public INonTerminalPage split() {
final int splitIndex = numberOfKeyEntries / 2;
middleKey = keys[splitIndex];
final int newNumberOfKeyEntries = splitIndex;
@@ -233,7 +252,7 @@
keys, splitIndex + 1, numberOfKeyEntries);
final long[] newNonTerminalPagePosition = Arrays.copyOfRange(
pagePositions, splitIndex + 1, numberOfKeyEntries + 1);
- final NonTerminalPage nonTerminalPage = new NonTerminalPage(
+ final INonTerminalPage nonTerminalPage = new NonTerminalPage(
newNonTerminalPageNumberOfKeyEntries, newNonTerminalKeys,
newNonTerminalPagePosition);
keys = newKeys;
@@ -243,7 +262,14 @@
return nonTerminalPage;
}
- public DataRecordIdentifier getMiddleKey() {
- return middleKey;
+ /**
+ * get and clear middle key computed by {@link #split()}
+ *
+ * @return middle key computed by {@link #split()}
+ */
+ public DataRecordIdentifier getAndClearMiddleKey() {
+ final DataRecordIdentifier result = middleKey;
+ middleKey = null;
+ return result;
}
}
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-04-24 04:44:11 UTC (rev 3029)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -30,6 +30,7 @@
import net.sf.joafip.Fortest;
import net.sf.joafip.btreeplus.entity.EnumRecordType;
import net.sf.joafip.btreeplus.entity.IDataBlock;
+import net.sf.joafip.btreeplus.entity.INonTerminalPage;
import net.sf.joafip.btreeplus.entity.IPageRecordable;
import net.sf.joafip.btreeplus.entity.LeafPage;
import net.sf.joafip.btreeplus.entity.NonTerminalPage;
@@ -263,13 +264,13 @@
newLeafPage);
} else {
if (!nonTerminalPage.add(leafPage, newLeafPage)) {
- NonTerminalPage newNonTerminalPage = nonTerminalPage
+ INonTerminalPage newNonTerminalPage = nonTerminalPage
.split();
do {
btreePlusElementMgr
.appendPageRecordable(newNonTerminalPage);
DataRecordIdentifier middleKey = nonTerminalPage
- .getMiddleKey();
+ .getAndClearMiddleKey();
NonTerminalPage parent = (NonTerminalPage) nonTerminalPage
.getParentPage();
if (parent == null) {
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-04-24 04:44:11 UTC (rev 3029)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -27,6 +27,7 @@
import net.sf.joafip.btreeplus.entity.DataBlockPage;
import net.sf.joafip.btreeplus.entity.HeaderPage;
import net.sf.joafip.btreeplus.entity.IDataBlock;
+import net.sf.joafip.btreeplus.entity.INonTerminalPage;
import net.sf.joafip.btreeplus.entity.IPageRecord;
import net.sf.joafip.btreeplus.entity.IPageRecordable;
import net.sf.joafip.btreeplus.entity.LeafPage;
@@ -239,7 +240,7 @@
final LeafPage rightLeafPage) throws HeapException {
final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
nonTerminalPage.setEntry(0, leftLeafPage.getPositionInFile(),
- leftLeafPage.lastKey());
+ leftLeafPage.getLastKey());
nonTerminalPage.setEntry(1, rightLeafPage.getPositionInFile(), null);
appendPageRecordable(nonTerminalPage);
nonTerminalPage.updateByteSize();
@@ -247,9 +248,9 @@
}
public void newRootNonTerminalPage(
- final NonTerminalPage leftNonTerminalPage,
+ final INonTerminalPage leftNonTerminalPage,
final DataRecordIdentifier middleKey,
- final NonTerminalPage rightNonTerminalPage) throws HeapException {
+ final INonTerminalPage rightNonTerminalPage) throws HeapException {
final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
nonTerminalPage.setEntry(0, leftNonTerminalPage.getPositionInFile(),
middleKey);
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-04-24 04:44:11 UTC (rev 3029)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -25,7 +25,6 @@
import net.sf.joafip.AbstractJoafipCommonTestCase;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
import net.sf.joafip.btreeplus.entity.mock.MockDataBlock;
import net.sf.joafip.btreeplus.entity.mock.MockPageRecordable;
@@ -38,7 +37,6 @@
*
*/
@NotStorableClass
-@StorableAccess
public class LeafPageTest extends AbstractJoafipCommonTestCase {
public LeafPageTest() throws TestException {
@@ -108,7 +106,7 @@
assertEquals("must not find", -1L,
leafPage.getDataBlockPosition(new DataRecordIdentifier(0)));
assertEquals("bad last key", new DataRecordIdentifier(lastKeyValue),
- leafPage.lastKey());
+ leafPage.getLastKey());
}
public void testSetDataBlock() throws HeapException {
Added: 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 (rev 0)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-04-25 04:28:28 UTC (rev 3030)
@@ -0,0 +1,382 @@
+/*
+ * 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.AbstractJoafipCommonTestCase;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.TestException;
+import net.sf.joafip.btreeplus.entity.mock.MockLeafPage;
+import net.sf.joafip.btreeplus.entity.mock.MockNonTerminalPage;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@StorableAccess
+public class NonTerminalPageTest extends AbstractJoafipCommonTestCase {
+
+ public NonTerminalPageTest() throws TestException {
+ super();
+ }
+
+ public NonTerminalPageTest(final String name) throws TestException {
+ super(name);
+ }
+
+ public void testCreation() {
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage();
+ assertEquals("must be empty", 0,
+ nonTerminalPage.getNumberOfKeyEntries());
+ assertEquals("must be one page", 1, nonTerminalPage.getNumberOfPage());
+ assertEquals("bad record type", EnumRecordType.NON_TERMINAL_PAGE,
+ nonTerminalPage.getRecordType());
+ assertEquals("bad byte size", byteSize(0),
+ nonTerminalPage.getByteSize());
+ }
+
+ public void testAddLeafPage() throws HeapException {
+ // A 10 B
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final MockLeafPage leafPageA = new MockLeafPage();
+ final long pageAPositionInFile = 1000;
+ leafPageA.setPositionInFile(pageAPositionInFile);
+ final MockLeafPage leafPageB = new MockLeafPage();
+ final long pageBPositionInFile = 2000;
+ leafPageB.setPositionInFile(pageBPositionInFile);
+ final DataRecordIdentifier key10 = new DataRecordIdentifier(10);
+ nonTerminalPage.setEntry(0, leafPageA.getPositionInFile(), key10);
+ nonTerminalPage.setEntry(1, leafPageB.getPositionInFile(), null);
+ nonTerminalPage.updateByteSize();
+
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key10 },
+ new long[] { pageAPositionInFile, pageBPositionInFile });
+ assertEquals("bad key 9 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+
+ // A 10 B -> A 5 C 10 B
+ final MockLeafPage leafPageC = new MockLeafPage();
+ final long pageCPositionInFile = 3000;
+ leafPageC.setPositionInFile(pageCPositionInFile);
+ final DataRecordIdentifier key5 = new DataRecordIdentifier(5);
+ leafPageA.setLastKey(key5);
+ leafPageA.setInParentIndex(0);
+
+ nonTerminalPage.add(leafPageA, leafPageC);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key10 },
+ new long[] { pageAPositionInFile, pageCPositionInFile,
+ pageBPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 9 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+
+ // A 5 C 10 B -> A 5 C 10 B 15 D
+ final MockLeafPage leafPageD = new MockLeafPage();
+ final long pageDPositionInFile = 4000;
+ leafPageD.setPositionInFile(pageDPositionInFile);
+ final DataRecordIdentifier key15 = new DataRecordIdentifier(15);
+ leafPageB.setLastKey(key15);
+ leafPageB.setInParentIndex(2);
+ nonTerminalPage.add(leafPageB, leafPageD);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key10,
+ key15 }, new long[] { pageAPositionInFile, pageCPositionInFile,
+ pageBPositionInFile, pageDPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 9 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+ assertEquals("bad key 16 index", 3,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(16)));
+
+ // A 5 C 10 B 15 D -> A 5 C 7 E 10 B 15 D
+ final MockLeafPage leafPageE = new MockLeafPage();
+ final long pageEPositionInFile = 5000;
+ leafPageE.setPositionInFile(pageEPositionInFile);
+ final DataRecordIdentifier key7 = new DataRecordIdentifier(7);
+ leafPageC.setLastKey(key7);
+ leafPageC.setInParentIndex(1);
+ nonTerminalPage.add(leafPageC, leafPageE);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key7,
+ key10, key15 }, new long[] { pageAPositionInFile,
+ pageCPositionInFile, pageEPositionInFile, pageBPositionInFile,
+ pageDPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 6 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(6)));
+ assertEquals("bad key 9 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 3,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+ assertEquals("bad key 16 index", 4,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(16)));
+
+ // A 5 C 7 E 10 B 15 D -> A 5 C 7 E 10 B 15 D 17 F
+ final MockLeafPage leafPageF = new MockLeafPage();
+ final long pageFPositionInFile = 6000;
+ leafPageF.setPositionInFile(pageFPositionInFile);
+ final DataRecordIdentifier key17 = new DataRecordIdentifier(17);
+ leafPageD.setLastKey(key17);
+ leafPageD.setInParentIndex(4);
+ nonTerminalPage.add(leafPageD, leafPageF);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key7,
+ key10, key15, key17 }, new long[] { pageAPositionInFile,
+ pageCPositionInFile, pageEPositionInFile, pageBPositionInFile,
+ pageDPositionInFile, pageFPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 6 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(6)));
+ assertEquals("bad key 9 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 3,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+ assertEquals("bad key 16 index", 4,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(16)));
+ assertEquals("bad key 18 index", 5,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(18)));
+ }
+
+ public void testAddLeafPageNeedSplit() throws HeapException {
+ // A 10 B
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final MockLeafPage leafPageA = new MockLeafPage();
+ final long pageAPositionInFile = 1000;
+ leafPageA.setPositionInFile(pageAPositionInFile);
+ final MockLeafPage leafPageB = new MockLeafPage();
+ final long pageBPositionInFile = 2000;
+ leafPageB.setPositionInFile(pageBPositionInFile);
+ final DataRecordIdentifier key10 = new DataRecordIdentifier(10);
+ nonTerminalPage.setEntry(0, leafPageA.getPositionInFile(), key10);
+ nonTerminalPage.setEntry(1, leafPageB.getPositionInFile(), null);
+ nonTerminalPage.updateByteSize();
+
+ MockLeafPage leftPage = leafPageB;
+ final int maxNumberOfEntries = maxNumberOfEntries();
+ while (nonTerminalPage.getNumberOfKeyEntries() < maxNumberOfEntries) {
+ final MockLeafPage rightPage = new MockLeafPage();
+ leftPage.setInParentIndex(nonTerminalPage.getNumberOfKeyEntries() - 1);
+ leftPage.setLastKey(key10);
+ assertTrue("must not need split",
+ nonTerminalPage.add(leftPage, rightPage));
+ leftPage = rightPage;
+ }
+ final MockLeafPage rightPage = new MockLeafPage();
+ leftPage.setInParentIndex(nonTerminalPage.getNumberOfKeyEntries() - 1);
+ leftPage.setLastKey(key10);
+ assertFalse("must need split", nonTerminalPage.add(leftPage, rightPage));
+ }
+
+ public void testAddNonTerminalPage() throws HeapException {
+ // A 10 B
+ final NonTerminalPage nonTerminalPage = new NonTerminalPage(1);
+ final MockNonTerminalPage pageA = new MockNonTerminalPage();
+ final long pageAPositionInFile = 1000;
+ pageA.setPositionInFile(pageAPositionInFile);
+ final MockNonTerminalPage pageB = new MockNonTerminalPage();
+ final long pageBPositionInFile = 2000;
+ pageB.setPositionInFile(pageBPositionInFile);
+ final DataRecordIdentifier key10 = new DataRecordIdentifier(10);
+ nonTerminalPage.setEntry(0, pageA.getPositionInFile(), key10);
+ nonTerminalPage.setEntry(1, pageB.getPositionInFile(), null);
+ nonTerminalPage.updateByteSize();
+
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key10 },
+ new long[] { pageAPositionInFile, pageBPositionInFile });
+ assertEquals("bad key 9 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+
+ // A 10 B -> A 5 C 10 B
+ final MockNonTerminalPage pageC = new MockNonTerminalPage();
+ final long pageCPositionInFile = 3000;
+ pageC.setPositionInFile(pageCPositionInFile);
+ final DataRecordIdentifier key5 = new DataRecordIdentifier(5);
+ pageA.setInParentIndex(0);
+ nonTerminalPage.add(pageA, key5, pageC);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key10 },
+ new long[] { pageAPositionInFile, pageCPositionInFile,
+ pageBPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 9 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+
+ // ------------
+ // A 5 C 10 B -> A 5 C 10 B 15 D
+ final MockNonTerminalPage pageD = new MockNonTerminalPage();
+ final long pageDPositionInFile = 4000;
+ pageD.setPositionInFile(pageDPositionInFile);
+ final DataRecordIdentifier key15 = new DataRecordIdentifier(15);
+ pageB.setInParentIndex(2);
+ nonTerminalPage.add(pageB, key15, pageD);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key10,
+ key15 }, new long[] { pageAPositionInFile, pageCPositionInFile,
+ pageBPositionInFile, pageDPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 9 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+ assertEquals("bad key 16 index", 3,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(16)));
+
+ // A 5 C 10 B 15 D -> A 5 C 7 E 10 B 15 D
+ final MockNonTerminalPage pageE = new MockNonTerminalPage();
+ final long pageEPositionInFile = 5000;
+ pageE.setPositionInFile(pageEPositionInFile);
+ final DataRecordIdentifier key7 = new DataRecordIdentifier(7);
+ pageC.setInParentIndex(1);
+ nonTerminalPage.add(pageC, key7, pageE);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key7,
+ key10, key15 }, new long[] { pageAPositionInFile,
+ pageCPositionInFile, pageEPositionInFile, pageBPositionInFile,
+ pageDPositionInFile });
+ assertEquals("bad key 4 index", 0,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(4)));
+ assertEquals("bad key 6 index", 1,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(6)));
+ assertEquals("bad key 9 index", 2,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(9)));
+ assertEquals("bad key 11 index", 3,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(11)));
+ assertEquals("bad key 16 index", 4,
+ nonTerminalPage.getIndex(new DataRecordIdentifier(16)));
+
+ // A 5 C 7 E 10 B 15 D -> A 5 C 7 E 10 B 15 D 17 F
+ final MockNonTerminalPage pageF = new MockNonTerminalPage();
+ final long pageFPositionInFile = 6000;
+ pageF.setPositionInFile(pageFPositionInFile);
+ final DataRecordIdentifier key17 = new DataRecordIdentifier(17);
+ pageD.setInParentIndex(4);
+ nonTerminalPage.add(pageD, key17, pageF);
+ checkState(nonTerminalPage, new DataRecordIdentifier[] { key5, key7,
+ key10, key15, key17 }, new long[] { pageAPositionInFile,
+ pageCPositionInFile, pageEPositionInFile, pageBPositionInFile,
+ pageDPositionInFile, pageFPositionInFile });
+ assertE...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-25 07:14:41
|
Revision: 3030
http://joafip.svn.sourceforge.net/joafip/?rev=3030&view=rev
Author: luc_peuvrier
Date: 2012-04-25 04:28:28 +0000 (Wed, 25 Apr 2012)
Log Message:
-----------
WIP btree plus, tests in progress. NonTerminalPage tests ok
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/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-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/BtreePlusEntityTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/ILeafPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/INonTerminalPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-26 03:53:28
|
Revision: 3033
http://joafip.svn.sourceforge.net/joafip/?rev=3033&view=rev
Author: luc_peuvrier
Date: 2012-04-26 03:53:20 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
added mock for IheapElementManager and IFileStorable
and some corrections
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/DataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.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/PageConstant.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/mock/MockDataBlock.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecord.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapRecordFactory.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/TestHeapElementManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/BtreePlusEntityTests.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,7 @@
*/
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;
@@ -31,6 +32,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public abstract class AbstractElement implements IPageRecordable {
private IPageRecord pageRecord;
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,7 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.entity.DataRecordKey;
import net.sf.joafip.kvstore.entity.AbstractFileStorable;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
@@ -36,6 +37,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public abstract class AbstractPageRecord extends AbstractFileStorable {
public AbstractPageRecord(final IFileForStorable fileForStorable,
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -25,6 +25,7 @@
import java.util.Arrays;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.service.HeapException;
/**
@@ -32,6 +33,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class DataBlock implements IDataBlock {
private final DataBlockPage dataBlockPage;
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,7 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.service.HeapException;
/**
@@ -30,6 +31,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class DataBlockPage extends AbstractElement {
public static final int HEAD_SIZE =
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,11 +23,14 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.NotStorableClass;
+
/**
*
* @author luc peuvrier
*
*/
+@NotStorableClass
public enum EnumRecordType {
/**
*
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,7 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.service.HeapException;
/**
@@ -30,6 +31,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class FreePage extends AbstractElement {
private final long nextFreePage;
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -25,6 +25,7 @@
import java.util.Arrays;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IFileForStorable;
@@ -33,6 +34,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class HeaderPage extends AbstractPageRecord implements IPageRecordable {
private long fileSizeAsNumberOfPage = -1L;
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -25,6 +25,7 @@
import java.util.Arrays;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
@@ -33,6 +34,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class LeafPage extends AbstractElement implements ILeafPage {
private long[] dataBlockPosition;
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -25,6 +25,7 @@
import java.util.Arrays;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
@@ -33,6 +34,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class NonTerminalPage extends AbstractElement implements
INonTerminalPage {
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageConstant.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageConstant.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageConstant.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,11 +23,14 @@
*/
package net.sf.joafip.btreeplus.entity;
+import net.sf.joafip.NotStorableClass;
+
/**
*
* @author luc peuvrier
*
*/
+@NotStorableClass
public final class PageConstant {
public final static int PAGE_BITS = 12;
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,7 @@
*/
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;
import net.sf.joafip.kvstore.service.IFileForStorable;
@@ -32,6 +33,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class PageRecord extends AbstractPageRecord implements IPageRecord {
private EnumRecordType recordType;
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -28,6 +28,7 @@
import java.util.Set;
import net.sf.joafip.Fortest;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.EnumRecordType;
import net.sf.joafip.btreeplus.entity.IDataBlock;
import net.sf.joafip.btreeplus.entity.INonTerminalPage;
@@ -48,6 +49,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class BtreePlusDataManager extends AbstractHeapDataManager {
/**
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -24,6 +24,7 @@
package net.sf.joafip.btreeplus.service;
import net.sf.joafip.Fortest;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.DataBlockPage;
import net.sf.joafip.btreeplus.entity.HeaderPage;
import net.sf.joafip.btreeplus.entity.IDataBlock;
@@ -36,7 +37,6 @@
import net.sf.joafip.btreeplus.entity.PageRecord;
import net.sf.joafip.kvstore.entity.IFileStorable;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.HeapElementManager;
import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.record.service.IHeapRecordFactory;
@@ -49,6 +49,7 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
public class BtreePlusElementMgr implements IHeapRecordFactory {
private static final JoafipLogger LOGGER = JoafipLogger
@@ -116,7 +117,7 @@
@Override
public IFileStorable createHeapRecord(
- final HeapElementManager heapElementManager,
+ final IHeapElementManager heapElementManager,
final long positionInFile) throws HeapException {
assert (positionInFile & PageConstant.IN_PAGE_POSITION_MASK) == 0;
return new PageRecord(fileForStorable,
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity.mock;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.IDataBlock;
import net.sf.joafip.kvstore.service.HeapException;
@@ -31,6 +33,8 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
+@NoStorableAccess
public class MockDataBlock implements IDataBlock {
private long position;
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity.mock;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.EnumRecordType;
import net.sf.joafip.btreeplus.entity.ILeafPage;
import net.sf.joafip.btreeplus.entity.IPageRecord;
@@ -35,6 +37,8 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
+@NoStorableAccess
public class MockLeafPage implements ILeafPage {
private long positionInFile;
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity.mock;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.EnumRecordType;
import net.sf.joafip.btreeplus.entity.INonTerminalPage;
import net.sf.joafip.btreeplus.entity.IPageRecord;
@@ -35,6 +37,8 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
+@NoStorableAccess
public class MockNonTerminalPage implements INonTerminalPage {
private long positionInFile;
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecord.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecord.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecord.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -1,8 +1,12 @@
package net.sf.joafip.btreeplus.entity.mock;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.IPageRecord;
import net.sf.joafip.kvstore.service.HeapException;
+@NotStorableClass
+@NoStorableAccess
public class MockPageRecord implements IPageRecord {
private long positionInFile;
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -23,6 +23,8 @@
*/
package net.sf.joafip.btreeplus.entity.mock;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.EnumRecordType;
import net.sf.joafip.btreeplus.entity.IPageRecord;
import net.sf.joafip.btreeplus.entity.IPageRecordable;
@@ -33,6 +35,8 @@
* @author luc peuvrier
*
*/
+@NotStorableClass
+@NoStorableAccess
public class MockPageRecordable implements IPageRecordable {
@Override
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-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -33,7 +33,6 @@
import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.entity.IFileStorable;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.HeapElementManager;
import net.sf.joafip.kvstore.record.service.HeapElementManagerFactory;
import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
import net.sf.joafip.kvstore.record.service.IHeapElementManager;
@@ -602,7 +601,7 @@
@Override
public IFileStorable createHeapRecord(
- final HeapElementManager heapElementManager,
+ final IHeapElementManager heapElementManager,
final long positionInFile) throws HeapException {
return new HeapRecord(heapElementManager, positionInFile);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -29,6 +29,7 @@
import net.sf.joafip.kvstore.entity.IFileStorable;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.record.service.HeapElementManager;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.record.service.IHeapRecordFactory;
import net.sf.joafip.kvstore.service.FileForStorable;
import net.sf.joafip.kvstore.service.HeapException;
@@ -146,7 +147,7 @@
@Override
public IFileStorable createHeapRecord(
- final HeapElementManager heapElementManager,
+ final IHeapElementManager heapElementManager,
final long positionInFile) throws HeapException {
return new HeapRecord(heapElementManager, positionInFile);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -24,7 +24,7 @@
import net.sf.joafip.kvstore.entity.IFileStorable;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.record.service.AbstractTestHeapElementManager;
-import net.sf.joafip.kvstore.record.service.HeapElementManager;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.redblacktree.entity.IRBTNode;
import net.sf.joafip.redblacktree.service.RBTException;
@@ -443,7 +443,7 @@
@Override
public IFileStorable createHeapRecord(
- final HeapElementManager heapElementManager,
+ final IHeapElementManager heapElementManager,
final long positionInFile) throws HeapException {
return new HeapRecord(heapElementManager, positionInFile);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -195,7 +195,7 @@
@Override
public IFileStorable createHeapRecord(
- final HeapElementManager heapElementManager,
+ final IHeapElementManager heapElementManager,
final long positionInFile) throws HeapException {
return new HeapRecord(heapElementManager, positionInFile);
}
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -185,7 +185,7 @@
IHeapRecordFactory getHeapRecordFactory();
- void setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyComparator);
+ void setDataRecordKeyManager(IDataRecordKeyManager dataRecordKeyManager);
IDataRecordKeyManager getDataRecordKeyManager();
Modified: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapRecordFactory.java
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapRecordFactory.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapRecordFactory.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -33,6 +33,6 @@
*/
public interface IHeapRecordFactory {
- IFileStorable createHeapRecord(HeapElementManager heapElementManager,
+ IFileStorable createHeapRecord(IHeapElementManager heapElementManager,
long positionInFile) throws HeapException;
}
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/TestHeapElementManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/TestHeapElementManager.java 2012-04-26 02:39:10 UTC (rev 3032)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/TestHeapElementManager.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -252,7 +252,7 @@
@Override
public IFileStorable createHeapRecord(
- final HeapElementManager heapElementManager,
+ final IHeapElementManager heapElementManager,
final long positionInFile) throws HeapException {
return new RecordForTest(heapElementManager, positionInFile,
RECORD_SIZE, positionInFile - RECORD_SIZE);
Added: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java 2012-04-26 03:53:20 UTC (rev 3033)
@@ -0,0 +1,178 @@
+/*
+ * 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.kvstore.record.service.mock;
+
+import java.io.File;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.file.service.FileIOErrorException;
+import net.sf.joafip.file.service.FileIOException;
+import net.sf.joafip.kvstore.entity.ToBackupRecord;
+import net.sf.joafip.kvstore.service.FileForStorable;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IFileForStorable;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class MockFileForStorable implements IFileForStorable {
+
+ private final byte[] image;
+
+ private int size;
+
+ private boolean openned;
+
+ private long positionInFile;
+
+ public MockFileForStorable(final int maxSize) {
+ super();
+ image = new byte[maxSize];
+ size = 0;
+ }
+
+ @Override
+ public void open() throws HeapException {
+ assertClosed();
+ this.positionInFile = 0;
+ openned = true;
+ }
+
+ @Override
+ public void close() throws HeapException {
+ assertOpenned();
+ openned = false;
+ }
+
+ @Override
+ public File getFile() {
+ return new File("MOCK");
+ }
+
+ @Override
+ public void deleteFileIfExists() throws HeapException {
+ assertClosed();
+ size = 0;
+ }
+
+ @Override
+ public void deleteFileIfExistsRenaming() throws HeapException {
+ assertClosed();
+ size = 0;
+ }
+
+ @Override
+ public long getFileSize() throws HeapException {
+ return size;
+ }
+
+ @Override
+ public void flush() throws HeapException {
+ assertOpenned();
+ // no implementation
+ }
+
+ @Override
+ public void resetFileSize() throws HeapException {
+ assertOpenned();
+ size = 0;
+ }
+
+ @Override
+ public void seek(final long positionInFile) throws HeapException {
+ assertOpenned();
+ this.positionInFile = positionInFile;
+ }
+
+ @Override
+ public int read(final byte[] data) throws HeapException {
+ return read(data, 0, data.length);
+ }
+
+ @Override
+ public int read(final byte[] data, final int offset, final int length)
+ throws HeapException {
+ assertOpenned();
+ int index = offset;
+ int count = 0;
+ while (count < length && positionInFile < size) {
+ data[index++] = image[(int) positionInFile++];
+ }
+ return count;
+ }
+
+ @Override
+ public void write(final byte[] data) throws HeapException {
+ assertOpenned();
+ if (positionInFile + data.length > size) {
+ size = (int) (positionInFile + data.length);
+ if (size > image.length) {
+ throw new HeapException("out of image buffer");
+ }
+ }
+ for (int index = 0; index < data.length; index++) {
+ image[(int) positionInFile++] = data[index];
+ }
+ }
+
+ @Override
+ public void write(final ToBackupRecord toBackupRecord) throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public void copy(FileForStorable fileForStorable) throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public void copy(String fileName) throws FileIOException {
+ throw new FileIOErrorException("unsupported", new File("MOCK"), null);
+ }
+
+ @Override
+ public boolean isUseCache() {
+ return false;
+ }
+
+ @Override
+ public int getCachePageSize() {
+ return 0;
+ }
+
+ private void assertOpenned() throws HeapException {
+ if (!openned) {
+ throw new HeapException("is closed");
+ }
+ }
+
+ private void assertClosed() throws HeapException {
+ if (openned) {
+ throw new HeapException("is openned");
+ }
+ }
+}
Added: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joa...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-26 03:53:27
|
Revision: 3033
http://joafip.svn.sourceforge.net/joafip/?rev=3033&view=rev
Author: luc_peuvrier
Date: 2012-04-26 03:53:20 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
added mock for IheapElementManager and IFileStorable
and some corrections
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/DataBlock.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/EnumRecordType.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.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/PageConstant.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/mock/MockDataBlock.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockLeafPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockNonTerminalPage.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecord.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockPageRecordable.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/TestIdNode.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapElementManager.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/IHeapRecordFactory.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/TestHeapElementManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/entity/BtreePlusEntityTests.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-27 20:29:49
|
Revision: 3034
http://joafip.svn.sourceforge.net/joafip/?rev=3034&view=rev
Author: luc_peuvrier
Date: 2012-04-27 20:29:42 +0000 (Fri, 27 Apr 2012)
Log Message:
-----------
WIP btree plus, tests in progress. BtreePlusElementMgr test in development
Modified Paths:
--------------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.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-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusServiceTests.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-27 20:29:49
|
Revision: 3034
http://joafip.svn.sourceforge.net/joafip/?rev=3034&view=rev
Author: luc_peuvrier
Date: 2012-04-27 20:29:42 +0000 (Fri, 27 Apr 2012)
Log Message:
-----------
WIP btree plus, tests in progress. BtreePlusElementMgr test in development
Modified Paths:
--------------
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.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-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusServiceTests.java
Modified: trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java
===================================================================
--- trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -37,7 +37,7 @@
@NotStorableClass
public class HeaderPage extends AbstractPageRecord implements IPageRecordable {
- private long fileSizeAsNumberOfPage = -1L;
+ private long fileSizeAsNumberOfPage = 1L;
/** page number of first free page. -1 means no free page */
private long pageNumberOfFirstFreePage = -1L;
@@ -96,7 +96,7 @@
public void clear() {
super.clear();
- fileSizeAsNumberOfPage = -1L;
+ fileSizeAsNumberOfPage = 1L;
pageNumberOfFirstFreePage = -1L;
rootPagePosition = -1L;
freeDataBlocks = null;
@@ -144,7 +144,11 @@
@Override
protected void unmarshallImpl() throws HeapException {
- readFileToIoBuffer((int) PageConstant.PAGE_SIZE);
+ final int read = readFileToIoBuffer((int) PageConstant.PAGE_SIZE);
+ if (read != PageConstant.PAGE_SIZE) {
+ throw new HeapException("read " + read + " for "
+ + PageConstant.PAGE_SIZE + " expected");
+ }
final EnumRecordType recordType = readRecordType();
if (!EnumRecordType.HEADER_PAGE.equals(recordType)) {
throw new HeapException(EnumRecordType.HEADER_PAGE
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-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -67,6 +67,8 @@
public LeafPage(final int numberOfKeyEntries,
final long[] dataBlockPosition, final DataRecordIdentifier[] keys) {
super();
+ assert numberOfKeyEntries == dataBlockPosition.length
+ && numberOfKeyEntries == keys.length;
this.numberOfKeyEntries = numberOfKeyEntries;
this.dataBlockPosition = dataBlockPosition;
this.keys = keys;
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-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -68,6 +68,8 @@
public NonTerminalPage(final int numberOfKeyEntries,
final DataRecordIdentifier[] keys, final long[] pagePosition) {
super();
+ assert numberOfKeyEntries == keys.length
+ && numberOfKeyEntries + 1 == pagePosition.length;
this.numberOfKeyEntries = numberOfKeyEntries;
this.keys = keys;
this.pagePositions = pagePosition;
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-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -116,7 +116,11 @@
@Override
protected void unmarshallImpl() throws HeapException {
// one page is minimum size
- readFileToIoBuffer((int) PageConstant.PAGE_SIZE);
+ final int read = readFileToIoBuffer((int) PageConstant.PAGE_SIZE);
+ if (read != PageConstant.PAGE_SIZE) {
+ throw new HeapException("read " + read + " for "
+ + PageConstant.PAGE_SIZE + " expected");
+ }
recordType = readRecordType();
switch (recordType) {
case NON_TERMINAL_PAGE:
@@ -231,7 +235,12 @@
final DataBlockPage dataBlockPage = new DataBlockPage(bits);
dataBlockPage.setPageRecord(this);
final int numberOfPage = dataBlockPage.getNumberOfPage();
- readFileAppendToIoBuffer(numberOfPage * (int) PageConstant.PAGE_SIZE);
+ final int newSize = numberOfPage * (int) PageConstant.PAGE_SIZE;
+ final int totalReadSize = readFileAppendToIoBuffer(newSize);
+ if (totalReadSize != newSize) {
+ throw new HeapException("failed to get " + newSize
+ + ", total read size is " + totalReadSize);
+ }
final IDataBlock[] dataBlocks = dataBlockPage.getDataBlocks();
for (IDataBlock dataBlock : dataBlocks) {
readBytes(dataBlock.getDataHolder());
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-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -87,7 +87,7 @@
@Override
public void setDataRecordKeyComparator(
IDataRecordKeyManager dataRecordKeyComparator) throws HeapException {
- btreePlusElementMgr.setDataRecordKeyComparator(dataRecordKeyComparator);
+ btreePlusElementMgr.setDataRecordKeyManager(dataRecordKeyComparator);
}
@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-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -28,6 +28,7 @@
import net.sf.joafip.btreeplus.entity.DataBlockPage;
import net.sf.joafip.btreeplus.entity.HeaderPage;
import net.sf.joafip.btreeplus.entity.IDataBlock;
+import net.sf.joafip.btreeplus.entity.ILeafPage;
import net.sf.joafip.btreeplus.entity.INonTerminalPage;
import net.sf.joafip.btreeplus.entity.IPageRecord;
import net.sf.joafip.btreeplus.entity.IPageRecordable;
@@ -77,10 +78,10 @@
}
}
- public void setDataRecordKeyComparator(
- final IDataRecordKeyManager dataRecordKeyComparator)
+ public void setDataRecordKeyManager(
+ final IDataRecordKeyManager dataRecordKeyManager)
throws HeapException {
- heapElementManager.setDataRecordKeyManager(dataRecordKeyComparator);
+ heapElementManager.setDataRecordKeyManager(dataRecordKeyManager);
}
public void startService() throws HeapException {
@@ -158,7 +159,8 @@
@Fortest
public long getLastRecordPositionInFile() throws HeapException {
- throw new UnsupportedOperationException("not implemented");
+ return (header.getFileSizeAsNumberOfPage() - 1)
+ * PageConstant.PAGE_SIZE;
}
public long getNextFreeDataRecordIdentifier() {
@@ -193,9 +195,13 @@
public IPageRecordable getPage(final long position,
final IPageRecordable parentPage, final int index)
throws HeapException {
- final IPageRecordable readHeapFileDataRecord = (IPageRecordable) heapElementManager
+ final PageRecord pageRecord = (PageRecord) heapElementManager
.readHeapFileDataRecord(position);
+ final IPageRecordable readHeapFileDataRecord = pageRecord
+ .getPageRecordable();
readHeapFileDataRecord.setParentPage(parentPage, index);
+ // ASSERTX
+ assert notInternalyManagedPage(readHeapFileDataRecord);
return readHeapFileDataRecord;
}
@@ -234,6 +240,7 @@
leafPage.setDataBlock(0, dataBlock);
leafPage.setNext(-1L);
leafPage.updateByteSize();
+ leafPage.setValueIsChangedValueToSave();
header.setRootPagePosition(leafPage.getPositionInFile());
}
@@ -245,6 +252,7 @@
nonTerminalPage.setEntry(1, rightLeafPage.getPositionInFile(), null);
appendPageRecordable(nonTerminalPage);
nonTerminalPage.updateByteSize();
+ nonTerminalPage.setValueIsChangedValueToSave();
header.setRootPagePosition(nonTerminalPage.getPositionInFile());
}
@@ -259,6 +267,7 @@
null);
appendPageRecordable(nonTerminalPage);
nonTerminalPage.updateByteSize();
+ nonTerminalPage.setValueIsChangedValueToSave();
header.setRootPagePosition(nonTerminalPage.getPositionInFile());
}
@@ -291,13 +300,20 @@
header.setFreeDataBlockPosition(bits, position);
}
- public void appendPageRecordable(IPageRecordable pageRecordable)
+ public void appendPageRecordable(final IPageRecordable pageRecordable)
throws HeapException {
- long pageNumber = header.getFileSizeAsNumberOfPage() + 1;
- header.setFileSizeAsNumberOfPage(pageNumber);
+ // ASSERTX
+ assert notInternalyManagedPage(pageRecordable);
+ long pageNumber = header.getFileSizeAsNumberOfPage();
+ header.setFileSizeAsNumberOfPage(pageNumber + 1);
final IPageRecord pageRecord = new PageRecord(fileForStorable,
pageRecordable, pageNumber);
pageRecordable.setPageRecord(pageRecord);
heapElementManager.appendHeapFileRecord(pageRecord);
}
+
+ private boolean notInternalyManagedPage(final IPageRecordable pageRecordable) {
+ return pageRecordable instanceof ILeafPage
+ || pageRecordable instanceof NonTerminalPage;
+ }
}
Added: 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 (rev 0)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgrTest.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -0,0 +1,161 @@
+/*
+ * 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.service;
+
+import net.sf.joafip.AbstractJoafipCommonTestCase;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.btreeplus.entity.IPageRecord;
+import net.sf.joafip.btreeplus.entity.IPageRecordable;
+import net.sf.joafip.btreeplus.entity.LeafPage;
+import net.sf.joafip.btreeplus.entity.NonTerminalPage;
+import net.sf.joafip.btreeplus.entity.PageConstant;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.service.mock.MockHeapElementManager;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@NoStorableAccess
+public class BtreePlusElementMgrTest extends AbstractJoafipCommonTestCase {
+
+ private static final String BAD_LAST_RECORD_POSITION = "bad last record position";
+ private static final String BAD_RECORD_POSITION = "bad record position";
+ private static final String MUST_BE_STORED = "must be stored";
+ private static final String MUST_BE_NOT_STORED = "must be not stored";
+ private BtreePlusElementMgr btreePlusElementMgr;
+
+ public BtreePlusElementMgrTest() throws TestException {
+ super();
+ }
+
+ public BtreePlusElementMgrTest(final String name) throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ btreePlusElementMgr = new BtreePlusElementMgr(
+ new MockHeapElementManager((int) (10 * PageConstant.PAGE_SIZE)));
+ btreePlusElementMgr.startService();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ try {
+ btreePlusElementMgr.closeTransactionDiscardChange();
+ } catch (Exception exception) {
+ // ignore error
+ }
+ try {
+ btreePlusElementMgr.stopService();
+ } catch (Exception exception) {
+ // ignore error
+ }
+ btreePlusElementMgr = null;
+ super.tearDown();
+ }
+
+ public void testAppendPageRecordable() throws HeapException {
+ btreePlusElementMgr.openTransaction();
+ IPageRecordable pageRecordable = new LeafPage();
+ assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
+ btreePlusElementMgr.appendPageRecordable(pageRecordable);
+ pageRecordable.setValueIsChangedValueToSave();
+ IPageRecord pageRecord = pageRecordable.getPageRecord();
+ assertNotNull(MUST_BE_STORED, pageRecord);
+ assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
+ pageRecord.getPositionInFile());
+ assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
+ btreePlusElementMgr.getLastRecordPositionInFile());
+
+ pageRecordable = new NonTerminalPage();
+ assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
+ btreePlusElementMgr.appendPageRecordable(pageRecordable);
+ pageRecordable.setValueIsChangedValueToSave();
+ pageRecord = pageRecordable.getPageRecord();
+ assertNotNull(MUST_BE_STORED, pageRecord);
+ assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 2,
+ pageRecord.getPositionInFile());
+ assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 2,
+ btreePlusElementMgr.getLastRecordPositionInFile());
+ btreePlusElementMgr.closeTransaction();
+ assertEquals("", PageConstant.PAGE_SIZE * 3, btreePlusElementMgr
+ .getFileForStorable().getFileSize());
+
+ btreePlusElementMgr.openTransaction();
+ final int numberOfKeyEntries = 1;
+ final DataRecordIdentifier[] keys = new DataRecordIdentifier[] { new DataRecordIdentifier(
+ 0) };
+ final long[] pagePosition = new long[] { 0, 1 };
+ pageRecordable = new NonTerminalPage(numberOfKeyEntries, keys,
+ pagePosition);
+ assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
+ btreePlusElementMgr.appendPageRecordable(pageRecordable);
+ pageRecordable.setValueIsChangedValueToSave();
+ pageRecord = pageRecordable.getPageRecord();
+ assertNotNull(MUST_BE_STORED, pageRecord);
+ assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 3,
+ pageRecord.getPositionInFile());
+ assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 3,
+ btreePlusElementMgr.getLastRecordPositionInFile());
+ btreePlusElementMgr.closeTransaction();
+ assertEquals("", PageConstant.PAGE_SIZE * 4, btreePlusElementMgr
+ .getFileForStorable().getFileSize());
+
+ btreePlusElementMgr.openTransaction();
+ long position = PageConstant.PAGE_SIZE;
+ pageRecordable = btreePlusElementMgr.getPage(position, null, 0);
+ assertTrue("leaf page expected", pageRecordable instanceof LeafPage);
+ position += PageConstant.PAGE_SIZE;
+ pageRecordable = btreePlusElementMgr.getPage(position, null, 0);
+ assertTrue("non terminal page expected",
+ pageRecordable instanceof NonTerminalPage);
+ NonTerminalPage nonTerminalPage = (NonTerminalPage) pageRecordable;
+ assertEquals("bad non terminal page #1 state", 0,
+ nonTerminalPage.getNumberOfKeyEntries());
+ position += PageConstant.PAGE_SIZE;
+ pageRecordable = btreePlusElementMgr.getPage(position, null, 0);
+ assertTrue("non terminal page expected",
+ pageRecordable instanceof NonTerminalPage);
+ nonTerminalPage = (NonTerminalPage) pageRecordable;
+ assertEquals("bad non terminal page #2 state", 1,
+ nonTerminalPage.getNumberOfKeyEntries());
+ btreePlusElementMgr.closeTransactionDiscardChange();
+ }
+
+ public void testDataBlock() {
+
+ }
+
+ public void testDataRecordIdentifier() {
+
+ }
+}
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-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/entity/AbstractFileStorable.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -220,6 +220,11 @@
protected int readFileToIoBuffer(final int size) throws HeapException {
ioBuffer = new byte[size];
readInIoBuffer = fileForStorable.read(ioBuffer);
+ // bad test because must read when only maximum size is known
+ // if( readInIoBuffer!=size) {
+ // throw new
+ // HeapException("failed read "+size+" bytes, read "+readInIoBuffer);
+ // }
numberOfByteReadWrote = 0;
return readInIoBuffer;
}
@@ -229,16 +234,22 @@
*
* @param newSize
* ioBuffer new size
+ * @return
* @throws HeapException
*/
- protected void readFileAppendToIoBuffer(final int newSize)
+ protected int readFileAppendToIoBuffer(final int newSize)
throws HeapException {
+ final int totalRead;
if (newSize > ioBuffer.length) {
ioBuffer = Arrays.copyOf(ioBuffer, newSize);
final int appendSize = newSize - readInIoBuffer;
- fileForStorable.read(ioBuffer, readInIoBuffer/* offset */,
- appendSize/* length */);
+ final int read = fileForStorable.read(ioBuffer,
+ readInIoBuffer/* offset */, appendSize/* length */);
+ totalRead = readInIoBuffer + read;
+ } else {
+ totalRead = ioBuffer.length;
}
+ return totalRead;
}
/**
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java 2012-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockFileForStorable.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -120,7 +120,9 @@
int index = offset;
int count = 0;
while (count < length && positionInFile < size) {
- data[index++] = image[(int) positionInFile++];
+ final byte value = image[(int) positionInFile++];
+ data[index++] = value;
+ count++;
}
return count;
}
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java 2012-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/record/service/mock/MockHeapElementManager.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -70,6 +70,7 @@
if (started) {
throw new HeapException("already started");
}
+ fileForStorable.open();
started = true;
}
@@ -86,6 +87,7 @@
throw new HeapException("already stopped");
}
started = false;
+ fileForStorable.close();
}
@Override
@@ -98,10 +100,19 @@
if (transactionOpen) {
throw new HeapException("transaction already openned");
}
- if (heapHeader != null) {
- heapHeader.clear();
+ cache.clear();
+ final long fileSize = getFileSize();
+ heapHeader.clear();
+ if (fileSize == 0) {
+ /* to save new header */
+ heapHeader.setValueIsChangedValueToSave();
+ heapHeader.writeToFile();
+ fileForStorable.flush();
+ fileForStorable.close();
+ fileForStorable.open();
+ } else {
+ heapHeader.readFromFile();
}
- cache.clear();
transactionOpen = true;
}
@@ -178,7 +189,6 @@
@Override
public void setHeapHeader(final IFileStorable heapHeader)
throws HeapException {
- assertTransactionOpenned();
this.heapHeader = heapHeader;
}
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java 2012-04-26 03:53:20 UTC (rev 3033)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/BtreePlusTests.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -27,6 +27,7 @@
import junit.framework.TestSuite;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.btreeplus.entity.BtreePlusEntityTests;
+import net.sf.joafip.btreeplus.service.BtreePlusServiceTests;
/**
*
@@ -44,6 +45,7 @@
final TestSuite suite = new TestSuite("Test for btree plus");
// $JUnit-BEGIN$
suite.addTest(BtreePlusEntityTests.suite());
+ suite.addTest(BtreePlusServiceTests.suite());
// $JUnit-END$
return suite;
}
Added: trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusServiceTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusServiceTests.java (rev 0)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusServiceTests.java 2012-04-27 20:29:42 UTC (rev 3034)
@@ -0,0 +1,50 @@
+/*
+ * 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.service;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.sf.joafip.NotStorableClass;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class BtreePlusServiceTests {
+
+ public static void main(final String[] args) {
+ //
+ }
+
+ public static Test suite() {
+ final TestSuite suite = new TestSuite("Test for btree plus service");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(BtreePlusElementMgrTest.class);
+ // $JUnit-END$
+ return suite;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 16:47:34
|
Revision: 3043
http://joafip.svn.sourceforge.net/joafip/?rev=3043&view=rev
Author: luc_peuvrier
Date: 2012-04-29 16:47:27 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestObjectReferenceLink.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStore.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreForPersistenteClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreWithBob.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.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/SearcherBKM.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
Added Paths:
-----------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/entity/
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/entity/BlockDataManagerHeader.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/entity/DataBlock.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerRecord.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.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/AbstractTestHeapDataManagerRecord.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/FileDataManagerIntegrityChecker.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 16:51:45
|
Revision: 3044
http://joafip.svn.sourceforge.net/joafip/?rev=3044&view=rev
Author: luc_peuvrier
Date: 2012-04-29 16:51:38 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerImpl.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 16:58:20
|
Revision: 3045
http://joafip.svn.sourceforge.net/joafip/?rev=3045&view=rev
Author: luc_peuvrier
Date: 2012-04-29 16:58:13 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerMultiFile.java
trunk/joafip/src/test/java/net/sf/joafip/service/bug/savenum/TestEnumPersistenceMemory.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestSubstitutionWithMethodInterception.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel300/TestExclusiveDataAccessSession.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageForegroundMemory.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageInBackground.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestLinkManagementInMemory.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestNoGarbageInMemory.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestObjectReferenceLinkInMemory.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryDirect.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryLazy.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreVisitedModified.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryDirect.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryLazy.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/TestPersistableCodeGeneratorInStore.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestLinkManager.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestStoreGarbager.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/AbstractTestIoManager.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyFieldReflect.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/FileForStorableBridge.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
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileForStorableBridge.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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 20:05:50
|
Revision: 3046
http://joafip.svn.sourceforge.net/joafip/?rev=3046&view=rev
Author: luc_peuvrier
Date: 2012-04-29 20:05:43 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/KeyValueStoreTests.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/TestBlockDataManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/service/KeyValueStoreServiceTests.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 20:05:50
|
Revision: 3046
http://joafip.svn.sourceforge.net/joafip/?rev=3046&view=rev
Author: luc_peuvrier
Date: 2012-04-29 20:05:43 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/KeyValueStoreTests.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/TestBlockDataManager.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/service/KeyValueStoreServiceTests.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -1,70 +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.heapfile.service;
-
-import net.sf.joafip.DoNotTransform;
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.TestException;
-import net.sf.joafip.kvstore.entity.HeapFileSetup;
-import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerImpl;
-import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.IHeapDataManager;
-
-@NotStorableClass
-@DoNotTransform
-public class TestBlockDataManager extends AbstractTestHeapDataManagerImpl {// NOPMD
-
- public TestBlockDataManager() throws TestException {
- super();
- }
-
- public TestBlockDataManager(final String name) throws TestException {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {// NOPMD
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {// NOPMD
- super.tearDown();
- }
-
- @Override
- protected IHeapDataManager createHeapDataManager(final HeapFileSetup setup)
- throws HeapException {
- return new HeapFileDataManager(setup, false);
- }
-
- @Override
- protected void createHeap(final boolean removeFile) throws HeapException {
- createBlockDataManager(removeFile);
- }
-
- @Override
- protected void checkIntegrity() throws HeapException {
- HeapFileDataManagerIntegrityChecker.getInstance().checkIntegrity(
- heapDataManager);
- }
-
- @Override
- protected boolean manageFreeRecord() {
- return false;
- }
-}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -54,7 +54,7 @@
@Override
protected void createHeap(final boolean removeFile) throws HeapException {
- createHeapFileDataManager(removeFile);
+ createFileHeapDataManager(removeFile);
}
@Override
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -55,7 +55,7 @@
@Override
protected void createHeap(final boolean removeFile) throws HeapException {
- createHeapFileDataManager(removeFile);
+ createFileHeapDataManager(removeFile);
}
@Override
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -47,7 +47,7 @@
@Override
protected void createHeap(final boolean removeFile) throws HeapException {
- createHeapFileDataManager(removeFile);
+ createFileHeapDataManager(removeFile);
}
@Override
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -42,7 +42,7 @@
@Override
protected void createHeap(final boolean removeFile) throws HeapException {
- createHeapFileDataManager(removeFile);
+ createFileHeapDataManager(removeFile);
}
@Override
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -69,7 +69,7 @@
public void testUseAsAMap() throws HeapException {
final DataRecordKeyManager keyManager = DataRecordKeyManager
.getInstance();
- createHeapFileDataManager(true);
+ createFileHeapDataManager(true);
heapDataManager.setDataRecordKeyComparator(keyManager);
final DataRecordIdentifier keyA = keyManager.createKey("A");
assertFalse("must not found 'A'", heapDataManager.hasDataRecord(keyA));
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -64,7 +64,7 @@
@Override
protected void createHeap(final boolean removeFile) throws HeapException {
- createHeapFileDataManager(removeFile);
+ createFileHeapDataManager(removeFile);
}
@Override
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -118,7 +118,7 @@
* @throws HeapException
*
*/
- protected void createHeapFileDataManager(final boolean removeFile)
+ protected void createFileHeapDataManager(final boolean removeFile)
throws HeapException {
final HeapFileSetup setup = new HeapFileSetup(dataFile,
true/* crashSafeMode */, false/* useCacheMode */,
@@ -134,12 +134,6 @@
protected abstract IHeapDataManager createHeapDataManager(
HeapFileSetup setup) throws HeapException;
- protected void createBlockDataManager(final boolean removeFile)
- throws HeapException {
- heapDataManager = new BlockDataManager(dataFilePath, 20000);
- heapDataManager.startService(removeFile);
- }
-
protected abstract void createHeap(final boolean removeFile)
throws HeapException;
Copied: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/TestBlockDataManager.java (from rev 3045, trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java)
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/TestBlockDataManager.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/TestBlockDataManager.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -0,0 +1,69 @@
+/*
+ * 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.kvstore.service;
+
+import net.sf.joafip.DoNotTransform;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+
+@NotStorableClass
+@DoNotTransform
+public class TestBlockDataManager extends AbstractTestHeapDataManagerImpl {// NOPMD
+
+ public TestBlockDataManager() throws TestException {
+ super();
+ }
+
+ public TestBlockDataManager(final String name) throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {// NOPMD
+ super.setUp();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {// NOPMD
+ super.tearDown();
+ }
+
+ @Override
+ protected IHeapDataManager createHeapDataManager(final HeapFileSetup setup)
+ throws HeapException {
+ // return new HeapFileDataManager(setup, false);
+ throw new HeapException("not implemented");
+ }
+
+ @Override
+ protected void createHeap(final boolean removeFile) throws HeapException {
+ heapDataManager = new BlockDataManager(dataFilePath, 20000);
+ heapDataManager.startService(removeFile);
+ }
+
+ @Override
+ protected void checkIntegrity() throws HeapException {
+ // HeapFileDataManagerIntegrityChecker.getInstance().checkIntegrity(
+ // heapDataManager);
+ }
+
+ @Override
+ protected boolean manageFreeRecord() {
+ return false;
+ }
+}
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -35,7 +35,6 @@
suite.addTestSuite(TestHeapFileDataManagerFreeing.class);
suite.addTestSuite(TestHeapFileDataManagerBackup.class);
suite.addTestSuite(TestHeapFileDataMgrWithScenario.class);
- suite.addTestSuite(TestBlockDataManager.class);
suite.addTestSuite(TestHeapFileDataMgrWithKey.class);
// $JUnit-END$
return suite;
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/KeyValueStoreTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/KeyValueStoreTests.java 2012-04-29 16:58:13 UTC (rev 3045)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/KeyValueStoreTests.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -20,6 +20,7 @@
import junit.framework.TestSuite;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.KVRecordTests;
+import net.sf.joafip.kvstore.service.KeyValueStoreServiceTests;
@NotStorableClass
public class KeyValueStoreTests {
@@ -32,6 +33,7 @@
final TestSuite suite = new TestSuite("Test for key value store");
// $JUnit-BEGIN$
suite.addTest(KVRecordTests.suite());
+ suite.addTest(KeyValueStoreServiceTests.suite());
// suite.addTest(HeapFileServiceTests.suite());
// $JUnit-END$
return suite;
Added: trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/service/KeyValueStoreServiceTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/service/KeyValueStoreServiceTests.java (rev 0)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/service/KeyValueStoreServiceTests.java 2012-04-29 20:05:43 UTC (rev 3046)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2007 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.kvstore.service;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.sf.joafip.NotStorableClass;
+
+@NotStorableClass
+public class KeyValueStoreServiceTests {
+
+ public static void main(final String[] args) {
+ //
+ }
+
+ public static Test suite() {
+ final TestSuite suite = new TestSuite(
+ "Test for key value store service");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(TestBlockDataManager.class);
+ // suite.addTest(HeapFileServiceTests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 20:17:00
|
Revision: 3047
http://joafip.svn.sourceforge.net/joafip/?rev=3047&view=rev
Author: luc_peuvrier
Date: 2012-04-29 20:16:53 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
Added Paths:
-----------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/HeapFileStateHelper.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerBackup.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileState.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 20:17:00
|
Revision: 3047
http://joafip.svn.sourceforge.net/joafip/?rev=3047&view=rev
Author: luc_peuvrier
Date: 2012-04-29 20:16:53 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
Added Paths:
-----------
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/HeapFileStateHelper.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerBackup.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileState.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2012-04-29 20:05:43 UTC (rev 3046)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2012-04-29 20:16:53 UTC (rev 3047)
@@ -37,10 +37,10 @@
import net.sf.joafip.entity.FilePersistenceProperties;
import net.sf.joafip.entity.FilePersistencePropertyEntry;
import net.sf.joafip.file.service.FileIOException;
-import net.sf.joafip.heapfile.service.HeapFileState;
import net.sf.joafip.java.util.PTreeMap;
import net.sf.joafip.kvstore.entity.EnumFileState;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapFileStateHelper;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.reflect.ExceptionOfTarget;
@@ -1674,7 +1674,7 @@
* @return file state for exception
*/
static public EnumFileState fileState(final Exception exception) {
- return HeapFileState.fileState(exception);
+ return HeapFileStateHelper.fileState(exception);
}
static public FileIOException fileIOException(final Exception exception) {
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-04-29 20:05:43 UTC (rev 3046)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractDataManagerTestCase.java 2012-04-29 20:16:53 UTC (rev 3047)
@@ -24,10 +24,10 @@
import net.sf.joafip.TestConstant;
import net.sf.joafip.TestException;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
-import net.sf.joafip.heapfile.service.HeapFileState;
import net.sf.joafip.kvstore.entity.EnumFileState;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.HeapFileStateHelper;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@NotStorableClass
@@ -71,7 +71,7 @@
if (dataManager == null) {
logger.debug("file state unknow");
} else {
- final EnumFileState fileState = HeapFileState
+ final EnumFileState fileState = HeapFileStateHelper
.fileState(exception);
switch (fileState) {
case STATE_OK:
Deleted: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileState.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileState.java 2012-04-29 20:05:43 UTC (rev 3046)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileState.java 2012-04-29 20:16:53 UTC (rev 3047)
@@ -1,54 +0,0 @@
-/*
- * Copyright 2007 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.heapfile.service;// NOPMD only static but not a singleton
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.file.service.FileIOException;
-import net.sf.joafip.kvstore.entity.EnumFileState;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- * helper to have file state from exception
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public class HeapFileState {// NOPMD no constructor
-
- /**
- * to have the file state give by exception or its primary cause
- *
- * @param exception
- * exception
- * @return file state for exception
- */
- static public EnumFileState fileState(final Exception exception) {
- Throwable throwable = exception;
- EnumFileState fileState = null;
- boolean fileIoError = false;
- while (throwable != null) {
- if (throwable.getClass() == HeapException.class) {
- fileState = ((HeapException) throwable).getFileState();
- }
- fileIoError |= throwable instanceof FileIOException;
- throwable = throwable.getCause();
- }
- return fileState == null ? (fileIoError ? EnumFileState.STATE_IO_ERROR
- : EnumFileState.STATE_OK) : fileState;
- }
-}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java 2012-04-29 20:05:43 UTC (rev 3046)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java 2012-04-29 20:16:53 UTC (rev 3047)
@@ -16,28 +16,19 @@
*/
package net.sf.joafip.heapfile.service;
-import java.io.File;
-
import net.sf.joafip.DoNotTransform;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
-import net.sf.joafip.file.service.FileIOException;
-import net.sf.joafip.file.service.HelperFileUtil;
-import net.sf.joafip.kvstore.entity.EnumFileState;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerRecord;
+import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerBackup;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@NotStorableClass
@DoNotTransform
public class TestHeapFileDataManagerBackup extends
- AbstractTestHeapDataManagerRecord {
+ AbstractTestHeapDataManagerBackup {
- private static final HelperFileUtil helperFileUtil = HelperFileUtil // NOPMD
- .getInstance();
-
public TestHeapFileDataManagerBackup() throws TestException {
super();
}
@@ -68,123 +59,4 @@
HeapFileDataManagerIntegrityChecker.getInstance().checkIntegrity(
heapDataManager);
}
-
- /**
- * check if backup content is good
- *
- * @throws HeapException
- * @throws FileIOException
- * @throws FileStateUnstableException
- * @throws FileStateRestoredException
- *
- */
- public void testBackupGoodBackup() throws HeapException, FileIOException {
-
- createHeap(true);
-
- addContent();
-
- final boolean diff = helperFileUtil.diffFile(dataFile, backupFile);
- assertFalse("data file and backup file must have the same content",
- diff);
- swapDataAndBackup();
-
- checkContent();
- }
-
- /**
- * test restoration when backup file unstable
- *
- * @throws HeapException
- * @throws FileIOException
- * @throws FileStateUnstableException
- * @throws FileStateRestoredException
- */
- public void testBackupRestoreBackup() throws HeapException, FileIOException {
-
- createHeap(true);
- addContent();
- new File(globalFlagFilePath).delete();
- new File(backupFlagFilePath).delete();
- assertReconstruct(false);
- // heap not opened
- // closeHeap();
- logger.info("backup should be reconstruct");
- /*
- * swap data file and backup file to check backup is a good copy
- */
- swapDataAndBackup();
- checkContent();
- }
-
- /**
- * test restoration when data file unstable
- *
- * @throws HeapException
- * @throws FileStateRestoredException
- * @throws FileStateUnstableException
- */
- public void testBackupRestoreData() throws HeapException {
-
- createHeap(true);
- addContent();
- new File(globalFlagFilePath).delete();
- new File(dataFlafFilePath).delete();
- assertReconstruct(true);
- checkContent();
- }
-
- /**
- * @throws HeapException
- * @throws FileStateUnstableException
- */
- private void assertReconstruct(final boolean dataLost) throws HeapException {
- try {
- createHeap(false/* remove file */);
- fail("must throw FileStateRestoredException");
- } catch (HeapException exception) {
- assertEquals("not expected data lost status: ",
- dataLost ? EnumFileState.STATE_RESTORED_DATA_LOST
- : EnumFileState.STATE_RESTORED_NO_DATA_LOST,
- HeapFileState.fileState(exception));
- }
- }
-
- /**
- * @throws HeapException
- * @throws FileIOException
- */
- private void swapDataAndBackup() throws HeapException, FileIOException {
- helperFileUtil.copyFile(dataFile, tempFile);
- helperFileUtil.copyFile(backupFile, dataFile);
- helperFileUtil.copyFile(tempFile, backupFile);
- }
-
- /**
- * @throws HeapException
- * @throws FileStateUnstableException
- * @throws FileStateRestoredException
- *
- */
- private void checkContent() throws HeapException {
- createHeap(false/* remove file */);
- checkIntegrity();
- DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- checkDataRecord(50, identifier);
- identifier = new DataRecordIdentifier(1);
- checkDataRecord(100, identifier);
- identifier = new DataRecordIdentifier(2);
- checkDataRecord(500, identifier);
- }
-
- /**
- * @throws HeapException
- *
- */
- private void addContent() throws HeapException {
- createRecord(50, 0);
- createRecord(100, 1);
- createRecord(500, 2);
- closeHeap();
- }
}
Copied: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/HeapFileStateHelper.java (from rev 3046, trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileState.java)
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/HeapFileStateHelper.java (rev 0)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/service/HeapFileStateHelper.java 2012-04-29 20:16:53 UTC (rev 3047)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007 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.kvstore.service;// NOPMD only static but not a singleton
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.file.service.FileIOException;
+import net.sf.joafip.kvstore.entity.EnumFileState;
+
+/**
+ * helper to have file state from exception
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class HeapFileStateHelper {// NOPMD no constructor
+
+ /**
+ * to have the file state give by exception or its primary cause
+ *
+ * @param exception
+ * exception
+ * @return file state for exception
+ */
+ static public EnumFileState fileState(final Exception exception) {
+ Throwable throwable = exception;
+ EnumFileState fileState = null;
+ boolean fileIoError = false;
+ while (throwable != null) {
+ if (throwable.getClass() == HeapException.class) {
+ fileState = ((HeapException) throwable).getFileState();
+ }
+ fileIoError |= throwable instanceof FileIOException;
+ throwable = throwable.getCause();
+ }
+ return fileState == null ? (fileIoError ? EnumFileState.STATE_IO_ERROR
+ : EnumFileState.STATE_OK) : fileState;
+ }
+}
Added: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerBackup.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerBackup.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerBackup.java 2012-04-29 20:16:53 UTC (rev 3047)
@@ -0,0 +1,174 @@
+/*
+ * 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.kvstore.service;
+
+import java.io.File;
+
+import net.sf.joafip.TestException;
+import net.sf.joafip.file.service.FileIOException;
+import net.sf.joafip.file.service.HelperFileUtil;
+import net.sf.joafip.kvstore.service.HeapFileStateHelper;
+import net.sf.joafip.kvstore.entity.EnumFileState;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public abstract class AbstractTestHeapDataManagerBackup extends
+ AbstractTestHeapDataManagerRecord {
+
+ private static final HelperFileUtil helperFileUtil = HelperFileUtil // NOPMD
+ .getInstance();
+
+ public AbstractTestHeapDataManagerBackup() throws TestException {
+ super();
+ }
+
+ public AbstractTestHeapDataManagerBackup(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ /**
+ * check if backup content is good
+ *
+ * @throws HeapException
+ * @throws FileIOException
+ * @throws FileStateUnstableException
+ * @throws FileStateRestoredException
+ *
+ */
+ public void testBackupGoodBackup() throws HeapException, FileIOException {
+
+ createHeap(true);
+
+ addContent();
+
+ final boolean diff = helperFileUtil.diffFile(dataFile, backupFile);
+ assertFalse("data file and backup file must have the same content",
+ diff);
+ swapDataAndBackup();
+
+ checkContent();
+ }
+
+ /**
+ * test restoration when backup file unstable
+ *
+ * @throws HeapException
+ * @throws FileIOException
+ * @throws FileStateUnstableException
+ * @throws FileStateRestoredException
+ */
+ public void testBackupRestoreBackup() throws HeapException, FileIOException {
+
+ createHeap(true);
+ addContent();
+ new File(globalFlagFilePath).delete();
+ new File(backupFlagFilePath).delete();
+ assertReconstruct(false);
+ // heap not opened
+ // closeHeap();
+ logger.info("backup should be reconstruct");
+ /*
+ * swap data file and backup file to check backup is a good copy
+ */
+ swapDataAndBackup();
+ checkContent();
+ }
+
+ /**
+ * test restoration when data file unstable
+ *
+ * @throws HeapException
+ * @throws FileStateRestoredException
+ * @throws FileStateUnstableException
+ */
+ public void testBackupRestoreData() throws HeapException {
+
+ createHeap(true);
+ addContent();
+ new File(globalFlagFilePath).delete();
+ new File(dataFlafFilePath).delete();
+ assertReconstruct(true);
+ checkContent();
+ }
+
+ /**
+ * @throws HeapException
+ * @throws FileStateUnstableException
+ */
+ private void assertReconstruct(final boolean dataLost) throws HeapException {
+ try {
+ createHeap(false/* remove file */);
+ fail("must throw FileStateRestoredException");
+ } catch (HeapException exception) {
+ assertEquals("not expected data lost status: ",
+ dataLost ? EnumFileState.STATE_RESTORED_DATA_LOST
+ : EnumFileState.STATE_RESTORED_NO_DATA_LOST,
+ HeapFileStateHelper.fileState(exception));
+ }
+ }
+
+ /**
+ * @throws HeapException
+ * @throws FileIOException
+ */
+ private void swapDataAndBackup() throws HeapException, FileIOException {
+ helperFileUtil.copyFile(dataFile, tempFile);
+ helperFileUtil.copyFile(backupFile, dataFile);
+ helperFileUtil.copyFile(tempFile, backupFile);
+ }
+
+ /**
+ * @throws HeapException
+ * @throws FileStateUnstableException
+ * @throws FileStateRestoredException
+ *
+ */
+ private void checkContent() throws HeapException {
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ checkDataRecord(50, identifier);
+ identifier = new DataRecordIdentifier(1);
+ checkDataRecord(100, identifier);
+ identifier = new DataRecordIdentifier(2);
+ checkDataRecord(500, identifier);
+ }
+
+ /**
+ * @throws HeapException
+ *
+ */
+ private void addContent() throws HeapException {
+ createRecord(50, 0);
+ createRecord(100, 1);
+ createRecord(500, 2);
+ closeHeap();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 21:13:11
|
Revision: 3048
http://joafip.svn.sourceforge.net/joafip/?rev=3048&view=rev
Author: luc_peuvrier
Date: 2012-04-29 21:13:04 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore. tests added for btree++, these tests failed
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerBackup.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMap.java
trunk/joafip-pmap/src/main/java/net/sf/joafip/pmap/FileTreeMapKeyMgr.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistenceLongTestsOnly.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusServiceTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/service/KeyValueStoreServiceTests.java
Added Paths:
-----------
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataManagerBackup.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrMemoryLeak.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithKey.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithScenario.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/AbstractDataRecordKeyComparator.java
trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/DataRecordKeyManager.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/AbstractTestDataMgrMemoryLeak.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/scenario1.txt
trunk/joafip-testsuite/src/main/java/net/sf/joafip/kvstore/KeyValueStoreLongTests.java
Removed Paths:
-------------
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/test/java/net/sf/joafip/heapfile/service/scenario1.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 16:47:36
|
Revision: 3043
http://joafip.svn.sourceforge.net/joafip/?rev=3043&view=rev
Author: luc_peuvrier
Date: 2012-04-29 16:47:27 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestObjectReferenceLink.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStore.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreForPersistenteClass.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreWithBob.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.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/SearcherBKM.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
Added Paths:
-----------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/entity/
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/entity/BlockDataManagerHeader.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/entity/DataBlock.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManager.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerRecord.java
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/BlockDataManager.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.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/AbstractTestHeapDataManagerRecord.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/FileDataManagerIntegrityChecker.java
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestObjectReferenceLink.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestObjectReferenceLink.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestObjectReferenceLink.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -24,7 +24,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.FileDataManagerIntegrityChecker;
+import net.sf.joafip.heapfile.service.HeapFileDataManagerIntegrityChecker;
import net.sf.joafip.java.util.PTreeMap;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
@@ -59,8 +59,8 @@
private static final String BOB1_MUST_HAVE_DATA_RECORD_IDENTIFIER = "bob1 must have data record identifier";
- private static final FileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
- /**/FileDataManagerIntegrityChecker.getInstance();
+ private static final HeapFileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
+ /**/HeapFileDataManagerIntegrityChecker.getInstance();
protected StoreForTest store;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStore.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStore.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStore.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -26,7 +26,7 @@
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
import net.sf.joafip.entity.MutableInteger;
-import net.sf.joafip.heapfile.service.FileDataManagerIntegrityChecker;
+import net.sf.joafip.heapfile.service.HeapFileDataManagerIntegrityChecker;
import net.sf.joafip.java.util.PLinkedList;
import net.sf.joafip.java.util.PTreeMap;
import net.sf.joafip.kvstore.service.HeapException;
@@ -56,8 +56,8 @@
private static final String MUST_HAVE_ROOT = "must have root";
- private final static FileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
- /**/FileDataManagerIntegrityChecker.getInstance();
+ private final static HeapFileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
+ /**/HeapFileDataManagerIntegrityChecker.getInstance();
protected StoreForTest store;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreForPersistenteClass.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreForPersistenteClass.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreForPersistenteClass.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -25,7 +25,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.FileDataManagerIntegrityChecker;
+import net.sf.joafip.heapfile.service.HeapFileDataManagerIntegrityChecker;
import net.sf.joafip.java.util.PLinkedHashMap;
import net.sf.joafip.java.util.PLinkedList;
import net.sf.joafip.java.util.PPriorityQueue;
@@ -54,8 +54,8 @@
private static final String ADDING = "adding ";
- private final static FileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
- /**/FileDataManagerIntegrityChecker.getInstance();
+ private final static HeapFileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
+ /**/HeapFileDataManagerIntegrityChecker.getInstance();
protected StoreForTest store;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreWithBob.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreWithBob.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestStoreWithBob.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -20,7 +20,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.FileDataManagerIntegrityChecker;
+import net.sf.joafip.heapfile.service.HeapFileDataManagerIntegrityChecker;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@@ -49,8 +49,8 @@
private static final String MUST_FIND_OBJECT = "must find object";
- private final static FileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
- /**/FileDataManagerIntegrityChecker.getInstance();
+ private final static HeapFileDataManagerIntegrityChecker DATA_MANAGER_INTEGRITY_CHECKER =
+ /**/HeapFileDataManagerIntegrityChecker.getInstance();
protected StoreForTest store;
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -2,7 +2,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
-import net.sf.joafip.heapfile.service.BlockDataManager;
+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.redblacktree.service.RBTException;
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-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -5,10 +5,10 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.BlockDataManager;
import net.sf.joafip.heapfile.service.DualWrapDataManager;
import net.sf.joafip.heapfile.service.HeapFileDataManager;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
+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.redblacktree.service.RBTException;
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -22,7 +22,7 @@
*/
package net.sf.joafip.performance.items.service;
-import net.sf.joafip.heapfile.service.BlockDataManager;
+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;
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-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -20,7 +20,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
-import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.kvstore.service.BlockDataManager;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
Modified: 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/SearcherBKM.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -18,7 +18,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
-import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.kvstore.service.BlockDataManager;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -1,151 +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.
- */
-package net.sf.joafip.heapfile.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-import net.sf.joafip.DoNotTransform;
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-@DoNotTransform
-public class BlockDataManagerHeader implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 8579792598621073099L;
-
- private int blockLength;
-
- private DataRecordIdentifier nextIdentifier;
-
- private long dataLength;
-
- private int numberOfDataRecord;
-
- public int getBlockLength() {
- return blockLength;
- }
-
- public void setBlockLength(final int blockLength) {
- this.blockLength = blockLength;
- }
-
- public DataRecordIdentifier getNextIdentifier() {
- return nextIdentifier;
- }
-
- public void setNextIdentifier(final DataRecordIdentifier nextIdentifier) {
- this.nextIdentifier = nextIdentifier;
- }
-
- public long getDataLength() {
- return dataLength;
- }
-
- public void setDataLength(final long dataLength) {
- this.dataLength = dataLength;
- }
-
- public int getNumberOfDataRecord() {
- return numberOfDataRecord;
- }
-
- public void setNumberOfDataRecord(final int numberOfDataRecord) {
- this.numberOfDataRecord = numberOfDataRecord;
- }
-
- public void decrementNumberOfDataRecord() {
- numberOfDataRecord--;
- }
-
- public void incrementNumberOfDataRecord() {
- numberOfDataRecord++;
- }
-
- public void set(final byte[] data) throws HeapException {
- try {
- final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- data);
- final ObjectInputStream objectInputStream = new ObjectInputStream(
- byteArrayInputStream);
- final BlockDataManagerHeader header = (BlockDataManagerHeader) objectInputStream
- .readObject();
- objectInputStream.close();
- set(header);
- } catch (IOException exception) {
- throw new HeapException(exception);
- } catch (ClassNotFoundException exception) {
- throw new HeapException(exception);
- }
- }
-
- private void set(final BlockDataManagerHeader header) {
- this.dataLength = header.dataLength;
- this.nextIdentifier = header.nextIdentifier;
- this.blockLength = header.blockLength;
- this.numberOfDataRecord = header.numberOfDataRecord;
- }
-
- public byte[] get() throws HeapException {
- try {
- final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
- byteArrayOutputStream);
- objectOutputStream.writeObject(this);
- objectOutputStream.close();
- return byteArrayOutputStream.toByteArray();
- } catch (IOException exception) {
- throw new HeapException(exception);
- }
- }
-
- private void writeObject(final ObjectOutputStream out) throws IOException {
- out.writeInt(blockLength);
- out.writeLong(dataLength);
- out.writeLong(nextIdentifier.value);
- out.writeInt(numberOfDataRecord);
- }
-
- private void readObject(final ObjectInputStream input) throws IOException,
- ClassNotFoundException {
- blockLength = input.readInt();
- dataLength = input.readLong();
- final long value = input.readLong();
- nextIdentifier = new DataRecordIdentifier(value);
- numberOfDataRecord = input.readInt();
- }
-}
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -1,61 +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.
- */
-package net.sf.joafip.heapfile.entity;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class DataBlock {
-
- private final long positionInFile;
-
- private boolean toWrite;
-
- private final byte[] data;
-
- public DataBlock(final long positionInFile, final boolean toWrite,
- final byte[] data) { // NOPMD
- super();
- this.positionInFile = positionInFile;
- this.toWrite = toWrite;
- this.data = data;
- }
-
- public boolean isToWrite() {
- return toWrite;
- }
-
- public void setToWrite(final boolean toWrite) {
- this.toWrite = toWrite;
- }
-
- public long getPositionInFile() {
- return positionInFile;
- }
-
- public byte[] getData() {
- return data; // NOPMD
- }
-}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -44,8 +44,8 @@
*/
@NotStorableClass
@DoNotTransform
-public class TestHeapRecordStoreRestore extends AbstractCommonDeleteFileTestCase
- implements // NOPMD
+public class TestHeapRecordStoreRestore extends
+ AbstractCommonDeleteFileTestCase implements // NOPMD
IHeapElementManager {
private FileForStorable fileForStorable; // NOPMD
Deleted: 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-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -1,153 +0,0 @@
-/*
- * Copyright 2007 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.heapfile.service;
-
-import java.io.File;
-
-import net.sf.joafip.AbstractCommonDeleteFileTestCase;
-import net.sf.joafip.DoNotTransform;
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.TestConstant;
-import net.sf.joafip.TestException;
-import net.sf.joafip.kvstore.entity.HeapFileSetup;
-import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.IHeapDataManager;
-
-@NotStorableClass
-@DoNotTransform
-public abstract class AbstractTestHeapDataManager extends
- AbstractCommonDeleteFileTestCase {
-
- protected String runtimePath;
-
- protected String traceFilePath;
-
- protected String dataFlafFilePath;
-
- protected String backupFlagFilePath;
-
- protected String backupFilePath;
-
- protected String globalFlagFilePath;
-
- protected String dataFilePath;
-
- protected String tempFilePath;
-
- protected IHeapDataManager heapDataManager; // NOPMD
-
- protected File dataFile; // NOPMD
-
- protected File backupFile; // NOPMD
-
- private File stateDataFile; // NOPMD
-
- private File stateDataBackupFile; // NOPMD
-
- private File globalStateFile; // NOPMD
-
- protected File tempFile; // NOPMD
-
- private File openFileTraceFile;
-
- public AbstractTestHeapDataManager() throws TestException {
- super();
- }
-
- public AbstractTestHeapDataManager(final String name) throws TestException {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {// NOPMD
- super.setUp();
- runtimePath = TestConstant.getWinRamDiskRuntimeDir();
- traceFilePath = runtimePath + File.separator + "trace.txt";
- dataFlafFilePath = runtimePath + File.separator + "data.flag";
- backupFlagFilePath = runtimePath + File.separator + "backup.flag";
- backupFilePath = runtimePath + File.separator + "backup.dat";
- globalFlagFilePath = runtimePath + File.separator + "global.flag";
- dataFilePath = runtimePath + File.separator + "test.dat";
- tempFilePath = runtimePath + File.separator + "temp.dat";
-
- dataFile = new File(dataFilePath);
- openFileTraceFile = new File(traceFilePath);
- dataFile.delete();
- backupFile = new File(backupFilePath);
- backupFile.delete();
- stateDataBackupFile = new File(backupFlagFilePath);
- stateDataBackupFile.delete();
- stateDataFile = new File(dataFlafFilePath);
- stateDataFile.delete();
- globalStateFile = new File(globalFlagFilePath);
- globalStateFile.delete();
- tempFile = new File(tempFilePath);
- tempFile.delete();
- }
-
- @Override
- protected void tearDown() throws Exception {// NOPMD
- try {
- heapDataManager.flush();
- } catch (Throwable throwable) {// NOPMD ignore all errors
- }
- try {
- heapDataManager.stopService();
- } catch (Throwable throwable) {// NOPMD ignore all errors
- }
- heapDataManager = null;// NOPMD
- super.tearDown();
- }
-
- /**
- * @param removeFile
- * @throws HeapException
- *
- */
- protected void createHeapFileDataManager(final boolean removeFile)
- throws HeapException {
- final HeapFileSetup setup = new HeapFileSetup(dataFile,
- true/* crashSafeMode */, false/* useCacheMode */,
- false/* deleteRenaming */, false/* clearResizeFile */, 1, 0,
- openFileTraceFile);
- setup.crashSafeSetup(backupFile, stateDataFile, stateDataBackupFile,
- globalStateFile);
- heapDataManager = new HeapFileDataManager(setup, false);
- heapDataManager.startService(removeFile);
- }
-
- protected void createBlockDataManager(final boolean removeFile)
- throws HeapException {
- heapDataManager = new BlockDataManager(dataFilePath, 20000);
- heapDataManager.startService(removeFile);
- }
-
- protected abstract void createHeap(final boolean removeFile)
- throws HeapException;
-
- protected abstract boolean manageFreeRecord();
-
- /**
- * @throws HeapException
- *
- */
- protected void closeHeap() throws HeapException {
- heapDataManager.flush();
- heapDataManager.stopService();
- }
-
-}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -26,6 +26,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerRecord;
import net.sf.joafip.kvstore.service.HeapException;
/**
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerRecord.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerRecord.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerRecord.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -1,121 +0,0 @@
-/*
- * Copyright 2008 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.heapfile.service;
-
-import net.sf.joafip.DoNotTransform;
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.TestException;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.HeapException;
-
-@NotStorableClass
-@DoNotTransform
-public abstract class AbstractTestHeapDataManagerRecord extends
- AbstractTestHeapDataManager {
-
- protected static final String DATA_MUST_BE_DEFINED = "data must be defined";
-
- public AbstractTestHeapDataManagerRecord() throws TestException {
- super();
- }
-
- public AbstractTestHeapDataManagerRecord(final String name)
- throws TestException {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {// NOPMD
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {// NOPMD
- super.tearDown();
- }
-
- protected DataRecordIdentifier newDataRecordIdentifier(final int identifier) {
- return new DataRecordIdentifier(identifier);
- }
-
- /**
- * create a data record.
- *
- * @param dataSize
- * size of data record to create
- * @param expectedIdentifier
- * expected identifier for created data record
- * @return the data recorded
- * @throws HeapException
- */
- protected byte[] createRecord(final int dataSize,
- final int expectedIdentifier) throws HeapException {
- final byte[] data = new byte[dataSize];
- for (int dataIndex = 0; dataIndex < dataSize; dataIndex++) {
- data[dataIndex] = (byte) (dataIndex & 0xff);
- }
- return createRecord(data, expectedIdentifier);
- }
-
- protected byte[] createRecord(final byte[] data,
- final int expectedIdentifier) throws HeapException {
- final DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- assertEquals("bad record identifier", expectedIdentifier,
- identifier.value);
- heapDataManager.writeDataRecord(identifier, data);
- return data;
- }
-
- /**
- * check data record content
- *
- * @param dataSize
- * @param dataRecordIdentifier
- * @throws HeapException
- */
- protected void checkDataRecord(final int dataSize,
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final byte[] data = heapDataManager
- .readDataRecord(dataRecordIdentifier);
- checkDataRecord(dataSize, data);
- }
-
- /**
- * check data record content
- *
- * @param dataSize
- * @param dataRecord
- * @throws HeapException
- */
- private void checkDataRecord(final int dataSize, final byte[] data)
- throws HeapException {
- assertNotNull("data record must be defined", data);
- assertNotNull(DATA_MUST_BE_DEFINED, data);
- assertEquals("bad data record data size", dataSize, data.length);
- for (int index = 0; index < dataSize; index++) {
- assertEquals("bad data value at " + index, data[index],
- (byte) (index & 0xff));
- }
- }
-
- protected void checkIntegrity() throws HeapException {
- FileDataManagerIntegrityC...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-29 16:51:46
|
Revision: 3044
http://joafip.svn.sourceforge.net/joafip/?rev=3044&view=rev
Author: luc_peuvrier
Date: 2012-04-29 16:51:38 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: implementation independant move to common joafip-kvstore
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
Added Paths:
-----------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerImpl.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2012-04-29 16:47:27 UTC (rev 3043)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2012-04-29 16:51:38 UTC (rev 3044)
@@ -1,628 +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.
- */
-package net.sf.joafip.heapfile.service;
-
-import net.sf.joafip.DoNotTransform;
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.TestException;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerRecord;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-@DoNotTransform
-public abstract class AbstractTestHeapDataManagerImpl extends
- AbstractTestHeapDataManagerRecord {
-
- private static final String BAD_VALUE = "bad value";
-
- private static final String MUST_DELETE_1 = "must delete #1";
-
- private static final String MUST_NOT_HAVE_DATA_RECORD = "must not have data record";
-
- private static final String MUST_DELETE_0 = "must delete #0";
-
- private static final String _0_FREE_RECORD_EXPECTED = "0 free record expected";
-
- private static final String LAST_RECORD_MISMATCH = "last record mismatch";
-
- private static final String MUST_HAVE_1_FREE_RECORD = "must have 1 free record";
-
- private static final String MUST_NOT_HAVE_FREE_RECORD = "must not have free record";
-
- private static final String MUST_HAVE_1_DATA_RECORD = "must have 1 data record";
-
- private static final String MUST_HAVE_3_DATA_RECORD = "must have 3 data record";
-
- public AbstractTestHeapDataManagerImpl() throws TestException {
- super();
- }
-
- public AbstractTestHeapDataManagerImpl(final String name)
- throws TestException {
- super(name);
- }
-
- public void testEmpty() throws HeapException {
- createHeap(true);
- assertNull("reading must failed",
- heapDataManager.readDataRecord(DataRecordIdentifier.ZERO));
- checkIntegrity();
- }
-
- public void testFirstCreateClose() throws HeapException {// NOPMD
- createHeap(true);
- final int dataSize = 100;
- createRecord(dataSize, 0);
- closeHeap();
- createHeap(false/* remove file */);
- checkIntegrity();
- firstCreatedReadAndCheck(dataSize);
- }
-
- public void testFirstCreateNoClose() throws HeapException {// NOPMD
- createHeap(true);
- final int dataSize = 100;
- createRecord(dataSize, 0);
- firstCreatedReadAndCheck(dataSize);
- }
-
- public void testDeleteClose() throws HeapException {// NOPMD
- createHeap(true);
- final int dataSize = 100;
- createRecord(dataSize, 0);
- checkIntegrity();
- closeHeap();
- createHeap(false/* remove file */);
- final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- closeHeap();
- createHeap(false/* remove file */);
- checkIntegrity();
- }
-
- public void testDeleteNoClose() throws HeapException {// NOPMD
- createHeap(true);
- final int dataSize = 100;
- createRecord(dataSize, 0);
- final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- checkIntegrity();
- }
-
- /**
- * @param dataSize
- * @throws HeapException
- *
- */
- private void firstCreatedReadAndCheck(final int dataSize)
- throws HeapException {
- final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- checkDataRecord(dataSize, identifier);
- checkIntegrity();
- }
-
- public void testAlloc() throws HeapException {
- createHeap(true);
- for (int index = 0; index < 10; index++) {
- final DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- final byte[] data = new byte[1000]; // NOPMD
- for (int dataIndex = 0; dataIndex < 1000; dataIndex++) {
- data[dataIndex] = (byte) index;
- }
- heapDataManager.writeDataRecord(identifier, data);
- logger.info("add #id=" + identifier);
- logger.info("--------");
- }
- checkIntegrity();
- closeHeap();
- createHeap(false/* remove file */);
- for (int identifier = 0; identifier < 10; identifier++) {
- final DataRecordIdentifier dataRecordIdentifier = newDataRecordIdentifier(identifier);
- final byte[] data = heapDataManager
- .readDataRecord(dataRecordIdentifier);
- assertNotNull("must exist data for identifier " + identifier, data);
- for (int dataIndex = 0; dataIndex < 1000; dataIndex++) {
- assertEquals("bad data value at " + dataIndex, data[dataIndex],
- (byte) identifier);
- }
- }
- }
-
- /**
- * realloc from only one free record keeping one free record
- *
- * @throws HeapException
- */
- public void testFreeReAlloc1() throws HeapException {
- /*
- * create record #0 of 10000 bytes, check data record and free record
- */
- createHeap(true);
- int dataSize = 10000;
- createRecord(dataSize, 0);
- closeHeap();
-
- createHeap(false/* remove file */);
- assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
-
- /*
- * delete record #0, check data record and free record
- */
- final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- closeHeap();
-
- createHeap(false/* remove file */);
- assertEquals(MUST_NOT_HAVE_DATA_RECORD, 0,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
-
- /*
- * create record #1 of 5000 byte, check 1 data record and 1 free record
- */
- dataSize = 5000;
- createRecord(dataSize, 1);
- closeHeap();
-
- createHeap(false/* remove file */);
- checkIntegrity();
- assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
- heapDataManager.getNumberOfFreeRecord());
- }
- closeHeap();
- }
-
- /**
- * realloc from only one free record keeping no more free record
- *
- * @throws HeapException
- */
- public void testFreeReAlloc2() throws HeapException {
- createHeap(true);
- int dataSize = 10000;
- createRecord(dataSize, 0);
- closeHeap();
- createHeap(false/* remove file */);
- assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
- final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- closeHeap();
- createHeap(false/* remove file */);
- assertEquals(MUST_NOT_HAVE_DATA_RECORD, 0,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
-
- dataSize = 9999;
- createRecord(dataSize, 1);
- closeHeap();
- createHeap(false/* remove file */);
- checkIntegrity();
- assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- closeHeap();
- }
-
- /**
- * realloc from only one free record keeping one free record
- *
- * @throws HeapException
- */
- public void testFreeReAlloc3() throws HeapException {
- createHeap(true);
- int dataSize = 10000;
- createRecord(dataSize, 0);
- createRecord(dataSize, 1);
- createRecord(dataSize, 2);
- closeHeap();
- createHeap(false/* remove file */);
- assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
- final DataRecordIdentifier identifier = new DataRecordIdentifier(1);
- assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
- closeHeap();
- createHeap(false/* remove file */);
- assertEquals("must have 2 data record", 2,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
-
- dataSize = 5000;
- createRecord(dataSize, 3);
- closeHeap();
- createHeap(false/* remove file */);
- checkIntegrity();
- assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
- heapDataManager.getNumberOfFreeRecord());
- }
- closeHeap();
- }
-
- /**
- * realloc from only one free record keeping no more free record
- *
- * @throws HeapException
- */
- public void testFreeReAlloc4() throws HeapException {
- createHeap(true);
- int dataSize = 10000;
- createRecord(dataSize, 0);
- assertEquals("1 data record expected", 1,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(_0_FREE_RECORD_EXPECTED, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- createRecord(dataSize, 1);
- assertEquals("2 data record expected", 2,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(_0_FREE_RECORD_EXPECTED, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- createRecord(dataSize, 2);
- assertEquals("3 data record expected", 3,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(_0_FREE_RECORD_EXPECTED, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- closeHeap();
- createHeap(false/* remove file */);
- assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
- final DataRecordIdentifier identifier = new DataRecordIdentifier(1);
- assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
- closeHeap();
- createHeap(false/* remove file */);
- assertEquals("must have 2 data record", 2,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
- heapDataManager.getNumberOfFreeRecord());
- }
- checkIntegrity();
-
- dataSize = 9999;
- createRecord(dataSize, 3);
- assertEquals("3 data record expected", 3,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(_0_FREE_RECORD_EXPECTED, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
-
- closeHeap();
- createHeap(false/* remove file */);
- checkIntegrity();
- assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
- heapDataManager.getNumberOfDataRecord());
- if (manageFreeRecord()) {
- assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
- heapDataManager.getNumberOfFreeRecord());
- }
- closeHeap();
- }
-
- public void testModification() throws HeapException {
- createHeap(true);
- byte[] data = createRecord(20, 0);
- assertNotNull(DATA_MUST_BE_DEFINED, data);
- for (int index = 0; index < 20; index++) {
- data[index] = (byte) index;
- }
- checkIntegrity();
- closeHeap();
- createHeap(false/* remove file */);
- final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
- data = heapDataManager.readDataRecord(identifier);
- for (int index = 0; index < 20; index++) {
- assertEquals(BAD_VALUE, data[index], index);
- }
- for (int index = 0; index < 20; index++) {
- data[index] = (byte) (10 + index);
- }
- heapDataManager.writeDataRecord(identifier, data);
- closeHeap();
- createHeap(false/* remove file */);
- data = heapDataManager.readDataRecord(identifier);
- for (int index = 0; index < 20; index++) {
- assertEquals(BAD_VALUE, data[index], 10 + index);
- }
- }
-
- public void testNoDataWrite() throws HeapException {
- createHeap(true);
- final DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- byte[] data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
- final DataRecordIdentifier identifier0 = new DataRecordIdentifier(0);
- assertEquals("not expected identifier", identifier0, identifier);
- closeHeap();
- createHeap(true/* remove file */);
- data = heapDataManager.readDataRecord(identifier0);
- assertNull("must failed since no data wrote", data);
- }
-
- public void testCreateDeleteReCreate() throws HeapException {
- createHeap(true);
- DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- byte[] data = new byte[10];
- heapDataManager.writeDataRecord(identifier, data);
-
- DataRecordIdentifier expectedIdentifier = new DataRecordIdentifier(0);
- assertEquals("identifier must be 0", expectedIdentifier, identifier);
- assertTrue("must have data record #0",
- heapDataManager.hasDataRecord(identifier));
-
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- assertFalse("must not have data record #0",
- heapDataManager.hasDataRecord(identifier));
-
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[10];
- heapDataManager.writeDataRecord(identifier, data);
-
- expectedIdentifier = new DataRecordIdentifier(1);
- assertEquals("identifier must be 1", expectedIdentifier, identifier);
- assertTrue("must have data record #0",
- heapDataManager.hasDataRecord(identifier));
- heapDataManager.flush();
- }
-
- public void testRecordFreeing1() throws HeapException {
- createHeap(true);
- /*
- * create record #0
- */
- DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- byte[] data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- final DataRecordIdentifier expectedIdentifier0 = new DataRecordIdentifier(
- 0);
- assertEquals("must create record #0", expectedIdentifier0, identifier);
-
- /*
- * create record #1
- */
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- final DataRecordIdentifier expectedIdentifier1 = new DataRecordIdentifier(
- 1);
- assertEquals("must create record #1", expectedIdentifier1, identifier);
-
- /*
- * create record #2
- */
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- final DataRecordIdentifier expectedIdentifier2 = new DataRecordIdentifier(
- 2);
- assertEquals("must create record #2", expectedIdentifier2, identifier);
-
- /*
- * delete #0
- */
- identifier = new DataRecordIdentifier(0);
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- heapDataManager.flush();
- final long record2PositionInFile = heapDataManager
- .getRecordPositionInfile(expectedIdentifier2);
-
- long lastRecordPositionInFile = heapDataManager
- .getLastRecordPositionInFile();
- assertEquals(LAST_RECORD_MISMATCH, record2PositionInFile,
- lastRecordPositionInFile);
-
- /*
- * delete #1
- */
- identifier = new DataRecordIdentifier(1);
- assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
- heapDataManager.flush();
- lastRecordPositionInFile = heapDataManager
- .getLastRecordPositionInFile();
- assertEquals(LAST_RECORD_MISMATCH, lastRecordPositionInFile,
- record2PositionInFile);
- }
-
- public void testRecordFreeing2() throws HeapException {
- createHeap(true);
- /*
- * create record #0
- */
- DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- byte[] data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- final DataRecordIdentifier expectedIdentifier = new DataRecordIdentifier(
- 0);
- assertEquals("must create record #0", expectedIdentifier, identifier);
-
- /*
- * create record #1
- */
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- final DataRecordIdentifier expectedIdentifier1 = new DataRecordIdentifier(
- 1);
- assertEquals("must create record #1", expectedIdentifier1, identifier);
- heapDataManager.flush();
- final long record1PositionInFile = heapDataManager
- .getRecordPositionInfile(expectedIdentifier1);
-
- /*
- * create record #2
- */
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- final DataRecordIdentifier expectedIdentifier2 = new DataRecordIdentifier(
- 2);
- assertEquals("must create record #2", expectedIdentifier2, identifier);
- heapDataManager.flush();
- final long record2PositionInFile = heapDataManager
- .getRecordPositionInfile(expectedIdentifier2);
-
- /*
- * delete #2
- */
- identifier = new DataRecordIdentifier(2);
- assertTrue("must delete #2",
- heapDataManager.deleteDataRecord(identifier));
- heapDataManager.flush();
- long lastRecordPositionInFile = heapDataManager
- .getLastRecordPositionInFile();
- assertEquals(LAST_RECORD_MISMATCH, record2PositionInFile,
- lastRecordPositionInFile);
-
- /*
- * delete #1
- */
- identifier = new DataRecordIdentifier(1);
- assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
- heapDataManager.flush();
- lastRecordPositionInFile = heapDataManager
- .getLastRecordPositionInFile();
- if (manageFreeRecord()) {
- assertEquals(LAST_RECORD_MISMATCH, record1PositionInFile,
- lastRecordPositionInFile);
- }
- }
-
- public void testRecordFreeing3() throws HeapException {
- createHeap(true);
- DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- byte[] data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- DataRecordIdentifier expectedIdentifier = new DataRecordIdentifier(0);
- assertEquals("must create record #0", expectedIdentifier, identifier);
-
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- expectedIdentifier = new DataRecordIdentifier(1);
- assertEquals("must create record #1", expectedIdentifier, identifier);
-
- identifier = heapDataManager.getNewDataRecordIdentifier();
- data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
-
- expectedIdentifier = new DataRecordIdentifier(2);
- assertEquals("must create record #2", expectedIdentifier, identifier);
-
- identifier = new DataRecordIdentifier(0);
- assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
- identifier = new DataRecordIdentifier(2);
- assertTrue("must delete #2",
- heapDataManager.deleteDataRecord(identifier));
- heapDataManager.flush();
- identifier = new DataRecordIdentifier(1);
- assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
- }
-
- public void testRemoveFirst() throws HeapException {
- createHeap(true);
- assertNull(MUST_NOT_HAVE_DATA_RECORD,
- heapDataManager.removeFirstDataRecord());
- DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- final byte[] data = new byte[100];
- heapDataManager.writeDataRecord(identifier, data);
- identifier = heapDataManager.getNewDataRecordIdentifier();
- heapDataManager.writeDataRecord(identifier, data);
- heapDataManager.flush();
- identifier = heapDataManager.removeFirstDataRecord();
- assertNotNull("must deleted first data record", identifier);
- assertEquals(BAD_VALUE, 0L, identifier.value);
- identifier = heapDataManager.removeFirstDataRecord();
- assertNotNull("must deleted first data record", identifier);
- assertEquals(BAD_VALUE, 1L, identifier.value);
- assertNull(MUST_NOT_HAVE_DATA_RECORD,
- heapDataManager.removeFirstDataRecord());
- }
-}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java 2012-04-29 16:47:27 UTC (rev 3043)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java 2012-04-29 16:51:38 UTC (rev 3044)
@@ -20,6 +20,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerImpl;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java 2012-04-29 16:47:27 UTC (rev 3043)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java 2012-04-29 16:51:38 UTC (rev 3044)
@@ -20,6 +20,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerImpl;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
Copied: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerImpl.java (from rev 3043, trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java)
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerImpl.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestHeapDataManagerImpl.java 2012-04-29 16:51:38 UTC (rev 3044)
@@ -0,0 +1,627 @@
+/*
+ * 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.
+ */
+package net.sf.joafip.kvstore.service;
+
+import net.sf.joafip.DoNotTransform;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@DoNotTransform
+public abstract class AbstractTestHeapDataManagerImpl extends
+ AbstractTestHeapDataManagerRecord {
+
+ private static final String BAD_VALUE = "bad value";
+
+ private static final String MUST_DELETE_1 = "must delete #1";
+
+ private static final String MUST_NOT_HAVE_DATA_RECORD = "must not have data record";
+
+ private static final String MUST_DELETE_0 = "must delete #0";
+
+ private static final String _0_FREE_RECORD_EXPECTED = "0 free record expected";
+
+ private static final String LAST_RECORD_MISMATCH = "last record mismatch";
+
+ private static final String MUST_HAVE_1_FREE_RECORD = "must have 1 free record";
+
+ private static final String MUST_NOT_HAVE_FREE_RECORD = "must not have free record";
+
+ private static final String MUST_HAVE_1_DATA_RECORD = "must have 1 data record";
+
+ private static final String MUST_HAVE_3_DATA_RECORD = "must have 3 data record";
+
+ public AbstractTestHeapDataManagerImpl() throws TestException {
+ super();
+ }
+
+ public AbstractTestHeapDataManagerImpl(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ public void testEmpty() throws HeapException {
+ createHeap(true);
+ assertNull("reading must failed",
+ heapDataManager.readDataRecord(DataRecordIdentifier.ZERO));
+ checkIntegrity();
+ }
+
+ public void testFirstCreateClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ firstCreatedReadAndCheck(dataSize);
+ }
+
+ public void testFirstCreateNoClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ firstCreatedReadAndCheck(dataSize);
+ }
+
+ public void testDeleteClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ checkIntegrity();
+ closeHeap();
+ createHeap(false/* remove file */);
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ }
+
+ public void testDeleteNoClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ checkIntegrity();
+ }
+
+ /**
+ * @param dataSize
+ * @throws HeapException
+ *
+ */
+ private void firstCreatedReadAndCheck(final int dataSize)
+ throws HeapException {
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ checkDataRecord(dataSize, identifier);
+ checkIntegrity();
+ }
+
+ public void testAlloc() throws HeapException {
+ createHeap(true);
+ for (int index = 0; index < 10; index++) {
+ final DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ final byte[] data = new byte[1000]; // NOPMD
+ for (int dataIndex = 0; dataIndex < 1000; dataIndex++) {
+ data[dataIndex] = (byte) index;
+ }
+ heapDataManager.writeDataRecord(identifier, data);
+ logger.info("add #id=" + identifier);
+ logger.info("--------");
+ }
+ checkIntegrity();
+ closeHeap();
+ createHeap(false/* remove file */);
+ for (int identifier = 0; identifier < 10; identifier++) {
+ final DataRecordIdentifier dataRecordIdentifier = newDataRecordIdentifier(identifier);
+ final byte[] data = heapDataManager
+ .readDataRecord(dataRecordIdentifier);
+ assertNotNull("must exist data for identifier " + identifier, data);
+ for (int dataIndex = 0; dataIndex < 1000; dataIndex++) {
+ assertEquals("bad data value at " + dataIndex, data[dataIndex],
+ (byte) identifier);
+ }
+ }
+ }
+
+ /**
+ * realloc from only one free record keeping one free record
+ *
+ * @throws HeapException
+ */
+ public void testFreeReAlloc1() throws HeapException {
+ /*
+ * create record #0 of 10000 bytes, check data record and free record
+ */
+ createHeap(true);
+ int dataSize = 10000;
+ createRecord(dataSize, 0);
+ closeHeap();
+
+ createHeap(false/* remove file */);
+ assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+
+ /*
+ * delete record #0, check data record and free record
+ */
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+
+ createHeap(false/* remove file */);
+ assertEquals(MUST_NOT_HAVE_DATA_RECORD, 0,
+ heapDataManager.getNumberOfDataRecord());...
[truncated message content] |