Thread: [Joafip-svn] SF.net SVN: joafip:[2937] trunk/joafip-4test/src/main/java
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2011-10-23 12:16:53
|
Revision: 2937
http://joafip.svn.sourceforge.net/joafip/?rev=2937&view=rev
Author: luc_peuvrier
Date: 2011-10-23 12:16:47 +0000 (Sun, 23 Oct 2011)
Log Message:
-----------
auto save now ok
Added Paths:
-----------
trunk/joafip-4test/src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-23 12:16:53
|
Revision: 2937
http://joafip.svn.sourceforge.net/joafip/?rev=2937&view=rev
Author: luc_peuvrier
Date: 2011-10-23 12:16:47 +0000 (Sun, 23 Oct 2011)
Log Message:
-----------
auto save now ok
Added Paths:
-----------
trunk/joafip-4test/src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.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
Added: trunk/joafip-4test/src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.java
===================================================================
--- trunk/joafip-4test/src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.java (rev 0)
+++ trunk/joafip-4test/src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.java 2011-10-23 12:16:47 UTC (rev 2937)
@@ -0,0 +1,76 @@
+package asm.net.sf.joafip.asm;
+
+import net.sf.joafip.asm.AnnotationVisitor;
+import net.sf.joafip.asm.ClassWriter;
+import net.sf.joafip.asm.FieldVisitor;
+import net.sf.joafip.asm.MethodVisitor;
+import net.sf.joafip.asm.Opcodes;
+
+@SuppressWarnings("PMD")
+public class NewProxyCallBackDump implements Opcodes {
+
+ @SuppressWarnings("unused")
+ public static byte[] dump() throws Exception {
+
+ ClassWriter cw = new ClassWriter(0);
+ FieldVisitor fv;
+ MethodVisitor mv;
+ AnnotationVisitor av0;
+
+ cw.visit(V1_6, ACC_PUBLIC + ACC_SUPER,
+ "net/sf/joafip/asm/NewProxyCallBack", null, "java/lang/Object",
+ null);
+
+ {
+ fv = cw.visitField(
+ ACC_PRIVATE + ACC_FINAL,
+ "proxyCallBack",
+ "Lnet/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation;",
+ null, null);
+ fv.visitEnd();
+ }
+ {
+ mv = cw.visitMethod(
+ ACC_PUBLIC,
+ "<init>",
+ "()V",
+ null,
+ new String[] { "net/sf/joafip/store/service/proxy/ProxyException" });
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>",
+ "()V");
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitTypeInsn(NEW,
+ "net/sf/joafip/store/service/proxy/ProxyCallBack");
+ mv.visitInsn(DUP);
+ mv.visitMethodInsn(INVOKESPECIAL,
+ "net/sf/joafip/store/service/proxy/ProxyCallBack",
+ "<init>", "()V");
+ mv.visitFieldInsn(PUTFIELD, "net/sf/joafip/asm/NewProxyCallBack",
+ "proxyCallBack",
+ "Lnet/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation;");
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(3, 1);
+ mv.visitEnd();
+ }
+ {
+ mv = cw.visitMethod(
+ ACC_PUBLIC,
+ "getProxyCallBack",
+ "()Lnet/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation;",
+ null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitFieldInsn(GETFIELD, "net/sf/joafip/asm/NewProxyCallBack",
+ "proxyCallBack",
+ "Lnet/sf/joafip/store/service/proxy/IProxyCallBackProxyDelegation;");
+ mv.visitInsn(ARETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+ }
+ cw.visitEnd();
+
+ return cw.toByteArray();
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/asm/MainAsmForNewProxyCallBack.java 2011-10-23 12:16:47 UTC (rev 2937)
@@ -0,0 +1,19 @@
+package net.sf.joafip.asm;
+
+import net.sf.joafip.asm.util.ASMifierClassVisitor;
+
+public final class MainAsmForNewProxyCallBack {
+
+ public static void main(final String[] args) {
+ try {
+ ASMifierClassVisitor.outAsm(false, NewProxyCallBack.class.getName(),
+ "src/main/java/asm/net/sf/joafip/asm/NewProxyCallBackDump.java");
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ private MainAsmForNewProxyCallBack() {
+ super();
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/asm/NewProxyCallBack.java 2011-10-23 12:16:47 UTC (rev 2937)
@@ -0,0 +1,20 @@
+package net.sf.joafip.asm;
+
+import net.sf.joafip.store.service.proxy.IProxyCallBackProxyDelegation;
+import net.sf.joafip.store.service.proxy.ProxyCallBack;
+import net.sf.joafip.store.service.proxy.ProxyException;
+
+public class NewProxyCallBack {
+
+ private final IProxyCallBackProxyDelegation proxyCallBack;
+
+ public NewProxyCallBack()
+ throws ProxyException {
+ super();
+ proxyCallBack=new ProxyCallBack();
+ }
+
+ public IProxyCallBackProxyDelegation getProxyCallBack() {
+ return proxyCallBack;
+ }
+}
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: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: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...
[truncated message content] |