lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1436414 - in /lucene/dev/branches/lucene4547/lucene: codecs/src/java/org/apache/lucene/codecs/diskdv/DiskDocValuesConsumer.java core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
Date Mon, 21 Jan 2013 15:29:11 GMT
Author: rmuir
Date: Mon Jan 21 15:29:11 2013
New Revision: 1436414

URL: http://svn.apache.org/viewvc?rev=1436414&view=rev
Log:
add a numeric dv field to disk full test and fix diskdv (some codecs still fail)

Modified:
    lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/diskdv/DiskDocValuesConsumer.java
    lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java

Modified: lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/diskdv/DiskDocValuesConsumer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/diskdv/DiskDocValuesConsumer.java?rev=1436414&r1=1436413&r2=1436414&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/diskdv/DiskDocValuesConsumer.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/codecs/src/java/org/apache/lucene/codecs/diskdv/DiskDocValuesConsumer.java
Mon Jan 21 15:29:11 2013
@@ -37,15 +37,23 @@ class DiskDocValuesConsumer extends DocV
   final int maxDoc;
   
   DiskDocValuesConsumer(SegmentWriteState state) throws IOException {
-    String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix,
"ddvd");
-    data = state.directory.createOutput(dataName, state.context);
-    CodecUtil.writeHeader(data, DiskDocValuesFormat.DATA_CODEC, 
-                                DiskDocValuesFormat.VERSION_CURRENT);
-    String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix,
"ddvm");
-    meta = state.directory.createOutput(metaName, state.context);
-    CodecUtil.writeHeader(meta, DiskDocValuesFormat.METADATA_CODEC, 
-                                DiskDocValuesFormat.VERSION_CURRENT);
-    maxDoc = state.segmentInfo.getDocCount();
+    boolean success = false;
+    try {
+      String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix,
"ddvd");
+      data = state.directory.createOutput(dataName, state.context);
+      CodecUtil.writeHeader(data, DiskDocValuesFormat.DATA_CODEC, 
+                                  DiskDocValuesFormat.VERSION_CURRENT);
+      String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix,
"ddvm");
+      meta = state.directory.createOutput(metaName, state.context);
+      CodecUtil.writeHeader(meta, DiskDocValuesFormat.METADATA_CODEC, 
+                                  DiskDocValuesFormat.VERSION_CURRENT);
+      maxDoc = state.segmentInfo.getDocCount();
+      success = true;
+    } finally {
+      if (!success) {
+        IOUtils.closeWhileHandlingException(this);
+      }
+    }
   }
   
   @Override
@@ -146,7 +154,18 @@ class DiskDocValuesConsumer extends DocV
   public void close() throws IOException {
     // nocommit: just write this to a RAMfile or something and flush it here, with #fields
first.
     // this meta is a tiny file so this hurts nobody
-    meta.writeVInt(-1);
-    IOUtils.close(data, meta);
+    boolean success = false;
+    try {
+      if (meta != null) {
+        meta.writeVInt(-1);
+      }
+      success = true;
+    } finally {
+      if (success) {
+        IOUtils.close(data, meta);
+      } else {
+        IOUtils.closeWhileHandlingException(data, meta);
+      }
+    }
   }
 }

Modified: lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java?rev=1436414&r1=1436413&r2=1436414&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
Mon Jan 21 15:29:11 2013
@@ -24,6 +24,7 @@ import org.apache.lucene.codecs.LiveDocs
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.LongDocValuesField;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.search.IndexSearcher;
@@ -558,6 +559,7 @@ public class TestIndexWriterOnDiskFull e
   {
       Document doc = new Document();
       doc.add(newTextField("content", "aaa", Field.Store.NO));
+      doc.add(new LongDocValuesField("numericdv", 1));
       writer.addDocument(doc);
   }
   
@@ -566,6 +568,7 @@ public class TestIndexWriterOnDiskFull e
       Document doc = new Document();
       doc.add(newTextField("content", "aaa " + index, Field.Store.NO));
       doc.add(newTextField("id", "" + index, Field.Store.NO));
+      doc.add(new LongDocValuesField("numericdv", 1));
       writer.addDocument(doc);
   }
 }



Mime
View raw message