lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r500611 - in /lucene/java/trunk/src: java/org/apache/lucene/store/RAMDirectory.java test/org/apache/lucene/index/store/TestRAMDirectory.java test/org/apache/lucene/store/MockRAMDirectory.java
Date Sat, 27 Jan 2007 20:39:15 GMT
Author: mikemccand
Date: Sat Jan 27 12:39:14 2007
New Revision: 500611

URL: http://svn.apache.org/viewvc?view=rev&rev=500611
Log:
LUCENE-785: make RAMDirectory serializable again

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/store/RAMDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/index/store/TestRAMDirectory.java
    lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/store/RAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/store/RAMDirectory.java?view=diff&rev=500611&r1=500610&r2=500611
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/store/RAMDirectory.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/store/RAMDirectory.java Sat Jan 27 12:39:14
2007
@@ -39,8 +39,6 @@
   private static final long serialVersionUID = 1l;
 
   HashMap fileMap = new HashMap();
-  private Set fileNames = fileMap.keySet();
-  Collection files = fileMap.values();
   long sizeInBytes = 0;
   
   // *****
@@ -101,6 +99,7 @@
 
   /** Returns an array of strings, one for each file in the directory. */
   public synchronized final String[] list() {
+    Set fileNames = fileMap.keySet();
     String[] result = new String[fileNames.size()];
     int i = 0;
     Iterator it = fileNames.iterator();
@@ -230,8 +229,6 @@
   /** Closes the store to future operations, releasing associated memory. */
   public final void close() {
     fileMap = null;
-    fileNames = null;
-    files = null;
   }
 
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/store/TestRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/store/TestRAMDirectory.java?view=diff&rev=500611&r1=500610&r2=500611
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/store/TestRAMDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/store/TestRAMDirectory.java Sat Jan
27 12:39:14 2007
@@ -19,6 +19,10 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+
 
 import junit.framework.TestCase;
 
@@ -189,6 +193,18 @@
     
     writer.close();
   }
+
+
+  public void testSerializable() throws IOException {
+    Directory dir = new RAMDirectory();
+    ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
+    assertEquals("initially empty", 0, bos.size());
+    ObjectOutput out = new ObjectOutputStream(bos);
+    int headerSize = bos.size();
+    out.writeObject(dir);
+    out.close();
+    assertTrue("contains more then just header", headerSize < bos.size());
+  } 
 
   public void tearDown() {
     // cleanup 

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java?view=diff&rev=500611&r1=500610&r2=500611
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/MockRAMDirectory.java Sat Jan 27 12:39:14
2007
@@ -108,7 +108,7 @@
   /** Provided for testing purposes.  Use sizeInBytes() instead. */
   public synchronized final long getRecomputedSizeInBytes() {
     long size = 0;
-    Iterator it = files.iterator();
+    Iterator it = fileMap.values().iterator();
     while (it.hasNext())
       size += ((RAMFile) it.next()).getSizeInBytes();
     return size;
@@ -122,7 +122,7 @@
 
   final long getRecomputedActualSizeInBytes() {
     long size = 0;
-    Iterator it = files.iterator();
+    Iterator it = fileMap.values().iterator();
     while (it.hasNext())
       size += ((RAMFile) it.next()).length;
     return size;



Mime
View raw message