On Sunday 08 August 2004 03:40, Kevin A. Burton wrote:
> Would a HashMap implementation of RAMDirectory beat out a cached
> FSDirectory?
It's easy to test, so it's worth a try. Please try if the attached patch
makes any difference for you compared to the current implementation of
RAMDirectory.
Regards
Daniel
--
http://www.danielnaber.de
Index: RAMDirectory.java
===
RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java,v
retrieving revision 1.16
diff -u -r1.16 RAMDirectory.java
--- RAMDirectory.java 7 Aug 2004 11:19:28 - 1.16
+++ RAMDirectory.java 8 Aug 2004 09:01:19 -
@@ -18,8 +18,11 @@
import java.io.IOException;
import java.io.File;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Set;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.InputStream;
@@ -31,7 +34,7 @@
* @version $Id: RAMDirectory.java,v 1.16 2004/08/07 11:19:28 dnaber Exp $
*/
public final class RAMDirectory extends Directory {
- Hashtable files = new Hashtable();
+ HashMap files = new HashMap();
/** Constructs an empty [EMAIL PROTECTED] Directory}. */
public RAMDirectory() {
@@ -93,9 +96,11 @@
public final String[] list() {
String[] result = new String[files.size()];
int i = 0;
-Enumeration names = files.keys();
-while (names.hasMoreElements())
- result[i++] = (String)names.nextElement();
+Set names = files.keySet();
+for (Iterator iter = names.iterator(); iter.hasNext();) {
+ String element = (String) iter.next();
+ result[i++] = element;
+}
return result;
}
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]