Author: mattmann Date: Fri Nov 24 09:54:28 2006 New Revision: 478933 URL: http://svn.apache.org/viewvc?view=rev&rev=478933 Log: - remove unnecessary comments - optimize counting of non-null values by performing it inline rather than calling a function and creating a new object
Modified: lucene/nutch/trunk/src/java/org/apache/nutch/metadata/Metadata.java Modified: lucene/nutch/trunk/src/java/org/apache/nutch/metadata/Metadata.java URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/metadata/Metadata.java?view=diff&rev=478933&r1=478932&r2=478933 ============================================================================== --- lucene/nutch/trunk/src/java/org/apache/nutch/metadata/Metadata.java (original) +++ lucene/nutch/trunk/src/java/org/apache/nutch/metadata/Metadata.java Fri Nov 24 09:54:28 2006 @@ -21,10 +21,8 @@ import java.io.IOException; import java.util.Enumeration; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Vector; import org.apache.hadoop.io.Text; import org.apache.hadoop.io.Writable; @@ -212,13 +210,16 @@ for (int i = 0; i < names.length; i++) { Text.writeString(out, names[i]); values = getValues(names[i]); - // @since NUTCH-406: get the set - // of non-null values, and work with - // them to avoid NPE exception - String[] nonNullVals = getNonNullValues(values); - out.writeInt(nonNullVals.length); - for (int j = 0; j < nonNullVals.length; j++) { - Text.writeString(out, nonNullVals[j]); + int cnt = 0; + for (int j = 0; j < values.length; j++) { + if (values[j] != null) + cnt++; + } + out.writeInt(cnt); + for (int j = 0; j < values.length; j++) { + if (values[j] != null) { + Text.writeString(out, values[j]); + } } } } @@ -233,21 +234,6 @@ add(key, Text.readString(in)); } } - } - - private String[] getNonNullValues(String[] values) { - if (values == null) { - return new String[0]; - } - - List<String> nonNull = new Vector<String>(); - for (int i = 0; i < values.length; i++) { - if (values[i] != null && !values[i].equals("")) { - nonNull.add(values[i]); - } - } - - return nonNull.toArray(new String[nonNull.size()]); } }