froehlich 02/01/21 14:02:36
Modified: simplestore/src/java/org/apache/commons/simplestore
SynchronizedStore.java Store.java
SoftRefMemoryStore.java MRUMemoryStore.java
JispFilesystemStore.java
Log:
some new features (or bugs):
a) added TestJispFilesystemstore junit test case
b) changed the Store interface, extending from java.util.Map
was to much, indeed (thx Juozas)
c) added a constructor in the JispFilesystemStore, because -well-
Revision Changes Path
1.4 +3 -33
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/SynchronizedStore.java
Index: SynchronizedStore.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/SynchronizedStore.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SynchronizedStore.java 20 Jan 2002 12:24:40 -0000 1.3
+++ SynchronizedStore.java 21 Jan 2002 22:02:36 -0000 1.4
@@ -19,7 +19,7 @@
* [EMAIL PROTECTED]</a>
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- * @version $Id: SynchronizedStore.java,v 1.3 2002/01/20 12:24:40 froehlich Exp $
+ * @version $Id: SynchronizedStore.java,v 1.4 2002/01/21 22:02:36 froehlich Exp $
*/
final class SynchronizedStore
implements Store {
@@ -65,9 +65,9 @@
}
}
- public Object put(Object key, Object value) {
+ public void put(Object key, Object value) {
synchronized(store) {
- return store.put(key,value);
+ store.put(key,value);
}
}
@@ -82,18 +82,6 @@
}
}
- public Set keySet() {
- synchronized(store) {
- return store.keySet();
- }
- }
-
- public boolean containsValue(Object value) {
- synchronized(store) {
- return store.containsValue(value);
- }
- }
-
public boolean isEmpty() {
synchronized(store) {
return store.isEmpty();
@@ -106,28 +94,10 @@
}
}
- public void putAll(Map t) {
- synchronized(store) {
- store.putAll(t);
- }
- }
-
public void clear() {
synchronized(store) {
store.clear();
}
- }
-
- public Collection values() {
- synchronized(store) {
- return store.values();
- }
- }
-
- public Set entrySet() {
- synchronized(store) {
- return store.entrySet();
- }
}
public Store getNextStore() {
1.10 +18 -14
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/Store.java
Index: Store.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/Store.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Store.java 20 Jan 2002 12:24:40 -0000 1.9
+++ Store.java 21 Jan 2002 22:02:36 -0000 1.10
@@ -8,28 +8,32 @@
package org.apache.commons.simplestore;
-import java.util.Map;
-
/**
* Interface for the Store implementations
*
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- * @version $Id: Store.java,v 1.9 2002/01/20 12:24:40 froehlich Exp $
+ * @version $Id: Store.java,v 1.10 2002/01/21 22:02:36 froehlich Exp $
*/
-public interface Store extends Map {
-
- /**
- * Returns the next Store in the tree
- *
- * @return next Store in the tree
- */
+public interface Store {
Store getNextStore();
- /**
- * Frees some object out of the cache. Depends on the implemented
- * algorithm.
- */
void free();
+
+ void clear();
+
+ Object get(Object key);
+
+ boolean isEmpty();
+
+ void put(Object key, Object value);
+
+ Object remove(Object key);
+
+ //put (Map m); //?
+
+ boolean containsKey(Object key);
+
+ int size();
}
1.5 +3 -27
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/SoftRefMemoryStore.java
Index: SoftRefMemoryStore.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/SoftRefMemoryStore.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SoftRefMemoryStore.java 20 Jan 2002 14:20:22 -0000 1.4
+++ SoftRefMemoryStore.java 21 Jan 2002 22:02:36 -0000 1.5
@@ -20,12 +20,12 @@
* [EMAIL PROTECTED]</a>
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- * @version $Id: SoftRefMemoryStore.java,v 1.4 2002/01/20 14:20:22 froehlich Exp $
+ * @version $Id: SoftRefMemoryStore.java,v 1.5 2002/01/21 22:02:36 froehlich Exp $
*/
public class SoftRefMemoryStore
implements Store {
- private static boolean DEBUG = false;
+ private static boolean DEBUG = true;
private Store store;
private int maxStrongRefCount;
private Object [] strongRefs;
@@ -85,13 +85,6 @@
}
/**
- * Returns the list of used keys as an Enumeration of Objects.
- */
- public Set keySet() {
- return store.keySet();
- }
-
- /**
* Remove the object associated to the given key.
*
* @param key the Key Object
@@ -127,11 +120,10 @@
* @param key the Key Object
* @param value the Value Object
*/
- public Object put(Object key, Object object) {
+ public void put(Object key, Object object) {
removeSoftRef();
store.put(key,object);
internalStoreObject(key,object);
- return null;
}
/**
@@ -156,10 +148,6 @@
return object;
}
- public boolean containsValue(Object value) {
- return store.containsValue(value);
- }
-
public boolean isEmpty() {
return store.isEmpty();
}
@@ -168,20 +156,8 @@
return store.size();
}
- public void putAll(Map t) {
- store.putAll(t);
- }
-
public void clear() {
store.clear();
- }
-
- public Collection values() {
- return store.values();
- }
-
- public Set entrySet() {
- return store.entrySet();
}
public Store getNextStore() {
1.12 +2 -25
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/MRUMemoryStore.java
Index: MRUMemoryStore.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/MRUMemoryStore.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- MRUMemoryStore.java 20 Jan 2002 14:00:43 -0000 1.11
+++ MRUMemoryStore.java 21 Jan 2002 22:02:36 -0000 1.12
@@ -22,7 +22,7 @@
*
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- * @version $Id: MRUMemoryStore.java,v 1.11 2002/01/20 14:00:43 froehlich Exp $
+ * @version $Id: MRUMemoryStore.java,v 1.12 2002/01/21 22:02:36 froehlich Exp $
*/
public final class MRUMemoryStore
implements Store {
@@ -77,14 +77,13 @@
* @param key with which the specified value is to be associated.
* @param value to be associated with the specified key.
*/
- public Object put(Object key, Object value) {
+ public void put(Object key, Object value) {
while (this.mMRUList.size() >= this.mMaxObjects) {
this.free();
}
this.mCache.put(key, value);
this.mMRUList.remove(key);
this.mMRUList.addFirst(key);
- return null;
}
/**
@@ -149,30 +148,8 @@
return mCache.isEmpty();
}
- /**
- * Returns true if this map maps one or more keys to the specified value.
- *
- * @param value value whose presence in this map is to be tested
- * @return true if this map maps one or more keys to the specified value
- */
- public boolean containsValue(Object value) {
- return mCache.containsValue(value);
- }
-
- public void putAll(Map t) {
- throw new UnsupportedOperationException("method not implemented yet");
- }
-
public void clear() {
throw new UnsupportedOperationException("method not implemented yet");
- }
-
- public Collection values() {
- return mCache.values();
- }
-
- public Set entrySet() {
- return mCache.entrySet();
}
public Store getNextStore() {
1.12 +17 -47
jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/JispFilesystemStore.java
Index: JispFilesystemStore.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/simplestore/src/java/org/apache/commons/simplestore/JispFilesystemStore.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- JispFilesystemStore.java 20 Jan 2002 12:24:40 -0000 1.11
+++ JispFilesystemStore.java 21 Jan 2002 22:02:36 -0000 1.12
@@ -28,7 +28,7 @@
*
* @author Gerhard Froehlich <a href="mailto:[EMAIL PROTECTED]">
* [EMAIL PROTECTED]</a>
- * @version $Id: JispFilesystemStore.java,v 1.11 2002/01/20 12:24:40 froehlich Exp $
+ * @version $Id: JispFilesystemStore.java,v 1.12 2002/01/21 22:02:36 froehlich Exp $
*/
public final class JispFilesystemStore
@@ -48,15 +48,20 @@
private int mOrder = 101;
private IndexedObjectDatabase mDatabase;
private BTreeIndex mIndex;
-
- /**
- * This method sets the name of the data file. Default
- * is default.dat.
- *
- * @param name name of the data file
- */
- public void setDatabaseName(String name) {
- this.mDatabaseName = name;
+
+ public JispFilesystemStore(String Directory,
+ String DatabaseName,
+ String IndexName,
+ int Order) {
+ this.mDatabaseName = DatabaseName;
+ this.mIndexName = IndexName;
+ this.mOrder = Order;
+ try {
+ this.setDirectory(Directory);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ this.initialize();
}
/**
@@ -70,16 +75,6 @@
}
/**
- * This method sets the name of the index file. Default
- * is default.idx.
- *
- * @param name name of the index file
- */
- public void setIndexfileName(String name) {
- this.mIndexName = name;
- }
-
- /**
* This method returns the name of the index file. Default
* is default.idx.
*
@@ -89,10 +84,6 @@
return this.mIndexName;
}
- public void setOrder(int order) {
- this.mOrder = order;
- }
-
public int getOrder() {
return this.mOrder;
}
@@ -204,7 +195,7 @@
* @param value the Value Object
* @exception IOException
*/
- public Object put(Object key, Object value) {
+ public void put(Object key, Object value) {
if (value instanceof Serializable) {
try {
KeyObject[] keyArray = new KeyObject[1];
@@ -216,7 +207,6 @@
} else {
throw new IllegalArgumentException("Object not Serializable");
}
- return null;
}
/**
@@ -283,14 +273,6 @@
}
}
- public Set keySet() {
- throw new UnsupportedOperationException("method not implemented yet");
- }
-
- public boolean containsValue(Object value) {
- throw new UnsupportedOperationException("method not implemented yet");
- }
-
public boolean isEmpty() {
throw new UnsupportedOperationException("method not implemented yet");
}
@@ -299,22 +281,10 @@
throw new UnsupportedOperationException("method not implemented yet");
}
- public void putAll(Map t) {
- throw new UnsupportedOperationException("method not implemented yet");
- }
-
public void clear() {
throw new UnsupportedOperationException("method not implemented yet");
}
-
- public Collection values() {
- throw new UnsupportedOperationException("method not implemented yet");
- }
-
- public Set entrySet() {
- throw new UnsupportedOperationException("method not implemented yet");
- }
-
+
public Store getNextStore() {
throw new UnsupportedOperationException("method not implemented yet");
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>