Skip to content

Apache Lucene open-source search software

LUCENE-5969: add cfs to TestIWExceptions2

Robert Muir7567059ca2d5
diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/package.html b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/package.html
index 63055fae34a..30e269f979f 100755
--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene50/package.html
+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene50/package.html
@@ -173,7 +173,7 @@ term occurs in each document. Note that this will not exist if all fields in
all documents omit position data.
</li>
<li>
-{@link org.apache.lucene.codecs.lucene49.Lucene49NormsFormat Normalization factors}.
+{@link org.apache.lucene.codecs.lucene50.Lucene50NormsFormat Normalization factors}.
For each field in each document, a value is stored
that is multiplied into the score for hits on that field.
</li>
@@ -243,7 +243,7 @@ file.</td>
<td>Stores metadata about a segment</td>
</tr>
<tr>
-<td>{@link org.apache.lucene.store.CompoundFileDirectory Compound File}</td>
+<td>{@link org.apache.lucene.codecs.lucene50.LUcene50CompoundFormat Compound File}</td>
<td>.cfs, .cfe</td>
<td>An optional "virtual" file consisting of all the other index files for
systems that frequently run out of file handles.</td>
@@ -289,7 +289,7 @@ systems that frequently run out of file handles.</td>
<td>Stores additional per-position metadata information such as character offsets and user payloads</td>
</tr>
<tr>
-<td>{@link org.apache.lucene.codecs.lucene49.Lucene49NormsFormat Norms}</td>
+<td>{@link org.apache.lucene.codecs.lucene50.Lucene50NormsFormat Norms}</td>
<td>.nvd, .nvm</td>
<td>Encodes length and boost factors for docs and fields</td>
</tr>
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
index 0719acac40f..7925356f5dd 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCodec.java
@@ -20,6 +20,7 @@ package org.apache.lucene.codecs.cranky;
import java.util.Random;
import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.codecs.CompoundFormat;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.FieldInfosFormat;
import org.apache.lucene.codecs.FilterCodec;
@@ -85,6 +86,11 @@ public class CrankyCodec extends FilterCodec {
return new CrankyTermVectorsFormat(delegate.termVectorsFormat(), random);
}
+ @Override
+ public CompoundFormat compoundFormat() {
+ return new CrankyCompoundFormat(delegate.compoundFormat(), random);
+ }
+
@Override
public String toString() {
return "Cranky(" + delegate + ")";
diff --git a/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCompoundFormat.java b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCompoundFormat.java
new file mode 100644
index 00000000000..8f64f9f56e1
--- /dev/null
+++ b/lucene/test-framework/src/java/org/apache/lucene/codecs/cranky/CrankyCompoundFormat.java
@@ -0,0 +1,56 @@
+package org.apache.lucene.codecs.cranky;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Random;
+
+import org.apache.lucene.codecs.CompoundFormat;
+import org.apache.lucene.index.MergeState.CheckAbort;
+import org.apache.lucene.index.SegmentInfo;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
+
+class CrankyCompoundFormat extends CompoundFormat {
+ CompoundFormat delegate;
+ Random random;
+
+ CrankyCompoundFormat(CompoundFormat delegate, Random random) {
+ this.delegate = delegate;
+ this.random = random;
+ }
+
+ @Override
+ public Directory getCompoundReader(Directory dir, SegmentInfo si, IOContext context) throws IOException {
+ return delegate.getCompoundReader(dir, si, context);
+ }
+
+ @Override
+ public void write(Directory dir, SegmentInfo si, Collection<String> files, CheckAbort checkAbort, IOContext context) throws IOException {
+ if (random.nextInt(100) == 0) {
+ throw new IOException("Fake IOException from CompoundFormat.write()");
+ }
+ delegate.write(dir, si, files, checkAbort, context);
+ }
+
+ @Override
+ public String[] files(SegmentInfo si) {
+ return delegate.files(si);
+ }
+}