joafip-svn Mailing List for java data object persistence in file (Page 17)
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...> - 2011-11-23 02:54:49
|
Revision: 2979
http://joafip.svn.sourceforge.net/joafip/?rev=2979&view=rev
Author: luc_peuvrier
Date: 2011-11-23 02:54:42 +0000 (Wed, 23 Nov 2011)
Log Message:
-----------
weak management of object corrected
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/util/DebugUtil.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/entity/RBTNode.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-11-22 06:53:30 UTC (rev 2978)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-11-23 02:54:42 UTC (rev 2979)
@@ -119,6 +119,8 @@
private ObjectAndPersistInfoWeakReference weakReference;
+ private boolean weaked;
+
public FieldInfo[] fieldToSetInfo;
private IProxyCallBackToImplement proxyCallBack;
@@ -405,21 +407,24 @@
/**
*
+ * @param queue
+ * @return true if weaked, false if not weaked because already weaked or
+ * acceded
*/
public boolean weakReferenceOnObject(
final ReferenceQueue<? super Object> queue) {
// object!=null may be unreferenced object and statemap not already
// cleared
- final boolean weaked;
- if (isNotAcceded() && weakReference == null && object != null) {
- weakReference = new ObjectAndPersistInfoWeakReference(object, this,
- queue);
+ final boolean wasWeaked = weaked;
+ if (!weaked && isNotAcceded() && object != null) {
+ if (weakReference == null) {
+ weakReference = new ObjectAndPersistInfoWeakReference(object,
+ this, queue);
+ }
clear();// Unreferenced
weaked = true;
- } else {
- weaked = false;
}
- return weaked;
+ return !wasWeaked && weaked;
}
private boolean isNotAcceded() {
@@ -435,37 +440,37 @@
@Override
protected Object getObjectForEquals() {
final Object result;
- if (weakReference == null) {
+ if (weaked) {
+ result = weakReference.get();
+ } else {
result = this.object;
- } else {
- result = weakReference.get();
}
return result;
}
public boolean referenceLost() {
- return weakReference != null && weakReference.get() == null;
+ return weaked && weakReference.get() == null;
}
@Override
public Object getObject() {
final Object result;
- if (weakReference == null) {
- result = this.object;
- } else {
+ if (weaked) {
result = weakReference.get();
assert result != null : "reference lost " + toString();
+ } else {
+ result = this.object;
}
return result;
}
public boolean unWeakReferenceOnObject() {
- if (weakReference != null) {
+ if (weaked) {
assert object == null;
final Object object = weakReference.get();
if (object != null) {
setObject(object);
- weakReference = null;// NOPMD
+ weaked = false;
objectStateMap.unWeakReferenceOnObject(this);
}
}
@@ -473,19 +478,19 @@
}
public boolean isWeak() {
- return weakReference != null;
+ return weaked;
}
public boolean isNotWeak() {
- return weakReference == null;
+ return true ^ weaked;
}
public boolean hasNoReferences() {
- return weakReference != null && weakReference.get() == null;
+ return weaked && weakReference.get() == null;
}
public boolean hasReferences() {
- return weakReference == null || weakReference.get() != null;
+ return !weaked || weakReference.get() != null;
}
public int getJoafipReleaseId() {
@@ -602,7 +607,7 @@
return /**/"object[" +
/**/(object == null ?
/**/"null" :
- /**/((objectClass == null ? "no class" : objectClass.getName()) +
+ /**/(objectClass.getName() +
/**/"@" + hashCode()))
/**/+ "]";
@@ -610,17 +615,18 @@
private String weakToString() {
final Object weak;
- if (weakReference == null) {
+ if (weaked) {
+ weak = weakReference.get();
+ } else {
weak = null;
- } else {
- weak = weakReference.get();
}
return /**/"weakReference["
- /**/+ (weakReference == null ?
- /**/"none" : // NOPMD
- /**/(weak == null ? "null" : (weak.getClass()
- .getName() + "@" + System
- .identityHashCode(weak))))
+ /**/+ (weaked ?
+ /**/(weak == null ? "null"
+ : (weak.getClass().getName() + "@" + System
+ .identityHashCode(weak))) :
+ /**/"none" // NOPMD
+ )
/**/+ "]";
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-11-22 06:53:30 UTC (rev 2978)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-11-23 02:54:42 UTC (rev 2979)
@@ -32,6 +32,7 @@
import net.sf.joafip.store.entity.classinfo.ClassInfo;
import net.sf.joafip.store.service.classinfo.ClassInfoException;
import net.sf.joafip.store.service.objectio.ObjectIOException;
+import net.sf.joafip.util.DebugUtil;
/**
* Maintains link between object in memory and their persistence information<br>
@@ -80,7 +81,7 @@
private boolean stopExpungeThread;
- private final Thread expungeThread;
+ private Thread expungeThread;
/**
* empty object state informations at construction
@@ -88,6 +89,10 @@
*/
public ObjectStateMap() {// NOPMD explicit constructor
super();
+ // startThread();
+ }
+
+ private void startThread() {
expungeThread = new Thread(this, "objectStateExpunge-Thread");
expungeThread.setDaemon(true);
expungeThread.setPriority(Thread.MAX_PRIORITY);
@@ -95,6 +100,12 @@
}
public void close() {
+ if (exclusiveAccessSession) {
+ stopThread();
+ }
+ }
+
+ private void stopThread() {
synchronized (this) {
if (!stopExpungeThread) {
stopExpungeThread = true;
@@ -110,14 +121,19 @@
}
public void setExclusiveAccessSession(final boolean exclusiveAccessSession) {
+ final boolean wasExclusiveAccessSession = this.exclusiveAccessSession;
this.exclusiveAccessSession = exclusiveAccessSession;
+ if (wasExclusiveAccessSession != this.exclusiveAccessSession) {
+ if (this.exclusiveAccessSession) {
+ startThread();
+ } else {
+ stopThread();
+ }
+ }
}
public ObjectAndPersistInfo getObjectPersistenceStateByObjectIdentityKey(
final IObjectIdentityKey objectIdentityKey) {
- // if (exclusiveAccessSession) {
- // expunge();
- // }
synchronized (this) {
return stateMap.get(objectIdentityKey);
}
@@ -125,9 +141,6 @@
public void clearObjectAndPersistInfoByDataRecordIdentifier(
final DataRecordIdentifier dataRecordIdentifier) {
- // if (exclusiveAccessSession) {
- // expunge();
- // }
synchronized (this) {
stateMapByIdentifier.remove(dataRecordIdentifier);
}
@@ -142,9 +155,6 @@
synchronized (this) {
// ASSERTX
assert objectAndPersistInfo.getObjectStateMap() == this;
- // if (exclusiveAccessSession) {
- // expunge();
- // }
// ASSERTX
assert objectAndPersistInfo.isNotWeak();
// ASSERTX
@@ -174,7 +184,6 @@
synchronized (this) {
ObjectAndPersistInfo objectAndPersistInfo;
if (exclusiveAccessSession) {
- // expunge();
objectAndPersistInfo = stateMapByIdentifier.get(identifier);
if (objectAndPersistInfo != null
&& !objectAndPersistInfo.unWeakReferenceOnObject()) {
@@ -204,9 +213,6 @@
synchronized (this) {
// ASSERTX
assert object != null : "null has not persistent state";
- // if (exclusiveAccessSession) {
- // expunge();
- // }
key.setObject(object);
final ObjectAndPersistInfo objectAndPersistInfo = stateMap.get(key);
// key must not more reference object
@@ -266,9 +272,6 @@
objectAndPersistInfo.setObjectStateMap(this);
// ASSERTX
assert objectAndPersistInfo.getObject() != null : "null object";
- // if (exclusiveAccessSession) {
- // expunge();
- // }
if (stateMap.put(objectAndPersistInfo, objectAndPersistInfo) != null) {
throw new ObjectIOException(
"persistence state already exists for "
@@ -316,9 +319,6 @@
public boolean objectHasPersistenceState(
final ObjectAndPersistInfo objectAndPersistInfo) {
synchronized (this) {
- // if (exclusiveAccessSession) {
- // expunge();
- // }
return stateMap.containsKey(objectAndPersistInfo);
}
}
@@ -330,9 +330,6 @@
*/
public void clear() throws ObjectIOException {
synchronized (this) {
- // if (exclusiveAccessSession) {
- // expunge();
- // }
stateMap.clear();
stateMapByIdentifier.clear();
key.clear();
@@ -383,7 +380,6 @@
// objectAndPersistInfo.weakReferenceOnObject();
// }
- // expunge();
// do not clear queueHead and queueTail
ObjectAndPersistInfo current = queueHead;
@@ -421,7 +417,6 @@
public void unWeakReferenceOnObject(final ObjectAndPersistInfo toUnWeak) {
if (exclusiveAccessSession) {
synchronized (this) {
- // expunge();
// final ObjectAndPersistInfo previous = stateMap.put(toUnWeak,
// toUnWeak);
// assert previous == null : "persistence state already set";
@@ -454,21 +449,6 @@
final Collection<ObjectAndPersistInfo> objectHavingStateSet =
/**/new LinkedHashSet<ObjectAndPersistInfo>();
- // if (exclusiveAccessSession) {
- // expunge();
- // for (ObjectAndPersistInfo objectAndPersistInfo :
- // stateMap.values()) {
- // if (objectAndPersistInfo.isNotWeak()) {
- // objectHavingStateSet.add(objectAndPersistInfo);
- // }
- // }
- // } else {
- // for (ObjectAndPersistInfo objectAndPersistInfo :
- // stateMap.values()) {
- // objectHavingStateSet.add(objectAndPersistInfo);
- // }
- // }
-
ObjectAndPersistInfo current = referencedQueueHead;
while (current != null) {
objectHavingStateSet.add(current);
@@ -489,10 +469,9 @@
final ObjectAndPersistInfo objectAndPersistInfoOfObject) {
if (exclusiveAccessSession) {
synchronized (this) {
- // expunge();
final boolean unWeaked = objectAndPersistInfoOfObject
.unWeakReferenceOnObject();
- assert unWeaked;
+ assert unWeaked : objectAndPersistInfoOfObject.toString();
assert stateMap.containsKey(objectAndPersistInfoOfObject) : "not in state map: "
+ objectAndPersistInfoOfObject.toString();
if (trackingOfAccessedObjectEnabled) {
@@ -527,7 +506,6 @@
*/
public Set<ObjectAndPersistInfo> mostAccessedObject(final int quota) {
synchronized (this) {
- // expunge();
final Set<ObjectAndPersistInfo> set = new LinkedHashSet<ObjectAndPersistInfo>();
int count = 0;
ObjectAndPersistInfo current = queueHead;
@@ -545,7 +523,6 @@
@Fortest
public List<ObjectAndPersistInfo> getObjectAndPersistInfoOfObjectFromQueue() {
synchronized (this) {
- // expunge();
final List<ObjectAndPersistInfo> list = new LinkedList<ObjectAndPersistInfo>();
ObjectAndPersistInfo current = queueHead;
while (current != null) {
@@ -562,7 +539,10 @@
while (!stopExpungeThread) {
final ObjectAndPersistInfoWeakReference ref = (ObjectAndPersistInfoWeakReference) referenceQueue
.remove(/* timeout ? */);
- if (ref != null) {/* can be null only if timeout */
+ if (!stopExpungeThread && ref != null) {/*
+ * can be null only if
+ * timeout
+ */
synchronized (ObjectStateMap.this) {
final ObjectAndPersistInfo objectAndPersistInfo = ref
.getObjectAndPersistInfo();
@@ -581,19 +561,23 @@
}
private void removeWeaked(final ObjectAndPersistInfo toRemove) {
- stateMap.remove(toRemove);
- stateMapByIdentifier.remove(toRemove.dataRecordIdentifier);
- // FIXMELUC ?___assert failure, why ?
- // assert x == toRemove : x + "\n" + toRemove;
+ final ObjectAndPersistInfo removed = stateMap.remove(toRemove);
+ assert removed != null : toRemove.toString();
+ /* removed = */stateMapByIdentifier
+ .remove(toRemove.dataRecordIdentifier);
+ // bad assert, may be no data record associated to object
+ // assert removed == toRemove : removed + "\n" + toRemove;
toRemove.clearSubstitution();
removeFromQueue(toRemove);
}
private void removeFromQueue(final ObjectAndPersistInfo toRemove) {
- // FIXMELUC ___may be not needed to clear queue link
toRemove.setObjectStateMap(null);
final ObjectAndPersistInfo previous = toRemove.previous;
- assert previous != null || toRemove == queueHead; // NOPMD
+ assert previous != null || toRemove == queueHead : // NOPMD
+ /**/"previousIsNull=" + (previous == null) + " nextIsNull="
+ + (toRemove.next == null) + // NOPMD
+ /**/" " + toRemove.toString();
final ObjectAndPersistInfo next = toRemove.next;
assert next != null || toRemove == queueTail;// NOPMD
toRemove.next = null;// NOPMD
Modified: trunk/joafip/src/main/java/net/sf/joafip/util/DebugUtil.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/util/DebugUtil.java 2011-11-22 06:53:30 UTC (rev 2978)
+++ trunk/joafip/src/main/java/net/sf/joafip/util/DebugUtil.java 2011-11-23 02:54:42 UTC (rev 2979)
@@ -103,7 +103,7 @@
final Class<?> toClass) {
final String stackTrace;
if (throwable == null) {
- stackTrace = "";
+ stackTrace = "none";
} else {
final StackTraceElement[] stackTraceElements = throwable
.getStackTrace();
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java 2011-11-22 06:53:30 UTC (rev 2978)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java 2011-11-23 02:54:42 UTC (rev 2979)
@@ -69,20 +69,26 @@
session.open();
- final RBTree tree = RBTree.newInstance(instanceFactory);
+ try {
+ final RBTree tree = RBTree.newInstance(instanceFactory);
+ session.setObject("tree", tree);
- for (int count = 0; count < 1000000; count++) {
- tree.append("" + count);// NOPMD
- if (count % 1000 == 0) {
- System.out.println("c=" + count);// NOPMD
+ for (int count = 0; count < 1000000; count++) {
+ tree.append("" + count);// NOPMD
+ if (count % 1000 == 0) {
+ System.out.println("c=" + count);// NOPMD
+ }
+ if (count > 8) {
+ tree.remove("" + (count - 8));// NOPMD
+ }
}
- if (count > 8) {
- tree.remove("" + (count - 8));// NOPMD
- }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ session.close();
}
- session.close();
-
+ filePersistence.xmlExport("runtime", "runtime/temp", false);
filePersistence.close();
}
Modified: trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/entity/RBTNode.java
===================================================================
--- trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/entity/RBTNode.java 2011-11-22 06:53:30 UTC (rev 2978)
+++ trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/entity/RBTNode.java 2011-11-23 02:54:42 UTC (rev 2979)
@@ -195,7 +195,7 @@
public boolean isBlack() throws RBTException {
if (noColorSetted) {
- throw new RBTException(COLOR_NOT_SET);
+ throw new RBTException(COLOR_NOT_SET + "\n" + toString());
}
return color == RedBlackTree.BLACK;
}
@@ -207,7 +207,7 @@
public boolean isRed() throws RBTException {
if (noColorSetted) {
- throw new RBTException(COLOR_NOT_SET);
+ throw new RBTException(COLOR_NOT_SET + "\n" + toString());
}
return color == RedBlackTree.RED;
}
@@ -255,7 +255,7 @@
public boolean getColor() throws RBTException {// NOPMD color is a value
if (noColorSetted) {
- throw new RBTException(COLOR_NOT_SET);
+ throw new RBTException(COLOR_NOT_SET + "\n" + toString());
}
return color;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-23 02:54:48
|
Revision: 2979
http://joafip.svn.sourceforge.net/joafip/?rev=2979&view=rev
Author: luc_peuvrier
Date: 2011-11-23 02:54:42 +0000 (Wed, 23 Nov 2011)
Log Message:
-----------
weak management of object corrected
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/util/DebugUtil.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java
trunk/joafip-rbtree/src/main/java/net/sf/joafip/redblacktree/impl/memory/entity/RBTNode.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-22 06:53:37
|
Revision: 2978
http://joafip.svn.sourceforge.net/joafip/?rev=2978&view=rev
Author: luc_peuvrier
Date: 2011-11-22 06:53:30 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
added test for auto save
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java
Removed Paths:
-------------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-22 06:53:37
|
Revision: 2978
http://joafip.svn.sourceforge.net/joafip/?rev=2978&view=rev
Author: luc_peuvrier
Date: 2011-11-22 06:53:30 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
added test for auto save
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java
Removed Paths:
-------------
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -292,6 +292,8 @@
.toString();
assert objectAndPersistInfo.isLoaded() : objectAndPersistInfo
.toString();
+ assert persisted;
+ assert dataRecordIdentifier == null;
objectAndPersistInfo.setStorageInfo(storageInfo);
// objectIOManager.objectIsAccessed(objectAndPersistInfo);
// objectAndPersistInfo.setNewObject(true);
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveInMethodTest.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -0,0 +1,38 @@
+package net.sf.joafip.entity.rel400;
+
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+public class BobForAutoSaveInMethodTest {
+
+ private final BobASHeld held;
+
+ private int value;
+
+ public BobForAutoSaveInMethodTest(final IInstanceFactory instanceFactory) {
+ super();
+ held = BobASHeld.newInstance(instanceFactory);
+ }
+
+ public static BobForAutoSaveInMethodTest newInstance(
+ final IInstanceFactory instanceFactory) {
+ final BobForAutoSaveInMethodTest newInstance;
+ if (instanceFactory == null) {
+ newInstance = new BobForAutoSaveInMethodTest(instanceFactory);
+ } else {
+ newInstance = (BobForAutoSaveInMethodTest) instanceFactory
+ .newInstance(BobForAutoSaveInMethodTest.class,
+ new Class<?>[] { IInstanceFactory.class },
+ new Object[] { instanceFactory });
+ }
+ return newInstance;
+ }
+
+ public void incrementValue() {
+ held.setOpened(true);
+ value++;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
Deleted: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -1,44 +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.entity.rel400;
-
-import net.sf.joafip.store.service.objectfortest.Bob1;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-public class BobForAutoSaveTest {
-
- private final int val;
-
- public BobForAutoSaveTest(final Bob1 bob1) {
- super();
- this.val = bob1.getVal();
- }
-
- public int getVal() {
- return val;
- }
-}
Copied: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java (from rev 2977, trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveTest.java)
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/BobForAutoSaveWhenConstructTest.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -0,0 +1,44 @@
+/*
+ * 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.entity.rel400;
+
+import net.sf.joafip.store.service.objectfortest.Bob1;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class BobForAutoSaveWhenConstructTest {
+
+ private final int val;
+
+ public BobForAutoSaveWhenConstructTest(final Bob1 bob1) {
+ super();
+ this.val = bob1.getVal();
+ }
+
+ public int getVal() {
+ return val;
+ }
+}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestAutoSave.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -34,7 +34,8 @@
import net.sf.joafip.entity.rel400.BobASDelegatingListenDelegate;
import net.sf.joafip.entity.rel400.BobASWithTransientCaller;
import net.sf.joafip.entity.rel400.BobAsDelegateNotifyDelegating;
-import net.sf.joafip.entity.rel400.BobForAutoSaveTest;
+import net.sf.joafip.entity.rel400.BobForAutoSaveInMethodTest;
+import net.sf.joafip.entity.rel400.BobForAutoSaveWhenConstructTest;
import net.sf.joafip.entity.rel400.KeyDef;
import net.sf.joafip.java.util.PTreeMap;
import net.sf.joafip.service.FilePersistence;
@@ -115,6 +116,7 @@
filePersistence.maintainInMemorySetup(0);// zero to save at each access,
// needed by the test
filePersistence.setMaintainedInMemoryEnabled(true);
+ filePersistence.addToNotCheckMethod(Bob1.class);
session = filePersistence.createExclusiveDataAccessSession();
}
@@ -264,8 +266,8 @@
assertFalse("must not be loaded",
ProxyManager2.proxiedObjectIsLoaded(bob1));
saveDoneFlag = false;
- final BobForAutoSaveTest bobForAutoSaveTest = (BobForAutoSaveTest) instanceFactory
- .newInstance(BobForAutoSaveTest.class,
+ final BobForAutoSaveWhenConstructTest bobForAutoSaveTest = (BobForAutoSaveWhenConstructTest) instanceFactory
+ .newInstance(BobForAutoSaveWhenConstructTest.class,
new Class[] { Bob1.class }, new Object[] { bob1 });
assertTrue(MUST_SAVE, saveDoneFlag);
session.setObject(KEY, bobForAutoSaveTest);
@@ -503,6 +505,36 @@
assertFalse("must not has next", iterator.hasNext());
}
+ public void testAutoSaveInMethod() throws FilePersistenceException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceTooBigForSerializationException, ProxyException {
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+ session.open();
+ BobForAutoSaveInMethodTest bob = BobForAutoSaveInMethodTest
+ .newInstance(instanceFactory);
+ assertEquals("bad initial state", 0, bob.getValue());
+ saveDoneFlag = false;
+ int expectedIncrement = 1;
+ for (int count = 0; count < 5; count++) {
+ bob.incrementValue();
+ assertTrue(MUST_SAVE, saveDoneFlag);
+ assertTrue("must be unloaded", ProxyManager2.isUnloaded(bob));
+ assertEquals("bad state", expectedIncrement, bob.getValue());
+ expectedIncrement++;
+ }
+ session.setObject(KEY, bob);
+ session.close();
+
+ session.open();
+ bob = (BobForAutoSaveInMethodTest) session.getObject(KEY);
+ assertEquals("bad state", expectedIncrement - 1, bob.getValue());
+ session.close();
+
+ }
+
@Override
public boolean doSave() {
return true;
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-11-22 05:40:43 UTC (rev 2977)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-11-22 06:53:30 UTC (rev 2978)
@@ -24,13 +24,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import net.sf.joafip.service.TestExportImport;
-import net.sf.joafip.service.TestExportObject;
-import net.sf.joafip.service.rel300.TestImport222;
-import net.sf.joafip.service.rel300.TestImport222NotLazy;
-import net.sf.joafip.service.rel301.TestImport300;
-import net.sf.joafip.service.rel310.TestImport301ConversionA;
-import net.sf.joafip.service.rel310.TestImport301ConversionB;
+import net.sf.joafip.store.service.TestGarbageForegroundFile;
+import net.sf.joafip.store.service.proxy.TestProxyCreationConstructed;
/**
*
@@ -47,13 +42,8 @@
public static Test suite() {
final TestSuite suite = new TestSuite("in error Tests");
// $JUnit-BEGIN$
- suite.addTestSuite(TestExportImport.class);
- suite.addTestSuite(TestExportObject.class);
- suite.addTestSuite(TestImport222.class);
- suite.addTestSuite(TestImport222NotLazy.class);
- suite.addTestSuite(TestImport300.class);
- suite.addTestSuite(TestImport301ConversionA.class);
- suite.addTestSuite(TestImport301ConversionB.class);
+ suite.addTestSuite(TestGarbageForegroundFile.class);
+ suite.addTestSuite(TestProxyCreationConstructed.class);
// suite.addTest(xxxx.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...> - 2011-11-22 05:40:50
|
Revision: 2977
http://joafip.svn.sourceforge.net/joafip/?rev=2977&view=rev
Author: luc_peuvrier
Date: 2011-11-22 05:40:43 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
refactoring
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/IObjectIOManagerForProxyObjectIO.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestGarbage.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractObjectIOTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractObjectIoManagerForProxyTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
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/BlockDataManager.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/TestHeapFileDataMgrWithScenario.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/IObjectIOManagerForProxyObjectIO.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/IObjectIOManagerForProxyObjectIO.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/IObjectIOManagerForProxyObjectIO.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -169,9 +169,6 @@
void unsetProxyObjectState(ObjectAndPersistInfo objectAndItsClassInfo)
throws ObjectIOException, ObjectIOInvalidClassException;
- void saveAndUnsetProxyObjectState(ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException;
-
IProxyManagerForObjectIO getProxyManager2();
ClassInfoFactory getClassInfoFactory();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -305,14 +305,6 @@
}
@Override
- public void saveAndUnsetProxyObjectState(
- final ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException {
- autoSave();
- unsetProxyObjectState(objectAndItsClassInfo);
- }
-
- @Override
protected DataRecordIdentifier associateNewDataRecordIdentifierToObject(
final ObjectAndPersistInfo objectAndPersistInfo)
throws ObjectIODataCorruptedException, ObjectIOException {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -375,13 +375,6 @@
throw new ObjectIOException(MUST_NOT_BE_CALLED);
}
- @Override
- public void saveAndUnsetProxyObjectState(
- final ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException {
- throw new ObjectIOException(MUST_NOT_BE_CALLED);
- }
-
/** not maintain in memory for joafip serialization in one data record */
@Override
public boolean isMaintainInMemoryEnabled() {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -65,8 +65,6 @@
private boolean wasLoaded;
- private boolean toUnload;
-
/**
* the proxy instance and persistence information for which is this proxy
* callback
@@ -264,10 +262,6 @@
@Override
public void constructorEnd$JOAFIP$() {
inObjectCount--;
- // if (autoSaveEnabled) {
- // unLoadAction(getInstance$JOAFIP$());
- // }
- toUnload = false;
assert inObjectCount >= 0 : "running in object count can not be negative, is "
+ inObjectCount;
}
@@ -276,7 +270,6 @@
@SuppressWarnings("PMD")
public void methodEnd$JOAFIP$() {
synchronized (storeMutex) {
- final ObjectAndPersistInfo instanceAndPersistInfo = getInstance$JOAFIP$();
inObjectCount--;
// ASSERTX
assert inObjectCount >= 0 : "running in object count can not be negative, is "
@@ -290,28 +283,11 @@
throw new ProxyInterceptException(exception);
}
}
- unLoadAction(instanceAndPersistInfo);
}
}
}
}
- private void unLoadAction(final ObjectAndPersistInfo instanceAndPersistInfo) {
- if (toUnload) {
- toUnload = false;
- loaded = false;
- assert instanceAndPersistInfo != null;
- try {
- objectIOManager
- .saveAndUnsetProxyObjectState(instanceAndPersistInfo);
- } catch (Exception exception) {
- LOGGER.error("method end interception error", exception);
- throw new ProxyInterceptException(
- instanceAndPersistInfo.toString(), exception);
- }
- }
- }
-
@Override
@SuppressWarnings("PMD")
public boolean isLoaded$JOAFIP$() throws ObjectIOException {
@@ -347,16 +323,14 @@
/*
* inObjectCount==0 because can not unload object when running its code
*/
- if (loaded) {
- if (!loading && (!exclusiveAccessSession || inObjectCount == 0)) {
- toUnload = false;
- loaded = false;
- objectIOManager.unsetProxyObjectState(getInstance$JOAFIP$());
- } else {
- toUnload = true;
- }
- } else {
- toUnload = false;
+ // FIXMELUC __________________________unload !exclusiveAccessSession
+ if (loaded && !loading && inObjectCount == 0) {
+ // if (loaded) {
+ // if (!loading && (!exclusiveAccessSession || inObjectCount == 0))
+ // {
+ loaded = false;
+ objectIOManager.unsetProxyObjectState(getInstance$JOAFIP$());
+ // }
}
// }
}
@@ -366,7 +340,6 @@
public void setIsLoaded$JOAFIP$() throws ObjectIOException {
if (!this.loaded) {
this.loaded = true;
- this.toUnload = false;
objectIOManager.newObjectLoaded();
}
}
@@ -376,7 +349,6 @@
public void setIsLoadedNoSave$JOAFIP$() {
if (!this.loaded) {
this.loaded = true;
- this.toUnload = false;
}
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestGarbage.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestGarbage.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestGarbage.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -67,6 +67,7 @@
visitedRecordManager = store.getVisitedRecordManager();
objectIoManager = store.getObjectIOManager();
heapRecordableManager = store.getHeapRecordableManager();
+ store.addToNotCheckMethod(Bob1.class);
}
@Override
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -329,13 +329,6 @@
}
@Override
- public void saveAndUnsetProxyObjectState(
- final ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException {
- throw new UnsupportedOperationException();
- }
-
- @Override
public void dataRecordIdentifierAssociatedToObjectSetted(
final ObjectAndPersistInfo objectAndItsClassInfo)
throws ObjectIOException {
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractObjectIOTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractObjectIOTest.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractObjectIOTest.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -368,13 +368,6 @@
// nothing to implement
}
- @Override
- public void saveAndUnsetProxyObjectState(
- final ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException {
- // nothing to implement
- }
-
public boolean isGarbageManagement() { // NOPMD
// nothing to implement
return false;
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractObjectIoManagerForProxyTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractObjectIoManagerForProxyTest.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractObjectIoManagerForProxyTest.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -167,13 +167,6 @@
}
@Override
- public void saveAndUnsetProxyObjectState(
- final ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException {
- setted = false;
- }
-
- @Override
@SuppressWarnings("PMD")
public ProxyManager2 getProxyManager2() {
// no implementation
@@ -187,7 +180,7 @@
@Override
public boolean isExclusiveAccessSession() {
- return false;
+ return true;
}
@Override
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -240,13 +240,6 @@
}
@Override
- public void saveAndUnsetProxyObjectState(
- final ObjectAndPersistInfo objectAndItsClassInfo)
- throws ObjectIOException, ObjectIOInvalidClassException {
- // no implementation
- }
-
- @Override
public boolean isExclusiveAccessSession() {
return false;
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -72,6 +72,7 @@
new Class<?>[] { String.class },
new Object[] { "a name" }, storageInfo, this,
DataRecordIdentifier.LAST, true);
+ assertEquals(0, proxyManager2.getInObjectCount(object));
inConstruction = false;
assertTrue("must say is a proxy",
ProxyManager2.isProxyOrEnhanced(object));
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -176,7 +176,7 @@
* @return data record identifier of first data record removed
* @throws HeapException
*/
- //FIXMELUC _____________________to test or remove or add more
+ // FIXMELUC ________to test or remove or add more
DataRecordIdentifier removeFirstDataRecord() throws HeapException;
/**
Modified: 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 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -49,13 +49,13 @@
private static final long serialVersionUID = 8579792598621073099L;
private int blockLength;
-
+
private DataRecordIdentifier nextIdentifier;
private long dataLength;
private int numberOfDataRecord;
-
+
public int getBlockLength() {
return blockLength;
}
@@ -116,8 +116,8 @@
private void set(final BlockDataManagerHeader header) {
this.dataLength = header.dataLength;
this.nextIdentifier = header.nextIdentifier;
- this.blockLength=header.blockLength;
- this.numberOfDataRecord=header.numberOfDataRecord;
+ this.blockLength = header.blockLength;
+ this.numberOfDataRecord = header.numberOfDataRecord;
}
public byte[] get() throws HeapException {
@@ -142,10 +142,10 @@
private void readObject(final ObjectInputStream input) throws IOException,
ClassNotFoundException {
- blockLength=input.readInt();
+ blockLength = input.readInt();
dataLength = input.readLong();
final long value = input.readLong();
nextIdentifier = new DataRecordIdentifier(value);
- numberOfDataRecord=input.readInt();
+ numberOfDataRecord = input.readInt();
}
}
Modified: 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 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -25,17 +25,18 @@
/**
*
* @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
+ public DataBlock(final long positionInFile, final boolean toWrite,
+ final byte[] data) { // NOPMD
super();
this.positionInFile = positionInFile;
this.toWrite = toWrite;
@@ -55,6 +56,6 @@
}
public byte[] getData() {
- return data; //NOPMD
+ return data; // NOPMD
}
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -116,7 +116,8 @@
* @throws HeapException
*
*/
- protected void createHeapFileDataManager(final boolean 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,
@@ -127,15 +128,17 @@
heapDataManager.startService(removeFile);
}
- protected void createBlockDataManager(final boolean removeFile) throws HeapException {
- heapDataManager = new BlockDataManager(dataFilePath,20000);
+ 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 void createHeap(final boolean removeFile)
+ throws HeapException;
+
protected abstract boolean manageFreeRecord();
-
+
/**
* @throws HeapException
*
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -195,7 +195,7 @@
final long position = getRecordPositionInfile(dataRecordIdentifier);
final boolean deleted;
final byte[] lengthData = new byte[2];
- final int read = read(position, 0, lengthData,true);
+ final int read = read(position, 0, lengthData, true);
if (read == 2) {
final int length = (((int) lengthData[0]) & 0xff) << 8
| (((int) lengthData[1]) & 0xff);
@@ -224,7 +224,7 @@
try {
final long position = getRecordPositionInfile(dataRecordIdentifier);
byte[] data = new byte[2];
- final int read = read(position, 0, data,true);
+ final int read = read(position, 0, data, true);
if (read == 2) {
final int length = (((int) data[0]) & 0xff) << 8
| (((int) data[1]) & 0xff);
@@ -233,7 +233,7 @@
data = null;// NOPMD
} else {
data = new byte[length];
- read(position, 2, data,true);
+ read(position, 2, data, true);
}
} else {
data = null;// NOPMD
@@ -260,7 +260,7 @@
final boolean created;
final byte[] lengthData = new byte[2];
int previousLength = -1;
- final int read = read(position, 0, lengthData,true);
+ final int read = read(position, 0, lengthData, true);
if (read == 2) {
previousLength = (((int) lengthData[0]) & 0xff) << 8
| (((int) lengthData[1]) & 0xff);
@@ -291,7 +291,7 @@
final long position = getRecordPositionInfile(dataRecordIdentifier);
final boolean hasDatarecord;
final byte[] lengthData = new byte[2];
- final int read = read(position, 0, lengthData,true);
+ final int read = read(position, 0, lengthData, true);
if (read == 2) {
final int length = (((int) lengthData[0]) & 0xff) << 8
| (((int) lengthData[1]) & 0xff);
@@ -337,7 +337,7 @@
long position = firstRecordPositionInfile;
final byte[] lengthData = new byte[2];
do {
- final int read = read(position, 0, lengthData,false);
+ final int read = read(position, 0, lengthData, false);
if (read == 2) {
final int length = (((int) lengthData[0]) & 0xff) << 8
| (((int) lengthData[1]) & 0xff);
@@ -475,7 +475,7 @@
throws FileIOException {
DataBlock dataBlock = cacheMap.get(position);
if (dataBlock == null) {
- dataBlock = readInFile(position,true);
+ dataBlock = readInFile(position, true);
if (dataBlock == null) {
final byte[] recordData = new byte[header.getBlockLength()];
dataBlock = new DataBlock(position, true, recordData);
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 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -38,7 +38,8 @@
super();
}
- public TestHeapFileDataManagerBackup(final String name) throws TestException {
+ public TestHeapFileDataManagerBackup(final String name)
+ throws TestException {
super(name);
}
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 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -30,7 +30,8 @@
super();
}
- public TestHeapFileDataManagerFreeing(final String name) throws TestException {
+ public TestHeapFileDataManagerFreeing(final String name)
+ throws TestException {
super(name);
}
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 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -31,7 +31,8 @@
super();
}
- public TestHeapFileDataMgrMemoryLeak(final String name) throws TestException {
+ public TestHeapFileDataMgrMemoryLeak(final String name)
+ throws TestException {
super(name);
}
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 2011-11-21 19:53:58 UTC (rev 2976)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java 2011-11-22 05:40:43 UTC (rev 2977)
@@ -47,7 +47,8 @@
super();
}
- public TestHeapFileDataMgrWithScenario(final String name) throws TestException {
+ public TestHeapFileDataMgrWithScenario(final String name)
+ throws TestException {
super(name);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-22 05:40:49
|
Revision: 2977
http://joafip.svn.sourceforge.net/joafip/?rev=2977&view=rev
Author: luc_peuvrier
Date: 2011-11-22 05:40:43 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
refactoring
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/IObjectIOManagerForProxyObjectIO.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/AbstractTestGarbage.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/copier/AbstractTestDeepCopier.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractObjectIOTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/AbstractObjectIoManagerForProxyTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/ProxyCallBackForTest.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/proxy/TestProxyCreationConstructed.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
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/BlockDataManager.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/TestHeapFileDataMgrWithScenario.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 19:54:05
|
Revision: 2976
http://joafip.svn.sourceforge.net/joafip/?rev=2976&view=rev
Author: luc_peuvrier
Date: 2011-11-21 19:53:58 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
refactoring
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractSerializeTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 19:54:05
|
Revision: 2976
http://joafip.svn.sourceforge.net/joafip/?rev=2976&view=rev
Author: luc_peuvrier
Date: 2011-11-21 19:53:58 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
refactoring
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractSerializeTest.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-11-21 07:14:22 UTC (rev 2975)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-11-21 19:53:58 UTC (rev 2976)
@@ -39,7 +39,7 @@
@NotStorableClass
public class ExportStoreQue {
- // FIXMELUC ____________________________why not empty ?
+ // FIXMELUC ______why not empty ?
// HeapFileDataManager not accept empty data
// net.sf.joafip.heapfile.service.HeapException: associated data size must
// be defined
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-11-21 07:14:22 UTC (rev 2975)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerIOForObject.java 2011-11-21 19:53:58 UTC (rev 2976)
@@ -833,10 +833,10 @@
@Override
public void newObjectLoaded() throws ObjectIOException {
- autoSave();
+ checkForAutoSave();
}
- protected abstract void autoSave() throws ObjectIOException;
+ protected abstract void checkForAutoSave() throws ObjectIOException;
/**
* creation of a not existing object delegating to
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-11-21 07:14:22 UTC (rev 2975)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-11-21 19:53:58 UTC (rev 2976)
@@ -308,7 +308,7 @@
public void saveAndUnsetProxyObjectState(
final ObjectAndPersistInfo objectAndItsClassInfo)
throws ObjectIOException, ObjectIOInvalidClassException {
- save();
+ autoSave();
unsetProxyObjectState(objectAndItsClassInfo);
}
@@ -677,17 +677,16 @@
}
@Override
- protected void autoSave() throws ObjectIOException {
+ protected void checkForAutoSave() throws ObjectIOException {
if (autoSaveEnabled) {
- // final int numberOfObjectState = getNumberOfObjectState();
final int numberOfObjectState = getNumberOfReferenced();
if (numberOfObjectState >= maxInMemoryThreshold && doAutoSave()) {
- save();
+ autoSave();
}
}
}
- protected void save() throws ObjectIOException {
+ protected void autoSave() throws ObjectIOException {
try {
final long beginTime = System.currentTimeMillis();
final boolean saveDone = saver.autoSave();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java 2011-11-21 07:14:22 UTC (rev 2975)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/SerializerObjectIOManager.java 2011-11-21 19:53:58 UTC (rev 2976)
@@ -409,7 +409,7 @@
}
@Override
- protected void autoSave() throws ObjectIOException {
+ protected void checkForAutoSave() throws ObjectIOException {
// no implementation
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java 2011-11-21 07:14:22 UTC (rev 2975)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java 2011-11-21 19:53:58 UTC (rev 2976)
@@ -32,8 +32,7 @@
builder.setGarbageManagement(false);
builder.setCrashSafeMode(false);
filePersistence = (FilePersistence) builder.build();
- // FIXMELUC ______________________NoPersistenceConstraintCheck
- // annotation
+ // FIXMELUC ___________NoPersistenceConstraintCheck annotation
final Method method = Bob1.class.getDeclaredMethod(
"doSomethingOnOtherBob1Private", new Class<?>[] { Bob1.class });
filePersistence.addToNotCheckMethod(method);
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractSerializeTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractSerializeTest.java 2011-11-21 07:14:22 UTC (rev 2975)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/objectio/serialize/AbstractSerializeTest.java 2011-11-21 19:53:58 UTC (rev 2976)
@@ -261,5 +261,4 @@
protected abstract void assertUnserialized(Object unserialized);
protected abstract Object[] modifyObjectToSerialize(Object object);
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 07:14:29
|
Revision: 2975
http://joafip.svn.sourceforge.net/joafip/?rev=2975&view=rev
Author: luc_peuvrier
Date: 2011-11-21 07:14:22 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
abject acceded management refactoring
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/SerializerModel.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/saver/StoreSaverSession.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -136,7 +136,7 @@
// FIXMELUC __why for checkAssertNotNull
public boolean checkAssertNotNull = true;
- public boolean acceded;
+ // public boolean acceded;
/**
* for {@link #NULL} and {@link ObjectAndPersistInfo#NULL_DEFINED }
@@ -411,7 +411,7 @@
// object!=null may be unreferenced object and statemap not already
// cleared
final boolean weaked;
- if (!acceded && weakReference == null && object != null) {
+ if (isNotAcceded() && weakReference == null && object != null) {
weakReference = new ObjectAndPersistInfoWeakReference(object, this,
queue);
clear();// Unreferenced
@@ -422,6 +422,16 @@
return weaked;
}
+ private boolean isNotAcceded() {
+ final boolean isNotAcceded;
+ if (proxyIntanceOrEnhanced) {
+ isNotAcceded = proxyCallBack.getInObjectCount$JOAFIP$() == 0;
+ } else {
+ isNotAcceded = true;
+ }
+ return isNotAcceded;
+ }
+
@Override
protected Object getObjectForEquals() {
final Object result;
@@ -534,30 +544,31 @@
return loadedOrNotAProxy;
}
- public void setIsLoaded() throws ObjectIOException {
- // out of constructor, no more acceded, to do before set is
- // loaded
- acceded = false;
- if (proxyIntanceOrEnhanced) {
- /*
- * set loaded state can call save and object is referenced only by
- * this created persist info object, so must not be unreferenced
- */
- assert assertProxyCallBack(proxyCallBack);
- proxyCallBack.setIsLoaded$JOAFIP$();
- }
- }
+ // public void setIsLoaded() throws ObjectIOException {
+ // // out of constructor, no more acceded, to do before set is
+ // // loaded
+ // acceded = false;
+ // if (proxyIntanceOrEnhanced) {
+ // /*
+ // * set loaded state can call save and object is referenced only by
+ // * this created persist info object, so must not be unreferenced
+ // */
+ // assert assertProxyCallBack(proxyCallBack);
+ // proxyCallBack.setIsLoaded$JOAFIP$();
+ // }
+ // }
- public void newInstanceAndCreatedBySave(final StorageInfo storageInfo)
- throws ObjectIOException {
- unWeakReferenceOnObject();
- setStorageInfo(storageInfo);
- setIsLoaded();
- }
+ // public void newInstanceAndCreatedBySave(final StorageInfo storageInfo)
+ // throws ObjectIOException {
+ // setStorageInfo(storageInfo);
+ // setIsLoaded();
+ // acceded=true;
+ // objectStateMap.objectIsAccessed(this);
+ // }
public void unloadAfterSave() throws ObjectIOException,
ObjectIOInvalidClassException {
- if (proxyIntanceOrEnhanced && !acceded) {
+ if (proxyIntanceOrEnhanced && isNotAcceded()) {
assert assertProxyCallBack(proxyCallBack);
proxyCallBack.unload$JOAFIP$();
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -18,8 +18,8 @@
import java.lang.ref.ReferenceQueue;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -46,7 +46,7 @@
* map between object in memory and persistence information for this object
*/
private final Map<IObjectIdentityKey, ObjectAndPersistInfo> stateMap =
- /**/new HashMap<IObjectIdentityKey, ObjectAndPersistInfo>();
+ /**/new LinkedHashMap<IObjectIdentityKey, ObjectAndPersistInfo>();
/**
* map to obtains object persistence information by data record identifier
@@ -451,7 +451,8 @@
public Collection<ObjectAndPersistInfo> getObjectHavingStateSet() {
synchronized (this) {
- final Collection<ObjectAndPersistInfo> objectHavingStateSet = new HashSet<ObjectAndPersistInfo>();
+ final Collection<ObjectAndPersistInfo> objectHavingStateSet =
+ /**/new LinkedHashSet<ObjectAndPersistInfo>();
// if (exclusiveAccessSession) {
// expunge();
@@ -527,7 +528,7 @@
public Set<ObjectAndPersistInfo> mostAccessedObject(final int quota) {
synchronized (this) {
// expunge();
- final Set<ObjectAndPersistInfo> set = new HashSet<ObjectAndPersistInfo>();
+ final Set<ObjectAndPersistInfo> set = new LinkedHashSet<ObjectAndPersistInfo>();
int count = 0;
ObjectAndPersistInfo current = queueHead;
while (count < quota && current != null) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/SerializerModel.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/SerializerModel.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/SerializerModel.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -22,7 +22,7 @@
*/
package net.sf.joafip.store.entity.objectio;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
@@ -49,7 +49,7 @@
* map between object in memory and persistence information for this object
*/
private final Map<IObjectIdentityKey, ObjectAndPersistInfo> stateMap =
- /**/new HashMap<IObjectIdentityKey, ObjectAndPersistInfo>();
+ /**/new LinkedHashMap<IObjectIdentityKey, ObjectAndPersistInfo>();
private final ObjectIdentityKey key = new ObjectIdentityKey();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/saver/StoreSaverSession.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/saver/StoreSaverSession.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/saver/StoreSaverSession.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -18,8 +18,8 @@
import java.util.Collection;
import java.util.Deque;
-import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.TreeSet;
@@ -52,7 +52,7 @@
/** visited for saving object set */
private final Set<ObjectAndPersistInfo> visitedForSave =
- /**/new HashSet<ObjectAndPersistInfo>();
+ /**/new LinkedHashSet<ObjectAndPersistInfo>();
/** set of data record identifier of object attached to root */
private final Set<DataRecordIdentifier> attachedToRoot =
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -623,7 +623,6 @@
@Override
public void objectIsAccessed(final ObjectAndPersistInfo objectAndPersistInfo) {
- objectAndPersistInfo.acceded = true;
objectIsAccessedDelegate(objectAndPersistInfo);
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -93,13 +93,15 @@
}
/**
- *
+ * only call by proxy constructor
*/
public ProxyCallBack() {
super();
inObjectCount = 1;
storeMutex = new JoafipMutex();
exclusiveAccessSession = true;
+ autoSaveEnabled = true;
+ loaded = true;
}
/**
@@ -262,11 +264,12 @@
@Override
public void constructorEnd$JOAFIP$() {
inObjectCount--;
+ // if (autoSaveEnabled) {
+ // unLoadAction(getInstance$JOAFIP$());
+ // }
+ toUnload = false;
assert inObjectCount >= 0 : "running in object count can not be negative, is "
+ inObjectCount;
- // if (objectIOManager != null) {
- // objectIsAccessed();
- // }
}
@Override
@@ -279,7 +282,6 @@
assert inObjectCount >= 0 : "running in object count can not be negative, is "
+ inObjectCount + " " + getInstance$JOAFIP$().toString();
if (inObjectCount == 0) {
- instanceAndPersistInfo.acceded = false;
if (autoSaveEnabled) {
if (!wasLoaded && loaded) {
try {
@@ -288,26 +290,28 @@
throw new ProxyInterceptException(exception);
}
}
- if (toUnload) {
- toUnload = false;
- loaded = false;
- assert instanceAndPersistInfo != null;
- try {
- objectIOManager
- .saveAndUnsetProxyObjectState(instanceAndPersistInfo);
- } catch (Exception exception) {
- LOGGER.error("method end interception error",
- exception);
- throw new ProxyInterceptException(
- instanceAndPersistInfo.toString(),
- exception);
- }
- }
+ unLoadAction(instanceAndPersistInfo);
}
}
}
}
+ private void unLoadAction(final ObjectAndPersistInfo instanceAndPersistInfo) {
+ if (toUnload) {
+ toUnload = false;
+ loaded = false;
+ assert instanceAndPersistInfo != null;
+ try {
+ objectIOManager
+ .saveAndUnsetProxyObjectState(instanceAndPersistInfo);
+ } catch (Exception exception) {
+ LOGGER.error("method end interception error", exception);
+ throw new ProxyInterceptException(
+ instanceAndPersistInfo.toString(), exception);
+ }
+ }
+ }
+
@Override
@SuppressWarnings("PMD")
public boolean isLoaded$JOAFIP$() throws ObjectIOException {
@@ -345,11 +349,14 @@
*/
if (loaded) {
if (!loading && (!exclusiveAccessSession || inObjectCount == 0)) {
+ toUnload = false;
loaded = false;
objectIOManager.unsetProxyObjectState(getInstance$JOAFIP$());
} else {
toUnload = true;
}
+ } else {
+ toUnload = false;
}
// }
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -231,6 +231,7 @@
objectAndPersistInfo = objectIOManager
.getObjectAndPersistInfoOfObject(instanceCreated);
+
if (objectAndPersistInfo == null) {
// not created by save
// FIXMELUC ___seems dataRecordIdentifier always null, see call
@@ -273,16 +274,28 @@
throw new ProxyException(
"data record identifier must not be defined if object not persisted");
}
- objectAndPersistInfo.setStorageInfo(storageInfo);
+ objectAndPersistInfo.setStorageInfo(storageInfo);
if (constructed) {
- assert objectAndPersistInfo.isNotWeak();
- objectAndPersistInfo.setIsLoaded();
+ assert objectAndPersistInfo.isNotWeak() : objectAndPersistInfo
+ .toString();
+ assert objectAndPersistInfo.isLoaded() : objectAndPersistInfo
+ .toString();
+ // objectIOManager.objectIsAccessed(objectAndPersistInfo);
+ // objectAndPersistInfo.setNewObject(true);
+ objectIOManager.newObjectLoaded();
}
} else {
// created by save
assert constructed;
- objectAndPersistInfo.newInstanceAndCreatedBySave(storageInfo);
+ assert objectAndPersistInfo.isNotWeak() : objectAndPersistInfo
+ .toString();
+ assert objectAndPersistInfo.isLoaded() : objectAndPersistInfo
+ .toString();
+ objectAndPersistInfo.setStorageInfo(storageInfo);
+ // objectIOManager.objectIsAccessed(objectAndPersistInfo);
+ // objectAndPersistInfo.setNewObject(true);
+ objectIOManager.newObjectLoaded();
}
return objectAndPersistInfo;
}
@@ -510,46 +523,32 @@
final IProxyCallBackToImplement proxyCallBack,
final boolean exclusiveAccessSession) throws ProxyException {
final Object object = objectAndPersistInfo.getObject();
- if (exclusiveAccessSession) {
- if (useJavaAgent) {
- final IProxyCallBackToImplement existing = StaticProxyCallBack
- .getProxyCallBack(object);
- if (existing == null) {
- StaticProxyCallBack.setProxyCallBack(object, proxyCallBack);
- proxyCallBack.setInstance$JOAFIP$(objectAndPersistInfo);
- objectAndPersistInfo.setProxyCallBack(proxyCallBack);
- } else {
- existing.initialize$JOAFIP$(proxyCallBack);
- existing.setInstance$JOAFIP$(objectAndPersistInfo);
- objectAndPersistInfo.setProxyCallBack(existing);
- objectAndPersistInfo.acceded = true;
- }
- } else {
- final IProxyCallBack proxy = (IProxyCallBack) object;
- final IProxyCallBackToImplement existing = proxy
- .getProxyCallBack$JOAFIP$();
- if (existing == null) {
- proxy.setProxyCallBack$JOAFIP$(proxyCallBack);
- proxyCallBack.setInstance$JOAFIP$(objectAndPersistInfo);
- objectAndPersistInfo.setProxyCallBack(proxyCallBack);
- } else {
- existing.initialize$JOAFIP$(proxyCallBack);
- existing.setInstance$JOAFIP$(objectAndPersistInfo);
- objectAndPersistInfo.setProxyCallBack(existing);
- objectAndPersistInfo.acceded = true;
- }
- }
- } else {
- if (useJavaAgent) {
+ // does not test exclusiveAccessSession because new instance construct
+ // can be called out of exclusive data access session
+ if (useJavaAgent) {
+ final IProxyCallBackToImplement existing = StaticProxyCallBack
+ .getProxyCallBack(object);
+ if (existing == null) {
StaticProxyCallBack.setProxyCallBack(object, proxyCallBack);
proxyCallBack.setInstance$JOAFIP$(objectAndPersistInfo);
objectAndPersistInfo.setProxyCallBack(proxyCallBack);
-
} else {
- final IProxyCallBack proxy = (IProxyCallBack) object;
+ existing.initialize$JOAFIP$(proxyCallBack);
+ existing.setInstance$JOAFIP$(objectAndPersistInfo);
+ objectAndPersistInfo.setProxyCallBack(existing);
+ }
+ } else {
+ final IProxyCallBack proxy = (IProxyCallBack) object;
+ final IProxyCallBackToImplement existing = proxy
+ .getProxyCallBack$JOAFIP$();
+ if (existing == null) {
proxy.setProxyCallBack$JOAFIP$(proxyCallBack);
proxyCallBack.setInstance$JOAFIP$(objectAndPersistInfo);
objectAndPersistInfo.setProxyCallBack(proxyCallBack);
+ } else {
+ existing.initialize$JOAFIP$(proxyCallBack);
+ existing.setInstance$JOAFIP$(objectAndPersistInfo);
+ objectAndPersistInfo.setProxyCallBack(existing);
}
}
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java 2011-11-21 07:11:53 UTC (rev 2974)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java 2011-11-21 07:14:22 UTC (rev 2975)
@@ -18,9 +18,9 @@
import java.io.File;
import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -150,7 +150,7 @@
private final List<String> wroteArrays = new LinkedList<String>();
private final Map<ObjectAndPersistInfo, Set<ObjectAndPersistInfo>> fatherMap =
- /**/new HashMap<ObjectAndPersistInfo, Set<ObjectAndPersistInfo>>();
+ /**/new LinkedHashMap<ObjectAndPersistInfo, Set<ObjectAndPersistInfo>>();
/** root of objects to save */
private Object rootOfObjectsToSave;
@@ -753,7 +753,7 @@
.getObjectAndPersistInfo();
Set<ObjectAndPersistInfo> set = fatherMap.get(sonAndPersistInfo);
if (set == null) {
- set = new HashSet<ObjectAndPersistInfo>();
+ set = new LinkedHashSet<ObjectAndPersistInfo>();
fatherMap.put(sonAndPersistInfo, set);
}
set.add(father);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 07:14:29
|
Revision: 2975
http://joafip.svn.sourceforge.net/joafip/?rev=2975&view=rev
Author: luc_peuvrier
Date: 2011-11-21 07:14:22 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
abject acceded management refactoring
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/SerializerModel.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/saver/StoreSaverSession.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyCallBack.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/saver/StoreSaver3.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 07:12:01
|
Revision: 2974
http://joafip.svn.sourceforge.net/joafip/?rev=2974&view=rev
Author: luc_peuvrier
Date: 2011-11-21 07:11:53 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
comment update. refactoring. test for auto save added.
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/eatmemory/MainEatMemory.java
trunk/joafip-4test/src/main/java/jrat/MainJRat.java
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainMemRBTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/RBTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/AbstractSpellCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/ISpellCheckDAO.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainReadWords.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckBase.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckException.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckJoafipDAO.java
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/AbstractSpellCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/ISpellCheckDAO.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainReadWords.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckBase.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckException.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java
Modified: trunk/joafip-4test/src/main/java/eatmemory/MainEatMemory.java
===================================================================
--- trunk/joafip-4test/src/main/java/eatmemory/MainEatMemory.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/eatmemory/MainEatMemory.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,3 +1,25 @@
+/*
+ * 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 eatmemory;
import java.util.Deque;
@@ -3,4 +25,9 @@
import java.util.LinkedList;
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
public final class MainEatMemory {
Modified: trunk/joafip-4test/src/main/java/jrat/MainJRat.java
===================================================================
--- trunk/joafip-4test/src/main/java/jrat/MainJRat.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/jrat/MainJRat.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,3 +1,25 @@
+/*
+ * 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 jrat;
import org.shiftone.jrat.cli.Cli;
@@ -2,2 +24,7 @@
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
public final class MainJRat {
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/AbstractSpellCheck.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/AbstractSpellCheck.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/AbstractSpellCheck.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,187 +0,0 @@
-package net.sf.joafip.autosave;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-@SuppressWarnings("PMD")
-public abstract class AbstractSpellCheck {
-
- protected static final int MAX_LABELS = 10;
-
- protected AbstractSpellCheck() {
- super();
- }
-
- protected List<String> splitValue(final String value) {
- final List<String> resultList = new LinkedList<String>();
- List<Integer> list = new ArrayList<Integer>(value.length());
- int index = 0;
- while (index < value.length()) {
- final int codePoint = value.codePointAt(index);
- if (!Character.isLetter(codePoint)) {
- if (!list.isEmpty()) {
- resultList.add(codePointToString(list));
- list = new ArrayList<Integer>(value.length());
- }
- index += Character.charCount(codePoint);
- } else {
- list.add(Character.toLowerCase(codePoint));
- index += Character.charCount(codePoint);
- }
- }
- if (!list.isEmpty()) {
- resultList.add(codePointToString(list));
- }
- return resultList;
- }
-
- protected void updateKeyMap(final ISpellCheckDAO spellCheckDAO,
- final NavigableSet<Integer> codePointSet) {
- final int length = codePointSet.size();
- reduce(spellCheckDAO, codePointSet, 0, length / 2);
- }
-
- private void reduce(final ISpellCheckDAO spellCheckDAO,
- final NavigableSet<Integer> keyCodePointSet,
- final int positionOffset, final int minimumSize) {
- if (keyCodePointSet.size() > minimumSize) {
- final String key = codePointToString(keyCodePointSet);
- final ArrayList<Integer> keyCodePointList = new ArrayList<Integer>(
- keyCodePointSet);
- for (int position = positionOffset; position < keyCodePointSet
- .size(); position++) {
- final NavigableSet<Integer> reducedSet = new TreeSet<Integer>();
- reducedSet.addAll(keyCodePointList.subList(0, position));
- reducedSet.addAll(keyCodePointList.subList(position + 1,
- keyCodePointList.size()));
- final String reduceKey = codePointToString(reducedSet);
- Set<String> set = spellCheckDAO.getKeySet(reduceKey);
- if (set == null) {
- set = spellCheckDAO.newSetOfString();
- spellCheckDAO.addKeySet(reduceKey, set);
- }
- set.add(key);
- reduce(spellCheckDAO, reducedSet, position, minimumSize);
- }
- }
- }
-
- protected Set<String> computeReduceKeys(final String key,
- final int minimumSize, final int maxSize) {
- final NavigableSet<Integer> keyInSet = computeKeyInSet(key);
- return computeReduceKeys(keyInSet, minimumSize, maxSize);
- }
-
- protected Set<String> computeReduceKeys(NavigableSet<Integer> keyInSet,
- final int minimumSize, final int maxSize) {
- if (minimumSize <= 0) {
- throw new IllegalArgumentException("bad minimum size "
- + minimumSize);
- }
- if (maxSize <= 0) {
- throw new IllegalArgumentException("bad maximum size "
- + minimumSize);
- }
- if (minimumSize > maxSize) {
- throw new IllegalArgumentException("bad minimum " + minimumSize
- + " greater than maximum " + maxSize);
- }
- // final NavigableSet<Integer> mainKeyInSet = computeKeyInSet(value);
- final Set<String> stringKeySet = new TreeSet<String>();
- stringKeySet.add(codePointToString(keyInSet));
- if (keyInSet.size() > minimumSize) {
- final List<Set<Integer>> list = reduce(keyInSet, 0, minimumSize);
- for (Set<Integer> set : list) {
- if (set.size() <= maxSize) {
- stringKeySet.add(codePointToString(set));
- }
- }
- }
- return stringKeySet;
- }
-
- private List<Set<Integer>> reduce(final NavigableSet<Integer> set,
- final int positionOffset, final int minimumSize) {
- final List<Set<Integer>> listOfSet = new LinkedList<Set<Integer>>();
- if (set.size() > 1) {
- final ArrayList<Integer> setInList = new ArrayList<Integer>(set);
- for (int position = positionOffset; position < set.size(); position++) {
- final NavigableSet<Integer> reducedSet = new TreeSet<Integer>();
- reducedSet.addAll(setInList.subList(0, position));
- reducedSet.addAll(setInList.subList(position + 1,
- setInList.size()));
- listOfSet.add(reducedSet);
- if (reducedSet.size() > minimumSize) {
- listOfSet.addAll(reduce(reducedSet, position, minimumSize));
- }
- }
- }
- return listOfSet;
- }
-
- @SuppressWarnings("unused")
- private String computeKey(final String value) {
- final Set<Integer> codePointSet = computeKeyInSet(value);
- return codePointToString(codePointSet);
- }
-
- protected String codePointToString(final Collection<Integer> codePointSet) {
- final StringBuilder stringBuilder = new StringBuilder();
- for (int codePoint : codePointSet) {
- stringBuilder.appendCodePoint(codePoint);
- }
- return stringBuilder.toString();
- }
-
- protected NavigableSet<Integer> computeKeyInSet(final String value) {
- final NavigableSet<Integer> codePointSet = new TreeSet<Integer>();
- int index = 0;
- while (index < value.length()) {
- final int codePoint = value.codePointAt(index);
- index += Character.charCount(codePoint);
- codePointSet.add(codePoint);
- }
- return codePointSet;
- }
-
- protected int computeAverrage(final String word) {
- int index = 0;
- int sum = 0;
- while (index < word.length()) {
- final int codePoint = word.codePointAt(index);
- index += Character.charCount(codePoint);
- sum += codePoint;
- }
- return sum * 1000 / index;
- }
-
- public static int computeLevenshteinDistance(CharSequence str1,
- CharSequence str2) {
- int[][] distance = new int[str1.length() + 1][str2.length() + 1];
-
- for (int i = 0; i <= str1.length(); i++)
- distance[i][0] = i;
- for (int j = 0; j <= str2.length(); j++)
- distance[0][j] = j;
-
- for (int i = 1; i <= str1.length(); i++)
- for (int j = 1; j <= str2.length(); j++)
- distance[i][j] = minimum(
- distance[i - 1][j] + 1,
- distance[i][j - 1] + 1,
- distance[i - 1][j - 1]
- + ((str1.charAt(i - 1) == str2.charAt(j - 1)) ? 0
- : 1));
-
- return distance[str1.length()][str2.length()];
- }
-
- private static int minimum(int a, int b, int c) {
- return Math.min(Math.min(a, b), c);
- }
-}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/ISpellCheckDAO.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/ISpellCheckDAO.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/ISpellCheckDAO.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,20 +0,0 @@
-package net.sf.joafip.autosave;
-
-import java.util.Set;
-
-public interface ISpellCheckDAO {
-
- Set<String> getWordSet(String key);
-
- void addWordSet(String key, Set<String> set);
-
- Set<String> getKeySet(String key);
-
- void addKeySet(String key, Set<String> set);
-
- Set<String> newSetOfString();
-
- void commit() throws SpellCheckException;
-
- void close(boolean save) throws SpellCheckException;
-}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainCheck.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainCheck.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainCheck.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,116 +0,0 @@
-package net.sf.joafip.autosave;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Map;
-import java.util.NavigableSet;
-import java.util.Set;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
-import net.sf.joafip.service.FilePersistenceBuilder;
-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.service.IFilePersistence;
-
-@SuppressWarnings("PMD")
-@NotStorableClass
-public class MainCheck extends AbstractSpellCheck {
-
- private static final String SPELL_CHECK_BASE = "spellCheckBase";
-
- private IFilePersistence filePersistence;
-
- private IDataAccessSession session;
-
- public static void main(String[] args) {
- (new MainCheck()).run();
- }
-
- private void run() {
- try {
- openFilePersistence();
- final InputStream in = getClass().getClassLoader()
- .getResourceAsStream("word_list.txt");
- ;
- final BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
-
- int wordValueCount = 0;
- int labelCount = 0;
- String line;
- final long startTime = System.currentTimeMillis();
- boolean done = false;
- while (!done && labelCount < MAX_LABELS
- && (line = reader.readLine()) != null) {
- labelCount++;
- for (String wordValue : splitValue(line)) {
- final NavigableSet<Integer> keyCodePointSet = computeKeyInSet(wordValue);
- final String key = codePointToString(keyCodePointSet);
- session.open();
- final SpellCheckBase spellCheckBase = (SpellCheckBase) session
- .getObject(SPELL_CHECK_BASE);
- final Map<String, Set<String>> wordsByKeyMap = spellCheckBase
- .getWordsByKeyMap();
- final Set<String> set = wordsByKeyMap.get(key);
- if (set == null) {
- System.out.println("ERROR no set for key " + key
- + " from word " + wordValue);
- done = true;
- } else if (!set.contains(wordValue)) {
- System.out.println("ERROR missing word " + wordValue
- + " in set ");
- done = true;
- }
- wordValueCount++;
- System.out.println(wordValue + " " + wordValueCount);
- session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
- }
- }
- System.out.println("labelCount " + labelCount);
- reader.close();
-
- closeFilePersistence();
-
- System.out.println("elapsed "
- + (System.currentTimeMillis() - startTime) + " mS");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void openFilePersistence() throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException {
- final FilePersistenceBuilder builder = new FilePersistenceBuilder();
- // builder.setPathName("runtime/spellcheckbase");
- builder.setPathName("Z:/");
- builder.setRemoveFiles(false);
- builder.setFileCache(16 * 1024/* pageSize */, 8 * 1024/* maxPage */);
- builder.setGarbageManagement(false);
- builder.setCrashSafeMode(false);
- filePersistence = builder.build();
- session = filePersistence.createDataAccessSession();
- }
-
- private void closeFilePersistence() throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException,
- FilePersistenceTooBigForSerializationException {
- if (session.isOpened()) {
- session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
- }
- filePersistence.close();
- }
-
-}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainReadWords.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainReadWords.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainReadWords.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,67 +0,0 @@
-package net.sf.joafip.autosave;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.NavigableSet;
-import java.util.Set;
-
-import net.sf.joafip.NotStorableClass;
-
-/**
- * @author luc peuvrier
- *
- */
-@SuppressWarnings("PMD")
-@NotStorableClass
-public class MainReadWords extends AbstractSpellCheck {
-
- public static void main(String[] args) {
- (new MainReadWords()).run();
- }
-
- private void run() {
- try {
- final ISpellCheckDAO spellCheckDAO = new SpellCheckJoafipDAO(true);
-
- final InputStream in = getClass().getClassLoader()
- .getResourceAsStream("word_list.txt");
-
- final BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
-
- int wordValueCount = 0;
- int labelCount = 0;
- String line;
- final long startTime = System.currentTimeMillis();
- while (labelCount < MAX_LABELS
- && (line = reader.readLine()) != null) {
- labelCount++;
- for (String wordValue : splitValue(line)) {
- final NavigableSet<Integer> keyCodePointSet = computeKeyInSet(wordValue);
- final String key = codePointToString(keyCodePointSet);
- Set<String> set = spellCheckDAO.getWordSet(key);
- if (set == null) {
- set = spellCheckDAO.newSetOfString();
- spellCheckDAO.addWordSet(key, set);
- // updateKeyMap(spellCheckDAO, keyCodePointSet);
- }
- if (set.add(wordValue)) {
- wordValueCount++;
- System.out.println(wordValue + " " + wordValueCount);
- }
- spellCheckDAO.commit();
- }
- }
- System.out.println("labelCount " + labelCount);
- reader.close();
-
- spellCheckDAO.close(true);
-
- System.out.println("elapsed "
- + (System.currentTimeMillis() - startTime) + " mS");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckBase.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckBase.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckBase.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,46 +0,0 @@
-package net.sf.joafip.autosave;
-
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.joafip.StorableClass;
-import net.sf.joafip.java.util.PTreeMap;
-import net.sf.joafip.store.service.proxy.IInstanceFactory;
-
-@SuppressWarnings("PMD")
-@StorableClass
-public class SpellCheckBase {
-
- Map<String, Set<String>> wordsByKeyMap;// = new TreeMap<String,
- // Set<String>>();
-
- Map<String, Set<String>> keysByKeyMap;// = new TreeMap<String,
- // Set<String>>();
-
- public static SpellCheckBase newInstance(
- final IInstanceFactory instanceFactory) {
- return (SpellCheckBase) instanceFactory.newInstance(
- SpellCheckBase.class, new Class[] { IInstanceFactory.class },
- new Object[] { instanceFactory });
- }
-
- @SuppressWarnings("unchecked")
- public SpellCheckBase(final IInstanceFactory instanceFactory) {
- super();
- if (instanceFactory == null) {
- wordsByKeyMap = new PTreeMap<String, Set<String>>();
- keysByKeyMap = new PTreeMap<String, Set<String>>();
- } else {
- wordsByKeyMap = PTreeMap.newInstance(instanceFactory);
- keysByKeyMap = PTreeMap.newInstance(instanceFactory);
- }
- }
-
- public Map<String, Set<String>> getWordsByKeyMap() {
- return wordsByKeyMap;
- }
-
- public Map<String, Set<String>> getKeysByKeyMap() {
- return keysByKeyMap;
- }
-}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckException.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckException.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckException.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,25 +0,0 @@
-package net.sf.joafip.autosave;
-
-public class SpellCheckException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = -3735427947716224960L;
-
- public SpellCheckException() {
- super();
- }
-
- public SpellCheckException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public SpellCheckException(final String message) {
- super(message);
- }
-
- public SpellCheckException(final Throwable cause) {
- super(cause);
- }
-}
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java 2011-11-21 07:08:50 UTC (rev 2973)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -1,282 +0,0 @@
-package net.sf.joafip.autosave;
-
-import java.util.Map;
-import java.util.Set;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
-import net.sf.joafip.java.util.PTreeSet;
-import net.sf.joafip.service.FilePersistenceBuilder;
-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.IAutoSaveEventListener;
-import net.sf.joafip.service.IDataAccessSession;
-import net.sf.joafip.service.IExclusiveDataAccessSession;
-import net.sf.joafip.service.IFilePersistence;
-import net.sf.joafip.store.service.proxy.IInstanceFactory;
-
-@SuppressWarnings("PMD")
-@NotStorableClass
-public class SpellCheckJoafipDAO implements IAutoSaveEventListener,
- ISpellCheckDAO {
-
- private static final String STORAGE_DIR_PATH = "Z:/";
-
- private static final boolean EX_SESSION = true;
-
- private static final boolean AUTOSAVE_ENABLED = false;
-
- private static final boolean COMMIT_SAVE = false;
-
- private static final String SPELL_CHECK_BASE = "spellCheckBase";
-
- private IFilePersistence filePersistence;
-
- private IExclusiveDataAccessSession exSession;
-
- private IDataAccessSession session;
-
- private transient IInstanceFactory instanceFactory;
-
- private SpellCheckBase spellCheckBase;
-
- private int maxVisited = Integer.MIN_VALUE;
-
- private int minVisited = Integer.MAX_VALUE;
-
- public SpellCheckJoafipDAO(final boolean removeFile)
- throws FilePersistenceException,
- FilePersistenceInvalidClassException,
- FilePersistenceNotSerializableException,
- FilePersistenceClassNotFoundException,
- FilePersistenceDataCorruptedException,
- FilePersistenceTooBigForSerializationException {
- super();
- final FilePersistenceBuilder builder = new FilePersistenceBuilder();
- builder.setPathName(STORAGE_DIR_PATH);
- builder.setRemoveFiles(removeFile);
- builder.setFileCache(16 * 1024/* pageSize */, 8 * 1024/* maxPage */);
- builder.setGarbageManagement(false);
- builder.setCrashSafeMode(false);
- filePersistence = builder.build();
- if (EX_SESSION) {
- if (AUTOSAVE_ENABLED) {
- // FIXMELUC ___TEST auto save=0
- filePersistence.autoSaveSetup(1000);
- filePersistence.setAutoSaveEnabled(AUTOSAVE_ENABLED);
- filePersistence.setAutoSaveEventListener(this);
- // FIXMELUC ___TEST maintain in memory
- // filePersistence.maintainInMemorySetup(100);
- // filePersistence.setMaintainedInMemoryEnabled(true);
- }
- exSession = filePersistence.createExclusiveDataAccessSession();
- instanceFactory = exSession.getInstanceFactory();
- exSession.open();
- if (removeFile) {
- if (AUTOSAVE_ENABLED) {
- spellCheckBase = SpellCheckBase
- .newInstance(instanceFactory);
- } else {
- spellCheckBase = new SpellCheckBase(null);
- }
- exSession.setObject(SPELL_CHECK_BASE, spellCheckBase);
- if (AUTOSAVE_ENABLED) {
- exSession.save();
- } else {
- if (COMMIT_SAVE) {
- exSession.save();
- } else {
- exSession.close();
- exSession.open();
- spellCheckBase = (SpellCheckBase) exSession
- .getObject(SPELL_CHECK_BASE);
- }
- }
- } else {
- spellCheckBase = (SpellCheckBase) exSession
- .getObject(SPELL_CHECK_BASE);
- if (spellCheckBase == null) {
- throw new IllegalStateException("no data");
- }
- }
- } else {
- session = filePersistence.createDataAccessSession();
- session.open();
- if (removeFile) {
- spellCheckBase = new SpellCheckBase(null);
- session.setObject(SPELL_CHECK_BASE, spellCheckBase);
- session.close(EnumFilePersistenceCloseAction.SAVE);
- session.open();
- spellCheckBase = (SpellCheckBase) session
- .getObject(SPELL_CHECK_BASE);
- } else {
- spellCheckBase = (SpellCheckBase) session
- .getObject(SPELL_CHECK_BASE);
- if (spellCheckBase == null) {
- throw new IllegalStateException("no data");
- }
- }
- }
- }
-
- @Override
- public void commit() throws SpellCheckException {
- try {
- if (EX_SESSION) {
- if (!AUTOSAVE_ENABLED) {
- if (COMMIT_SAVE) {
- exSession.save();
- updateVisitedForSave();
- } else {
- exSession.close();
- updateVisitedForSave();
- exSession.open();
- spellCheckBase = (SpellCheckBase) exSession
- .getObject(SPELL_CHECK_BASE);
- }
- }
- } else {
- session.close(EnumFilePersistenceCloseAction.SAVE);
- updateVisitedForSave();
- session.open();
- spellCheckBase = (SpellCheckBase) session
- .getObject(SPELL_CHECK_BASE);
- }
- } catch (FilePersistenceException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceInvalidClassException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceNotSerializableException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceClassNotFoundException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceDataCorruptedException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceTooBigForSerializationException e) {
- throw new SpellCheckException(e);
- }
- }
-
- private void updateVisitedForSave() throws FilePersistenceException {
- final int visited = filePersistence.getNumberOfVisited();
- if (visited > maxVisited) {
- maxVisited = visited;
- }
- if (visited < minVisited) {
- minVisited = visited;
- }
- // System.out.println("visited "+visited+" "+minVisited+"/"+maxVisited);
- }
-
- @Override
- public void close(final boolean save) throws SpellCheckException {
- try {
- if (EX_SESSION) {
- exSession.close();
- } else {
- session.close(EnumFilePersistenceCloseAction.SAVE);
- }
- System.out.println("nb of data records "
- + filePersistence.getNumberOfDataRecord());
- export();
- filePersistence.close();
- System.out.println("min visited " + minVisited + " max visited "
- + maxVisited);
- } catch (FilePersistenceException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceInvalidClassException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceNotSerializableException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceClassNotFoundException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceDataCorruptedException e) {
- throw new SpellCheckException(e);
- } catch (FilePersistenceTooBigForSerializationException e) {
- throw new SpellCheckException(e);
- }
- }
-
- private void export() throws FilePersistenceException,
- FilePersistenceClassNotFoundException,
- FilePersistenceInvalidClassException,
- FilePersistenceDataCorruptedException,
- FilePersistenceNotSerializableException,
- FilePersistenceTooBigForSerializationException {
- final String directoryName;
- if (EX_SESSION) {
- if (AUTOSAVE_ENABLED) {
- directoryName = "runtime/export/autosave";
- } else {
- directoryName = "runtime/export/exsession";
- }
- } else {
- directoryName = "runtime/export/session";
- }
- filePersistence.xmlExport(directoryName, STORAGE_DIR_PATH + "/tmp",
- false/* exportPersistedClassByteCode */);
- final int nbExported = filePersistence.getNumberOfObjectExported();
- System.out.println("number of object exported=" + nbExported);
- }
-
- @Override
- public Set<String> getWordSet(final String key) {
- final Map<String, Set<String>> wordsByKeyMap = spellCheckBase
- .getWordsByKeyMap();
- return wordsByKeyMap.get(key);
- }
-
- @Override
- public void addWordSet(final String key, final Set<String> set) {
- final Map<String, Set<String>> wordsByKeyMap = spellCheckBase
- .getWordsByKeyMap();
- wordsByKeyMap.put(key, set);
- }
-
- @Override
- public Set<String> getKeySet(final String key) {
- final Map<String, Set<String>> keysByKeyMap = spellCheckBase
- .getKeysByKeyMap();
- return keysByKeyMap.get(key);
- }
-
- @Override
- public void addKeySet(final String key, final Set<String> set) {
- final Map<String, Set<String>> keysByKeyMap = spellCheckBase
- .getKeysByKeyMap();
- keysByKeyMap.put(key, set);
- }
-
- @SuppressWarnings({ "unchecked", "unused" })
- public Set<String> newSetOfString() {
- Set<String> set;
- if (EX_SESSION && AUTOSAVE_ENABLED) {
- set = PTreeSet.newInstance(instanceFactory);
- } else {
- set = new PTreeSet<String>();
- }
- return set;
- }
-
- @Override
- public boolean doSave() {
- assert EX_SESSION && AUTOSAVE_ENABLED;
- return true;
- }
-
- @Override
- public void saveDone(final int numberOfObjectState,
- final int numberOfWeakreference, final long msDuration) {
- assert EX_SESSION && AUTOSAVE_ENABLED;
- try {
- updateVisitedForSave();
- } catch (FilePersistenceException e) {
- e.printStackTrace();
- }
- System.out.println("SAVE");
- }
-}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainMemRBTree.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainMemRBTree.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainMemRBTree.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,73 @@
+/*
+ * 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.autosave.rbtree;
+
+import net.sf.joafip.redblacktree.service.RBTException;
+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;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public final class MainMemRBTree {
+
+ private MainMemRBTree() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainMemRBTree main = new MainMemRBTree();
+ main.run();
+ } catch (Exception exception) {
+ exception.printStackTrace();// NOPMD
+ }
+ }
+
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException {
+
+ final RBTree tree = RBTree.newInstance(null);
+
+ for (int count = 0; count < 1000000; count++) {
+ tree.append("" + count);// NOPMD
+ if (count % 1000 == 0) {
+ System.out.println("c=" + count);// NOPMD
+ }
+ if (count > 8) {
+ tree.remove("" + (count - 8));// NOPMD
+ }
+ }
+ }
+
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,128 @@
+/*
+ * 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.autosave.rbtree;
+
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+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.IAutoSaveEventListener;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public final class MainRBTree implements IAutoSaveEventListener {
+
+ private MainRBTree() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainRBTree main = new MainRBTree();
+ main.run();
+ } catch (Exception exception) {
+ exception.printStackTrace();// NOPMD
+ }
+ }
+
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException {
+ final IFilePersistence filePersistence = createFilePersistence();
+ // filePersistence.setAutoSaveEventListener(this);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+
+ session.open();
+
+ final RBTree tree = RBTree.newInstance(instanceFactory);
+
+ for (int count = 0; count < 1000000; count++) {
+ tree.append("" + count);// NOPMD
+ if (count % 1000 == 0) {
+ System.out.println("c=" + count);// NOPMD
+ }
+ if (count > 8) {
+ tree.remove("" + (count - 8));// NOPMD
+ }
+ }
+
+ session.close();
+
+ filePersistence.close();
+ }
+
+ private IFilePersistence createFilePersistence()
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName("runtime");
+ // builder.setFileCache(setup.getPageSize(), setup.getMaxPage());
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ builder.setAutoSaveEnabled(true);
+ builder.setMaxInMemoryThreshold(0);
+ // builder.setMaintenedInMemory(true);
+ // builder.setMaintenedInMemoryQuota(500);
+ builder.setFileCache(1000, 10 * 1024);
+ return builder.build();
+ }
+
+ @Override
+ public boolean doSave() {
+ return true;
+ }
+
+ @SuppressWarnings("PMD")
+ @Override
+ public void saveDone(final int numberOfObjectState,
+ final int numberOfWeakreference, final long msDuration) {
+ System.out.print("n=");
+ System.out.print(numberOfObjectState);
+ System.out.print(" w=");
+ System.out.print(numberOfWeakreference);
+ System.out.print(" d=");
+ System.out.print(msDuration);
+ System.out.println(" mS");
+ }
+
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/RBTree.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/RBTree.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/RBTree.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,93 @@
+/*
+ * 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.autosave.rbtree;
+
+import net.sf.joafip.redblacktree.entity.IRBTNode;
+import net.sf.joafip.redblacktree.entity.RBTSentinel;
+import net.sf.joafip.redblacktree.impl.memory.entity.RBTNode;
+import net.sf.joafip.redblacktree.service.IRBTNodeManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.redblacktree.service.RedBlackTree;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class RBTree implements IRBTNodeManager<String> {
+
+ private final IInstanceFactory instanceFactory;
+
+ private final RedBlackTree<String> tree;
+
+ private IRBTNode<String> rootNode;
+
+ @SuppressWarnings("unchecked")
+ public RBTree(final IInstanceFactory instanceFactory) {
+ super();
+ this.instanceFactory = instanceFactory;
+ tree = RedBlackTree.newInstance(instanceFactory, this,
+ true/* manageNodeIndex */, false/* uniqueValue */);
+ }
+
+ public static RBTree newInstance(final IInstanceFactory instanceFactory) {
+ final RBTree tree;
+ if (instanceFactory == null) {
+ tree = new RBTree(instanceFactory);
+ } else {
+ tree = (RBTree) instanceFactory.newInstance(RBTree.class,
+ new Class<?>[] { IInstanceFactory.class },
+ new Object[] { instanceFactory });
+ }
+ return tree;
+ }
+
+ @Override
+ public IRBTNode<String> getRootNode() throws RBTException {
+ return rootNode;
+ }
+
+ @Override
+ public void setRootNode(final IRBTNode<String> rootNode)
+ throws RBTException {
+ this.rootNode = rootNode;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IRBTNode<String> newSentinel() {
+ return RBTSentinel.newInstance(instanceFactory);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void append(final String value) throws RBTException {
+ final IRBTNode<String> nodeToAppend = RBTNode.newInstance(
+ instanceFactory, value);
+ tree.append(nodeToAppend);
+ }
+
+ public void remove(final String value) throws RBTException {
+ tree.delete(value);
+ }
+}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/AbstractSpellCheck.java (from rev 2972, trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/AbstractSpellCheck.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/AbstractSpellCheck.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/AbstractSpellCheck.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,214 @@
+/*
+ * 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.autosave.spellcheck;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NavigableSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@SuppressWarnings("PMD")
+public abstract class AbstractSpellCheck {
+
+ protected static final int MAX_LABELS = 10;
+
+ protected AbstractSpellCheck() {
+ super();
+ }
+
+ protected List<String> splitValue(final String value) {
+ final List<String> resultList = new LinkedList<String>();
+ List<Integer> list = new ArrayList<Integer>(value.length());
+ int index = 0;
+ while (index < value.length()) {
+ final int codePoint = value.codePointAt(index);
+ if (!Character.isLetter(codePoint)) {
+ if (!list.isEmpty()) {
+ resultList.add(codePointToString(list));
+ list = new ArrayList<Integer>(value.length());
+ }
+ index += Character.charCount(codePoint);
+ } else {
+ list.add(Character.toLowerCase(codePoint));
+ index += Character.charCount(codePoint);
+ }
+ }
+ if (!list.isEmpty()) {
+ resultList.add(codePointToString(list));
+ }
+ return resultList;
+ }
+
+ protected void updateKeyMap(final ISpellCheckDAO spellCheckDAO,
+ final NavigableSet<Integer> codePointSet) {
+ final int length = codePointSet.size();
+ reduce(spellCheckDAO, codePointSet, 0, length / 2);
+ }
+
+ private void reduce(final ISpellCheckDAO spellCheckDAO,
+ final NavigableSet<Integer> keyCodePointSet,
+ final int positionOffset, final int minimumSize) {
+ if (keyCodePointSet.size() > minimumSize) {
+ final String key = codePointToString(keyCodePointSet);
+ final ArrayList<Integer> keyCodePointList = new ArrayList<Integer>(
+ keyCodePointSet);
+ for (int position = positionOffset; position < keyCodePointSet
+ .size(); position++) {
+ final NavigableSet<Integer> reducedSet = new TreeSet<Integer>();
+ reducedSet.addAll(keyCodePointList.subList(0, position));
+ reducedSet.addAll(keyCodePointList.subList(position + 1,
+ keyCodePointList.size()));
+ final String reduceKey = codePointToString(reducedSet);
+ Set<String> set = spellCheckDAO.getKeySet(reduceKey);
+ if (set == null) {
+ set = spellCheckDAO.newSetOfString();
+ spellCheckDAO.addKeySet(reduceKey, set);
+ }
+ set.add(key);
+ reduce(spellCheckDAO, reducedSet, position, minimumSize);
+ }
+ }
+ }
+
+ protected Set<String> computeReduceKeys(final String key,
+ final int minimumSize, final int maxSize) {
+ final NavigableSet<Integer> keyInSet = computeKeyInSet(key);
+ return computeReduceKeys(keyInSet, minimumSize, maxSize);
+ }
+
+ protected Set<String> computeReduceKeys(NavigableSet<Integer> keyInSet,
+ final int minimumSize, final int maxSize) {
+ if (minimumSize <= 0) {
+ throw new IllegalArgumentException("bad minimum size "
+ + minimumSize);
+ }
+ if (maxSize <= 0) {
+ throw new IllegalArgumentException("bad maximum size "
+ + minimumSize);
+ }
+ if (minimumSize > maxSize) {
+ throw new IllegalArgumentException("bad minimum " + minimumSize
+ + " greater than maximum " + maxSize);
+ }
+ // final NavigableSet<Integer> mainKeyInSet = computeKeyInSet(value);
+ final Set<String> stringKeySet = new TreeSet<String>();
+ stringKeySet.add(codePointToString(keyInSet));
+ if (keyInSet.size() > minimumSize) {
+ final List<Set<Integer>> list = reduce(keyInSet, 0, minimumSize);
+ for (Set<Integer> set : list) {
+ if (set.size() <= maxSize) {
+ stringKeySet.add(codePointToString(set));
+ }
+ }
+ }
+ return stringKeySet;
+ }
+
+ private List<Set<Integer>> reduce(final NavigableSet<Integer> set,
+ final int positionOffset, final int minimumSize) {
+ final List<Set<Integer>> listOfSet = new LinkedList<Set<Integer>>();
+ if (set.size() > 1) {
+ final ArrayList<Integer> setInList = new ArrayList<Integer>(set);
+ for (int position = positionOffset; position < set.size(); position++) {
+ final NavigableSet<Integer> reducedSet = new TreeSet<Integer>();
+ reducedSet.addAll(setInList.subList(0, position));
+ reducedSet.addAll(setInList.subList(position + 1,
+ setInList.size()));
+ listOfSet.add(reducedSet);
+ if (reducedSet.size() > minimumSize) {
+ listOfSet.addAll(reduce(reducedSet, position, minimumSize));
+ }
+ }
+ }
+ return listOfSet;
+ }
+
+ @SuppressWarnings("unused")
+ private String computeKey(final String value) {
+ final Set<Integer> codePointSet = computeKeyInSet(value);
+ return codePointToString(codePointSet);
+ }
+
+ protected String codePointToString(final Collection<Integer> codePointSet) {
+ final StringBuilder stringBuilder = new StringBuilder();
+ for (int codePoint : codePointSet) {
+ stringBuilder.appendCodePoint(codePoint);
+ }
+ return stringBuilder.toString();
+ }
+
+ protected NavigableSet<Integer> computeKeyInSet(final String value) {
+ final NavigableSet<Integer> codePointSet = new TreeSet<Integer>();
+ int index = 0;
+ while (index < value.length()) {
+ final int codePoint = value.codePointAt(index);
+ index += Character.charCount(codePoint);
+ codePointSet.add(codePoint);
+ }
+ return codePointSet;
+ }
+
+ protected int computeAverrage(final String word) {
+ int index = 0;
+ int sum = 0;
+ while (index < word.length()) {
+ final int codePoint = word.codePointAt(index);
+ index += Character.charCount(codePoint);
+ sum += codePoint;
+ }
+ return sum * 1000 / index;
+ }
+
+ public static int computeLevenshteinDistance(CharSequence str1,
+ CharSequence str2) {
+ int[][] distance = new int[str1.length() + 1][str2.length() + 1];
+
+ for (int i = 0; i <= str1.length(); i++)
+ distance[i][0] = i;
+ for (int j = 0; j <= str2.length(); j++)
+ distance[0][j] = j;
+
+ for (int i = 1; i <= str1.length(); i++)
+ for (int j = 1; j <= str2.length(); j++)
+ distance[i][j] = minimum(
+ distance[i - 1][j] + 1,
+ distance[i][j - 1] + 1,
+ distance[i - 1][j - 1]
+ + ((str1.charAt(i - 1) == str2.charAt(j - 1)) ? 0
+ : 1));
+
+ return distance[str1.length()][str2.length()];
+ }
+
+ private static int minimum(int a, int b, int c) {
+ return Math.min(Math.min(a, b), c);
+ }
+}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/ISpellCheckDAO.java (from rev 2972, trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/ISpellCheckDAO.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/ISpellCheckDAO.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/ISpellCheckDAO.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,47 @@
+/*
+ * 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.autosave.spellcheck;
+
+import java.util.Set;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public interface ISpellCheckDAO {
+
+ Set<String> getWordSet(String key);
+
+ void addWordSet(String key, Set<String> set);
+
+ Set<String> getKeySet(String key);
+
+ void addKeySet(String key, Set<String> set);
+
+ Set<String> newSetOfString();
+
+ void commit() throws SpellCheckException;
+
+ void close(boolean save) throws SpellCheckException;
+}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainCheck.java (from rev 2972, trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainCheck.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainCheck.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainCheck.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,143 @@
+/*
+ * 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.autosave.spellcheck;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Map;
+import java.util.NavigableSet;
+import java.util.Set;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.service.FilePersistenceBuilder;
+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.service.IFilePersistence;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@SuppressWarnings("PMD")
+@NotStorableClass
+public class MainCheck extends AbstractSpellCheck {
+
+ private static final String SPELL_CHECK_BASE = "spellCheckBase";
+
+ private IFilePersistence filePersistence;
+
+ private IDataAccessSession session;
+
+ public static void main(String[] args) {
+ (new MainCheck()).run();
+ }
+
+ private void run() {
+ try {
+ openFilePersistence();
+ final InputStream in = getClass().getClassLoader()
+ .getResourceAsStream("word_list.txt");
+ ;
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(in));
+
+ int wordValueCount = 0;
+ int labelCount = 0;
+ String line;
+ final long startTime = System.currentTimeMillis();
+ boolean done = false;
+ while (!done && labelCount < MAX_LABELS
+ && (line = reader.readLine()) != null) {
+ labelCount++;
+ for (String wordValue : splitValue(line)) {
+ final NavigableSet<Integer> keyCodePointSet = computeKeyInSet(wordValue);
+ final String key = codePointToString(keyCodePointSet);
+ session.open();
+ final SpellCheckBase spellCheckBase = (SpellCheckBase) session
+ .getObject(SPELL_CHECK_BASE);
+ final Map<String, Set<String>> wordsByKeyMap = spellCheckBase
+ .getWordsByKeyMap();
+ final Set<String> set = wordsByKeyMap.get(key);
+ if (set == null) {
+ System.out.println("ERROR no set for key " + key
+ + " from word " + wordValue);
+ done = true;
+ } else if (!set.contains(wordValue)) {
+ System.out.println("ERROR missing word " + wordValue
+ + " in set ");
+ done = true;
+ }
+ wordValueCount++;
+ System.out.println(wordValue + " " + wordValueCount);
+ session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
+ }
+ }
+ System.out.println("labelCount " + labelCount);
+ reader.close();
+
+ closeFilePersistence();
+
+ System.out.println("elapsed "
+ + (System.currentTimeMillis() - startTime) + " mS");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void openFilePersistence() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ // builder.setPathName("runtime/spellcheckbase");
+ builder.setPathName("Z:/");
+ builder.setRemoveFiles(false);
+ builder.setFileCache(16 * 1024/* pageSize */, 8 * 1024/* maxPage */);
+ builder.setGarbageManagement(false);
+ builder.setCrashSafeMode(false);
+ filePersistence = builder.build();
+ session = filePersistence.createDataAccessSession();
+ }
+
+ private void closeFilePersistence() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+ if (session.isOpened()) {
+ session.close(EnumFilePersistenceCloseAction.DO_NOT_SAVE);
+ }
+ filePersistence.close();
+ }
+
+}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainReadWords.java (from rev 2972, trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainReadWords.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainReadWords.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainReadWords.java 2011-11-21 07:11:53 UTC (rev 2974)
@@ -0,0 +1,89 @@
+/*
+ * 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.autosave.spellcheck;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.NavigableSet;
+import java.util.Set;
+
+import net.sf.joafip.NotStorableClass;
+
+/**
+ * @author luc peuvrier
+ *
+ */
+@SuppressWarnings("PMD")
+@NotStorableClass
+public class MainReadWords extends AbstractSpellCheck {
+
+ public static void main(String[] args) {
+ (new MainReadWords()).run();
+ }
+
+ private void run() {
+ try {
+ final ISpellCheckDAO spellCheckDAO = new SpellCheckJoafipDAO(true);
+
+ final InputStream in = getClass().getClassLoader()
+ .getResourceAsStream("word_list.txt");
+
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(in));
+
+ int wordValueCount = 0;
+ int labelCount = 0;
+ String line;
+ final long startTime = System.currentTimeMillis();
+ while (labelCount < MAX_LABELS
+ && (line = reader.readLine()) != null) {
+ labelCount++;
+ for (String wordValue : splitValue(line)) {
+ final NavigableSet<Integer> keyCodePointSet = computeKeyInSet(wordValue);
+ final String key = codePointToString(keyCodePointSet);
+ Set<String> set = spellCheckDAO.getWordSet(key);
+ if (set == null) {
+ set = spellCheckDAO.newSetOfString();
+ spellCheckDAO.addWordSet(key, set);
+ // updateKeyMap(spellCheckDAO, keyCodePointSet);
+ }
+ if (set.add(wordValue)) {
+ wordValueCount++;
+ System.out.println(wordValue + " " + wordValueCount);
+ }
+ spellCheckDAO.commit();
+ }
+ }
+ System.out.println("labelCount " + labelCount);
+ reader.close();
+
+ spellCheckDAO.close(true);
+
+ System.out.println("elapsed "
+ + (System.currentTimeMillis() - startTime) + " mS");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Copied: trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckBase.java (from rev 2972, trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckBase.java)
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckBase.java ...
[truncated message content] |
|
From: <luc...@us...> - 2011-11-21 07:11:59
|
Revision: 2974
http://joafip.svn.sourceforge.net/joafip/?rev=2974&view=rev
Author: luc_peuvrier
Date: 2011-11-21 07:11:53 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
comment update. refactoring. test for auto save added.
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/eatmemory/MainEatMemory.java
trunk/joafip-4test/src/main/java/jrat/MainJRat.java
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainMemRBTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/MainRBTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/rbtree/RBTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/AbstractSpellCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/ISpellCheckDAO.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/MainReadWords.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckBase.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckException.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/spellcheck/SpellCheckJoafipDAO.java
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/AbstractSpellCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/ISpellCheckDAO.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainCheck.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/MainReadWords.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckBase.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckException.java
trunk/joafip-4test/src/main/java/net/sf/joafip/autosave/SpellCheckJoafipDAO.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 07:08:56
|
Revision: 2973
http://joafip.svn.sourceforge.net/joafip/?rev=2973&view=rev
Author: luc_peuvrier
Date: 2011-11-21 07:08:50 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
page size adaptation log as info instead of warning
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-21 07:08:56
|
Revision: 2973
http://joafip.svn.sourceforge.net/joafip/?rev=2973&view=rev
Author: luc_peuvrier
Date: 2011-11-21 07:08:50 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
page size adaptation log as info instead of warning
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2011-11-19 06:19:01 UTC (rev 2972)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2011-11-21 07:08:50 UTC (rev 2973)
@@ -136,7 +136,7 @@
this.maxPage = newMaxPage == 0 ? 1 : newMaxPage;
this.haveReadCache = true;
if (this.pageSize != pageSize || this.maxPage != maxPage) {// NOPMD
- logger.warn(getFile().getPath() + " use cache size of "
+ logger.info(getFile().getPath() + " use cache size of "
+ (this.maxPage * this.pageSize) + " bytes, "
+ this.maxPage + " pages, " + this.pageSize
+ " page size. was configured for: " + (maxPage * pageSize)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-19 06:19:08
|
Revision: 2972
http://joafip.svn.sourceforge.net/joafip/?rev=2972&view=rev
Author: luc_peuvrier
Date: 2011-11-19 06:19:01 +0000 (Sat, 19 Nov 2011)
Log Message:
-----------
xml export namespace is now http://joafip.sourceforge.net
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd
trunk/joafip/src/test/java/net/sf/joafip/service/TestExportImport.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestImport222.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel301/TestImport300.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel310/AbstractTestImport301.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -1749,7 +1749,7 @@
}
@Override
- public void xmlImport(final String directoryName)
+ public void xmlImport(final String directoryName, final boolean validating)
throws FilePersistenceException,
FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
@@ -1760,7 +1760,7 @@
assertSessionClosed();
newAccessSessionAndReadOrCreateRootObject(false);
assertNoObjectStored();
- store.xmlImport(directoryName);
+ store.xmlImport(directoryName, validating);
} catch (final StoreException exception) {
throw new FilePersistenceException(exception);
} catch (final StoreClassNotFoundException exception) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -1027,13 +1027,15 @@
*
* @param directoryName
* directory name where are stored exported data to import
+ * @param validating
* @throws FilePersistenceException
* @throws FilePersistenceClassNotFoundException
* @throws FilePersistenceInvalidClassException
* @throws FilePersistenceDataCorruptedException
* @throws FilePersistenceNotSerializableException
*/
- void xmlImport(String directoryName) throws FilePersistenceException,
+ void xmlImport(String directoryName, boolean validating)
+ throws FilePersistenceException,
FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
FilePersistenceDataCorruptedException,
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -491,11 +491,12 @@
}
@Override
- public void xmlImport(final String directoryName) throws StoreException,
- StoreClassNotFoundException, StoreInvalidClassException,
- StoreDataCorruptedException, StoreNotSerializableException {
+ public void xmlImport(final String directoryName, final boolean validating)
+ throws StoreException, StoreClassNotFoundException,
+ StoreInvalidClassException, StoreDataCorruptedException,
+ StoreNotSerializableException {
try {
- xmlImporter.doImport(directoryName);
+ xmlImporter.doImport(directoryName, validating);
} catch (final ImportException exception) {
throw new StoreException(exception);
} catch (final ImportClassNotFoundException exception) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -663,15 +663,17 @@
*
* @param directoryName
* directory name where are stored exported data to import
+ * @param validating
* @throws StoreException
* @throws StoreNotSerializableException
* @throws StoreDataCorruptedException
* @throws StoreInvalidClassException
* @throws StoreClassNotFoundException
*/
- void xmlImport(String directoryName) throws StoreException,
- StoreClassNotFoundException, StoreInvalidClassException,
- StoreDataCorruptedException, StoreNotSerializableException;
+ void xmlImport(String directoryName, boolean validating)
+ throws StoreException, StoreClassNotFoundException,
+ StoreInvalidClassException, StoreDataCorruptedException,
+ StoreNotSerializableException;
void setImportListener(IImportListener listener);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -158,9 +158,10 @@
}
@Override
- public void doImport(final String directoryName) throws ImportException,
- ImportClassNotFoundException, ImportDataCorruptedException,
- ImportInvalidClassException, ImportNotSerializableException {
+ public void doImport(final String directoryName, final boolean validating)
+ throws ImportException, ImportClassNotFoundException,
+ ImportDataCorruptedException, ImportInvalidClassException,
+ ImportNotSerializableException {
numberOfImported = 0;
final File directory = new File(directoryName);
if (directory.exists()) {
@@ -173,7 +174,7 @@
synchronized (storeMutex) {
objectMap = new TreeMap<Integer, Object>();
dummyObjectSet = new HashSet<ObjectAndPersistInfo>();
- importImpl(directory);
+ importImpl(directory, validating);
try {
storeSaver.saveModification();
} catch (final StoreException exception) {
@@ -190,16 +191,18 @@
*
* @param directoryName
* directory name where are stored exported data to import
+ * @param validating
+ * true if validating according to joafip.xsd
* @throws ImportException
* @throws ImportClassNotFoundException
* @throws ImportDataCorruptedException
* @throws ImportInvalidClassException
* @throws ImportNotSerializableException
*/
- protected abstract void importImpl(final File directory)
- throws ImportException, ImportClassNotFoundException,
- ImportDataCorruptedException, ImportInvalidClassException,
- ImportNotSerializableException;
+ protected abstract void importImpl(final File directory,
+ final boolean validating) throws ImportException,
+ ImportClassNotFoundException, ImportDataCorruptedException,
+ ImportInvalidClassException, ImportNotSerializableException;
protected void setReleaseAndDataModelIdentifier(
final String previousReleaseName,
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -36,6 +36,7 @@
*
* @param directoryName
* directory name where are stored exported data to import
+ * @param validating
* @throws StoreException
* @throws StoreNotSerializableException
* @throws StoreDataCorruptedException
@@ -47,10 +48,10 @@
* @throws ImportDataCorruptedException
* @throws ImportClassNotFoundException
*/
- void doImport(String directoryName) throws StoreException,
- StoreClassNotFoundException, StoreInvalidClassException,
- StoreDataCorruptedException, StoreNotSerializableException,
- ImportException, ImportClassNotFoundException,
- ImportDataCorruptedException, ImportInvalidClassException,
- ImportNotSerializableException;
+ void doImport(String directoryName, boolean validating)
+ throws StoreException, StoreClassNotFoundException,
+ StoreInvalidClassException, StoreDataCorruptedException,
+ StoreNotSerializableException, ImportException,
+ ImportClassNotFoundException, ImportDataCorruptedException,
+ ImportInvalidClassException, ImportNotSerializableException;
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -18,16 +18,14 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Deque;
import java.util.LinkedList;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.SchemaFactory;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.store.service.IStore;
@@ -48,6 +46,12 @@
@NotStorableClass
public class XmlImporter extends AbstractImporter implements ContentHandler {// NOPMD
+ private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+
+ private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
+
+ private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
+
private Locator locator;
private Deque<ICurrentHandler> handlerStack;
@@ -60,32 +64,33 @@
}
@Override
- protected void importImpl(final File directory) throws ImportException,
- ImportClassNotFoundException, ImportDataCorruptedException,
- ImportInvalidClassException, ImportNotSerializableException {
+ protected void importImpl(final File directory, final boolean validating)
+ throws ImportException, ImportClassNotFoundException,
+ ImportDataCorruptedException, ImportInvalidClassException,
+ ImportNotSerializableException {
exportFile = new File(directory, "export.xml");
if (!exportFile.exists()) {
throw new ImportException(exportFile + " does not exists");
}
final SAXParserFactory factory = SAXParserFactory.newInstance();
- // FIXMELUC ?____why not validating ?
- factory.setValidating(false);
+ factory.setValidating(validating);
factory.setNamespaceAware(true);
- final SchemaFactory schemaFactory = SchemaFactory
- .newInstance("http://www.w3.org/2001/XMLSchema");
try {
- final InputStream inputStream = classLoaderProvider
- .getClassLoader()
- .getResourceAsStream(
- "net/sf/joafip/store/service/export_import/joafip.xsd");
- factory.setSchema(schemaFactory
- .newSchema(new Source[] { new StreamSource(inputStream) }));
+ final SAXParser saxParser = factory.newSAXParser();
+ if (validating) {
+ saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
- final SAXParser parser = factory.newSAXParser();
- final XMLReader reader = parser.getXMLReader();
+ final URI schemaSourceUri = ClassLoader.getSystemResource(
+ "net/sf/joafip/store/service/export_import/joafip.xsd")
+ .toURI();
+ saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File(
+ schemaSourceUri));
+ }
+ final XMLReader reader = saxParser.getXMLReader();
reader.setErrorHandler(new XmlReaderErrorHandler(this));
reader.setContentHandler(this);
- reader.parse(new InputSource(exportFile.toURI().toString()));
+ final String sourcePath = exportFile.toURI().toString();
+ reader.parse(new InputSource(sourcePath));
} catch (SAXException exception) {
final String message = exception.getMessage();
final Exception embeddedException = exception.getException();
@@ -108,6 +113,8 @@
throw new ImportException(exception);
} catch (IllegalArgumentException exception) {
throw new ImportException(exception);
+ } catch (URISyntaxException exception) {
+ throw new ImportException(exception);
}
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd 2011-11-19 06:19:01 UTC (rev 2972)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://joafip.sourceforge.net/schema" xmlns="http://joafip.sourceforge.net/schema"
+ targetNamespace="http://joafip.sourceforge.net" xmlns="http://joafip.sourceforge.net"
elementFormDefault="qualified">
<xs:annotation>
@@ -55,7 +55,7 @@
<!-- field -->
<xs:element name="field" minOccurs="0" maxOccurs="unbounded">
<xs:complexType mixed="false">
- <xs:group ref="fieldElt" />
+ <xs:group ref="fieldElt" minOccurs="1" maxOccurs="1" />
<xs:attribute name="class" type="xs:string" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="declClass" type="xs:string"
@@ -85,7 +85,7 @@
<!-- field -->
<xs:element name="field" minOccurs="0" maxOccurs="unbounded">
<xs:complexType mixed="false">
- <xs:group ref="fieldElt" />
+ <xs:group ref="fieldElt" minOccurs="1" maxOccurs="1" />
<xs:attribute name="class" type="xs:string" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="declClass" type="xs:string"
@@ -114,13 +114,13 @@
<xs:choice>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:choice>
- <xs:group ref="reference" />
- <xs:group ref="object" />
+ <xs:group ref="reference" minOccurs="1" maxOccurs="1" />
+ <xs:group ref="object" minOccurs="1" maxOccurs="1" />
</xs:choice>
</xs:sequence>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:group ref="value" />
+ <xs:group ref="value" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:choice>
@@ -225,7 +225,7 @@
</xs:sequence>
- <!-- static field -->
+ <!-- static field -->
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:element name="staticField" minOccurs="1"
maxOccurs="1">
@@ -262,13 +262,10 @@
</xs:complexType>
- <!--
- <xs:key name="object_id"> <xs:selector xpath=" ./ object | ./ string
- | ./ enum | ./ array" /> <xs:field xpath="@id"/> </xs:key> <xs:keyref
- name="ref_object_id" refer="object_id"> <xs:selector
- xpath="./object/field/reference" /> <xs:field xpath="@id"/>
- </xs:keyref>
- -->
+ <!-- <xs:key name="object_id"> <xs:selector xpath=" ./ object | ./ string
+ | ./ enum | ./ array" /> <xs:field xpath="@id"/> </xs:key> <xs:keyref name="ref_object_id"
+ refer="object_id"> <xs:selector xpath="./object/field/reference" /> <xs:field
+ xpath="@id"/> </xs:keyref> -->
<!-- objects -->
</xs:element>
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestExportImport.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestExportImport.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestExportImport.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -144,7 +144,7 @@
* Forbidden import
*/
try {
- filePersistence.xmlImport(RUNTIME);
+ filePersistence.xmlImport(RUNTIME, true);
fail("must fail");// NOPMD
} catch (final FilePersistenceException exception) {// NOPMD
// expected
@@ -176,7 +176,7 @@
/* import */
- filePersistence.xmlImport(RUNTIME);
+ filePersistence.xmlImport(RUNTIME, true);
assertEquals("", 'a', bobForExport.getCharValue());
@@ -279,7 +279,7 @@
builder.setCrashSafeMode(false);
filePersistence = builder.build();
- filePersistence.xmlImport(RUNTIME);
+ filePersistence.xmlImport(RUNTIME, true);
dataAccessSession = filePersistence.createDataAccessSession();
dataAccessSession.open();
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -1,8 +1,11 @@
package net.sf.joafip.service;
+import java.lang.reflect.Method;
+
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.StorableAccess;
import net.sf.joafip.TestException;
+import net.sf.joafip.store.service.objectfortest.Bob1;
@NotStorableClass
@StorableAccess
@@ -29,6 +32,11 @@
builder.setGarbageManagement(false);
builder.setCrashSafeMode(false);
filePersistence = (FilePersistence) builder.build();
+ // FIXMELUC ______________________NoPersistenceConstraintCheck
+ // annotation
+ final Method method = Bob1.class.getDeclaredMethod(
+ "doSomethingOnOtherBob1Private", new Class<?>[] { Bob1.class });
+ filePersistence.addToNotCheckMethod(method);
}
@Override
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestImport222.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestImport222.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestImport222.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -49,7 +49,7 @@
FilePersistenceTooBigForSerializationException {
Container.skipBug222 = true;
HelperReflect.getInstance().setAlwaysAcceptNullField(true);
- filePersistence.xmlImport("../joafip/export222");
+ filePersistence.xmlImport("../joafip/export222", false);
final IDataAccessSession dataAccessSession = filePersistence
.createDataAccessSession();
dataAccessSession.open();
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel301/TestImport300.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel301/TestImport300.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel301/TestImport300.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -88,7 +88,7 @@
}
@Override
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception { // NOPMD
try {
filePersistence.close();
} catch (final Throwable throwable) {// NOPMD
@@ -105,7 +105,7 @@
FilePersistenceDataCorruptedException,
FilePersistenceNotSerializableException, ProxyException,
FilePersistenceTooBigForSerializationException {
- filePersistence.xmlImport("../joafip/export300");
+ filePersistence.xmlImport("../joafip/export300", false);
final IDataAccessSession dataAccessSession = filePersistence
.createDataAccessSession();
dataAccessSession.open();
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel310/AbstractTestImport301.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel310/AbstractTestImport301.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel310/AbstractTestImport301.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -58,7 +58,7 @@
FilePersistenceNotSerializableException, ProxyException,
FilePersistenceTooBigForSerializationException {
- filePersistence.xmlImport("../joafip/export301b");
+ filePersistence.xmlImport("../joafip/export301b", false);
checkObjectState();
}
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -965,10 +965,11 @@
exportPersistedClassByteCode);
}
- public void xmlImport(final String directoryName) throws StoreException,
- StoreClassNotFoundException, StoreInvalidClassException,
- StoreDataCorruptedException, StoreNotSerializableException {
- store.xmlImport(directoryName);
+ public void xmlImport(final String directoryName, final boolean validating)
+ throws StoreException, StoreClassNotFoundException,
+ StoreInvalidClassException, StoreDataCorruptedException,
+ StoreNotSerializableException {
+ store.xmlImport(directoryName, validating);
}
public ObjectAndPersistInfo getObjectAndPersistInfoOfObjectFromQueue(
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -78,7 +78,7 @@
filePersistence.setImportListener(this);
startTime = System.currentTimeMillis();
- filePersistence.xmlImport("runtime_perf/export");
+ filePersistence.xmlImport("runtime_perf/export", true);
System.out.println(numberOfImported + " imported, duration "// NOPMD
+ (System.currentTimeMillis() - startTime));
filePersistence.close();
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-11-18 04:46:52 UTC (rev 2971)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java 2011-11-19 06:19:01 UTC (rev 2972)
@@ -24,10 +24,13 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import net.sf.joafip.service.TestExportImport;
+import net.sf.joafip.service.TestExportObject;
import net.sf.joafip.service.rel300.TestImport222;
import net.sf.joafip.service.rel300.TestImport222NotLazy;
-import net.sf.joafip.service.rel300.TestUseRuntime222;
-import net.sf.joafip.service.rel300.TestUseRuntime222NotLazy;
+import net.sf.joafip.service.rel301.TestImport300;
+import net.sf.joafip.service.rel310.TestImport301ConversionA;
+import net.sf.joafip.service.rel310.TestImport301ConversionB;
/**
*
@@ -44,10 +47,13 @@
public static Test suite() {
final TestSuite suite = new TestSuite("in error Tests");
// $JUnit-BEGIN$
- suite.addTestSuite(TestUseRuntime222.class);
- suite.addTestSuite(TestUseRuntime222NotLazy.class);
+ suite.addTestSuite(TestExportImport.class);
+ suite.addTestSuite(TestExportObject.class);
suite.addTestSuite(TestImport222.class);
suite.addTestSuite(TestImport222NotLazy.class);
+ suite.addTestSuite(TestImport300.class);
+ suite.addTestSuite(TestImport301ConversionA.class);
+ suite.addTestSuite(TestImport301ConversionB.class);
// suite.addTest(xxxx.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...> - 2011-11-19 06:19:07
|
Revision: 2972
http://joafip.svn.sourceforge.net/joafip/?rev=2972&view=rev
Author: luc_peuvrier
Date: 2011-11-19 06:19:01 +0000 (Sat, 19 Nov 2011)
Log Message:
-----------
xml export namespace is now http://joafip.sourceforge.net
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/service/IFilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/AbstractDelegatingToStoreManagers.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/IStore.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/IImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd
trunk/joafip/src/test/java/net/sf/joafip/service/TestExportImport.java
trunk/joafip/src/test/java/net/sf/joafip/service/TestFilePersistenceNoG.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel300/AbstractTestImport222.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel301/TestImport300.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel310/AbstractTestImport301.java
trunk/joafip/src/test/java/net/sf/joafip/store/service/StoreForTest.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/Importer.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/InErrorTests.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-18 04:46:58
|
Revision: 2971
http://joafip.svn.sourceforge.net/joafip/?rev=2971&view=rev
Author: luc_peuvrier
Date: 2011-11-18 04:46:52 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
xml export namespace is now http://joafip.sourceforge.net
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/XmlExporter.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-18 04:46:58
|
Revision: 2971
http://joafip.svn.sourceforge.net/joafip/?rev=2971&view=rev
Author: luc_peuvrier
Date: 2011-11-18 04:46:52 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
xml export namespace is now http://joafip.sourceforge.net
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/XmlExporter.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/XmlExporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/XmlExporter.java 2011-11-18 02:52:27 UTC (rev 2970)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/XmlExporter.java 2011-11-18 04:46:52 UTC (rev 2971)
@@ -135,7 +135,7 @@
throws StoreException {
try {
objectsStartTag.addAttribute("xmlns",
- "http://joafip.sourceforge.net/schema");
+ "http://joafip.sourceforge.net");
objectsStartTag.addAttribute("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance");
objectsStartTag.addAttribute("xsi:schemaLocation",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-18 02:52:34
|
Revision: 2970
http://joafip.svn.sourceforge.net/joafip/?rev=2970&view=rev
Author: luc_peuvrier
Date: 2011-11-18 02:52:27 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
error in xml value import reading corrected
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/doc/missing.txt
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InValueHandler.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java
trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.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/bugtree/MainTreeMultiFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/util/TestXmlWriter.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/UtilTests.java
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip/doc/_todo.txt 2011-11-18 02:52:27 UTC (rev 2970)
@@ -19,6 +19,7 @@
- asm 3.3 embedded
- java agent changed
- project divided on sub project
+- import error reading xml value corrected
- export speed up
- kept in memory for object referenced by static field
- persisted class byte code checked for persistence constraints
@@ -79,25 +80,25 @@
currently:
-------------------------------------------------------------------------------------
-auto save problems with jhupedom:
-- HeapFileDataManager problem ?
-
-export/import problem.
-- test with BlockDataManger
+export:
- no more static field management
+- use of a linked list in file instead of heapFileDataManager
xml file for export:
bad namespace xmlns="http://joafip.sourceforge.net/schema"
should be xmlns="http://joafip.sourceforge.net"
may be /joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd to update
+auto save problems with jhupedom:
+- HeapFileDataManager problem ?
+
+garbage management error with jhupedom
+
BlockDataManger
- test performance with cache, if ok it is a good alternative but:
- big file, do not reuse free space
- fixed max data record length
-garbage management error with jhupedom
-
kept in memory problem
joafip reflect project (see setAccessible )
Modified: trunk/joafip/doc/missing.txt
===================================================================
--- trunk/joafip/doc/missing.txt 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip/doc/missing.txt 2011-11-18 02:52:27 UTC (rev 2970)
@@ -3,4 +3,64 @@
missing list=[108738, 118200, 132948, 142808, 165872]
using HeapFileDataManager:
-missing list=[108738, 118200, 132948, 142808, 165872]
\ No newline at end of file
+missing list=[108738, 118200, 132948, 142808, 165872]
+
+from xml analyse: check of item identifier
+missing 197290 197290
+missing 197806 197806
+missing 230918 230918
+missing 244118 244118
+missing 250610 250610
+missing 252190 252190
+missing 285034 285034
+missing 298138 298138
+missing 303602 303602
+missing 307170 307170
+missing 315234 315234
+missing 331234 331234
+missing 357662 357662
+missing 361086 361086
+missing 373054 373054
+missing 386462 386462
+missing 412458 412458
+missing 412794 412794
+missing 443458 443458
+missing 476050 476050
+missing 520578 520578
+missing 522050 522050
+missing 524382 524382
+
+
+from import searcher:
+ missing list=
+108738
+118200
+132948
+142808
+165872
+
+mismatch list=
+
+90 for 197290
+6 for 197806
+8 for 230918
+8 for 244118
+10 for 250610
+90 for 252190
+4 for 285034
+38 for 298138
+2 for 303602
+0 for 307170
+34 for 315234
+4 for 331234
+2 for 357662
+86 for 361086
+54 for 373054
+62 for 386462
+8 for 412458
+4 for 412794
+8 for 443458
+0 for 476050
+78 for 520578
+0 for 522050
+82 for 524382
\ No newline at end of file
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InValueHandler.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InValueHandler.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InValueHandler.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -28,7 +28,7 @@
@NotStorableClass
public class InValueHandler extends InSimpleHandler {
- private Object data;
+ private final StringBuilder dataBuilder = new StringBuilder();
public InValueHandler(final XmlImporter xmlImporter) {
super(xmlImporter);
@@ -37,11 +37,11 @@
@Override
public void characters(final char[] chars, final int start, final int length)// NOPMD
throws SAXException {
- data = new String(chars, start, length);
+ dataBuilder.append(chars, start, length);
}
@Override
public Object getData() {
- return data;
+ return dataBuilder.toString();
}
}
Modified: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -42,8 +42,7 @@
this.identifier = identifier;
}
- public Item(final int identifier,
- final String value) {
+ public Item(final int identifier, final String value) {
super();
this.identifier = identifier;
this.value = value;
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -65,17 +65,17 @@
IFilePersistence filePersistence = createFilePersistence(true);
IDataAccessSession session = filePersistence.createDataAccessSession();
session.open();
- Item item=new Item(0, "value");
- session.setObject("key",item);
+ Item item = new Item(0, "value");
+ session.setObject("key", item);
session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
filePersistence.close();
filePersistence = createFilePersistence(false);
session = filePersistence.createDataAccessSession();
session.open();
- item=(Item) session.getObject("key");
- assertEquals("bad state",0,item.getIdentifier());
- assertEquals("bad state","value",item.getValue());
+ item = (Item) session.getObject("key");
+ assertEquals("bad state", 0, item.getIdentifier());
+ assertEquals("bad state", "value", item.getValue());
session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
filePersistence.close();
}
Added: trunk/joafip/src/test/java/net/sf/joafip/util/TestXmlWriter.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/util/TestXmlWriter.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/util/TestXmlWriter.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -0,0 +1,81 @@
+/*
+ * 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.util;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+import net.sf.joafip.AbstractJoafipTestCase;
+import net.sf.joafip.NoStorableAccess;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestConstant;
+import net.sf.joafip.TestException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@NoStorableAccess
+public class TestXmlWriter extends AbstractJoafipTestCase {
+
+ public TestXmlWriter() throws TestException {
+ super();
+ }
+
+ public TestXmlWriter(final String name) throws TestException {
+ super(name);
+ }
+
+ public void test() throws XmlWriterException, IOException, TestException {
+ final String file = TestConstant.getWinRamDiskRuntimeDir()
+ + "/xmlWriterTestFile.txt";
+ final OutputStream outputStream = new FileOutputStream(file);
+ final XmlWriter xmlWriter = new XmlWriter(outputStream);
+ for (int index = 0; index <= 1000000; index++) {
+ xmlWriter
+ .writeText(0, Integer.toString(index), true/* writeNewLine */);
+ }
+ xmlWriter.close();
+
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file), "UTF-8"));
+ int index = 0;
+ String line;
+ // skip xml declaration
+ assertNotNull("must has line", reader.readLine());
+ // then check lines
+ while ((line = reader.readLine()) != null) {// NOPMD
+ final int value = Integer.parseInt(line);
+ assertEquals("bad value", index, value);
+ index++;
+ }
+ assertEquals("missing value", 1000001, index);
+ reader.close();
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -6,8 +6,9 @@
public static void main(final String[] args) {
try {
- ASMifierClassVisitor.outAsm(false, NewProxyCallBack.class.getName(),
- "src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.java");
+ ASMifierClassVisitor
+ .outAsm(false, NewProxyCallBack.class.getName(),
+ "src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.java");
} catch (Exception e) {
e.printStackTrace();// NOPMD
}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -8,10 +8,9 @@
private final IProxyCallBackProxyDelegation proxyCallBack;
- public NewProxyCallBack()
- throws ProxyException {
+ public NewProxyCallBack() throws ProxyException {
super();
- proxyCallBack=new ProxyCallBack();
+ proxyCallBack = new ProxyCallBack();
}
public IProxyCallBackProxyDelegation getProxyCallBack() {
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 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -45,7 +45,8 @@
FilePersistenceTooBigForSerializationException, RBTException,
HeapException {
final FilePersistenceBuilder builder = new FilePersistenceBuilder();
- final IHeapDataManager dataManager = new BlockDataManager(10 * 1024, 10 * 1024,1024);
+ final IHeapDataManager dataManager = new BlockDataManager(10 * 1024,
+ 10 * 1024, 1024);
builder.setDataManager(dataManager);
builder.setProxyMode(true);
builder.setRemoveFiles(true);
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 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -51,18 +51,21 @@
FilePersistenceTooBigForSerializationException, RBTException,
HeapException, TestException {
final FilePersistenceBuilder builder = new FilePersistenceBuilder();
- final String dir = "runtime";//TestConstant.getWinRamDiskRuntimeDir();
- final IHeapDataManager blockDataManager = new BlockDataManager(dir+"/data",1024);
-// 10 * 1024, 10 * 1024);
- final HeapFileSetup setup = new HeapFileSetup(new File(dir+"/store.data"), false/*crashSafeMode*/,
- false/*useCacheMode*/,false/*deleteRenaming*/, false/*clearResizeFile*/,
- 0/*maxFileOperationRetry*/,0/*fileOperationRetryMsDelay*/,
- new File("runtime/openFileTraceFile.txt"));
+ final String dir = "runtime";// TestConstant.getWinRamDiskRuntimeDir();
+ final IHeapDataManager blockDataManager = new BlockDataManager(dir
+ + "/data", 1024);
+ // 10 * 1024, 10 * 1024);
+ final HeapFileSetup setup = new HeapFileSetup(new File(dir
+ + "/store.data"), false/* crashSafeMode */,
+ false/* useCacheMode */, false/* deleteRenaming */,
+ false/* clearResizeFile */, 0/* maxFileOperationRetry */,
+ 0/* fileOperationRetryMsDelay */, new File(
+ "runtime/openFileTraceFile.txt"));
final IHeapDataManager fileDataManager = new HeapFileDataManager(setup);
builder.setDataManager(new DualWrapDataManager(fileDataManager,
blockDataManager));
-
+
builder.setProxyMode(true);
builder.setRemoveFiles(true);
builder.setCrashSafeMode(false);
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 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -77,7 +77,7 @@
@Override
public void saveDone(final int numberOfObjectState,
final int numberOfWeakreference, final long msDuration) {
- System.out.println("n=" + numberOfObjectState + " w="//NOPMD
+ System.out.println("n=" + numberOfObjectState + " w="// NOPMD
+ numberOfWeakreference + " t=" + msDuration + " mS");
}
}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -9,7 +9,7 @@
import net.sf.joafip.redblacktree.service.RedBlackTree;
@StorableClass
-public class TreeMem<E> extends Tree<E>{
+public class TreeMem<E> extends Tree<E> {
@AssertNotNull
protected final RedBlackTree<E> redBlackTree;
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -32,6 +32,7 @@
import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
import net.sf.joafip.heapfile.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
+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;
@@ -86,18 +87,29 @@
initializeByItemDuration();
int missingCount = 0;
final List<Integer> missingList = new LinkedList<Integer>();
+ int misMatchCount = 0;
+ final List<String> misMatchList = new LinkedList<String>();
for (int identifier = 0; identifier < NUMBER_OF_ITEM; identifier++) {
final ItemList itemList = getItemList(session);
final long startSearchTime = System.currentTimeMillis();
- if (itemList.get(identifier) == null) {
+ final Item item = itemList.get(identifier);
+ if (item == null) {
// throw new
// IllegalStateException("missing item for identifier "
// + identifier);
logger.info("missing item for identifier " + identifier);
missingCount++;
- if (missingCount < 20) {
+ if (missingCount < 40) {
missingList.add(identifier);
}
+ } else {
+ if (item.getIdentifier() != identifier) {
+ misMatchCount++;
+ if (misMatchCount < 40) {
+ misMatchList.add(item.getIdentifier() + " for "
+ + identifier);
+ }
+ }
}
final long currentTime = System.currentTimeMillis();
final long searchDuration = currentTime - startSearchTime;
@@ -123,8 +135,27 @@
logger.info("max search time " + maxSearchTime);
logger.info((endTime - startTime) + " mS for " + NUMBER_OF_ITEM
+ " items");
+
logger.info("missing count=" + missingCount);
- logger.info("missing list=" + missingList.toString());
+ StringBuilder stringBuilder = new StringBuilder();
+
+ stringBuilder.append("missing list=\n");
+ for (int missing : missingList) {
+ stringBuilder.append(missing);
+ stringBuilder.append('\n');
+ }
+ logger.info(stringBuilder.toString());
+
+ logger.info("mismatch count=" + misMatchCount);
+
+ stringBuilder = new StringBuilder();
+ stringBuilder.append("mismatch list=\n");
+ for (String mismatch : misMatchList) {
+ stringBuilder.append(mismatch);
+ stringBuilder.append('\n');
+ }
+ logger.info(stringBuilder.toString());
+
final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
new FileOutputStream(DURATION_BIN));
objectOutputStream.writeObject(byItemDuration);
Deleted: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -1,240 +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.performance.items.service;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.logger.JoafipLogger;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public final class MainExportScanner implements ErrorHandler, ContentHandler {
-
- private static final JoafipLogger LOGGER = JoafipLogger
- .getLogger(MainExportScanner.class);
-
- private final Deque<String> que = new LinkedList<String>();
-
- private final Deque<String> attrQue = new LinkedList<String>();
-
- private final Set<Integer> valueSet = new TreeSet<Integer>();
-
- private int total;
-
- private int count;
-
- private PrintWriter printWriter;
-
- private MainExportScanner() {
- super();
- }
-
- public static void main(final String[] args) {
- try {
- final MainExportScanner main = new MainExportScanner();
- main.run();
- } catch (Exception exception) {
- LOGGER.error("execution failure", exception);
- }
- }
-
- private void run() throws ParserConfigurationException, SAXException,
- IOException {
- printWriter = new PrintWriter(new File(
- "runtime_perf/export/missing.txt"));
- total = 0;
- count = 0;
- valueSet.add(108738);
- valueSet.add(118200);
- valueSet.add(132948);
- valueSet.add(142808);
- valueSet.add(165872);
-
- final SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating(false);
- factory.setNamespaceAware(true);
- final SAXParser parser = factory.newSAXParser();
- final XMLReader reader = parser.getXMLReader();
- reader.setErrorHandler(this);
- reader.setContentHandler(this);
- reader.parse(new InputSource("runtime_perf/export/export.xml"));
- System.out.println("count=" + count + " total=" + total);// NOPMD
- printWriter.close();
- }
-
- @Override
- public void warning(final SAXParseException exception) throws SAXException {
- LOGGER.warn("sax error", exception);
- }
-
- @Override
- public void error(final SAXParseException exception) throws SAXException {
- LOGGER.warn("sax error", exception);
- }
-
- @Override
- public void fatalError(final SAXParseException exception)
- throws SAXException {
- LOGGER.warn("sax error", exception);
- }
-
- @Override
- public void startDocument() throws SAXException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void endDocument() throws SAXException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void setDocumentLocator(final Locator locator) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void startPrefixMapping(final String prefix, final String uri)
- throws SAXException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void endPrefixMapping(final String prefix) throws SAXException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void startElement(final String uri, final String localName,
- final String qName, final Attributes atts) throws SAXException {
- final StringBuilder stringBuilder = new StringBuilder();
- final String peekLast = que.peekLast();
- if (peekLast != null) {
- stringBuilder.append(peekLast);
- }
- stringBuilder.append('/');
- stringBuilder.append(localName);
- if ("field".equals(localName)) {
- stringBuilder.append('{');
- stringBuilder.append(atts.getValue("name"));
- stringBuilder.append(',');
- stringBuilder.append(atts.getValue("declClass"));
- stringBuilder.append('}');
- }
- que.addLast(stringBuilder.toString());
- attrQue.addLast(attrToString(atts));
- }
-
- @Override
- public void endElement(final String uri, final String localName,
- final String qName) throws SAXException {
- que.removeLast();
- attrQue.removeLast();
- }
-
- @Override
- public void characters(final char[] chars, final int start, final int length)
- throws SAXException {
- final String peekLast = que.peekLast();
- if ("/objects/object/field{identifier,net.sf.joafip.performance.items.entity.Item}/value"
- .equals(peekLast)) {
- final int value = Integer.parseInt(new String(Arrays.copyOfRange(
- chars, start, start + length)));
- total++;
- if (valueSet.contains(value)) {
- count++;
- final Iterator<String> iterator = attrQue.descendingIterator();
- for (int count = 0; count < 2; count++) {
- iterator.next();
- }
- final String attrs = iterator.next();
- printWriter.print(attrs);
- printWriter.print(", value=");
- printWriter.println(value);
- }
- }
- }
-
- private String attrToString(final Attributes attrs) {
- final StringBuilder stringBuilder = new StringBuilder();
- final int length = attrs.getLength();
- for (int index = 0; index < length; index++) {
- stringBuilder.append(attrs.getQName(index));
- stringBuilder.append('=');
- stringBuilder.append(attrs.getValue(index));
- stringBuilder.append(',');
- }
- return stringBuilder.toString();
- }
-
- @Override
- public void ignorableWhitespace(final char[] chars, final int start,
- final int length) throws SAXException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void processingInstruction(final String target, final String data)
- throws SAXException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void skippedEntity(final String name) throws SAXException {
- // TODO Auto-generated method stub
-
- }
-}
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java 2011-11-13 06:40:17 UTC (rev 2969)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -27,6 +27,7 @@
import net.sf.joafip.redblacktree.RedBlackTreeTests;
import net.sf.joafip.service.ServiceTests;
import net.sf.joafip.store.StoreTests;
+import net.sf.joafip.util.UtilTests;
@NotStorableClass
public class PersistanceTestsNoLongTests {// NOPMD
@@ -39,6 +40,7 @@
final TestSuite suite = new TestSuite(
"main (speed) Tests for persistence");
// $JUnit-BEGIN$
+ suite.addTest(UtilTests.suite());
suite.addTest(MemInspectorTests.suite());
suite.addTest(OGraphTests.suite());
suite.addTest(RedBlackTreeTests.suite());
Added: trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/UtilTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/UtilTests.java (rev 0)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/UtilTests.java 2011-11-18 02:52:27 UTC (rev 2970)
@@ -0,0 +1,45 @@
+/*
+ * 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.util;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.sf.joafip.NotStorableClass;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class UtilTests {
+
+ public static Test suite() {
+ final TestSuite suite = new TestSuite("util Tests");
+ // $JUnit-BEGIN$
+ suite.addTestSuite(TestXmlWriter.class);
+ // suite.addTest(xxxx.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...> - 2011-11-18 02:52:33
|
Revision: 2970
http://joafip.svn.sourceforge.net/joafip/?rev=2970&view=rev
Author: luc_peuvrier
Date: 2011-11-18 02:52:27 +0000 (Fri, 18 Nov 2011)
Log Message:
-----------
error in xml value import reading corrected
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
trunk/joafip/doc/missing.txt
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InValueHandler.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java
trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.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/bugtree/MainTreeMultiFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/PersistanceTestsNoLongTests.java
Added Paths:
-----------
trunk/joafip/src/test/java/net/sf/joafip/util/TestXmlWriter.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/
trunk/joafip-testsuite/src/main/java/net/sf/joafip/util/UtilTests.java
Removed Paths:
-------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/MainExportScanner.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-13 06:40:23
|
Revision: 2969
http://joafip.svn.sourceforge.net/joafip/?rev=2969&view=rev
Author: luc_peuvrier
Date: 2011-11-13 06:40:17 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
Added block data manager for tests
Modified Paths:
--------------
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/HeapFileLongTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-13 06:40:23
|
Revision: 2969
http://joafip.svn.sourceforge.net/joafip/?rev=2969&view=rev
Author: luc_peuvrier
Date: 2011-11-13 06:40:17 +0000 (Sun, 13 Nov 2011)
Log Message:
-----------
Added block data manager for tests
Modified Paths:
--------------
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/HeapFileLongTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java
trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/HeapFileLongTests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/HeapFileLongTests.java 2011-11-12 16:58:23 UTC (rev 2968)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/HeapFileLongTests.java 2011-11-13 06:40:17 UTC (rev 2969)
@@ -19,7 +19,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.heapfile.service.TestHeapDataMgrMemoryLeak;
+import net.sf.joafip.heapfile.service.TestHeapFileDataMgrMemoryLeak;
@NotStorableClass
public class HeapFileLongTests {
@@ -31,7 +31,7 @@
public static Test suite() {
final TestSuite suite = new TestSuite("Test for heapfile");
// $JUnit-BEGIN$
- suite.addTestSuite(TestHeapDataMgrMemoryLeak.class);
+ suite.addTestSuite(TestHeapFileDataMgrMemoryLeak.class);
// $JUnit-END$
return suite;
}
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 2011-11-12 16:58:23 UTC (rev 2968)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/heapfile/service/HeapFileServiceTests.java 2011-11-13 06:40:17 UTC (rev 2969)
@@ -31,10 +31,11 @@
final TestSuite suite = new TestSuite("Test for heapfile.service");
// $JUnit-BEGIN$
// suite.addTestSuite(TestHeapDataMgrMemoryLeak.class); too long
- suite.addTestSuite(TestHeapDataManager.class);
- suite.addTestSuite(TestHeapDataManagerFreeing.class);
- suite.addTestSuite(TestHeapDataManagerBackup.class);
- suite.addTestSuite(TestHeapDataMgrWithScenario.class);
+ suite.addTestSuite(TestHeapFileDataManager.class);
+ suite.addTestSuite(TestHeapFileDataManagerFreeing.class);
+ suite.addTestSuite(TestHeapFileDataManagerBackup.class);
+ suite.addTestSuite(TestHeapFileDataMgrWithScenario.class);
+ suite.addTestSuite(TestBlockDataManager.class);
// $JUnit-END$
return suite;
}
Modified: trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java
===================================================================
--- trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java 2011-11-12 16:58:23 UTC (rev 2968)
+++ trunk/joafip-testsuite/src/main/java/net/sf/joafip/service/rel400/ServiceRel400Tests.java 2011-11-13 06:40:17 UTC (rev 2969)
@@ -25,6 +25,7 @@
suite.addTestSuite(TestConstructEntrySetIteratorOfPMapKeyNavigableSet.class);
suite.addTestSuite(TestPHashMapNewInstance.class);
suite.addTestSuite(TestPrivateAccess.class);
+ suite.addTestSuite(TestEnumMap.class);
// $JUnit-END$
return suite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:58:29
|
Revision: 2968
http://joafip.svn.sourceforge.net/joafip/?rev=2968&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:58:23 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added tests. added fix. correction
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/test/resources/log4j.properties
Added Paths:
-----------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/que/
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:58:29
|
Revision: 2968
http://joafip.svn.sourceforge.net/joafip/?rev=2968&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:58:23 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added tests. added fix. correction
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
trunk/joafip/src/test/resources/log4j.properties
Added Paths:
-----------
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/que/
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java
trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-11-12 16:56:52 UTC (rev 2967)
+++ trunk/joafip/src/main/java/net/sf/joafip/service/FilePersistence.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -59,7 +59,6 @@
import net.sf.joafip.store.service.objectio.manager.ISubsituteSynchronizer;
import net.sf.joafip.store.service.objectio.serialize.input.IObjectInput;
import net.sf.joafip.store.service.objectio.serialize.output.IObjectOutput;
-import net.sf.joafip.store.service.proxy.ProxyManager2;
/**
*
@@ -1291,7 +1290,6 @@
}
private void storedEnumMapPutAll(final Map<EnumKey, Enum<?>> map) {
- assert !ProxyManager2.isProxyOrEnhanced(map);
for (final Map.Entry<EnumKey, Enum<?>> entry : map.entrySet()) {
storedEnumMap.put(entry.getKey(), entry.getValue());
}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-11-12 16:56:52 UTC (rev 2967)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/out/ExportStoreQue.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -39,7 +39,14 @@
@NotStorableClass
public class ExportStoreQue {
- private static final byte[] DATA = new byte[] {};
+ // FIXMELUC ____________________________why not empty ?
+ // HeapFileDataManager not accept empty data
+ // net.sf.joafip.heapfile.service.HeapException: associated data size must
+ // be defined
+ // at
+ // net.sf.joafip.heapfile.record.entity.HeapRecord.assertDataRecordStateForMarshalling(HeapRecord.java:385)
+ // private static final byte[] DATA = new byte[] {};
+ private static final byte[] DATA = new byte[] { 0 };
private static final int MAX_RECORDS = 1000;
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/EnumItemState.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -0,0 +1,27 @@
+/*
+ * 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.entity.rel400;
+
+/**
+ * for test
+ *
+ * @author luc peuvrier
+ */
+public enum EnumItemState {
+ /**/STATE1,
+ /**/STATE2;
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/entity/rel400/Item.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -0,0 +1,132 @@
+/*
+ * 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.entity.rel400;
+
+import net.sf.joafip.StorableClass;
+
+@SuppressWarnings("PMD")
+@StorableClass
+public class Item implements Cloneable {
+
+ private final int identifier;
+
+ private String value;
+
+ private EnumItemState itemState;
+
+ /**
+ * default constructor to make this persistable
+ *
+ */
+ public Item() {
+ super();
+ identifier = -1;
+ }
+
+ public Item(final int identifier) {
+ super();
+ this.identifier = identifier;
+ }
+
+ public Item(final int identifier,
+ final String value) {
+ super();
+ this.identifier = identifier;
+ this.value = value;
+ }
+
+ /**
+ * copy constructor
+ *
+ * @param item
+ */
+ public Item(final Item item) {
+ super();
+ identifier = item.getIdentifier();
+ final String valueFromItem = item.getValue();
+ if (valueFromItem == null) {
+ value = null;
+ } else {
+ value = "" + valueFromItem;
+ }
+ itemState = item.getItemState();
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(final String value) {
+ this.value = value;
+ }
+
+ public int getIdentifier() {
+ return identifier;
+ }
+
+ public EnumItemState getItemState() {
+ return itemState;
+ }
+
+ public void setItemState(final EnumItemState itemState) {
+ this.itemState = itemState;
+ }
+
+ @Override
+ public String toString() {
+ return "id=" + identifier + " value=" + value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + identifier;
+ result = PRIME * result + ((value == null) ? 0 : value.hashCode());
+ return result;
+ }
+
+ @Override
+ @SuppressWarnings("PMD")
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Item)) {
+ return false;
+ }
+ final Item other = (Item) obj;
+ if (identifier != other.getIdentifier())
+ return false;
+ if (value == null) {
+ if (other.getValue() != null)
+ return false;
+ } else if (!value.equals(other.getValue()))
+ return false;
+ return true;
+ }
+
+ @Override
+ public Item clone() {// NOPMD
+ try {
+ return (Item) super.clone();
+ } catch (CloneNotSupportedException exception) {
+ throw new InternalError();// NOPMD
+ }
+ }
+}
Added: trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java (rev 0)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/rel400/TestEnumMap.java 2011-11-12 16:58:23 UTC (rev 2968)
@@ -0,0 +1,97 @@
+/*
+ * 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.service.rel400;
+
+import net.sf.joafip.AbstractDeleteFileTestCase;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.TestException;
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.entity.rel400.Item;
+import net.sf.joafip.service.FilePersistenceBuilder;
+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.service.IFilePersistence;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@StorableAccess
+public class TestEnumMap extends AbstractDeleteFileTestCase {
+
+ public TestEnumMap() throws TestException {
+ super();
+ }
+
+ public TestEnumMap(final String name) throws TestException {
+ super(name);
+ }
+
+ public void testEnumMap() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException {
+
+ IFilePersistence filePersistence = createFilePersistence(true);
+ IDataAccessSession session = filePersistence.createDataAccessSession();
+ session.open();
+ Item item=new Item(0, "value");
+ session.setObject("key",item);
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+ filePersistence.close();
+
+ filePersistence = createFilePersistence(false);
+ session = filePersistence.createDataAccessSession();
+ session.open();
+ item=(Item) session.getObject("key");
+ assertEquals("bad state",0,item.getIdentifier());
+ assertEquals("bad state","value",item.getValue());
+ session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
+ filePersistence.close();
+ }
+
+ private IFilePersistence createFilePersistence(final boolean removeFile)
+ throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName(path.getAbsolutePath());
+ builder.setRemoveFiles(removeFile);
+ builder.setProxyMode(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ return builder.build();
+ }
+}
Modified: trunk/joafip/src/test/resources/log4j.properties
===================================================================
--- trunk/joafip/src/test/resources/log4j.properties 2011-11-12 16:56:52 UTC (rev 2967)
+++ trunk/joafip/src/test/resources/log4j.properties 2011-11-12 16:58:23 UTC (rev 2968)
@@ -127,7 +127,9 @@
#log4j.logger.net.sf.joafip.performance.service=debug
#log4j.logger.net.sf.joafip.service.bug.emis.TestEmis=debug
log4j.logger.net.sf.joafip.performance.items.service.Inserter=info
+log4j.logger.net.sf.joafip.performance.items.service.InserterBKM=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.ImportSearcher=info
log4j.logger.net.sf.joafip.service.MainCrash=info
log4j.logger.net.sf.joafip.service.MainAfterCrash=info
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:56:58
|
Revision: 2967
http://joafip.svn.sourceforge.net/joafip/?rev=2967&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:56:52 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
todo update. doc for debug added
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
Added Paths:
-----------
trunk/joafip/doc/_bug_tree.txt
trunk/joafip/doc/missing.txt
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|