Author: ab
Date: Mon Jan  9 00:58:58 2006
New Revision: 367251

URL: http://svn.apache.org/viewcvs?rev=367251&view=rev
Log:
Replace the custom metadata serialization with the one provided by the
ContentProperties class. This fixes the breakage if multiple property
values per key are in use.

Modified:
    lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseData.java

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseData.java
URL: 
http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseData.java?rev=367251&r1=367250&r2=367251&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseData.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseData.java Mon Jan  
9 00:58:58 2006
@@ -31,7 +31,7 @@
 public final class ParseData extends VersionedWritable {
   public static final String DIR_NAME = "parse_data";
 
-  private final static byte VERSION = 2;
+  private final static byte VERSION = 3;
 
   private String title;
   private Outlink[] outlinks;
@@ -96,10 +96,15 @@
       Outlink.skip(in);
     }
     
-    int propertyCount = in.readInt();             // read metadata
-    metadata = new ContentProperties();
-    for (int i = 0; i < propertyCount; i++) {
-      metadata.put(UTF8.readString(in), UTF8.readString(in));
+    if (version < 3) {
+      int propertyCount = in.readInt();             // read metadata
+      metadata = new ContentProperties();
+      for (int i = 0; i < propertyCount; i++) {
+        metadata.put(UTF8.readString(in), UTF8.readString(in));
+      }
+    } else {
+      metadata = new ContentProperties();
+      metadata.readFields(in);
     }
     
   }
@@ -113,14 +118,7 @@
     for (int i = 0; i < outlinks.length; i++) {
       outlinks[i].write(out);
     }
-
-    out.writeInt(metadata.size());                // write metadata
-    Iterator i = metadata.entrySet().iterator();
-    while (i.hasNext()) {
-      Map.Entry e = (Map.Entry)i.next();
-      UTF8.writeString(out, (String)e.getKey());
-      UTF8.writeString(out, (String)e.getValue());
-    }
+    metadata.write(out);
   }
 
   public static ParseData read(DataInput in) throws IOException {


Reply via email to