joafip-svn Mailing List for java data object persistence in file (Page 11)
Brought to you by:
luc_peuvrier
You can subscribe to this list here.
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(102) |
Nov
(52) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2012 |
Jan
(4) |
Feb
|
Mar
(14) |
Apr
(116) |
May
(100) |
Jun
(14) |
Jul
|
Aug
|
Sep
(30) |
Oct
|
Nov
(108) |
Dec
(2) |
|
From: <luc...@us...> - 2012-05-01 15:44:45
|
Revision: 3054
http://joafip.svn.sourceforge.net/joafip/?rev=3054&view=rev
Author: luc_peuvrier
Date: 2012-05-01 15:44:39 +0000 (Tue, 01 May 2012)
Log Message:
-----------
clean up
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java 2012-05-01 07:39:04 UTC (rev 3053)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java 2012-05-01 15:44:39 UTC (rev 3054)
@@ -50,8 +50,6 @@
return INSTANCE;
}
- // private transient HeapFileDataManager heapFileDataManager;
-
private transient RedBlackTree<DataRecordIdentifier> idNodeTree;
private transient RedBlackTree<Integer> freeNodeTree;
@@ -69,19 +67,9 @@
private void checkIntegrity(final HeapFileDataManager heapFileDataManager)
throws HeapException {
- // this.heapFileDataManager = heapFileDataManager;
final IHeapElementManager heapElementManager = heapFileDataManager
.getHeapElementManager();
- // final IFileForStorable fileForStorable = new FileForStorableBridge(
- // manager.getFileForStorable());
- // this.manager = new HeapElementManager(fileForStorable, null/*
- // openFileTraceFile */);
- // this.manager.startService();
- // this.manager.openTransaction();
- // this.manager.setWriteAlwaysEnable(false);
- // this.manager.setWriteEnable(false);
-
idNodeTree = heapFileDataManager.getIdNodeTree();
freeNodeTree = heapFileDataManager.getFreeNodeTree();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 15:44:45
|
Revision: 3054
http://joafip.svn.sourceforge.net/joafip/?rev=3054&view=rev
Author: luc_peuvrier
Date: 2012-05-01 15:44:39 +0000 (Tue, 01 May 2012)
Log Message:
-----------
clean up
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 07:39:12
|
Revision: 3053
http://joafip.svn.sourceforge.net/joafip/?rev=3053&view=rev
Author: luc_peuvrier
Date: 2012-05-01 07:39:04 +0000 (Tue, 01 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization
Modified Paths:
--------------
trunk/joafip-4test/pom.xml
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/resources/log4j.properties
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.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/LeafPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
Added Paths:
-----------
trunk/joafip-4test/jrat.xml
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java
Property Changed:
----------------
trunk/joafip-4test/
Property changes on: trunk/joafip-4test
___________________________________________________________________
Modified: svn:ignore
- target
.settings
.classpath
.project
runtime
logs
.pmd
lib
runtime_perf
+ target
.settings
.classpath
.project
runtime
logs
.pmd
lib
runtime_perf
jrat.output
Added: trunk/joafip-4test/jrat.xml
===================================================================
--- trunk/joafip-4test/jrat.xml (rev 0)
+++ trunk/joafip-4test/jrat.xml 2012-05-01 07:39:04 UTC (rev 3053)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jrat>
+ <settings>
+ <property name="httpServerEnabled" value="false"/>
+ </settings>
+
+ <profile name="my code">
+
+ <criteria>
+ <include/>
+ </criteria>
+
+ <handlers>
+
+ <handler factory="org.shiftone.jrat.provider.tree.TreeMethodHandlerFactory">
+ <property name="outputFile" value="joafip.jrat"/>
+ </handler>
+
+ </handlers>
+
+ </profile>
+</jrat>
\ No newline at end of file
Modified: trunk/joafip-4test/pom.xml
===================================================================
--- trunk/joafip-4test/pom.xml 2012-04-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-4test/pom.xml 2012-05-01 07:39:04 UTC (rev 3053)
@@ -51,6 +51,12 @@
<dependency>
<groupId>net.sf.joafip</groupId>
+ <artifactId>joafip-btreeplus</artifactId>
+ <version>4.0.0b8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.joafip</groupId>
<artifactId>joafip-rbtree</artifactId>
<version>4.0.0b8</version>
</dependency>
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2012 Luc Peuvrier
+ * All rights reserved.
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.performance.items.entity.Item;
+import net.sf.joafip.performance.items.entity.ItemList;
+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.service.IDataAccessSession;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class AbstractDeleter extends AbstractPerfService {
+
+ public AbstractDeleter(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
+ public AbstractDeleter(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ protected void run() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceTooBigForSerializationException, IOException {
+ final IDataAccessSession session = filePersistence
+ .createDataAccessSession();
+ session.open();
+ int batchCount = 0;
+ int count = 0;
+ BufferedReader reader = new BufferedReader(new FileReader(
+ "runtime_perf/toDelete.txt"));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ final int identifier = Integer.parseInt(line);
+ final ItemList itemList = getItemList(session);
+ final Item item = itemList.removeItem(identifier);
+ if (item == null) {
+ throw new FilePersistenceException("must found #" + identifier
+ + " to be deleted");
+ }
+ if (++count == BATCH_SIZE) {
+ count = 0;
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+ session.open();
+ ++batchCount;
+ logger.info("delete batch #" + batchCount);
+ }
+ }
+ reader.close();
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+
+ session.open();
+ batchCount = 0;
+ count = 0;
+ reader = new BufferedReader(new FileReader("runtime_perf/toSearch.txt"));
+ while ((line = reader.readLine()) != null) {
+ final int identifier = Integer.parseInt(line);
+ final ItemList itemList = getItemList(session);
+ Item item = itemList.get(identifier);
+ if (item == null) {
+ throw new FilePersistenceException("must found #" + identifier
+ + " because not deleted");
+ }
+ if (++count == BATCH_SIZE) {
+ count = 0;
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+ session.open();
+ ++batchCount;
+ logger.info("search batch #" + batchCount);
+ }
+ }
+ reader.close();
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+
+ session.open();
+ batchCount = 0;
+ count = 0;
+ reader = new BufferedReader(new FileReader("runtime_perf/toDelete.txt"));
+ while ((line = reader.readLine()) != null) {
+ final int identifier = Integer.parseInt(line);
+ final ItemList itemList = getItemList(session);
+ final Item item = itemList.getItem(identifier);
+ if (item != null) {
+ throw new FilePersistenceException("must not found #"
+ + identifier + " because deleted");
+ }
+ if (++count == BATCH_SIZE) {
+ count = 0;
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+ session.open();
+ ++batchCount;
+ logger.info("search deleted batch #" + batchCount);
+ }
+ }
+ reader.close();
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+ }
+}
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -53,15 +53,15 @@
protected static final int BATCH_SIZE = 1000;
- protected static final int NUMBER_OF_ITEM = 1000000;
+ public static final int NUMBER_OF_ITEM = 1000000;
- private static final boolean CRASH_SAFE_MODE = false;
+ protected static final boolean CRASH_SAFE_MODE = false;
private static final boolean GARBAGE = false;
protected static final boolean FILE_CACHE = true;
- private static final int PAGE_SIZE = 4 * 1024;
+ protected static final int PAGE_SIZE = 4 * 1024;
protected static final int NUMBER_OF_PAGE = 4 * 1024;
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012 Luc Peuvrier
+ * All rights reserved.
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.Random;
+
+import net.sf.joafip.java.util.PTreeList;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class CreateDeleteList {
+
+ public static void main(String[] args) {
+ try {
+ final List<Integer> list = new PTreeList<Integer>();
+ for (int identifier = 0; identifier < AbstractPerfService.NUMBER_OF_ITEM; identifier++) {
+ list.add(identifier);
+ }
+ PrintWriter writer = new PrintWriter("runtime_perf/toDelete.txt");
+ final Random random = new Random(System.currentTimeMillis());
+ for (int count = 0; count < AbstractPerfService.NUMBER_OF_ITEM / 2; count++) {
+ final int upperBound = list.size();
+ final int index = random.nextInt(upperBound);
+ int identifier = list.remove(index);
+ writer.println(identifier);
+ }
+ writer.close();
+ writer = new PrintWriter("runtime_perf/toSearch.txt");
+ for (int identifier : list) {
+ writer.println(identifier);
+ }
+ writer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2012 Luc Peuvrier
+ * All rights reserved.
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;
+
+import java.io.File;
+
+import net.sf.joafip.btreeplus.service.BtreePlusDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DeleterBtreePlus extends AbstractDeleter {
+
+ private final static JoafipLogger LOGGER = JoafipLogger
+ .getLogger(DeleterBtreePlus.class);
+
+ public DeleterBtreePlus(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
+ public DeleterBtreePlus(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ public static void main(final String[] args) {
+ final String dataFilePath = RUNTIME_DIR + "/block.data";
+ final File dataFile = new File(dataFilePath);
+ DeleterBtreePlus deleter;
+ try {
+ final HeapFileSetup setup = new HeapFileSetup(dataFile,
+ CRASH_SAFE_MODE/* crashSafeMode */,
+ false/* FILE_CACHE *//* useCacheMode */,
+ false/* deleteRenaming */, false/* clearResizeFile */,
+ 0/* maxFileOperationRetry */,
+ 0/* fileOperationRetryMsDelay */, null/* openFileTraceFile */);
+ // if (FILE_CACHE) {
+ // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
+ // }
+ final IHeapDataManager dataManager =
+ /**/new BtreePlusDataManager(setup);
+ deleter = new DeleterBtreePlus(dataManager);
+ deleter.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.performance.items.service;//NOPMD
+
+import java.io.File;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.btreeplus.service.BtreePlusDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public final class InserterBtreePlus extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterBtreePlus.class);
+
+ private InserterBtreePlus(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ private InserterBtreePlus(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
+ public static void main(final String[] args) {
+ /* remove existing data */
+ final File dataDirectory = new File(RUNTIME_DIR);
+ for (final File file : dataDirectory.listFiles()) {
+ file.delete();
+ }
+ dataDirectory.mkdirs();
+ final String dataFilePath = RUNTIME_DIR + "/block.data";
+ /* remove existing data */
+ final File dataFile = new File(dataFilePath);
+ dataFile.delete();
+ InserterBtreePlus inserter;
+ try {
+ final HeapFileSetup setup = new HeapFileSetup(dataFile,
+ CRASH_SAFE_MODE/* crashSafeMode */,
+ false/* FILE_CACHE *//* useCacheMode */,
+ false/* deleteRenaming */, false/* clearResizeFile */,
+ 0/* maxFileOperationRetry */,
+ 0/* fileOperationRetryMsDelay */, null/* openFileTraceFile */);
+ // if (FILE_CACHE) {
+ // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
+ // }
+ final IHeapDataManager dataManager =
+ /**/new BtreePlusDataManager(setup);
+ inserter = new InserterBtreePlus(dataManager);
+ inserter.run(NUMBER_OF_ITEM);
+ inserter.close();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -0,0 +1,83 @@
+/*
+ * 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.btreeplus.service.BtreePlusDataManager;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+@NotStorableClass
+@StorableAccess
+public class SearcherBtreePlus extends AbstractSearcher {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(SearcherBtreePlus.class);
+
+ public SearcherBtreePlus(final String pathName)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ public SearcherBtreePlus(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
+ public static void main(final String[] args) {
+ final String dataFilePath = RUNTIME_DIR + "/block.data";
+ final File dataFile = new File(dataFilePath);
+ SearcherBtreePlus searcher;
+ try {
+ final HeapFileSetup setup = new HeapFileSetup(dataFile,
+ CRASH_SAFE_MODE/* crashSafeMode */,
+ false/* FILE_CACHE *//* useCacheMode */,
+ false/* deleteRenaming */, false/* clearResizeFile */,
+ 0/* maxFileOperationRetry */,
+ 0/* fileOperationRetryMsDelay */, null/* openFileTraceFile */);
+ // if (FILE_CACHE) {
+ // setup.cacheSetup(PAGE_SIZE, NUMBER_OF_PAGE);
+ // }
+ final IHeapDataManager dataManager =
+ /**/new BtreePlusDataManager(setup);
+ searcher = new SearcherBtreePlus(dataManager);
+ searcher.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Modified: trunk/joafip-4test/src/main/resources/log4j.properties
===================================================================
--- trunk/joafip-4test/src/main/resources/log4j.properties 2012-04-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-4test/src/main/resources/log4j.properties 2012-05-01 07:39:04 UTC (rev 3053)
@@ -130,11 +130,16 @@
log4j.logger.net.sf.joafip.performance.items.service.InserterBKM=info
log4j.logger.net.sf.joafip.performance.items.service.InserterJdbm=info
log4j.logger.net.sf.joafip.performance.items.service.InserterBabuDB=info
+log4j.logger.net.sf.joafip.performance.items.service.InserterBtreePlus=info
log4j.logger.net.sf.joafip.performance.items.service.Searcher=info
log4j.logger.net.sf.joafip.performance.items.service.SearcherBKM=info
log4j.logger.net.sf.joafip.performance.items.service.SearcherJdbm=info
log4j.logger.net.sf.joafip.performance.items.service.ImportSearcher=info
+log4j.logger.net.sf.joafip.performance.items.service.SearcherBtreePlus=info
+
+log4j.logger.net.sf.joafip.performance.items.service.DeleterBtreePlus=info
+
log4j.logger.net.sf.joafip.service.MainCrash=info
log4j.logger.net.sf.joafip.service.MainAfterCrash=info
log4j.logger.net.sf.joafip.service.MainWarnDataRecord1=debug
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -66,6 +66,10 @@
return pageRecord.getPositionInFile();
}
+ public long getPreviousRecordPositionInFile() throws HeapException {
+ return pageRecord.getPreviousRecordPositionInFile();
+ }
+
protected int entrySize(final DataRecordIdentifier key) {
int entryByteSize = 8/* long size for pointer */+ 8/* long size for value */;
final int dataSize = key.getKeyDataSize();
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -35,6 +35,7 @@
public class DataBlockPage extends AbstractElement {
public static final int HEAD_SIZE =
+ /**/8/* byte size for previous record position */+
/**/1/* byte size for record type */+
/**/1/* byte size for bits */;
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/FreePage.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -59,7 +59,9 @@
@Override
public int getByteSize() {
// return PageConstant.PAGE_SIZE;
- return 1/* byte size for record type */+
+ return
+ /**/8/* byte size for previous record position */+
+ /**/1/* byte size for record type */+
/**/8/* long size for next free page */+
/**/4/* int size for crc32 */;
}
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -48,6 +48,8 @@
private long nextDataRecordIdentifier;
+ private long lastRecordPositionInFile;
+
public HeaderPage(final IHeapElementManager heapElementManager) {
super(heapElementManager, 0L);
}
@@ -106,6 +108,7 @@
rootPagePosition = -1L;
freeDataBlocks = null;
nextDataRecordIdentifier = 0;
+ lastRecordPositionInFile = -1L;
}
@Override
@@ -140,6 +143,7 @@
writeLong(pageNumberOfFirstFreePage);
writeLong(rootPagePosition);
writeLong(nextDataRecordIdentifier);
+ writeLong(lastRecordPositionInFile);
initializeFreeDataBlock();
for (int index = 0; index < PageConstant.NUMBER_OF_BLOCK_TYPE; index++) {
writeLong(freeDataBlocks[index]);
@@ -163,6 +167,7 @@
pageNumberOfFirstFreePage = readLong();
rootPagePosition = readLong();
nextDataRecordIdentifier = readLong();
+ lastRecordPositionInFile = readLong();
initializeFreeDataBlock();
for (int index = 0; index < PageConstant.NUMBER_OF_BLOCK_TYPE; index++) {
freeDataBlocks[index] = readLong();
@@ -241,4 +246,12 @@
public int getInParentIndex() throws HeapException {
throw new HeapException("unsupported");
}
+
+ public void setLastRecordPositionInFile(final long lastRecordPositionInFile) {
+ this.lastRecordPositionInFile = lastRecordPositionInFile;
+ }
+
+ public long getLastRecordPositionInFile() {
+ return lastRecordPositionInFile;
+ }
}
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/LeafPage.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -37,7 +37,9 @@
@NotStorableClass
public class LeafPage extends AbstractElement implements ILeafPage {
- public static int HEAD_TAIL_SIZE = 1/* byte size for record type */+
+ public static int HEAD_TAIL_SIZE =
+ /**/8/* byte size for previous record position */+
+ /**/1/* byte size for record type */+
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
/**/8/* for next */;
@@ -167,7 +169,7 @@
*/
public long getDataBlockPosition(
final DataRecordIdentifier dataRecordIdentifier) {
- // FIXMELUC _________dichotomic search
+ // FIXMELUC _________________LONG dichotomic search
long position = -1;
for (index = 0; position == -1L && index < numberOfKeyEntries; index++) {
if (keys[index].compareTo(dataRecordIdentifier) == 0) {
@@ -306,6 +308,7 @@
private int computeInsertBeforeIndex(
final DataRecordIdentifier dataRecordIdentifier) {
+ // FIXMELUC _________________LONG
int index;
for (index = 0; index < numberOfKeyEntries
&& dataRecordIdentifier.compareTo(keys[index]) > 0; index++)
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -38,7 +38,9 @@
public class NonTerminalPage extends AbstractElement implements
INonTerminalPage {
- public static int HEAD_TAIL_SIZE = 1/* byte size for record type */+
+ public static int HEAD_TAIL_SIZE =
+ /**/8/* byte size for previous record position */+
+ /**/1/* byte size for record type */+
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
/**/8/* last pointer long size */;
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -42,6 +42,8 @@
private final long pageNumber;
+ private long previousRecordPositionInFile;
+
/**
* creation for reading
*
@@ -52,11 +54,14 @@
final long pageNumber) {
super(heapElementManager, pageNumber << PageConstant.PAGE_BITS);
this.pageNumber = pageNumber;
+ this.previousRecordPositionInFile = -1L;
}
public PageRecord(final IHeapElementManager heapElementManager,
+ final Long previousRecordPositionInFile,
final IPageRecordable pageRecordable, final long pageNumber) {
super(heapElementManager, pageNumber << PageConstant.PAGE_BITS);
+ this.previousRecordPositionInFile = previousRecordPositionInFile;
this.pageNumber = pageNumber;
this.pageRecordable = pageRecordable;
this.recordType = pageRecordable.getRecordType();
@@ -90,9 +95,26 @@
@Override
public long getPreviousRecordPositionInFile() throws HeapException {
- return -1L;
+ return previousRecordPositionInFile;
}
+ public void setPreviousRecordPositionInFile(
+ final long previousRecordPositionInFile) throws HeapException {
+ setValueIsChangedValueToSave();
+ this.previousRecordPositionInFile = previousRecordPositionInFile;
+ assertPreviousPositionInFile();
+ }
+
+ private boolean assertPreviousPositionInFile() throws HeapException {
+ if (previousRecordPositionInFile == -1
+ && positionInFile != PageConstant.PAGE_SIZE) {
+ throw new HeapException("bad position of first record "
+ + positionInFile + " for " + PageConstant.PAGE_SIZE
+ + " expected");
+ }
+ return true;
+ }
+
@Override
public int getRecordSize() throws HeapException {
// ASSERTX
@@ -115,6 +137,7 @@
assert pageRecordable.getPageRecord() == this;
// ASSERTX
assert recordType.equals(pageRecordable.getRecordType());
+ writeLong(previousRecordPositionInFile);
writeByteRecordType(recordType);
switch (recordType) {
case NON_TERMINAL_PAGE:
@@ -143,6 +166,8 @@
throw new HeapException("read " + read + " for "
+ PageConstant.PAGE_SIZE + " expected");
}
+ previousRecordPositionInFile = readLong();
+ assertPreviousPositionInFile();
recordType = readRecordType();
switch (recordType) {
case NON_TERMINAL_PAGE:
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -270,21 +270,27 @@
throws HeapException {
// FIXMELUC ________rotation, dispatch on sibling
INonTerminalPage newNonTerminalPage = nonTerminalPage.split();
+ DataRecordIdentifier middleKey = nonTerminalPage.getAndClearMiddleKey();
+ // ASSERTX
+ assert middleKey != null;
do {
btreePlusElementMgr.appendPageRecordable(newNonTerminalPage);
newNonTerminalPage.setValueIsChangedValueToSave();
- DataRecordIdentifier middleKey = nonTerminalPage
- .getAndClearMiddleKey();
NonTerminalPage parent = (NonTerminalPage) nonTerminalPage
.getParentPage();
if (parent == null) {
btreePlusElementMgr.newRootNonTerminalPage(nonTerminalPage,
middleKey, newNonTerminalPage);
+ newNonTerminalPage = null;
} else {
if (parent.add(nonTerminalPage, middleKey, newNonTerminalPage)) {
newNonTerminalPage = null;
} else {
- newNonTerminalPage = nonTerminalPage.split();
+ newNonTerminalPage = parent.split();
+ middleKey = parent.getAndClearMiddleKey();
+ // ASSERTX
+ assert middleKey != null;
+ nonTerminalPage = parent;
}
}
} while (newNonTerminalPage != 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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -306,21 +306,26 @@
final IPageRecordable pageRecordable) throws HeapException {
long pageNumber = header.getPageNumberOfFirstFreePage();
boolean newPage;
+ final long previousRecordPositionInFile;
if (pageNumber == -1) {
newPage = true;
pageNumber = header.getFileSizeAsNumberOfPage();
+ previousRecordPositionInFile = header.getLastRecordPositionInFile();
} else {
newPage = false;
final FreePage freePage = (FreePage) ((PageRecord) heapElementManager
.readHeapFileDataRecord(pageNumber << PageConstant.PAGE_BITS))
.getPageRecordable();
header.setPageNumberOfFirstFreePage(freePage.getNextFreePage());
+ previousRecordPositionInFile = freePage
+ .getPreviousRecordPositionInFile();
}
final IPageRecord pageRecord = new PageRecord(heapElementManager,
- pageRecordable, pageNumber);
+ previousRecordPositionInFile, pageRecordable, pageNumber);
if (newPage) {
header.setFileSizeAsNumberOfPage(pageNumber
+ pageRecord.getNumberOfPage());
+ header.setLastRecordPositionInFile(pageNumber << PageConstant.PAGE_BITS);
} else {
// ASSERTX
assert pageRecord.getNumberOfPage() == 1;
@@ -338,8 +343,10 @@
final long freePageNumber = header.getPageNumberOfFirstFreePage();
FreePage freePage = new FreePage(freePageNumber);
final long newFreePageNumber = pageRecord.getPageNumber();
- PageRecord pageRecord2 = new PageRecord(heapElementManager, freePage,
- newFreePageNumber);
+ final long previousRecordPositionInFile = pageRecord
+ .getPreviousRecordPositionInFile();
+ PageRecord pageRecord2 = new PageRecord(heapElementManager,
+ previousRecordPositionInFile, freePage, newFreePageNumber);
freePage.setPageRecord(pageRecord2);
freePage.setValueIsChangedValueToSave();
heapElementManager.appendHeapFileRecord(pageRecord2);
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-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -334,7 +334,9 @@
}
private int byteSize(final int numberOfKeyEntries) {
- int byteSize = 1/* byte size for record type */+
+ int byteSize =
+ /**/8/* byte size for previous record position */+
+ /**/1/* byte size for record type */+
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
/**/(numberOfKeyEntries + 1/* for next */) * 8/*
@@ -345,6 +347,6 @@
}
private int maxNumberOfEntries() {
- return (int) ((PageConstant.PAGE_SIZE - (1 + 4 + 4 + 8)) / (8 * 2));
+ return (int) ((PageConstant.PAGE_SIZE - (8 + 1 + 4 + 4 + 8)) / (8 * 2));
}
}
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-04-30 05:17:03 UTC (rev 3052)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java 2012-05-01 07:39:04 UTC (rev 3053)
@@ -539,7 +539,9 @@
}
private int byteSize(final int numberOfKeyEntries) {
- int xbyteSize = 1/* byte size for record type */+
+ int xbyteSize =
+ /**/8/* byte size for previous record position */+
+ /**/1/* byte size for record type */+
/**/4/* int size for number of entries */+
/**/4/* int size for crc32 */+
/**/numberOfKeyEntries * 8/* key entries */+
@@ -549,6 +551,6 @@
}
private int maxNumberOfEntries() {
- return (int) ((PageConstant.PAGE_SIZE - (1 + 4 + 4 + 8)) / (8 * 2));
+ return (int) ((PageConstant.PAGE_SIZE - (8 + 1 + 4 + 4 + 8)) / (8 * 2));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-05-01 07:39:11
|
Revision: 3053
http://joafip.svn.sourceforge.net/joafip/?rev=3053&view=rev
Author: luc_peuvrier
Date: 2012-05-01 07:39:04 +0000 (Tue, 01 May 2012)
Log Message:
-----------
WIP btree plus: tests OK : WIP check and optimization
Modified Paths:
--------------
trunk/joafip-4test/pom.xml
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/resources/log4j.properties
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractElement.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/LeafPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/NonTerminalPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/LeafPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/NonTerminalPageTest.java
Added Paths:
-----------
trunk/joafip-4test/jrat.xml
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractDeleter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/CreateDeleteList.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/DeleterBtreePlus.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBtreePlus.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBtreePlus.java
Property Changed:
----------------
trunk/joafip-4test/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-30 05:17:10
|
Revision: 3052
http://joafip.svn.sourceforge.net/joafip/?rev=3052&view=rev
Author: luc_peuvrier
Date: 2012-04-30 05:17:03 +0000 (Mon, 30 Apr 2012)
Log Message:
-----------
WIP btree plus: clean up after tests
Modified Paths:
--------------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java 2012-04-29 23:23:20 UTC (rev 3051)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java 2012-04-30 05:17:03 UTC (rev 3052)
@@ -84,10 +84,6 @@
} else {
opData = dataFromString(opElt[2]);
}
- // FIXMELUC ___________________tests
- if (lineNumber == 40) {
- System.out.println();
- }
final byte[] read = heapDataManager
.readDataRecord(dataRecordIdentifier);
if (opData == null) {
@@ -107,10 +103,6 @@
assertEquals(lineNumber + ": bad id created",
dataRecordIdentifier, newId);
} else if ("write".equals(instruction)) {
- // FIXMELUC ___________________tests
- if (lineNumber == 13) {
- System.out.println();
- }
final DataRecordIdentifier dataRecordIdentifier =
/**/new DataRecordIdentifier(Integer.parseInt(opElt[1]));// NOPMD
final byte[] opData = dataFromString(opElt[2]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-30 05:17:10
|
Revision: 3052
http://joafip.svn.sourceforge.net/joafip/?rev=3052&view=rev
Author: luc_peuvrier
Date: 2012-04-30 05:17:03 +0000 (Mon, 30 Apr 2012)
Log Message:
-----------
WIP btree plus: clean up after tests
Modified Paths:
--------------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.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 23:23:26
|
Revision: 3051
http://joafip.svn.sourceforge.net/joafip/?rev=3051&view=rev
Author: luc_peuvrier
Date: 2012-04-29 23:23:20 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
todo update
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 23:23:26
|
Revision: 3051
http://joafip.svn.sourceforge.net/joafip/?rev=3051&view=rev
Author: luc_peuvrier
Date: 2012-04-29 23:23:20 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
todo update
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2012-04-29 23:06:57 UTC (rev 3050)
+++ trunk/joafip/doc/_todo.txt 2012-04-29 23:23:20 UTC (rev 3051)
@@ -35,6 +35,7 @@
- static field persistence feature removed because a non sense
- heap file project make able to create a map in file with a comparable key
- new joafip-pmap project, a file persisted tree map
+- heap data manager implemented in btree+
minor changes:
- added search last in red black tree manager
@@ -89,9 +90,18 @@
currently:
-------------------------------------------------------------------------------------
+btree+ implementation
+- problems with previous data record
+- management of leaf page link
+ - add to header first leaf page position
+ - check link to leaf page to next
+ - implement quick iterator
+- consistency check to add
+
storage in btree+
- performance tests when use as main store, then add usage option in file persistence builder
- replace HeapDataFileManager direct use and option for main joafip storage
+- replace internal use of HeapFileDataManager by BtreePlusDataManager
changes for garbage management because of autosave
- tests to add
@@ -124,6 +134,10 @@
collection apache and google
+-------------------------------------------------------------------------------------
+transactionnal:
+use of a log of changes, applies logs to main storage at commit
+-------------------------------------------------------------------------------------
BlockDataManger
- test performance with cache, if ok it is a good alternative but:
- big file, do not reuse free space
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 23:07:03
|
Revision: 3050
http://joafip.svn.sourceforge.net/joafip/?rev=3050&view=rev
Author: luc_peuvrier
Date: 2012-04-29 23:06:57 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: correction to make test pass, kept some problems, not yet stable
Modified Paths:
--------------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java
Modified: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java 2012-04-29 23:06:16 UTC (rev 3049)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.java 2012-04-29 23:06:57 UTC (rev 3050)
@@ -70,7 +70,9 @@
createHeap(true);
String operation;
+ int lineNumber = 0;
while ((operation = reader.readLine()) != null) {// NOPMD
+ lineNumber++;
final String[] opElt = operation.split(";");
final String instruction = opElt[0];
if ("read".equals(instruction)) {
@@ -82,12 +84,19 @@
} else {
opData = dataFromString(opElt[2]);
}
+ // FIXMELUC ___________________tests
+ if (lineNumber == 40) {
+ System.out.println();
+ }
final byte[] read = heapDataManager
.readDataRecord(dataRecordIdentifier);
if (opData == null) {
- assertNull("bad data read\n" + dataToString(read), read);
+ assertNull(lineNumber + ": bad data read\n"
+ + dataToString(read), read);
} else {
- assertTrue("bad data read\n" + dataToString(read), Arrays// NOPMD
+ assertTrue(lineNumber + ": bad data read "
+ + dataRecordIdentifier + "\n" + dataToString(read),
+ Arrays// NOPMD
.equals(opData, read));
}
} else if ("new".equals(instruction)) {
@@ -95,8 +104,13 @@
/**/new DataRecordIdentifier(Integer.parseInt(opElt[1]));// NOPMD
final DataRecordIdentifier newId = heapDataManager
.getNewDataRecordIdentifier();
- assertEquals("bad id created", dataRecordIdentifier, newId);
+ assertEquals(lineNumber + ": bad id created",
+ dataRecordIdentifier, newId);
} else if ("write".equals(instruction)) {
+ // FIXMELUC ___________________tests
+ if (lineNumber == 13) {
+ System.out.println();
+ }
final DataRecordIdentifier dataRecordIdentifier =
/**/new DataRecordIdentifier(Integer.parseInt(opElt[1]));// NOPMD
final byte[] opData = dataFromString(opElt[2]);
@@ -127,7 +141,11 @@
private String dataToString(final byte data[]) {
final StringBuilder builder = new StringBuilder();
- if (data != null) {
+ if (data == null) {
+ builder.append("null");
+ } else if (data.length == 0) {
+ builder.append("empty");
+ } else {
for (byte byteValue : data) {
builder.append(String.format("%02X", (int) byteValue));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-29 23:07:03
|
Revision: 3050
http://joafip.svn.sourceforge.net/joafip/?rev=3050&view=rev
Author: luc_peuvrier
Date: 2012-04-29 23:06:57 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: correction to make test pass, kept some problems, not yet stable
Modified Paths:
--------------
trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrWithScenario.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 23:06:22
|
Revision: 3049
http://joafip.svn.sourceforge.net/joafip/?rev=3049&view=rev
Author: luc_peuvrier
Date: 2012-04-29 23:06:16 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: correction to make test pass, kept some problems, not yet stable
Modified Paths:
--------------
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/HeaderPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.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/DataBlockPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.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 23:06:22
|
Revision: 3049
http://joafip.svn.sourceforge.net/joafip/?rev=3049&view=rev
Author: luc_peuvrier
Date: 2012-04-29 23:06:16 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: correction to make test pass, kept some problems, not yet stable
Modified Paths:
--------------
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/HeaderPage.java
trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.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/DataBlockPageTest.java
trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/AbstractPageRecord.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -24,13 +24,13 @@
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;
+import net.sf.joafip.kvstore.record.entity.DataRecordKey;
import net.sf.joafip.kvstore.record.entity.IDataRecordKey;
import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.IFileForStorable;
/**
*
@@ -40,16 +40,14 @@
@NotStorableClass
public abstract class AbstractPageRecord extends AbstractFileStorable {
- public AbstractPageRecord(final IFileForStorable fileForStorable,
+ protected final IHeapElementManager heapElementManager;
+
+ public AbstractPageRecord(final IHeapElementManager heapElementManager,
final long positionInFile) {
- super(fileForStorable, positionInFile);
+ super(heapElementManager.getFileForStorable(), positionInFile);
+ this.heapElementManager = heapElementManager;
}
- @Override
- protected void valueChangedAction() throws HeapException {
- // no implementation
- }
-
protected EnumRecordType readRecordType() throws HeapException {
final int typeIdentifier = readByte() & 0xff;
return EnumRecordType.get(typeIdentifier);
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlock.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -98,6 +98,16 @@
}
@Override
+ public int getSize() {
+ return size;
+ }
+
+ @Override
+ public void setSize(final int size) {
+ this.size = size;
+ }
+
+ @Override
public void setData(final byte[] data) throws HeapException {
System.arraycopy(data, 0, this.data, 0, size = data.length);
setValueIsChangedValueToSave();
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/DataBlockPage.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -44,7 +44,7 @@
private final int numberOfPage;
- private final int dataBlockDataSize;
+ private final int dataBlockSize;
private final IDataBlock[] dataBlocks;
@@ -63,11 +63,12 @@
public DataBlockPage(final byte bits) {
super();
this.bits = bits;
- dataBlockDataSize = 1 << bits;
- if (dataBlockDataSize > PageConstant.PAGE_SIZE - HEAD_TAIL_SIZE) {
+ final int maxSize = 1 << bits;
+ dataBlockSize = maxSize + 4/* for data size */;
+ if (dataBlockSize > PageConstant.PAGE_SIZE - HEAD_TAIL_SIZE) {
// one data block on one or more pages
numberOfBlock = 1;
- final int totalSize = HEAD_TAIL_SIZE + dataBlockDataSize;
+ final int totalSize = HEAD_TAIL_SIZE + dataBlockSize;
final int n = totalSize >> PageConstant.PAGE_BITS;
if ((totalSize & PageConstant.IN_PAGE_POSITION_MASK) == 0) {
numberOfPage = n;
@@ -82,14 +83,15 @@
numberOfPage = 1;
// numberOfBlock = ((int)PageConstant.PAGE_SIZE - FIX_VALUE_SIZE)
// / dataBlockDataSize;
- numberOfBlock = ((int) PageConstant.PAGE_SIZE - HEAD_TAIL_SIZE) >> bits;
+ numberOfBlock = ((int) PageConstant.PAGE_SIZE - HEAD_TAIL_SIZE)
+ / dataBlockSize;
}
final int minSize = bits == PageConstant.MIN_DATA_BLOCK_BITS ? 0
: ((1 << (bits - 1)) + 1);
dataBlocks = new DataBlock[numberOfBlock];
for (int dataBlockIndex = 0; dataBlockIndex < numberOfBlock; dataBlockIndex++) {
dataBlocks[dataBlockIndex] = new DataBlock(this, dataBlockIndex,
- bits, minSize, dataBlockDataSize);
+ bits, minSize, maxSize);
}
}
@@ -115,9 +117,7 @@
@Override
public int getByteSize() {
- return numberOfPage * (int) PageConstant.PAGE_SIZE;
- // FIXMELUC ________use <<
- // return numberOfPage <<PageConstant.PAGE_BITS
+ return numberOfPage << PageConstant.PAGE_BITS;
}
public int getNumberOfBlock() {
@@ -129,20 +129,20 @@
}
public IDataBlock getDataBlock(final long dataBlockPosition) {
- // >> bits as divide by data block size
- final int index = ((int) (dataBlockPosition - getPositionInFile()) - HEAD_SIZE) >> bits;
+ final int index = ((int) (dataBlockPosition - getPositionInFile()) - HEAD_SIZE)
+ / dataBlockSize;
return dataBlocks[index];
}
public long getPositionInFile(final int index) {
- return getPositionInFile() + HEAD_SIZE + (index << bits);
+ return getPositionInFile() + HEAD_SIZE + index * dataBlockSize;
}
public void setAllFree() throws HeapException {
- long nextPosition = getPositionInFile() + HEAD_SIZE + dataBlockDataSize;
+ long nextPosition = getPositionInFile() + HEAD_SIZE + dataBlockSize;
for (int index = 0; index < dataBlocks.length - 1; index++) {
dataBlocks[index].setNextFreeDataBlockPositionOfFree(nextPosition);
- nextPosition += dataBlockDataSize;
+ nextPosition += dataBlockSize;
}
dataBlocks[dataBlocks.length - 1]
.setNextFreeDataBlockPositionOfFree(-1L);
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/HeaderPage.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -26,8 +26,8 @@
import java.util.Arrays;
import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.IFileForStorable;
/**
*
@@ -48,10 +48,15 @@
private long nextDataRecordIdentifier;
- public HeaderPage(final IFileForStorable fileForStorable) {
- super(fileForStorable, 0L);
+ public HeaderPage(final IHeapElementManager heapElementManager) {
+ super(heapElementManager, 0L);
}
+ @Override
+ protected void valueChangedAction() throws HeapException {
+ // no implementation
+ }
+
public long getFileSizeAsNumberOfPage() {
return fileSizeAsNumberOfPage;
}
Modified: 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 2012-04-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/IDataBlock.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -70,4 +70,8 @@
LeafPage getParentLeafPage();
int getIndexInLeafPage();
+
+ int getSize();
+
+ void setSize(int size);
}
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/entity/PageRecord.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -25,8 +25,8 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.IFileForStorable;
/**
*
@@ -45,23 +45,31 @@
/**
* creation for reading
*
- * @param fileForStorable
+ * @param heapElementManager
* @param pageNumber
*/
- public PageRecord(final IFileForStorable fileForStorable,
+ public PageRecord(final IHeapElementManager heapElementManager,
final long pageNumber) {
- super(fileForStorable, pageNumber << PageConstant.PAGE_BITS);
+ super(heapElementManager, pageNumber << PageConstant.PAGE_BITS);
this.pageNumber = pageNumber;
}
- public PageRecord(final IFileForStorable fileForStorable,
+ public PageRecord(final IHeapElementManager heapElementManager,
final IPageRecordable pageRecordable, final long pageNumber) {
- super(fileForStorable, pageNumber << PageConstant.PAGE_BITS);
+ super(heapElementManager, pageNumber << PageConstant.PAGE_BITS);
this.pageNumber = pageNumber;
this.pageRecordable = pageRecordable;
this.recordType = pageRecordable.getRecordType();
}
+ @Override
+ protected void valueChangedAction() throws HeapException {
+ /*
+ * is to be saved
+ */
+ heapElementManager.appendHeapFileRecord(this);
+ }
+
public EnumRecordType getRecordType() {
return recordType;
}
@@ -240,6 +248,7 @@
* PageConstant.PAGE_SIZE;
final IDataBlock[] dataBlocks = dataBlockPage.getDataBlocks();
for (IDataBlock dataBlock : dataBlocks) {
+ writeInteger(dataBlock.getSize());
writeBytes(dataBlock.getDataHolder());
}
writeCrc32();
@@ -258,6 +267,7 @@
}
final IDataBlock[] dataBlocks = dataBlockPage.getDataBlocks();
for (IDataBlock dataBlock : dataBlocks) {
+ dataBlock.setSize(readInteger());
readBytes(dataBlock.getDataHolder());
}
readAndCheckCrc32();
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusDataManager.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -513,7 +513,7 @@
page = null;
} else {
page = root;
- while (!EnumRecordType.LEAF_PAGE.equals(page)) {
+ while (!EnumRecordType.LEAF_PAGE.equals(page.getRecordType())) {
final NonTerminalPage nonTerminalPage = (NonTerminalPage) page;
final int index = nonTerminalPage
.getIndex(dataRecordIdentifier);
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/main/java/net/sf/joafip/btreeplus/service/BtreePlusElementMgr.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -67,7 +67,7 @@
throws HeapException {
super();
this.heapElementManager = heapElementManager;
- header = new HeaderPage(heapElementManager.getFileForStorable());
+ header = new HeaderPage(heapElementManager);
heapElementManager.setHeapRecordFactory(this);
heapElementManager.setHeapHeader(header);
fileForStorable = heapElementManager.getFileForStorable();
@@ -123,7 +123,7 @@
final long positionInFile) throws HeapException {
// ASSERTX
assert (positionInFile & PageConstant.IN_PAGE_POSITION_MASK) == 0;
- return new PageRecord(fileForStorable,
+ return new PageRecord(heapElementManager,
(int) (positionInFile >> PageConstant.PAGE_BITS));
}
@@ -230,7 +230,9 @@
final IDataBlock dataBlock) throws HeapException {
final LeafPage leafPage = new LeafPage(1);
appendPageRecordable(leafPage);
- leafPage.setDataBlock(0, dataBlock);
+ // leafPage.setDataBlock(0, dataBlock);
+ leafPage.setEntry(0, dataBlock.getPositionInFile(),
+ dataRecordIdentifier);
leafPage.setNext(-1L);
leafPage.updateByteSize();
leafPage.setValueIsChangedValueToSave();
@@ -314,7 +316,7 @@
.getPageRecordable();
header.setPageNumberOfFirstFreePage(freePage.getNextFreePage());
}
- final IPageRecord pageRecord = new PageRecord(fileForStorable,
+ final IPageRecord pageRecord = new PageRecord(heapElementManager,
pageRecordable, pageNumber);
if (newPage) {
header.setFileSizeAsNumberOfPage(pageNumber
@@ -336,7 +338,7 @@
final long freePageNumber = header.getPageNumberOfFirstFreePage();
FreePage freePage = new FreePage(freePageNumber);
final long newFreePageNumber = pageRecord.getPageNumber();
- PageRecord pageRecord2 = new PageRecord(fileForStorable, freePage,
+ PageRecord pageRecord2 = new PageRecord(heapElementManager, freePage,
newFreePageNumber);
freePage.setPageRecord(pageRecord2);
freePage.setValueIsChangedValueToSave();
Modified: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/DataBlockPageTest.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/DataBlockPageTest.java 2012-04-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/DataBlockPageTest.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -60,7 +60,7 @@
dataBlockPage.setPageRecord(pageRecord);
final int numberOfBlock = dataBlockPage.getNumberOfBlock();
- final int blockByteSize = 1 << bits;
+ final int blockByteSize = (1 << bits) + 4/* int for data length */;
final long dataAreaSize = PageConstant.PAGE_SIZE
- DataBlockPage.HEAD_SIZE;
final int numberOfPage = (int) ((blockByteSize <= dataAreaSize) ? 1
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-29 21:13:04 UTC (rev 3048)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/entity/mock/MockDataBlock.java 2012-04-29 23:06:16 UTC (rev 3049)
@@ -115,4 +115,13 @@
public int getIndexInLeafPage() {
return 0;
}
+
+ @Override
+ public int getSize() {
+ return 0;
+ }
+
+ @Override
+ public void setSize(final int size) {
+ }
}
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:13
|
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
Added: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataManagerBackup.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataManagerBackup.java (rev 0)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataManagerBackup.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,67 @@
+/*
+ * 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.DoNotTransform;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+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 TestBtreePlusDataManagerBackup extends
+ AbstractTestHeapDataManagerBackup {
+
+ public TestBtreePlusDataManagerBackup() throws TestException {
+ super();
+ }
+
+ public TestBtreePlusDataManagerBackup(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected IHeapDataManager createHeapDataManager(final HeapFileSetup setup)
+ throws HeapException {
+ return new BtreePlusDataManager(setup);
+ }
+
+ @Override
+ protected void createHeap(final boolean removeFile) throws HeapException {
+ createFileHeapDataManager(removeFile);
+ }
+
+ @Override
+ protected boolean manageFreeRecord() {
+ return true;
+ }
+
+ @Override
+ protected void checkIntegrity() throws HeapException {
+ }
+}
Added: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrMemoryLeak.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrMemoryLeak.java (rev 0)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrMemoryLeak.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,78 @@
+/*
+ * 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.DoNotTransform;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.AbstractTestHeapDataManager;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@DoNotTransform
+public class TestBtreePlusDataMgrMemoryLeak extends AbstractTestHeapDataManager {
+
+ public TestBtreePlusDataMgrMemoryLeak() throws TestException {
+ super();
+ }
+
+ public TestBtreePlusDataMgrMemoryLeak(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected void createHeap(final boolean removeFile) throws HeapException {
+ createFileHeapDataManager(removeFile);
+ }
+
+ @Override
+ protected boolean manageFreeRecord() {
+ return true;
+ }
+
+ @Override
+ protected void setUp() throws Exception {// NOPMD
+ super.setUp();
+ createHeap(true);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {// NOPMD
+ super.tearDown();
+ }
+
+ @Override
+ protected IHeapDataManager createHeapDataManager(final HeapFileSetup setup)
+ throws HeapException {
+ return new BtreePlusDataManager(setup);
+ }
+}
Added: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithKey.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithKey.java (rev 0)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithKey.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,66 @@
+/*
+ * 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.btreeplus.service;
+
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.kvstore.entity.HeapFileSetup;
+import net.sf.joafip.kvstore.service.AbstractTesDataMgrWithKey;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@NoStorableAccess
+public class TestBtreePlusDataMgrWithKey extends AbstractTesDataMgrWithKey {
+
+ public TestBtreePlusDataMgrWithKey() throws TestException {
+ super();
+ }
+
+ public TestBtreePlusDataMgrWithKey(final String name) throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected IHeapDataManager createHeapDataManager(final HeapFileSetup setup)
+ throws HeapException {
+ return new BtreePlusDataManager(setup);
+ }
+
+ @Override
+ protected void createHeap(final boolean removeFile) throws HeapException {
+ // not implemented
+ }
+
+ @Override
+ protected boolean manageFreeRecord() {
+ // not implemented
+ return false;
+ }
+}
Added: trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithScenario.java
===================================================================
--- trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithScenario.java (rev 0)
+++ trunk/joafip-btreeplus/src/test/java/net/sf/joafip/btreeplus/service/TestBtreePlusDataMgrWithScenario.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2010 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.btreeplus.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.AbstractTestDataMgrWithScenario;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@DoNotTransform
+public class TestBtreePlusDataMgrWithScenario extends
+ AbstractTestDataMgrWithScenario {
+
+ public TestBtreePlusDataMgrWithScenario() throws TestException {
+ super();
+ }
+
+ public TestBtreePlusDataMgrWithScenario(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ @Override
+ protected IHeapDataManager createHeapDataManager(final HeapFileSetup setup)
+ throws HeapException {
+ return new BtreePlusDataManager(setup);
+ }
+
+ @Override
+ protected void createHeap(final boolean removeFile) throws HeapException {
+ createFileHeapDataManager(removeFile);
+ }
+
+ @Override
+ protected boolean manageFreeRecord() {
+ return true;
+ }
+
+ @Override
+ protected void checkIntegrity() throws HeapException {
+ }
+}
Deleted: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java 2012-04-29 20:16:53 UTC (rev 3047)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -1,59 +0,0 @@
-/*
- * Copyright 2012 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.heapfile.record.service;
-
-import java.util.Comparator;
-
-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
- *
- * @param <K>
- */
-@NotStorableClass
-public abstract class AbstractDataRecordKeyComparator<K extends Comparable<K>>
- implements IDataRecordKeyManager {
-
- private final Comparator<? super K> comparator;
-
- public AbstractDataRecordKeyComparator(
- final Comparator<? super K> comparator) {
- super();
- this.comparator = comparator;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public int compareDataRecordKey(final IDataRecordKey dataRecordKey1,
- final IDataRecordKey dataRecordKey2) throws HeapException {
- final K key1 = (K) dataRecordKey1.getKey();
- final K key2 = (K) dataRecordKey2.getKey();
- return comparator == null ? key1.compareTo(key2) : comparator.compare(
- key1, key2);
- }
-}
Deleted: 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-29 20:16:53 UTC (rev 3047)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -1,93 +0,0 @@
-/*
- * Copyright 2012 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.heapfile.record.service;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Comparator;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.entity.DataRecordKey;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-@SuppressWarnings("rawtypes")
-public class DataRecordKeyManager extends AbstractDataRecordKeyComparator {
-
- private static final DataRecordKeyManager INSTANCE = new DataRecordKeyManager();
-
- public static DataRecordKeyManager getInstance() {
- return INSTANCE;
- }
-
- @SuppressWarnings("unchecked")
- private DataRecordKeyManager() {
- super(null);
- }
-
- @SuppressWarnings("unchecked")
- protected DataRecordKeyManager(final Comparator comparator) {
- super(comparator);
- }
-
- @Override
- public Comparable<?> unmarshall(final byte[] keyData) throws HeapException {
- try {
- final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
- keyData);
- final ObjectInputStream objectInputStream = new ObjectInputStream(
- byteArrayInputStream);
- final Object result = objectInputStream.readObject();
- objectInputStream.close();
- return (Comparable<?>) result;
- } catch (Exception exception) {
- throw new HeapException("unmarshalling key", exception);
- }
- }
-
- @Override
- public DataRecordIdentifier createKey(final Object key)
- throws HeapException {
- try {
- final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
- final ObjectOutputStream outputStream = new ObjectOutputStream(
- byteArrayOutputStream);
- outputStream.writeObject(key);
- outputStream.close();
- final byte[] keyData = byteArrayOutputStream.toByteArray();
- final DataRecordKey dataRecordKey = new DataRecordKey(this, keyData);
- dataRecordKey.setKey(key);
- return new DataRecordIdentifier(dataRecordKey);
- } catch (Exception exception) {
- throw new HeapException("creating key", exception);
- }
- }
-}
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 20:16:53 UTC (rev 3047)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -16,21 +16,17 @@
*/
package net.sf.joafip.heapfile.service;
-import net.sf.joafip.HelperMemoryUse;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.AbstractTestHeapDataManager;
+import net.sf.joafip.kvstore.service.AbstractTestDataMgrMemoryLeak;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@NotStorableClass
-public class TestHeapFileDataMgrMemoryLeak extends AbstractTestHeapDataManager {
+public class TestHeapFileDataMgrMemoryLeak extends
+ AbstractTestDataMgrMemoryLeak {
- private static final HelperMemoryUse helperMemoryUse = HelperMemoryUse // NOPMD
- .getInstance();
-
public TestHeapFileDataMgrMemoryLeak() throws TestException {
super();
}
@@ -66,25 +62,4 @@
throws HeapException {
return new HeapFileDataManager(setup, false);
}
-
- /**
- * NOTE jmv: very slow on Linux<br>
- * RESPONSE luc: on windows xp jvm to.<br>
- * because of a lot of data record wrote in file<br>
- * take 187 seconds Intel Core 2 Duo E6320 1.86GHz with sun 32 bits jvm<br>
- */
- public void test() throws HeapException { // NOPMD
- helperMemoryUse.log("start");
- for (int i = 0; i < 1000; i++) {
- final DataRecordIdentifier identifier = heapDataManager
- .getNewDataRecordIdentifier();
- final byte[] data = new byte[100];// NOPMD
- heapDataManager.writeDataRecord(identifier, data);
-
- heapDataManager.flush();
- if (i % 10 == 9) {
- helperMemoryUse.log("created " + (i + 1));
- }
- }
- }
}
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 20:16:53 UTC (rev 3047)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -25,10 +25,8 @@
import net.sf.joafip.NoStorableAccess;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.record.service.DataRecordKeyManager;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.AbstractTestHeapDataManager;
+import net.sf.joafip.kvstore.service.AbstractTesDataMgrWithKey;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@@ -39,7 +37,7 @@
*/
@NotStorableClass
@NoStorableAccess
-public class TestHeapFileDataMgrWithKey extends AbstractTestHeapDataManager {
+public class TestHeapFileDataMgrWithKey extends AbstractTesDataMgrWithKey {
public TestHeapFileDataMgrWithKey() throws TestException {
super();
@@ -65,20 +63,4 @@
// not implemented
return false;
}
-
- public void testUseAsAMap() throws HeapException {
- final DataRecordKeyManager keyManager = DataRecordKeyManager
- .getInstance();
- createFileHeapDataManager(true);
- heapDataManager.setDataRecordKeyComparator(keyManager);
- final DataRecordIdentifier keyA = keyManager.createKey("A");
- assertFalse("must not found 'A'", heapDataManager.hasDataRecord(keyA));
- final byte[] dataA = "valueA".getBytes();
- heapDataManager.writeDataRecord(keyA, dataA);
- assertTrue("must found 'A'", heapDataManager.hasDataRecord(keyA));
- final byte[] readDataA = heapDataManager.readDataRecord(keyA);
- assertNotNull("must read 'A' data", readDataA);
- assertEquals("bad value", "valueA", new String(readDataA));
- }
-
}
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 20:16:53 UTC (rev 3047)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -22,18 +22,11 @@
*/
package net.sf.joafip.heapfile.service;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-
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.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.service.AbstractTestHeapDataManagerRecord;
+import net.sf.joafip.kvstore.service.AbstractTestDataMgrWithScenario;
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.kvstore.service.IHeapDataManager;
@@ -45,7 +38,7 @@
@NotStorableClass
@DoNotTransform
public class TestHeapFileDataMgrWithScenario extends
- AbstractTestHeapDataManagerRecord {
+ AbstractTestDataMgrWithScenario {
public TestHeapFileDataMgrWithScenario() throws TestException {
super();
@@ -77,87 +70,4 @@
HeapFileDataManagerIntegrityChecker.getInstance().checkIntegrity(
heapDataManager);
}
-
- public void test1() throws NumberFormatException, HeapException,// NOPMD
- IOException {
- testFromFile("scenario1.txt");
- }
-
- private void testFromFile(final String fileName) throws HeapException,
- NumberFormatException, IOException {
- final String name = getClass().getPackage().getName().replace('.', '/')
- + "/" + fileName;
- final InputStream inputStream = ClassLoader
- .getSystemResourceAsStream(name);
- assertNotNull("resource " + name + " not found", inputStream);
- final BufferedReader reader = new BufferedReader(new InputStreamReader(
- inputStream));
-
- createHeap(true);
- String operation;
- while ((operation = reader.readLine()) != null) {// NOPMD
- final String[] opElt = operation.split(";");
- final String instruction = opElt[0];
- if ("read".equals(instruction)) {
- final DataRecordIdentifier dataRecordIdentifier =
- /**/new DataRecordIdentifier(Integer.parseInt(opElt[1]));// NOPMD
- final byte[] opData;
- if (opElt.length < 3) {
- opData = null;
- } else {
- opData = dataFromString(opElt[2]);
- }
- final byte[] read = heapDataManager
- .readDataRecord(dataRecordIdentifier);
- if (opData == null) {
- assertNull("bad data read\n" + dataToString(read), read);
- } else {
- assertTrue("bad data read\n" + dataToString(read), Arrays// NOPMD
- .equals(opData, read));
- }
- } else if ("new".equals(instruction)) {
- final DataRecordIdentifier dataRecordIdentifier =
- /**/new DataRecordIdentifier(Integer.parseInt(opElt[1]));// NOPMD
- final DataRecordIdentifier newId = heapDataManager
- .getNewDataRecordIdentifier();
- assertEquals("bad id created", dataRecordIdentifier, newId);
- } else if ("write".equals(instruction)) {
- final DataRecordIdentifier dataRecordIdentifier =
- /**/new DataRecordIdentifier(Integer.parseInt(opElt[1]));// NOPMD
- final byte[] opData = dataFromString(opElt[2]);
- heapDataManager.writeDataRecord(dataRecordIdentifier, opData);
- } else if ("flush".equals(instruction)) {
- heapDataManager.flush();
- HeapFileDataManagerIntegrityChecker.getInstance()
- .checkIntegrity(heapDataManager);
- }
- }
- closeHeap();
- reader.close();
- }
-
- private byte[] dataFromString(final String string) {
- final int length = string.length();
- final byte[] data;
- if (length == 0) {
- data = null;
- } else {
- data = new byte[length / 2];
- for (int index = 0; index < length; index += 2) {
- data[index / 2] = (byte) Integer.parseInt(
- string.substring(index, index + 2), 16);
- }
- }
- return data;
- }
-
- private String dataToString(final byte data[]) {
- final StringBuilder builder = new StringBuilder();
- if (data != null) {
- for (byte byteValue : data) {
- builder.append(String.format("%02X", (int) byteValue));
- }
- }
- return builder.toString();
- }
}
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/scenario1.txt
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/scenario1.txt 2012-04-29 20:16:53 UTC (rev 3047)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/scenario1.txt 2012-04-29 21:13:04 UTC (rev 3048)
@@ -1,145 +0,0 @@
-writeAlwaysEnable;false
-writeEnable;true
-read;0;
-new;0
-write;0;FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC000FFFFFFC600
-flush
-read;1;
-writeEnable;true
-new;1
-writeEnable;true
-new;2
-new;3
-write;1;FFFFFFC2FFFFFF80000000FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC23AFFFFFFB41A3CFFFFFF880000000000000000FFFFFFC80000000000000002FFFFFFC200000001FFFFFF880000000000000000FFFFFF880000000000000000
-new;4
-new;5
-new;6
-write;2;FFFFFFC2FFFFFF80000001FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC21513FFFFFFC040FFFFFFC80000000000000004FFFFFF880000000000000000FFFFFFC80000000000000005FFFFFF880000000000000000
-new;7
-new;8
-write;4;FFFFFFC2FFFFFF80000002FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF84FFFFFFD1FFFFFF9422FFFFFF880000000000000000FFFFFFC80000000000000007
-new;9
-write;5;FFFFFFC2FFFFFF80000003FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFB75CFFFFFFBE29FFFFFFC80000000000000002
-new;10
-new;11
-new;12
-write;7;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC8000000000000000AFFFFFFC8000000000000000BFFFFFFC601FFFFFFC600FFFFFFC200000000FFFFFF880000000000000000
-new;13
-write;10;FFFFFFC2FFFFFF80000005FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFE0FFFFFFCBFFFFFFD76EFFFFFF880000000000000000
-new;14
-write;11;FFFFFFC2FFFFFF80000006FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC207FFFFFF944374FFFFFFC8000000000000000AFFFFFFC601FFFFFFC601
-write;0;FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC8000000000000000EFFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC000FFFFFFC600
-write;3;FFFFFFC200000000FFFFFF880000000000000000256E65742E73662E6A6F616669702E73746F72652E656E746974792E53746F7265526F6F74340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;6;FFFFFFC200000001FFFFFFC80000000000000003206E65742E73662E6A6F616669702E6A6176612E7574696C2E50547265654D617000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;8;FFFFFFC200000002FFFFFFC80000000000000006206E65742E73662E6A6F616669702E6A6176612E7574696C2E505472656553657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;9;FFFFFFC200000003FFFFFFC800000000000000082B6E65742E73662E6A6F616669702E6A6176612E7574696C2E4D6170436F6C6C656374696F6E56616C7565730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;12;FFFFFFC200000004FFFFFFC80000000000000009306E65742E73662E6A6F616669702E6A6176612E7574696C2E737570706F72742E747265652E54726565537570706F7274000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;13;FFFFFFC200000005FFFFFFC8000000000000000C3D6E65742E73662E6A6F616669702E726564626C61636B747265652E696D706C2E6D656D6F72792E736572766963652E5242544E6F64654D616E616765720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;14;FFFFFFC200000006FFFFFFC8000000000000000D2F6E65742E73662E6A6F616669702E726564626C61636B747265652E736572766963652E526564426C61636B5472656500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-flush
-read;1;FFFFFFC2FFFFFF80000000FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC23AFFFFFFB41A3CFFFFFF880000000000000000FFFFFFC80000000000000002FFFFFFC200000001FFFFFF880000000000000000FFFFFF880000000000000000
-writeEnable;true
-read;1;FFFFFFC2FFFFFF80000000FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC23AFFFFFFB41A3CFFFFFF880000000000000000FFFFFFC80000000000000002FFFFFFC200000001FFFFFF880000000000000000FFFFFF880000000000000000
-read;2;FFFFFFC2FFFFFF80000001FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC21513FFFFFFC040FFFFFFC80000000000000004FFFFFF880000000000000000FFFFFFC80000000000000005FFFFFF880000000000000000
-writeEnable;true
-read;2;FFFFFFC2FFFFFF80000001FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC21513FFFFFFC040FFFFFFC80000000000000004FFFFFF880000000000000000FFFFFFC80000000000000005FFFFFF880000000000000000
-read;4;FFFFFFC2FFFFFF80000002FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF84FFFFFFD1FFFFFF9422FFFFFF880000000000000000FFFFFFC80000000000000007
-read;5;FFFFFFC2FFFFFF80000003FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFB75CFFFFFFBE29FFFFFFC80000000000000002
-read;4;FFFFFFC2FFFFFF80000002FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF84FFFFFFD1FFFFFF9422FFFFFF880000000000000000FFFFFFC80000000000000007
-read;7;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC8000000000000000AFFFFFFC8000000000000000BFFFFFFC601FFFFFFC600FFFFFFC200000000FFFFFF880000000000000000
-read;7;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC8000000000000000AFFFFFFC8000000000000000BFFFFFFC601FFFFFFC600FFFFFFC200000000FFFFFF880000000000000000
-read;11;FFFFFFC2FFFFFF80000006FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC207FFFFFF944374FFFFFFC8000000000000000AFFFFFFC601FFFFFFC601
-read;11;FFFFFFC2FFFFFF80000006FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC207FFFFFF944374FFFFFFC8000000000000000AFFFFFFC601FFFFFFC601
-writeEnable;true
-new;15
-write;1;FFFFFFC2FFFFFF80000000FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC23AFFFFFFB41A3CFFFFFFC8000000000000000FFFFFFFC80000000000000002FFFFFFC200000001FFFFFF880000000000000000FFFFFF880000000000000000
-new;16
-new;17
-write;15;FFFFFFC2FFFFFF80000001FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC21513FFFFFFC040FFFFFFC80000000000000010FFFFFF880000000000000000FFFFFFC80000000000000011FFFFFF880000000000000000
-new;18
-write;16;FFFFFFC2FFFFFF80000002FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF84FFFFFFD1FFFFFF9422FFFFFF880000000000000000FFFFFFC80000000000000012
-write;17;FFFFFFC2FFFFFF80000003FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFB75CFFFFFFBE29FFFFFFC8000000000000000F
-new;19
-new;20
-write;18;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC80000000000000013FFFFFFC80000000000000014FFFFFFC601FFFFFFC600FFFFFFC200000000FFFFFF880000000000000000
-write;7;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC8000000000000000AFFFFFFC8000000000000000BFFFFFFC601FFFFFFC600FFFFFFC200000002FFFFFF880000000000000000
-write;19;FFFFFFC2FFFFFF80000005FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFE0FFFFFFCBFFFFFFD76EFFFFFF880000000000000000
-write;20;FFFFFFC2FFFFFF80000006FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC207FFFFFF944374FFFFFFC80000000000000013FFFFFFC601FFFFFFC601
-new;21
-write;10;FFFFFFC2FFFFFF80000005FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFE0FFFFFFCBFFFFFFD76EFFFFFFC80000000000000015
-new;22
-new;23
-new;24
-new;25
-write;21;FFFFFFC2FFFFFF80000007FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFF216FFFFFFC320FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC601FFFFFFC600FFFFFF880000000000000000FFFFFFC80000000000000016FFFFFFC80000000000000017FFFFFFC80000000000000018FFFFFF880000000000000000FFFFFFC200000001
-new;26
-write;22;FFFFFFC2FFFFFF80000008FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC271166B2CFFFFFFC80000000000000015
-new;27
-new;28
-new;29
-write;23;FFFFFFC2FFFFFF80000007FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFF216FFFFFFC320FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC600FFFFFFC600FFFFFFC80000000000000015FFFFFFC8000000000000001BFFFFFFC8000000000000001CFFFFFFC8000000000000001DFFFFFF880000000000000000FFFFFFC200000000
-new;30
-new;31
-new;32
-write;24;FFFFFFC2FFFFFF80000009FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF9DFFFFFFAEFFFFFFD5FFFFFFF1FFFFFF880000000000000000FFFFFFC8000000000000001EFFFFFFC8000000000000001F
-write;27;FFFFFFC2FFFFFF80000008FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC271166B2CFFFFFFC80000000000000017
-write;28;FFFFFFC2FFFFFF80000008FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC271166B2CFFFFFFC80000000000000017
-new;33
-new;34
-write;29;FFFFFFC2FFFFFF80000009FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF9DFFFFFFAEFFFFFFD5FFFFFFF1FFFFFF880000000000000000FFFFFFC80000000000000021FFFFFFC80000000000000022
-new;35
-new;36
-write;30;FFFFFFC2FFFFFF8000000AFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFB966FFFFFFD5FFFFFFD7FFFFFFC80000000000000023
-new;37
-write;31;FFFFFFC2FFFFFF8000000BFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC200000010FFFFFFC70069FFFFFFC70074FFFFFFC70065FFFFFFC7006DFFFFFFC70054FFFFFFC70065FFFFFFC7006DFFFFFFC70070FFFFFFC7006CFFFFFFC70061FFFFFFC70074FFFFFFC70065FFFFFFC7004CFFFFFFC70069FFFFFFC70073FFFFFFC70074
-new;38
-new;39
-write;33;FFFFFFC2FFFFFF8000000CFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC22F08713DFFFFFFC80000000000000026
-write;34;FFFFFFC2FFFFFF8000000BFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC200000008FFFFFFC70069FFFFFFC70074FFFFFFC70065FFFFFFC7006DFFFFFFC7004CFFFFFFC70069FFFFFFC70073FFFFFFC70074
-new;40
-new;41
-new;42
-write;35;FFFFFFC2FFFFFF8000000DFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFBDFFFFFFA40600FFFFFFC80000000000000028FFFFFFC80000000000000029FFFFFF880000000000000000FFFFFF880000000000000000
-new;43
-new;44
-write;38;FFFFFFC2FFFFFF80000001FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC21513FFFFFFC040FFFFFFC8000000000000002BFFFFFF880000000000000000FFFFFFC8000000000000002CFFFFFF880000000000000000
-new;45
-new;46
-write;40;FFFFFFC2FFFFFF8000000EFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFD11B43FFFFFFC0FFFFFFC8000000000000002DFFFFFF880000000000000000
-write;41;FFFFFFC2FFFFFF80000003FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFB75CFFFFFFBE29FFFFFFC80000000000000023
-new;47
-write;43;FFFFFFC2FFFFFF80000002FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF84FFFFFFD1FFFFFF9422FFFFFF880000000000000000FFFFFFC8000000000000002F
-write;44;FFFFFFC2FFFFFF80000003FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFB75CFFFFFFBE29FFFFFFC80000000000000026
-new;48
-new;49
-new;50
-new;51
-write;45;FFFFFFC2FFFFFF8000000FFFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC239FFFFFFE42420FFFFFFC80000000000000030FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC200000000FFFFFFC80000000000000031FFFFFFC80000000000000032
-new;52
-new;53
-write;47;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC80000000000000034FFFFFFC80000000000000035FFFFFFC601FFFFFFC600FFFFFFC200000000FFFFFF880000000000000000
-new;54
-write;48;FFFFFFC2FFFFFF80000010FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2396166FFFFFF80FFFFFFC8000000000000002DFFFFFF880000000000000000FFFFFFC200000000FFFFFF880000000000000000
-new;55
-new;56
-write;49;FFFFFFC2FFFFFF80000004FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFF87FFFFFF8465FFFFFFB3FFFFFF880000000000000000FFFFFFC80000000000000037FFFFFFC80000000000000038FFFFFFC600FFFFFFC600FFFFFFC200000000FFFFFF880000000000000000
-new;57
-write;50;FFFFFFC2FFFFFF80000011FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC26770FFFFFFED2DFFFFFF880000000000000000
-write;52;FFFFFFC2FFFFFF80000005FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFE0FFFFFFCBFFFFFFD76EFFFFFF880000000000000000
-write;53;FFFFFFC2FFFFFF80000006FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC207FFFFFF944374FFFFFFC80000000000000034FFFFFFC601FFFFFFC601
-write;55;FFFFFFC2FFFFFF80000005FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC2FFFFFFE0FFFFFFCBFFFFFFD76EFFFFFF880000000000000000
-write;56;FFFFFFC2FFFFFF80000006FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC207FFFFFF944374FFFFFFC80000000000000037FFFFFFC600FFFFFFC601
-write;0;FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC80000000000000039FFFFFF880000000000000000FFFFFF880000000000000000FFFFFF880000000000000000FFFFFFC000FFFFFFC600
-write;25;FFFFFFC200000007FFFFFFC8000000000000000E346E65742E73662E6A6F616669702E6A6176612E7574696C2E737570706F72742E747265652E54726565537570706F72744E6F64650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;26;FFFFFFC200000008FFFFFFC800000000000000192D6E65742E73662E6A6F616669702E726564626C61636B747265652E656E746974792E52425453656E74696E656C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;32;FFFFFFC200000009FFFFFFC8000000000000001A256E65742E73662E6A6F616669702E6A6176612E7574696C2E50547265654D6170456E7472790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;36;FFFFFFC20000000AFFFFFFC80000000000000020376E65742E73662E6A6F616669702E706572666F726D616E63652E6974656D732E656E746974792E4974656D54656D706C6174654C6973740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;37;FFFFFFC20000000BFFFFFFC80000000000000024106A6176612E6C616E672E537472696E670000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;39;FFFFFFC20000000CFFFFFFC800000000000000252F6E65742E73662E6A6F616669702E706572666F726D616E63652E6974656D732E656E746974792E4974656D4C69737400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;42;FFFFFFC20000000DFFFFFFC80000000000000027266E65742E73662E6A6F616669702E6A6176612E7574696C2E504C696E6B6564486173684D617000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;46;FFFFFFC20000000EFFFFFFC8000000000000002A266E65742E73662E6A6F616669702E6A6176612E7574696C2E504C696E6B65644861736853657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;51;FFFFFFC20000000FFFFFFFC8000000000000002E3D6E65742E73662E6A6F616669702E6A6176612E7574696C2E737570706F72742E6C696E6B65642E686173682E4C696E6B656448617368537570706F72740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;54;FFFFFFC200000010FFFFFFC80000000000000033436E65742E73662E6A6F616669702E6A6176612E7574696C2E737570706F72742E6C696E6B65646C6973742E4C696E6B65644C697374537570706F72744D616E616765720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-write;57;FFFFFFC200000011FFFFFFC800000000000000362E6E65742E73662E6A6F616669702E6A6176612E7574696C2E486173684D6170456E747279436F6D70617261746F720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
-flush
-read;1;FFFFFFC2FFFFFF80000000FFFFFFC10001FFFFFFC204000000FFFFFFC200000001FFFFFFC000FFFFFFC23AFFFFFFB41A3CFFFFFFC8000000000000000FFFFFFFC80000000000000002FFFFFFC200000001FFFFFF880000000000000000FFFFFF880000000000000000
Copied: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/AbstractDataRecordKeyComparator.java (from rev 3047, trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/AbstractDataRecordKeyComparator.java)
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/AbstractDataRecordKeyComparator.java (rev 0)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/AbstractDataRecordKeyComparator.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,58 @@
+/*
+ * 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.service;
+
+import java.util.Comparator;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.kvstore.record.entity.IDataRecordKey;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ * @param <K>
+ */
+@NotStorableClass
+public abstract class AbstractDataRecordKeyComparator<K extends Comparable<K>>
+ implements IDataRecordKeyManager {
+
+ private final Comparator<? super K> comparator;
+
+ public AbstractDataRecordKeyComparator(
+ final Comparator<? super K> comparator) {
+ super();
+ this.comparator = comparator;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public int compareDataRecordKey(final IDataRecordKey dataRecordKey1,
+ final IDataRecordKey dataRecordKey2) throws HeapException {
+ final K key1 = (K) dataRecordKey1.getKey();
+ final K key2 = (K) dataRecordKey2.getKey();
+ return comparator == null ? key1.compareTo(key2) : comparator.compare(
+ key1, key2);
+ }
+}
Copied: trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/DataRecordKeyManager.java (from rev 3047, trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/DataRecordKeyManager.java)
===================================================================
--- trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/DataRecordKeyManager.java (rev 0)
+++ trunk/joafip-kvstore/src/main/java/net/sf/joafip/kvstore/record/service/DataRecordKeyManager.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,93 @@
+/*
+ * 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.service;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Comparator;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.entity.DataRecordKey;
+import net.sf.joafip.kvstore.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@SuppressWarnings("rawtypes")
+public class DataRecordKeyManager extends AbstractDataRecordKeyComparator {
+
+ private static final DataRecordKeyManager INSTANCE = new DataRecordKeyManager();
+
+ public static DataRecordKeyManager getInstance() {
+ return INSTANCE;
+ }
+
+ @SuppressWarnings("unchecked")
+ private DataRecordKeyManager() {
+ super(null);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected DataRecordKeyManager(final Comparator comparator) {
+ super(comparator);
+ }
+
+ @Override
+ public Comparable<?> unmarshall(final byte[] keyData) throws HeapException {
+ try {
+ final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ keyData);
+ final ObjectInputStream objectInputStream = new ObjectInputStream(
+ byteArrayInputStream);
+ final Object result = objectInputStream.readObject();
+ objectInputStream.close();
+ return (Comparable<?>) result;
+ } catch (Exception exception) {
+ throw new HeapException("unmarshalling key", exception);
+ }
+ }
+
+ @Override
+ public DataRecordIdentifier createKey(final Object key)
+ throws HeapException {
+ try {
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ final ObjectOutputStream outputStream = new ObjectOutputStream(
+ byteArrayOutputStream);
+ outputStream.writeObject(key);
+ outputStream.close();
+ final byte[] keyData = byteArrayOutputStream.toByteArray();
+ final DataRecordKey dataRecordKey = new DataRecordKey(this, keyData);
+ dataRecordKey.setKey(key);
+ return new DataRecordIdentifier(dataRecordKey);
+ } catch (Exception exception) {
+ throw new HeapException("creating key", exception);
+ }
+ }
+}
Added: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTesDataMgrWithKey.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,63 @@
+/*
+ * 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.service;
+
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.service.DataRecordKeyManager;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@NoStorableAccess
+public abstract class AbstractTesDataMgrWithKey extends
+ AbstractTestHeapDataManager {
+
+ public AbstractTesDataMgrWithKey() throws TestException {
+ super();
+ }
+
+ public AbstractTesDataMgrWithKey(final String name) throws TestException {
+ super(name);
+ }
+
+ public void testUseAsAMap() throws HeapException {
+ final DataRecordKeyManager keyManager = DataRecordKeyManager
+ .getInstance();
+ createFileHeapDataManager(true);
+ heapDataManager.setDataRecordKeyComparator(keyManager);
+ final DataRecordIdentifier keyA = keyManager.createKey("A");
+ assertFalse("must not found 'A'", heapDataManager.hasDataRecord(keyA));
+ final byte[] dataA = "valueA".getBytes();
+ heapDataManager.writeDataRecord(keyA, dataA);
+ assertTrue("must found 'A'", heapDataManager.hasDataRecord(keyA));
+ final byte[] readDataA = heapDataManager.readDataRecord(keyA);
+ assertNotNull("must read 'A' data", readDataA);
+ assertEquals("bad value", "valueA", new String(readDataA));
+ }
+}
Added: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrMemoryLeak.java
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrMemoryLeak.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/AbstractTestDataMgrMemoryLeak.java 2012-04-29 21:13:04 UTC (rev 3048)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2012 Luc Peuvrier
+ * All rights reserved.
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.kvstore.service;
+
+import net.sf.joafip.HelperMemoryUse;
+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
+ *
+ */
+@NotStorabl...
[truncated message content] |
|
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 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 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: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: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 16:58:22
|
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
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerMultiFile.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerMultiFile.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestDataManagerMultiFile.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -22,7 +22,7 @@
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestConstant;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMultiFileDataManager;
+import net.sf.joafip.kvstore.service.HeapMultiFileDataManager;
/**
*
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/bug/savenum/TestEnumPersistenceMemory.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/bug/savenum/TestEnumPersistenceMemory.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/bug/savenum/TestEnumPersistenceMemory.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -31,7 +31,7 @@
import net.sf.joafip.TestException;
import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
import net.sf.joafip.entity.MutableInteger;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.service.FilePersistenceBuilder;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestSubstitutionWithMethodInterception.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestSubstitutionWithMethodInterception.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestSubstitutionWithMethodInterception.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -26,7 +26,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.service.FilePersistence;
import net.sf.joafip.service.FilePersistenceBuilder;
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel300/TestExclusiveDataAccessSession.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel300/TestExclusiveDataAccessSession.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel300/TestExclusiveDataAccessSession.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -26,7 +26,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.service.FilePersistence;
import net.sf.joafip.service.FilePersistenceBuilder;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageForegroundMemory.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageForegroundMemory.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageForegroundMemory.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
/**
* garbage in foreground implementation
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageInBackground.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageInBackground.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestGarbageInBackground.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
/**
* garbage in background implementation
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestLinkManagementInMemory.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestLinkManagementInMemory.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestLinkManagementInMemory.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
/**
* test reference link management for garbage in memory<br>
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestNoGarbageInMemory.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestNoGarbageInMemory.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestNoGarbageInMemory.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
/**
*
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestObjectReferenceLinkInMemory.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestObjectReferenceLinkInMemory.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestObjectReferenceLinkInMemory.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
/**
*
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryDirect.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryDirect.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryDirect.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
@NotStorableClass
@StorableAccess
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryLazy.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryLazy.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreForPersistenteClassMemoryLazy.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
@NotStorableClass
@StorableAccess
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreVisitedModified.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreVisitedModified.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreVisitedModified.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -29,7 +29,7 @@
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
import net.sf.joafip.entity.MutableInteger;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.store.entity.ForTestVisitedModified;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryDirect.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryDirect.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryDirect.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
@NotStorableClass
@StorableAccess
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryLazy.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryLazy.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/TestStoreWithBobMemoryLazy.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -19,7 +19,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
@NotStorableClass
@StorableAccess
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/TestPersistableCodeGeneratorInStore.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/TestPersistableCodeGeneratorInStore.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/bytecode/TestPersistableCodeGeneratorInStore.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -21,7 +21,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.store.service.StoreClassNotFoundException;
import net.sf.joafip.store.service.StoreDataCorruptedException;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestLinkManager.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestLinkManager.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestLinkManager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -29,8 +29,8 @@
import net.sf.joafip.DoNotTransform;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.store.entity.StoreHeader;
import net.sf.joafip.store.entity.garbage.ReferenceLinkGarbageException;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestStoreGarbager.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestStoreGarbager.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/garbage/TestStoreGarbager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -36,9 +36,9 @@
import net.sf.joafip.DoNotTransform;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.redblacktree.service.RBTException;
import net.sf.joafip.service.JoafipMutex;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/AbstractTestIoManager.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/AbstractTestIoManager.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/manager/AbstractTestIoManager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -28,9 +28,9 @@
import net.sf.joafip.DoNotTransform;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.service.ClassLoaderProvider;
import net.sf.joafip.store.entity.StoreSynchro;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyFieldReflect.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyFieldReflect.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyFieldReflect.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -21,8 +21,8 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
-import net.sf.joafip.heapfile.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapMemoryDataManagerMock;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.service.ClassLoaderProvider;
import net.sf.joafip.store.entity.StoreHeader;
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:51:38 UTC (rev 3044)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -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.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.DualWrapDataManager;
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/MainTreeMultiFile.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java 2012-04-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -4,7 +4,7 @@
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
-import net.sf.joafip.heapfile.service.HeapMultiFileDataManager;
+import net.sf.joafip.kvstore.service.HeapMultiFileDataManager;
import net.sf.joafip.kvstore.service.IHeapDataManager;
import net.sf.joafip.redblacktree.service.RBTException;
import net.sf.joafip.service.FilePersistenceBuilder;
Deleted: 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-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -1,370 +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 java.util.Arrays;
-import java.util.Iterator;
-import java.util.Set;
-
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
-import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.HeapRuntimeException;
-import net.sf.joafip.kvstore.service.IHeapDataManager;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class DualWrapDataManager implements IHeapDataManager {
-
- private static final String DATA_RECORD_MISMATCH = "data record mismatch ";
-
- private final IHeapDataManager firstDataManager;
-
- private final IHeapDataManager secondDataManager;
-
- public DualWrapDataManager(final IHeapDataManager firstDataManager,
- final IHeapDataManager secondDataManager) {
- super();
- this.firstDataManager = firstDataManager;
- this.secondDataManager = secondDataManager;
- }
-
- @Override
- public boolean isDataLost() {
- // no implementation
- return false;
- }
-
- @Override
- public void startService(final boolean removeFiles) throws HeapException {
- firstDataManager.startService(removeFiles);
- secondDataManager.startService(removeFiles);
- }
-
- @Override
- public void stopService() throws HeapException {
- firstDataManager.stopService();
- secondDataManager.stopService();
- }
-
- @Override
- public boolean isServiceStarted() {
- final boolean started1 = firstDataManager.isServiceStarted();
- final boolean started2 = secondDataManager.isServiceStarted();
- if (started1 != started2) {
- throw new HeapRuntimeException("started stated missmatch "
- + started1 + " " + started2);
- }
- return started1;
- }
-
- @Override
- public void clear() throws HeapException {
- firstDataManager.clear();
- secondDataManager.clear();
- }
-
- @Override
- public DataRecordIdentifier getNextFreeDataRecordIdentifier()
- throws HeapException {
- final DataRecordIdentifier next1 = firstDataManager
- .getNextFreeDataRecordIdentifier();
- final DataRecordIdentifier next2 = secondDataManager
- .getNextFreeDataRecordIdentifier();
- if (next1.value != next2.value) {
- throw new HeapException("new data record identifier missmatch "
- + next1.value + " " + next2.value);
- }
- return next1;
- }
-
- @Override
- public void setNextFreeDataRecordIdentifier(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- firstDataManager.setNextFreeDataRecordIdentifier(dataRecordIdentifier);
- secondDataManager.setNextFreeDataRecordIdentifier(dataRecordIdentifier);
- }
-
- @Override
- public DataRecordIdentifier getNewDataRecordIdentifier()
- throws HeapException {
- final DataRecordIdentifier new1 = firstDataManager
- .getNewDataRecordIdentifier();
- final DataRecordIdentifier new2 = secondDataManager
- .getNewDataRecordIdentifier();
- if (new1.value != new2.value) {
- throw new HeapException("new data record identifier missmatch "
- + new1.value + " " + new2.value);
- }
- return new1;
- }
-
- @Override
- public boolean hasDataRecord(final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final boolean has1 = firstDataManager
- .hasDataRecord(dataRecordIdentifier);
- final boolean has2 = secondDataManager
- .hasDataRecord(dataRecordIdentifier);
- if (has1 != has2) {
- throw new HeapException("has data record missmatch " + has1 + " "
- + has2);
- }
- return has1;
- }
-
- @Override
- public byte[] readDataRecord(final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final byte[] data1 = firstDataManager
- .readDataRecord(dataRecordIdentifier);
- final byte[] data2 = secondDataManager
- .readDataRecord(dataRecordIdentifier);
- if (!Arrays.equals(data1, data2)) {
- throw new HeapException("data differs");
- }
- return data1;
- }
-
- @Override
- public boolean writeDataRecord(
- final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
- throws HeapException {
- final boolean created1 = firstDataManager.writeDataRecord(
- dataRecordIdentifier, data);
- final boolean created2 = secondDataManager.writeDataRecord(
- dataRecordIdentifier, data);
- if (created1 != created2) {
- throw new HeapException("created state missmatch " + created1 + " "
- + created2 + " for " + dataRecordIdentifier);
- }
- return created1;
- }
-
- @Override
- public boolean deleteDataRecord(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final boolean deleted1 = firstDataManager
- .deleteDataRecord(dataRecordIdentifier);
- final boolean deleted2 = secondDataManager
- .deleteDataRecord(dataRecordIdentifier);
- if (deleted1 != deleted2) {
- throw new HeapException("deleted state missmatch " + deleted1 + " "
- + deleted2);
- }
- return deleted1;
- }
-
- @Override
- public DataRecordIdentifier removeFirstDataRecord() throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .removeFirstDataRecord();
- final DataRecordIdentifier dr2 = secondDataManager
- .removeFirstDataRecord();
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public void flush() throws HeapException {
- firstDataManager.flush();
- secondDataManager.flush();
- }
-
- @Override
- public void clearStandbyModification() throws HeapException {
- firstDataManager.clearStandbyModification();
- secondDataManager.clearStandbyModification();
- }
-
- @Override
- public DataRecordIdentifier firstDataRecordIdentifier()
- throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .firstDataRecordIdentifier();
- final DataRecordIdentifier dr2 = secondDataManager
- .firstDataRecordIdentifier();
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public DataRecordIdentifier lastDataRecordIdentifier() throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .lastDataRecordIdentifier();
- final DataRecordIdentifier dr2 = secondDataManager
- .lastDataRecordIdentifier();
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public DataRecordIdentifier lowerDataRecordIdentifier(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .lowerDataRecordIdentifier(dataRecordIdentifier);
- final DataRecordIdentifier dr2 = secondDataManager
- .lowerDataRecordIdentifier(dataRecordIdentifier);
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public DataRecordIdentifier floorDataRecordIdentifier(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .floorDataRecordIdentifier(dataRecordIdentifier);
- final DataRecordIdentifier dr2 = secondDataManager
- .floorDataRecordIdentifier(dataRecordIdentifier);
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public DataRecordIdentifier ceilingDataRecordIdentifier(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .ceilingDataRecordIdentifier(dataRecordIdentifier);
- final DataRecordIdentifier dr2 = secondDataManager
- .ceilingDataRecordIdentifier(dataRecordIdentifier);
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public DataRecordIdentifier higherDataRecordIdentifier(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final DataRecordIdentifier dr1 = firstDataManager
- .higherDataRecordIdentifier(dataRecordIdentifier);
- final DataRecordIdentifier dr2 = secondDataManager
- .higherDataRecordIdentifier(dataRecordIdentifier);
- if (dr1.value != dr2.value) {
- throw new HeapException(DATA_RECORD_MISMATCH + dr1.value + " "
- + dr2.value);
- }
- return dr1;
- }
-
- @Override
- public int getNumberOfDataRecord() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- public int getNumberOfFreeRecord() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- public long heapSize() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- public long freeSize() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- public long usedSize() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- public String backup(final long identifier, final int maxBackup)
- throws HeapException {
- // no implementation
- return null;
- }
-
- @Override
- public String getStorageFileName() throws HeapException {
- // no implementation
- return null;
- }
-
- @Override
- public Set<DataRecordIdentifier> getDataRecordIdentifierSet()
- throws HeapException {
- // no implementation
- return null;
- }
-
- @Override
- public Iterator<DataRecordIdentifier> dataRecordIterator()
- throws HeapException {
- // no implementation
- return null;
- }
-
- @Override
- public long getRecordPositionInfile(final DataRecordIdentifier identifier)
- throws HeapException {
- throw new HeapException("unsupported");
- }
-
- @Override
- public long getLastRecordPositionInFile() throws HeapException {
- throw new HeapException("unsupported");
- }
-
- @Override
- public void setDataRecordKeyComparator(
- final IDataRecordKeyManager dataRecordKeyComparator)
- throws HeapException {
- firstDataManager.setDataRecordKeyComparator(dataRecordKeyComparator);
- secondDataManager.setDataRecordKeyComparator(dataRecordKeyComparator);
- }
-}
Deleted: 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-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileForStorableBridge.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -1,106 +0,0 @@
-package net.sf.joafip.heapfile.service;
-
-import java.io.File;
-
-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;
-
-public class FileForStorableBridge implements IFileForStorable {
-
- private final IFileForStorable delegate;
-
- public FileForStorableBridge(final IFileForStorable delegate) {
- super();
- this.delegate = delegate;
- }
-
- @Override
- public void resetFileSize() throws HeapException {
- delegate.resetFileSize();
- }
-
- @Override
- public void close() throws HeapException {
- // delegate.close();
- }
-
- @Override
- public void deleteFileIfExists() throws HeapException {
- delegate.deleteFileIfExists();
- }
-
- @Override
- public void deleteFileIfExistsRenaming() throws HeapException {
- delegate.deleteFileIfExistsRenaming();
- }
-
- @Override
- public void flush() throws HeapException {
- delegate.flush();
- }
-
- @Override
- public File getFile() {
- return delegate.getFile();
- }
-
- @Override
- public long getFileSize() throws HeapException {
- return delegate.getFileSize();
- }
-
- @Override
- public void open() throws HeapException {
- // delegate.open();
- }
-
- @Override
- public int read(final byte[] ioBuffer) throws HeapException { // NOPMD
- return delegate.read(ioBuffer);
- }
-
- @Override
- public int read(final byte[] data, final int offset, final int length)
- throws HeapException {
- return delegate.read(data, offset, length);
- }
-
- @Override
- public void seek(final long positionInFile) throws HeapException {
- delegate.seek(positionInFile);
- }
-
- @Override
- public void write(final byte[] ioBuffer) throws HeapException {
- delegate.write(ioBuffer);
- }
-
- @Override
- public void write(final ToBackupRecord toBackupRecord) throws HeapException {
- delegate.write(toBackupRecord);
- }
-
- @Override
- public void copy(final FileForStorable fileForStorable)
- throws HeapException {
- delegate.copy(fileForStorable);
- }
-
- @Override
- 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-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -25,6 +25,7 @@
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.HeapMultiFileDataManager;
import net.sf.joafip.kvstore.service.IHeapDataManager;
/**
Deleted: 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-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -1,305 +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.Serializable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
-import net.sf.joafip.kvstore.service.AbstractHeapDataManager;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- * mock of heap data manager in memory for tests
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public class HeapMemoryDataManagerMock extends AbstractHeapDataManager
- implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -955909842940111778L;
-
- private static final String UNSUPPORTED = "unsupported";
-
- /** simulate the data in file */
- private final Map<DataRecordIdentifier, byte[]> fileRecordMap =
- /**/new TreeMap<DataRecordIdentifier, byte[]>();
-
- private final Map<DataRecordIdentifier, byte[]> toWritePendigRecordMap =
- /**/new TreeMap<DataRecordIdentifier, byte[]>();
-
- private final Set<DataRecordIdentifier> toDeletePending =
- /**/new TreeSet<DataRecordIdentifier>();
-
- private DataRecordIdentifier nextFreeIdentifier = DataRecordIdentifier.ZERO;
-
- private final List<DataRecordIdentifier> dataRecordIdentifierCreatedList =
- /**/new LinkedList<DataRecordIdentifier>();
-
- @Override
- protected void startServiceImpl(final boolean removeFiles)
- throws HeapException {
- if (removeFiles) {
- fileRecordMap.clear();
- nextFreeIdentifier = DataRecordIdentifier.ZERO;
- }
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- }
-
- @Override
- protected void stopServiceImpl() throws HeapException {
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- }
-
- @Override
- protected void clearImpl() throws HeapException {
- fileRecordMap.clear();
- nextFreeIdentifier = DataRecordIdentifier.ZERO;
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- }
-
- @Override
- public boolean deleteDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- toWritePendigRecordMap.remove(dataRecordIdentifier);
- return toDeletePending.add(dataRecordIdentifier);
- }
-
- @Override
- protected DataRecordIdentifier removeFirstDataRecordImpl()
- throws HeapException {
- final Iterator<DataRecordIdentifier> iterator = fileRecordMap.keySet()
- .iterator();
- final DataRecordIdentifier dataRecordIdentifier;
- if (iterator.hasNext()) {
- dataRecordIdentifier = iterator.next();
- deleteDataRecordImpl(dataRecordIdentifier);
- } else {
- dataRecordIdentifier = null;
- }
- return dataRecordIdentifier;
- }
-
- @Override
- public DataRecordIdentifier getNewDataRecordIdentifierImpl()
- throws HeapException {
- final DataRecordIdentifier identifier = nextFreeIdentifier;
- nextFreeIdentifier = new DataRecordIdentifier(identifier);
- if (logger.debugEnabled) {
- dataRecordIdentifierCreatedList.add(identifier);
- }
- return identifier;
- }
-
- @Override
- public byte[] readDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- byte[] data = toWritePendigRecordMap.get(dataRecordIdentifier);
- if (data == null) {
- data = fileRecordMap.get(dataRecordIdentifier);
- }
- final byte[] result;
- if (data == null) {
- result = null;
- } else {
- result = data.clone();
- }
- return result;
- }
-
- @Override
- public boolean writeDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
- throws HeapException {
- // fileRecordMap.put(dataRecordIdentifier, data);
- final boolean created = toWritePendigRecordMap.put(
- dataRecordIdentifier, data.clone()) == null;
- toDeletePending.remove(dataRecordIdentifier);
- if (logger.debugEnabled) {
- dataRecordIdentifierCreatedList.remove(dataRecordIdentifier);
- }
- return created;
- }
-
- @Override
- protected void flushImp() throws HeapException {
- for (Map.Entry<DataRecordIdentifier, byte[]> entry : toWritePendigRecordMap
- .entrySet()) {
- fileRecordMap.put(entry.getKey(), entry.getValue());
- }
- for (DataRecordIdentifier dataRecordIdentifier : toDeletePending) {
- fileRecordMap.remove(dataRecordIdentifier);
- }
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- if (logger.debugEnabled) {
- if (dataRecordIdentifierCreatedList.isEmpty()) {
- logger.debug("flush");
- } else {
- final StringBuilder stringBuilder = new StringBuilder();
- stringBuilder
- .append("flush but created data record not wrote: ");
- for (DataRecordIdentifier dataRecordIdentifier : dataRecordIdentifierCreatedList) {
- stringBuilder.append(dataRecordIdentifier);
- stringBuilder.append(' ');
- }
- logger.debug(stringBuilder.toString());
- }
- }
- }
-
- @Override
- protected void clearStandbyModificationImpl() throws HeapException {
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- if (logger.debugEnabled) {
- dataRecordIdentifierCreatedList.clear();
- }
- }
-
- @Override
- protected void closeHeapManagerAfterException() {
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- if (logger.debugEnabled) {
- dataRecordIdentifierCreatedList.clear();
- }
- }
-
- @Override
- protected void removeFiles() throws HeapException {
- fileRecordMap.clear();
- toWritePendigRecordMap.clear();
- toDeletePending.clear();
- if (logger.debugEnabled) {
- dataRecordIdentifierCreatedList.clear();
- }
- }
-
- @Override
- protected DataRecordIdentifier getNextFreeDataRecordIdentifierImpl()
- throws HeapException {
- return nextFreeIdentifier;
- }
-
- @Override
- protected void setNextFreeDataRecordIdentifierImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- nextFreeIdentifier = dataRecordIdentifier;
- }
-
- @Override
- public int getNumberOfDataRecordImpl() throws HeapException {
- return getDataRecordIdentifierSet().size();
- }
-
- @Override
- public int getNumberOfFreeRecordImpl() {
- return 0;
- }
-
- @Override
- public long heapSizeImpl() {
- return 0;
- }
-
- @Override
- public long freeSizeImpl() {
- return 0;
- }
-
- @Override
- public long usedSizeImpl() {
- return 0;
- }
-
- @Override
- public boolean isDataLost() {
- // can not lost data
- return false;
- }
-
- @Override
- public Set<DataRecordIdentifier> getDataRecordIdentifierSetImpl() {
- final Set<DataRecordIdentifier> set = new TreeSet<DataRecordIdentifier>();
- set.addAll(fileRecordMap.keySet());
- set.addAll(toWritePendigRecordMap.keySet());
- set.removeAll(toDeletePending);
- return set;
- }
-
- @Override
- public boolean hasDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier) {
- return (fileRecordMap.containsKey(dataRecordIdentifier) || toWritePendigRecordMap
- .containsKey(dataRecordIdentifier))
- && !toDeletePending.contains(dataRecordIdentifier);
- }
-
- @Override
- public String backup(final long identifier, final int maxBackup)
- throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
- public String getStorageFileName() throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
- public Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
- return getDataRecordIdentifierSetImpl().iterator();
- }
-
- @Override
- public long getRecordPositionInfile(final DataRecordIdentifier identifier)
- throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
- public long getLastRecordPositionInFile() throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
- public void setDataRecordKeyComparator(
- final IDataRecordKeyManager dataRecordKeyComparator) {
- throw new UnsupportedOperationException(
- "works only with long data record identifier");
- }
-}
\ No newline at end of file
Deleted: 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-29 16:51:38 UTC (rev 3044)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -1,476 +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 java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
-import net.sf.joafip.kvstore.service.AbstractHeapDataManager;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- * Data management on heap multiple file implementation<br>
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public class HeapMultiFileDataManager extends AbstractHeapDataManager {
-
- /**
- *
- */
- private static final long serialVersionUID = 6544930761771904832L;
-
- private static final String IDENTIFIER = "identifier";
-
- private static final String UNSUPPORTED = "unsupported";
-
- private final File rootDirectory;
-
- public HeapMultiFileDataManager(final File rootDirectory) {
- super();
- this.rootDirectory = rootDirectory;
- }
-
- @Override
- protected void startServiceImpl(final boolean removeFiles)
- throws HeapException {
- if (removeFiles) {
- deleteDir(rootDirectory);
- }
- rootDirectory.mkdirs();
- }
-
- @Override
- protected void stopServiceImpl() throws HeapException {
- // no implementation
- }
-
- @Override
- protected void clearImpl() throws HeapException {
- deleteDir(rootDirectory);
- rootDirectory.mkdirs();
- }
-
- @Override
- public boolean deleteDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final File file = fileForRecord(dataRecordIdentifier, false);
- final boolean deleted = file.exists();
- if (deleted) {
- file.delete();
-
- File parent = file.getParentFile();
- while (parent != null && !rootDirectory.equals(parent)) {
- if (parent.list().length == 0) {
- parent.delete();
- parent = parent.getParentFile();
- } else {
- parent = null;// NOPMD
- }
- }
-
- }
- return deleted;
- }
-
- @Override
- public byte[] readDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final byte[] result;
- final File file = fileForRecord(dataRecordIdentifier, false);
- if (file.exists()) {
- ObjectInputStream objectInputStream = null;
- try {
- final FileInputStream fileInputStream = new FileInputStream(
- file);
- objectInputStream = new ObjectInputStream(fileInputStream);
- result = (byte[]) objectInputStream.readObject();
- } catch (Exception exception) {
- throw new HeapException(exception);
- } finally {
- if (objectInputStream != null) {
- try {
- objectInputStream.close();
- } catch (IOException exception) {// NOPMD
- // ignore error
- logger.error("close error", exception);
- }
- }
- }
- } else {
- result = null;
- }
- return result;
- }
-
- @Override
- public boolean writeDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
- throws HeapException {
- ObjectOutputStream objectOutputStream = null;
- try {
- final File fileForRecord = fileForRecord(dataRecordIdentifier, true);
- final boolean created = true ^ fileForRecord.exists();
- final FileOutputStream fileOutputStream = new FileOutputStream(
- fileForRecord);
- objectOutputStream = new ObjectOutputStream(fileOutputStream);
- objectOutputStream.writeObject(data);
- return created;
- } catch (Exception exception) {
- throw new HeapException(exception);
- } finally {
- if (objectOutputStream != null) {
- try {
- objectOutputStream.close();
- } catch (IOException exception) {// NOPMD
- // ignore error
- logger.error("closing error", exception);
- }
- }
- }
- }
-
- @Override
- protected DataRecordIdentifier removeFirstDataRecordImpl()
- throws HeapException {
- final File firstFile = firstFile();
- final DataRecordIdentifier dataRecordIdentifier;
- if (firstFile == null) {
- dataRecordIdentifier = null;
- } else {
- dataRecordIdentifier = new DataRecordIdentifier(
- Long.parseLong(firstFile.getName()));
- deleteDataRecord(dataRecordIdentifier);
- }
- return dataRecordIdentifier;
- }
-
- @Override
- protected void clearStandbyModificationImpl() throws HeapException {
- // no implementation
- }
-
- @Override
- protected void closeHeapManagerAfterException() {
- // no implementation
- }
-
- @Override
- protected void flushImp() throws HeapException {
- // no implementation
- }
-
- @Override
- protected long freeSizeImpl() throws HeapException {
- return 0;
- }
-
- @Override
- protected int getNumberOfFreeRecordImpl() throws HeapException {
- return 0;
- }
-
- @Override
- protected long heapSizeImpl() throws HeapException {
- return 0;
- }
-
- @Override
- protected long usedSizeImpl() throws HeapException {
- return 0;
- }
-
- @Override
- public boolean isDataLost() {
- return false;
- }
-
- @Override
- protected void removeFiles() throws HeapException {
- deleteDir(rootDirectory);
- final File identifierFile = new File(rootDirectory, IDENTIFIER);
- identifierFile.delete();
- }
-
- @Override
- protected Set<DataRecordIdentifier> getDataRecordIdentifierSetImpl()
- throws HeapException {
- final Set<DataRecordIdentifier> set = new TreeSet<DataRecordIdentifier>();
- final File[] childFiles = rootDirectory.listFiles();
- for (File childFile : childFiles) {
- if (childFile.isDirectory()) {
- set.addAll(getSub(newFile(rootDirectory, childFile)));
- }
- }
- return set;
- }
-
- private List<DataRecordIdentifier> getSub(final File rootDir) {
- final List<DataRecordIdentifier> list = new LinkedList<DataRecordIdentifier>();
- final File[] childFiles = rootDir.listFiles();
- for (File childFile : childFiles) {
- if (childFile.isDirectory()) {
- list.addAll(getSub(newFile(rootDir, childFile)));
- } else if (childFile.isFile()) {
- list.add(newDataRecordIdentifier(childFile));
- }
- }
- return list;
- }
-
- @Override
- protected int getNumberOfDataRecordImpl() throws HeapException {
- int total = 0;
- final File[] childFiles = rootDirectory.listFiles();
- for (File childFile : childFiles) {
- if (childFile.isDirectory()) {
- total += countSub(newFile(rootDirectory, childFile));
- }
- }
- return total;
- }
-
- private int countSub(final File rootDir) {
- int total = 0;
- final File[] childFiles = rootDir.listFiles();
- for (File childFile : childFiles) {
- if (childFile.isDirectory()) {
- total += countSub(newFile(rootDir, childFile));
- } else if (childFile.isFile()) {
- total++;
- }
- }
- return total;
- }
-
- @Override
- protected DataRecordIdentifier getNextFreeDataRecordIdentifierImpl()
- throws HeapException {
- try {
- DataRecordIdentifier dataRecordIdentifier;
- final File identifierFile = new File(rootDirectory, IDENTIFIER);
- if (identifierFile.exists()) {
- final FileInputStream fileInputStream = new FileInputStream(
- identifierFile);
- final ObjectInputStream objectInputStream = new ObjectInputStream(
- fileInputStream);
- dataRecordIdentifier = (DataRecordIdentifier) objectInputStream
- .readObject();
- objectInputStream.close();
- } else {
- dataRecordIdentifier = DataRecordIdentifier.ZERO;
- }
- return dataRecordIdentifier;
- } catch (Exception exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected void setNextFreeDataRecordIdentifierImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
-
- try {
-
- final File identifierFile = new File(rootDirectory, IDENTIFIER);
- final FileOutputStream fileOutputStream = new FileOutputStream(
- identifierFile);
- final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
- fileOutputStream);
- objectOutputStream.writeObject(dataRecordIdentifier);
- objectOutputStream.close();
-
- } catch (Exception exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected DataRecordIdentifier getNewDataRecordIdentifierImpl()
- throws HeapException {
- try {
-
- DataRecordIdentifier dataRecordIdentifier;
- final File identifierFile = new File(rootDirectory, IDENTIFIER);
- if (identifierFile.exists()) {
- final FileInputStream fileInputStream = new FileInputStream(
- identifierFile);
- final ObjectInputStream objectInputStream = new ObjectInputStream(
- fileInputStream);
- dataRecordIdentifier = (DataRecordIdentifier) objectInputStream
- .readObject();
- objectInputStream.close();
- } else {
- dataRecordIdentifier = DataRecordIdentifier.ZERO;
- }
- final DataRecordIdentifier nextDataRecordIdentifier = new DataRecordIdentifier(
- dataRecordIdentifier);
-
- final FileOutputStream fileOutputStream = new FileOutputStream(
- identifierFile);
- final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
- fileOutputStream);
- objectOutputStream.writeObject(nextDataRecordIdentifier);
- objectOutputStream.close();
-
- return dataRecordIdentifier;
-
- } catch (Exception exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected boolean hasDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final File file = fileForRecord(dataRecordIdentifier, false);
- return file.exists();
- }
-
- /**
- * create file for a record
- *
- * @param identifier
- * @return
- * @throws HeapException
- */
- private File fileForRecord(final DataRecordIdentifier identifier,
- final boolean createDir) throws HeapException {
- final String fileName = String.format("%010d",
- new Object[] { identifier.value });
- File fileForRecord = rootDirectory;
- for (int index = 0; index < 4; index++) {
- fileForRecord = newFile(fileForRecord,
- newFile(fileName.substring(index * 2, index * 2 + 2)));
- if (createDir && !fileForRecord.exists() && !fileForRecord.mkdir()) {
- throw new HeapException("failed create " + fileForRecord);
-
- }
- }
- return new File(fileForRecord, fileName);
- }
-
- private File firstFile() {
- File current = rootDirectory;
- for (int index = 0; index < 5; index++) {
- final NavigableSet<String> set = new TreeSet<String>(); // NOPMD
- for (String name : current.list()) {
- set.add(name);
- }
- final String first = set.pollFirst();
- if (first == null) {
- return null;// NOPMD
- }
- current = newFile(current, first);
- }
- return current;
- }
-
- /**
- * delete recursively file
- *
- * @param strFile
- * @return
- * @throws HeapException
- */
- private void deleteDir(final File file) throws HeapException {
-
- // Validate directory
- if (file.isDirectory()) {
- // -- Get children
- final File[] childFile = file.listFiles();
- if (childFile == null) {
- throw new HeapException("faile list file of " + file);
- }
- // -- Go through each
- for (int i = 0; i < childFile.length; i++) {
- deleteDir(newFile(file, childFile[i]));
- }
- }
- // The directory is now empty so delete it
- file.delete();
- }
-
- private DataRecordIdentifier newDataRecordIdentifier(final File childFile) {
- return new DataRecordIdentifier(Long.parseLong(childFile.getName()));
- }
-
- private File newFile(final File fatherDir, final File childFile) {
- return new File(fatherDir, childFile.getName());
- }
-
- private File newFile(final File fatherDir, final String childFileName) {
- return new File(fatherDir, childFileName);
- }
-
- private File newFile(final String name) {
- return new File(name);
- }
-
- @Override
- public String backup(final long identifier, final int maxBackup)
- throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
- public String getStorageFileName() throws HeapException {
- throw new HeapException(UNSUPPORTED);
- }
-
- @Override
- public Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getRecordPositionInfile(final DataRecordIdentifier identifier)
- throws HeapException {
- throw new HeapException("unsupported");
- }
-
- @Override
- public long getLastRecordPositionInFile() throws HeapException {
- throw new HeapException("unsupported");
- }
-
- @Override
- public void setDataRecordKeyComparator(
- final IDataRecordKeyManager dataRecordKeyComparator) {
- throw new UnsupportedOperationException(
- "works only with long data record identifier");
- }
-}
Copied: trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java (from rev 3044, trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java)
===================================================================
--- trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java (rev 0)
+++ trunk/joafip-kvstore/src/test/java/net/sf/joafip/kvstore/service/DualWrapDataManager.java 2012-04-29 16:58:13 UTC (rev 3045)
@@ -0,0 +1,370 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.Iterator;
+import java.util.Set;
+
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.HeapRuntimeException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DualWrapDataManager implements IHeapDataManager {
+
+ private static final String DATA_RECORD_MISMATCH = "data record mismatch ";
+
+ private final IHeapDataManager firstDataManager;
+
+ private final IHeapDataManager s...
[truncated message content] |
|
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 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());
+ 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());
+ }
+}
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: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 {
- FileDataManagerIntegrityChecker.getInstance().checkIntegrity(
- heapDataManager);
- }
-}
Deleted: 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-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -1,492 +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 java.io.File;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.file.service.FileIOException;
-import net.sf.joafip.file.service.IRandomAccessFile;
-import net.sf.joafip.file.service.RandomAccessFileDirectNio;
-import net.sf.joafip.file.service.RandomAccessFileReadWriteCache;
-import net.sf.joafip.heapfile.entity.BlockDataManagerHeader;
-import net.sf.joafip.heapfile.entity.DataBlock;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.IDataRecordKeyManager;
-import net.sf.joafip.kvstore.service.AbstractHeapDataManager;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public class BlockDataManager extends AbstractHeapDataManager {
-
- /**
- *
- */
- private static final long serialVersionUID = -7880032946404411395L;
-
- private static final int FIRST_BLOCK_LENGTH = 1024;
-
- private final IRandomAccessFile randomAccessFile;
-
- private final BlockDataManagerHeader header = new BlockDataManagerHeader();
-
- private final Map<Long, DataBlock> cacheMap = new TreeMap<Long, DataBlock>();
-
- public BlockDataManager(final String filePath, final int blockLength)
- throws HeapException {
- super();
- final File file = new File(filePath);
- randomAccessFile = new RandomAccessFileDirectNio(file, 0, 0);
- // randomAccessFile = new RandomAccessFileDirect(file, 0, 0);
- header.setBlockLength(blockLength);
- }
-
- public BlockDataManager(final int pageSize, final int maxPage,
- final int blockLength) throws HeapException {
- super();
- final File file = new File("runtime/data");
- final IRandomAccessFile drandomAccessFile = new RandomAccessFileDirectNio(
- file, 0, 0);
- randomAccessFile = new RandomAccessFileReadWriteCache(
- drandomAccessFile, pageSize, maxPage, true);
- header.setBlockLength(blockLength);
- }
-
- @Override
- protected void removeFiles() throws HeapException {
- try {
- randomAccessFile.deleteIfExists();
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected void startServiceImpl(final boolean removeFiles)
- throws HeapException {
- try {
- randomAccessFile.open();
- randomAccessFile.seek(0);
- final byte[] block = new byte[FIRST_BLOCK_LENGTH];
- if (removeFiles) {
- randomAccessFile.write(block);
- header.setNextIdentifier(new DataRecordIdentifier());
- header.setNumberOfDataRecord(0);
- } else {
- if (randomAccessFile.read(block) == FIRST_BLOCK_LENGTH) {
- final int length = (((int) block[0]) & 0xff) << 8
- | (((int) block[1]) & 0xff);
- final byte[] data = new byte[length];
- System.arraycopy(block, 2, data, 0, length);
- header.set(data);
- } else {
- randomAccessFile.write(block);
- header.setNextIdentifier(new DataRecordIdentifier());
- header.setNumberOfDataRecord(0);
- }
- }
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected void stopServiceImpl() throws HeapException {
- try {
- writeHeader();
- randomAccessFile.close();
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- private void writeHeader() throws HeapException, FileIOException {
- final byte[] data = header.get();
- final int length = data.length;
- final byte[] block = new byte[(int) FIRST_BLOCK_LENGTH];
- block[0] = (byte) (length >> 8);
- block[1] = (byte) length;
- System.arraycopy(data, 0, block, 2, length);
- randomAccessFile.seek(0);
- randomAccessFile.write(block);
- }
-
- @Override
- protected void clearImpl() throws HeapException {
- removeFiles();
- }
-
- @Override
- protected void flushImp() throws HeapException {
- try {
- for (Map.Entry<Long, DataBlock> entry : cacheMap.entrySet()) {
- final long position = entry.getKey();
- final DataBlock dataBlock = entry.getValue();
- if (dataBlock.isToWrite()) {
- randomAccessFile.seek(position);
- randomAccessFile.write(dataBlock.getData());
- }
- }
- writeHeader();
- randomAccessFile.flush();
- cacheMap.clear();
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected void clearStandbyModificationImpl() throws HeapException {
- cacheMap.clear();
- }
-
- @Override
- protected DataRecordIdentifier getNextFreeDataRecordIdentifierImpl()
- throws HeapException {
- return header.getNextIdentifier();
- }
-
- @Override
- protected void setNextFreeDataRecordIdentifierImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- header.setNextIdentifier(dataRecordIdentifier);
- }
-
- @Override
- protected DataRecordIdentifier getNewDataRecordIdentifierImpl()
- throws HeapException {
- final DataRecordIdentifier result = header.getNextIdentifier();
- header.setNextIdentifier(new DataRecordIdentifier(result));
- return result;
- }
-
- @Override
- protected boolean deleteDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- try {
- final long position = getRecordPositionInfile(dataRecordIdentifier);
- final boolean deleted;
- final byte[] lengthData = new byte[2];
- final int read = read(position, 0, lengthData, true);
- if (read == 2) {
- final int length = (((int) lengthData[0]) & 0xff) << 8
- | (((int) lengthData[1]) & 0xff);
- if (length == 0) {
- deleted = false;
- } else {
- header.decrementNumberOfDataRecord();
- deleted = true;
- lengthData[0] = (byte) 0;
- lengthData[1] = (byte) 0;
- write(position, 0, lengthData);
- }
- } else {
- deleted = false;
- }
- return deleted;
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected byte[] readDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- try {
- final long position = getRecordPositionInfile(dataRecordIdentifier);
- byte[] data = new byte[2];
- final int read = read(position, 0, data, true);
- if (read == 2) {
- final int length = (((int) data[0]) & 0xff) << 8
- | (((int) data[1]) & 0xff);
-
- if (length == 0) {
- data = null;// NOPMD
- } else {
- data = new byte[length];
- read(position, 2, data, true);
- }
- } else {
- data = null;// NOPMD
- }
- return data;
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected boolean writeDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
- throws HeapException {
- if (data.length == 0) {
- throw new HeapException("no data");
- }
- if (data.length > header.getBlockLength() - 2) {
- throw new HeapException("too big data: " + data.length
- + " for block of " + header.getBlockLength());
- }
- try {
- final long position = getRecordPositionInfile(dataRecordIdentifier);
- final boolean created;
- final byte[] lengthData = new byte[2];
- int previousLength = -1;
- final int read = read(position, 0, lengthData, true);
- if (read == 2) {
- previousLength = (((int) lengthData[0]) & 0xff) << 8
- | (((int) lengthData[1]) & 0xff);
- created = previousLength == 0;
- } else {
- created = true;
- }
- if (created) {
- header.incrementNumberOfDataRecord();
- }
- final int length = data.length;
- lengthData[0] = (byte) (length >> 8);
- lengthData[1] = (byte) length;
- write(position, 0, lengthData);
- write(position, 2, data);
- return created;
- } catch (FileIOException exception) {
- throw new HeapException("for data record #" + dataRecordIdentifier,
- exception);
- }
- }
-
- @Override
- protected boolean hasDataRecordImpl(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- try {
- final long position = getRecordPositionInfile(dataRecordIdentifier);
- final boolean hasDatarecord;
- final byte[] lengthData = new byte[2];
- final int read = read(position, 0, lengthData, true);
- if (read == 2) {
- final int length = (((int) lengthData[0]) & 0xff) << 8
- | (((int) lengthData[1]) & 0xff);
- hasDatarecord = length != 0;
- } else {
- hasDatarecord = false;
- }
- return hasDatarecord;
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- public long getRecordPositionInfile(
- final DataRecordIdentifier dataRecordIdentifier)
- throws HeapException {
- final long value = dataRecordIdentifier.value;
- return getRecordPositionInfile(value);
- }
-
- private long getRecordPositionInfile(final long value) {
- return value * header.getBlockLength() + FIRST_BLOCK_LENGTH;
- }
-
- @Override
- public long getLastRecordPositionInFile() throws HeapException {
- return getRecordPositionInfile((header.getDataLength() - 1 - FIRST_BLOCK_LENGTH)
- / header.getBlockLength());
- }
-
- @Override
- protected int getNumberOfDataRecordImpl() throws HeapException {
- return header.getNumberOfDataRecord();
- }
-
- @Override
- protected DataRecordIdentifier removeFirstDataRecordImpl()
- throws HeapException {
- try {
- boolean found = false;
- final long firstRecordPositionInfile = getRecordPositionInfile(0);
- long position = firstRecordPositionInfile;
- final byte[] lengthData = new byte[2];
- do {
- final int read = read(position, 0, lengthData, false);
- if (read == 2) {
- final int length = (((int) lengthData[0]) & 0xff) << 8
- | (((int) lengthData[1]) & 0xff);
- if (length == 0) {
- position += header.getBlockLength();
- } else {
- found = true;
- }
- } else {
- position = Long.MAX_VALUE;
- }
- } while (!found && position < header.getDataLength());
- DataRecordIdentifier result;
- if (found) {
- lengthData[0] = 0;
- lengthData[1] = 0;
- write(position, 0, lengthData);
- result = new DataRecordIdentifier(
- (position - firstRecordPositionInfile)
- / header.getBlockLength());
- } else {
- result = null;// NOPMD
- }
- return result;
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- protected int getNumberOfFreeRecordImpl() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- protected long heapSizeImpl() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- protected long freeSizeImpl() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- protected long usedSizeImpl() throws HeapException {
- // no implementation
- return 0;
- }
-
- @Override
- protected Set<DataRecordIdentifier> getDataRecordIdentifierSetImpl()
- throws HeapException {
- // no implementation
- return null;
- }
-
- @Override
- protected Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
- // no implementation
- return null;
- }
-
- @Override
- protected void closeHeapManagerAfterException() {
- // no implementation
- }
-
- @Override
- public boolean isDataLost() {
- return false;
- }
-
- @Override
- public String getStorageFileName() throws HeapException {
- return randomAccessFile.getFile().getAbsolutePath();
- }
-
- @Override
- public String backup(final long identifier, final int maxBackup)
- throws HeapException {
- throw new HeapException("not implemented");
- }
-
- private int read(final long position, final int offset, final byte[] data,
- final boolean addToCache) throws FileIOException {
- DataBlock dataBlock = cacheMap.get(position);
- if (dataBlock == null) {
- dataBlock = readInFile(position, addToCache);
- }
- final int result;
- if (dataBlock == null) {
- result = 0;
- } else {
- result = data.length;
- final byte[] recordData = dataBlock.getData();
- System.arraycopy(recordData, offset, data, 0, result);
- }
- return result;
- }
-
- private DataBlock readInFile(final long position, final boolean addToCache)
- throws FileIOException {
- final DataBlock dataBlock;
- randomAccessFile.seek(position);
- final int blockLength = header.getBlockLength();
- final byte[] recordData = new byte[blockLength];
- final int read = randomAccessFile.read(recordData);
- if (read == blockLength) {
- dataBlock = new DataBlock(position, false, recordData);
- if (addToCache) {
- cacheMap.put(position, dataBlock);
- }
- } else {
- dataBlock = null;
- }
- return dataBlock;
- }
-
- private void write(final long position, final int offset, final byte[] data)
- throws FileIOException {
- DataBlock dataBlock = cacheMap.get(position);
- if (dataBlock == null) {
- dataBlock = readInFile(position, true);
- if (dataBlock == null) {
- final byte[] recordData = new byte[header.getBlockLength()];
- dataBlock = new DataBlock(position, true, recordData);
- cacheMap.put(position, dataBlock);
- }
- } else {
- dataBlock.setToWrite(true);
- }
- System.arraycopy(data, 0, dataBlock.getData(), offset, data.length);
- final long length = position + header.getBlockLength();
- if (length > header.getDataLength()) {
- header.setDataLength(length);
- }
- }
-
- @Override
- public void setDataRecordKeyComparator(
- final IDataRecordKeyManager dataRecordKeyComparator) {
- throw new UnsupportedOperationException(
- "works only with long data record identifier");
- }
-}
Deleted: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java 2012-04-29 16:12:32 UTC (rev 3042)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -1,263 +0,0 @@
-/*
- * Copyright 2010 Luc Peuvrier
- *
- * This file is a part of JOAFIP.
- *
- * JOAFIP is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License.
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.gnu.org/licenses/lgpl.html
- *
- * JOAFIP is distributed in the hope that it will be useful, but
- * unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.sf.joafip.heapfile.service;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.heapfile.record.entity.HeapFreeNode;
-import net.sf.joafip.heapfile.record.entity.HeapHeader;
-import net.sf.joafip.heapfile.record.entity.HeapIdNode;
-import net.sf.joafip.heapfile.record.entity.HeapRecord;
-import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
-import net.sf.joafip.kvstore.record.service.IHeapElementManager;
-import net.sf.joafip.kvstore.service.HeapException;
-import net.sf.joafip.kvstore.service.IHeapDataManager;
-import net.sf.joafip.redblacktree.service.RBTException;
-import net.sf.joafip.redblacktree.service.RedBlackTree;
-import net.sf.joafip.redblacktree.service.RedBlackTreeIntegrityChecker;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public final class FileDataManagerIntegrityChecker {
-
- private final static FileDataManagerIntegrityChecker INSTANCE =
- /**/new FileDataManagerIntegrityChecker();
-
- public static FileDataManagerIntegrityChecker getInstance() {
- return INSTANCE;
- }
-
- // private transient HeapFileDataManager heapFileDataManager;
-
- private transient RedBlackTree<DataRecordIdentifier> idNodeTree;
-
- private transient RedBlackTree<Integer> freeNodeTree;
-
- private FileDataManagerIntegrityChecker() {
- super();
- }
-
- public void checkIntegrity(final IHeapDataManager dataManager)
- throws HeapException {
- if (HeapFileDataManager.class.equals(dataManager.getClass())) {
- checkIntegrity((HeapFileDataManager) dataManager);
- }
- }
-
- private void checkIntegrity(final HeapFileDataManager heapFileDataManager)
- throws HeapException {
- // this.heapFileDataManager = heapFileDataManager;
- final IHeapElementManager heapElementManager = heapFileDataManager
- .getHeapElementManager();
-
- // final IFileForStorable fileForStorable = new FileForStorableBridge(
- // manager.getFileForStorable());
- // this.manager = new HeapElementManager(fileForStorable, null/*
- // openFileTraceFile */);
- // this.manager.startService();
- // this.manager.openTransaction();
- // this.manager.setWriteAlwaysEnable(false);
- // this.manager.setWriteEnable(false);
-
- idNodeTree = heapFileDataManager.getIdNodeTree();
- freeNodeTree = heapFileDataManager.getFreeNodeTree();
-
- checkTrees();
-
- final HeapRecordIterator heapRecordIterator = new HeapRecordIterator(
- heapElementManager);
-
- final HeapHeader header = heapRecordIterator.getHeapHeader();
- if (header != null) {
- int freeRecordCount = 0;
- int dataRecordCount = 0;
- long identifier = -1;
- HeapRecord heapRecord = heapRecordIterator.getNextHeapRecord();
- HeapRecord lastHeapRecord = null;
- try {
- while (heapRecord != null) {
- if (heapRecord.isFreeRecord()) {
- freeRecordCount++;
- checkFreeNodeInTree(heapRecord);
- } else {
- dataRecordCount++;
- checkDataNodeInTree(heapRecord);
- final long heapRecordId = heapRecord
- .getNodeIdentifier().value;
- if (heapRecordId > identifier) {
- identifier = heapRecordId;
- }
- }
- lastHeapRecord = heapRecord;
- heapRecord = heapRecordIterator.getNextHeapRecord();
- }
- final long nextId = header.getNextDataRecordIdentifier();
- if (nextId <= identifier) {
- throw new HeapException("bad data record identifier");
- }
- checkLastRecord(header, lastHeapRecord);
- } catch (RBTException exception) {
- throw new HeapException(exception);
- }
-
- checkTotalNumberOfRecord(freeRecordCount, dataRecordCount);
- }
- }
-
- private void checkFreeNodeInTree(final HeapRecord heapRecord)
- throws RBTException, HeapException {
- if (!heapRecord.isFreeRecord()) {
- throw new HeapException("must be a free node");
- }
- final HeapFreeNode node = (HeapFreeNode) heapRecord.getFreeNode();
- if (node.getPositionInFile() != heapRecord.getPositionInFile()) {
- throw new HeapException(
- "position in file mismatch: heap record is "
- + heapRecord.getPositionInFile()
- + " and free node is " + node.getPositionInFile());
- }
- if (node.getRecordSize() != heapRecord.getRecordSize()) {
- throw new HeapException("area size mismatch: heap record is "
- + heapRecord.getRecordSize() + " and free node is "
- + node.getRecordSize());
- }
-
- HeapFreeNode found;
- found = (HeapFreeNode) freeNodeTree.search(heapRecord.getRecordSize());
- if (found == null) {
- throw new HeapException("free record must exist in free tree\n"
- + heapRecord);
- }
- while (found.getPositionInFile() != heapRecord.getPositionInFile()) {
- found = (HeapFreeNode) freeNodeTree.next(found);
- if (found == null
- || found.getRecordSize() != heapRecord.getRecordSize()) {
- throw new HeapException("free record must exist in free tree");
- }
- }
- }
-
- /**
- * check if heap record for data is in identifier tree
- *
- * @param heapRecord
- * @throws HeapException
- * @throws RBTException
- */
- private void checkDataNodeInTree(final HeapRecord heapRecord)
- throws HeapException, RBTException {
- if (heapRecord.isFreeRecord()) {
- throw new HeapException("must be a data record");
- }
- final DataRecordIdentifier identifier = heapRecord.getNodeIdentifier();
- final HeapIdNode foundIdNode = (HeapIdNode) idNodeTree
- .search(identifier);
- if (foundIdNode == null) {
- throw new HeapException("record for data, node #" + identifier
- + " must be in node identifier tree");
- }
- if (foundIdNode.getPositionInFile() != heapRecord.getPositionInFile()) {
- throw new HeapException("data record detached from id tree");
- }
- }
-
- private void checkLastRecord(final HeapHeader header,
- final HeapRecord lastHeapRecord) throws HeapException {
- if (lastHeapRecord == null) {
- if (header.getLastRecordPositionInFile() != -1) {
- throw new HeapException(
- "last record position in file must be undefined");
- }
- if (header.getEndOfRecordPositionInFile() != HeapHeader.HEAP_HEADER_SIZE) {
- throw new HeapException(
- "end of record position in file must be end of header size");
- }
- } else {
- if (header.getLastRecordPositionInFile() != lastHeapRecord
- .getPositionInFile()) {
- throw new HeapException(
- "last record position in file must be last record position");
- }
- if (header.getEndOfRecordPositionInFile() != lastHeapRecord
- .getPositionInFile() + lastHeapRecord.getRecordSize()) {
- throw new HeapException(
- "end of record position in file must be end of last record");
- }
- }
- }
-
- /**
- * check id node tree and free node tree
- *
- * @throws HeapException
- */
- private void checkTrees() throws HeapException {
- final RedBlackTreeIntegrityChecker<DataRecordIdentifier> idNodeTreeChecker =
- /**/new RedBlackTreeIntegrityChecker<DataRecordIdentifier>(idNodeTree);
- try {
- idNodeTreeChecker.checkTree();
- } catch (RBTException exception) {
- throw new HeapException("identifier tree corruption", exception);
- }
- final RedBlackTreeIntegrityChecker<Integer> freeNodeTreeChecker =
- /**/new RedBlackTreeIntegrityChecker<Integer>(freeNodeTree);
- try {
- freeNodeTreeChecker.checkTree();
- } catch (RBTException exception) {
- throw new HeapException("free node tree corruption", exception);
- }
- }
-
- /**
- * check total number of record
- *
- * @param freeRecordCount
- * free record count
- * @param dataRecordCount
- * data record count
- * @throws HeapException
- * bad number of record or access error
- */
- private void checkTotalNumberOfRecord(final int freeRecordCount,
- final int dataRecordCount) throws HeapException {
- try {
- final int numberOfRecord = idNodeTree.getNumberOfElement()
- + freeNodeTree.getNumberOfElement();
- if (dataRecordCount + freeRecordCount != numberOfRecord) {
- throw new HeapException(
- "bad number of record count: dataRecordCount="
- + dataRecordCount + ", freeRecordCount="
- + freeRecordCount + ", idNode="
- + idNodeTree.getNumberOfElement()
- + ", freeNode="
- + freeNodeTree.getNumberOfElement()
- + ", freeNode+idNode=" + numberOfRecord);
- }
- } catch (RBTException exception) {
- throw new HeapException("failed get number of element", exception);
- }
- }
-}
Copied: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java (from rev 3041, trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java)
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java (rev 0)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileDataManagerIntegrityChecker.java 2012-04-29 16:47:27 UTC (rev 3043)
@@ -0,0 +1,263 @@
+/*
+ * Copyright 2010 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.sf.joafip.heapfile.service;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.heapfile.record.entity.HeapFreeNode;
+import net.sf.joafip.heapfile.record.entity.HeapHeader;
+import net.sf.joafip.heapfile.record.entity.HeapIdNode;
+import net.sf.joafip.heapfile.record.entity.HeapRecord;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.record.service.IHeapElementManager;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.IHeapDataManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.redblacktree.service.RedBlackTree;
+import net.sf.joafip.redblacktree.service.RedBlackTreeIntegrityChecker;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public final class HeapFileDataManagerIntegrityChecker {
+
+ private final static HeapFileDataManagerIntegrityChecker INSTANCE =
+ /**/new HeapFileDataManagerIntegrityChecker();
+
+ public static HeapFileDataManagerIntegrityChecker getInstance() {
+ return INSTANCE;
+ }
+
+ // private transient HeapFileDataManager heapFileDataManager;
+
+ private transient RedBlackTree<DataRecordIdentifier> idNodeTree;
+
+ private transient RedBlackTree<Integer> freeNodeTree;
+
+ private HeapFileDataManagerIntegrityChecker() {
+ super();
+ }
+
+ public void checkIntegrity(final IHeapDataManager dataManager)
+ throws HeapException {
+ if (HeapFileDataManager.class.equals(dataManager.getClass())) {
+ checkIntegrity((HeapFileDataManager) dataManager);
+ }
+ }
+
+ private void checkIntegrity(final HeapFileDataManager heapFileDataManager)
+ throws HeapException {
+ // this.heapFileDataManager = heapFileDataManager;
+ final IHeapElementManager heapElementManager = heapFileDataManager
+ .getHeapElementManager();
+
+ // final IFileForStorable fileForStorable = new FileForStorableBridge(
+ // manager.getFileForStorable());
+ // this.manager = new HeapElementManager(fileForStorable, null/*
+ // openFileTraceFile */);
+ // this.manager.startService();
+ // this.manager.openTransaction();
+ // this.manager.setWriteAlwaysEnable(false);
+ // this.manager.setWriteEnable(false);
+
+ idNodeTree = heapFileDataManager.getIdNodeTree();
+ freeNodeTree = heapFileDataManager.getFreeNodeTree();
+
+ checkTrees();
+
+ final HeapRecordIterator heapRecordIterator = new HeapRecordIterator(
+ heapElementManager);
+
+ final HeapHeader header = heapRecordIterator.getHeapHeader();
+ if (header != null) {
+ int freeRecordCount = 0;
+ int dataRecordCount = 0;
+ long identifier = -1;
+ HeapRecord heapRecord = heapRecordIterator.getNextHeapRecord();
+ HeapRecord lastHeapRecord = null;
+ try {
+ while (heapRecord != null) {
+ if (heapRecord.isFreeRecord()) {
+ freeRecordCount++;
+ checkFreeNodeInTree(heapRecord);
+ } else {
+ dataRecordCount++;
+ checkDataNodeInTree(heapRecord);
+ final long heapRecordId = heapRecord
+ .getNodeIdentifier().value;
+ if (heapRecordId > identifier) {
+ identifier = heapRecordId;
+ }
+ }
+ lastHeapRecord = heapRecord;
+ heapRecord = heapRecordIterator.getNextHeapRecord();
+ }
+ final long nextId = header.getNextDataRecordIdentifier();
+ if (nextId <= identifier) {
+ throw new HeapException("bad data record identifier");
+ }
+ checkLastRecord(header, lastHeapRecord);
+ } catch (RBTException exception) {
+ throw new HeapException(exception);
+ }
+
+ checkTotalNumberOfRecord(freeRecordCount, dataRecordCount);
+ }
+ }
+
+ private void checkFreeNodeInTree(final HeapRecord heapRecord)
+ throws RBTException, HeapException {
+ if (!heapRecord.isFreeRecord()) {
+ throw new HeapException("must be a free node");
+ }
+ final HeapFreeNode node = (HeapFreeNode) heapRecord.getFreeNode();
+ if (node.getPositionInFile() != heapRecord.getPositionInFile()) {
+ throw new HeapException(
+ "position in file mismatch: heap record is "
+ + heapRecord.getPositionInFile()
+ + " and free node i...
[truncated message content] |
|
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:12:38
|
Revision: 3042
http://joafip.svn.sourceforge.net/joafip/?rev=3042&view=rev
Author: luc_peuvrier
Date: 2012-04-29 16:12:32 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
WIP btree plus: renamed because a heap file data manager dependent test
Modified Paths:
--------------
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/record/service/RecordServiceTests.java
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/record/service/RecordServiceTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/record/service/RecordServiceTests.java 2012-04-29 16:07:07 UTC (rev 3041)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/record/service/RecordServiceTests.java 2012-04-29 16:12:32 UTC (rev 3042)
@@ -29,7 +29,7 @@
// $JUnit-BEGIN$
suite.addTestSuite(TestHeapElementManagerWithHeapRecord.class);
suite.addTestSuite(TestHeapRecordManage.class);
- suite.addTestSuite(TestStoreRestore.class);
+ suite.addTestSuite(TestHeapRecordStoreRestore.class);
// $JUnit-END$
return suite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|