Index: lucene/src/test/org/apache/lucene/index/TestCodecs.java =================================================================== --- lucene/src/test/org/apache/lucene/index/TestCodecs.java (revision 982024) +++ lucene/src/test/org/apache/lucene/index/TestCodecs.java (working copy) @@ -32,7 +32,7 @@ import org.apache.lucene.index.codecs.FieldsProducer; import org.apache.lucene.index.codecs.PostingsConsumer; import org.apache.lucene.index.codecs.TermsConsumer; -import org.apache.lucene.index.codecs.sep.SepCodec; +import org.apache.lucene.index.codecs.mocksep.MockSepCodec; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.PhraseQuery; @@ -344,7 +344,7 @@ final Directory dir = new RAMDirectory(); final IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_31, new MockAnalyzer()); - config.setCodecProvider(new SepCodecs()); + config.setCodecProvider(new MockSepCodecs()); final IndexWriter writer = new IndexWriter(dir, config); try { @@ -397,15 +397,15 @@ } } - public static class SepCodecs extends CodecProvider { + public static class MockSepCodecs extends CodecProvider { - protected SepCodecs() { - this.register(new SepCodec()); + protected MockSepCodecs() { + this.register(new MockSepCodec()); } @Override public Codec getWriter(final SegmentWriteState state) { - return this.lookup("Sep"); + return this.lookup("MockSep"); } } Index: lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockFactory.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.intblock; +package org.apache.lucene.index.codecs.mockintblock; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -24,18 +24,21 @@ import java.io.IOException; -/** @lucene.experimental */ -public class SimpleIntBlockFactory extends IntStreamFactory { +/** Silly int factory that reads/writes block of ints by + * simply encoding each as vInt. Don't use this + * (performance will be poor)! This is here just to test + * the core intblock codec classes.*/ +public class MockFixedIntBlockFactory extends IntStreamFactory { private final int blockSize; - public SimpleIntBlockFactory(int blockSize) { + public MockFixedIntBlockFactory(int blockSize) { this.blockSize = blockSize; } @Override public IntIndexInput openInput(Directory dir, String fileName, int readBufferSize) throws IOException { - return new SimpleIntBlockIndexInput(dir, fileName, readBufferSize); + return new MockFixedIntBlockIndexInput(dir, fileName, readBufferSize); } @Override public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException { - return new SimpleIntBlockIndexOutput(dir, fileName, blockSize); + return new MockFixedIntBlockIndexOutput(dir, fileName, blockSize); } } Index: lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexInput.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.intblock; +package org.apache.lucene.index.codecs.mockintblock; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -24,21 +24,18 @@ import org.apache.lucene.util.CodecUtil; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexInput; +import org.apache.lucene.index.codecs.intblock.FixedIntBlockIndexInput; import java.io.IOException; -/** - * Don't use this class!! It naively encodes ints one vInt - * at a time. Use it only for testing. - * - * @lucene.experimental - */ -public class SimpleIntBlockIndexInput extends FixedIntBlockIndexInput { +/** Don't use this class!! It naively encodes ints one vInt + * at a time. Use it only for testing. */ +public class MockFixedIntBlockIndexInput extends FixedIntBlockIndexInput { - public SimpleIntBlockIndexInput(Directory dir, String fileName, int readBufferSize) throws IOException { + public MockFixedIntBlockIndexInput(Directory dir, String fileName, int readBufferSize) throws IOException { IndexInput in = dir.openInput(fileName, readBufferSize); - CodecUtil.checkHeader(in, SimpleIntBlockIndexOutput.CODEC, - SimpleIntBlockIndexOutput.VERSION_START, SimpleIntBlockIndexOutput.VERSION_START); + CodecUtil.checkHeader(in, MockFixedIntBlockIndexOutput.CODEC, + MockFixedIntBlockIndexOutput.VERSION_START, MockFixedIntBlockIndexOutput.VERSION_START); init(in); } Index: lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockIndexOutput.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.intblock; +package org.apache.lucene.index.codecs.mockintblock; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -24,22 +24,19 @@ import org.apache.lucene.util.CodecUtil; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexOutput; +import org.apache.lucene.index.codecs.intblock.FixedIntBlockIndexOutput; import java.io.IOException; -/** - * Don't use this class!! It naively encodes ints one vInt - * at a time. Use it only for testing. - * - * @lucene.experimental - */ -public class SimpleIntBlockIndexOutput extends FixedIntBlockIndexOutput { +/** Don't use this class!! It naively encodes ints one vInt + * at a time. Use it only for testing. */ +public class MockFixedIntBlockIndexOutput extends FixedIntBlockIndexOutput { public final static String CODEC = "SIMPLE_INT_BLOCKS"; public final static int VERSION_START = 0; public final static int VERSION_CURRENT = VERSION_START; - public SimpleIntBlockIndexOutput(Directory dir, String fileName, int blockSize) throws IOException { + public MockFixedIntBlockIndexOutput(Directory dir, String fileName, int blockSize) throws IOException { IndexOutput out = dir.createOutput(fileName); CodecUtil.writeHeader(out, CODEC, VERSION_CURRENT); init(out, blockSize); Index: lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.intblock; +package org.apache.lucene.index.codecs.mockintblock; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -26,7 +26,6 @@ import org.apache.lucene.index.codecs.Codec; import org.apache.lucene.index.codecs.FieldsConsumer; import org.apache.lucene.index.codecs.FieldsProducer; -import org.apache.lucene.index.codecs.sep.SepCodec; import org.apache.lucene.index.codecs.sep.SepPostingsReaderImpl; import org.apache.lucene.index.codecs.sep.SepPostingsWriterImpl; import org.apache.lucene.index.codecs.standard.SimpleStandardTermsIndexReader; @@ -42,17 +41,20 @@ import org.apache.lucene.util.BytesRef; /** - * @lucene.experimental + * A silly codec that simply writes each block as a series + * of vInts. Don't use this (performance will be poor)! + * This is here just to test the core intblock codec + * classes. */ -public class IntBlockCodec extends Codec { +public class MockFixedIntBlockCodec extends Codec { - public IntBlockCodec() { - name = "IntBlock"; + public MockFixedIntBlockCodec() { + name = "MockFixedIntBlock"; } @Override public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { - StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new SimpleIntBlockFactory(1024)); + StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new MockFixedIntBlockFactory(1024)); boolean success = false; StandardTermsIndexWriter indexWriter; @@ -86,7 +88,7 @@ StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, state.segmentInfo, state.readBufferSize, - new SimpleIntBlockFactory(1024)); + new MockFixedIntBlockFactory(1024)); StandardTermsIndexReader indexReader; boolean success = false; @@ -135,6 +137,8 @@ @Override public void getExtensions(Set extensions) { - SepCodec.getSepExtensions(extensions); + SepPostingsWriterImpl.getExtensions(extensions); + StandardTermsDictReader.getExtensions(extensions); + SimpleStandardTermsIndexReader.getIndexExtensions(extensions); } } Index: lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.sep; +package org.apache.lucene.index.codecs.mocksep; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -35,20 +35,27 @@ import org.apache.lucene.index.codecs.standard.StandardTermsIndexReader; import org.apache.lucene.index.codecs.standard.StandardTermsIndexWriter; import org.apache.lucene.index.codecs.standard.StandardCodec; +import org.apache.lucene.index.codecs.sep.SepPostingsWriterImpl; +import org.apache.lucene.index.codecs.sep.SepPostingsReaderImpl; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; -/** @lucene.experimental */ -public class SepCodec extends Codec { +/** + * A silly codec that simply writes each file separately as + * single vInts. Don't use this (performance will be poor)! + * This is here just to test the core sep codec + * classes. + */ +public class MockSepCodec extends Codec { - public SepCodec() { - name = "Sep"; + public MockSepCodec() { + name = "MockSep"; } @Override public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { - StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new SingleIntFactory()); + StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new MockSingleIntFactory()); boolean success = false; StandardTermsIndexWriter indexWriter; @@ -77,16 +84,10 @@ } } - final static String DOC_EXTENSION = "doc"; - final static String SKIP_EXTENSION = "skp"; - final static String FREQ_EXTENSION = "frq"; - final static String POS_EXTENSION = "pos"; - final static String PAYLOAD_EXTENSION = "pyl"; - @Override public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException { - StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, state.segmentInfo, state.readBufferSize, new SingleIntFactory()); + StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, state.segmentInfo, state.readBufferSize, new MockSingleIntFactory()); StandardTermsIndexReader indexReader; boolean success = false; @@ -139,11 +140,7 @@ } public static void getSepExtensions(Set extensions) { - extensions.add(DOC_EXTENSION); - extensions.add(FREQ_EXTENSION); - extensions.add(SKIP_EXTENSION); - extensions.add(POS_EXTENSION); - extensions.add(PAYLOAD_EXTENSION); + SepPostingsWriterImpl.getExtensions(extensions); StandardTermsDictReader.getExtensions(extensions); SimpleStandardTermsIndexReader.getIndexExtensions(extensions); } Index: lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.sep; +package org.apache.lucene.index.codecs.mocksep; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -20,7 +20,7 @@ import org.apache.lucene.store.IndexOutput; import org.apache.lucene.store.Directory; import org.apache.lucene.util.CodecUtil; - +import org.apache.lucene.index.codecs.sep.IntIndexOutput; import java.io.IOException; /** Writes ints directly to the file (not in blocks) as @@ -28,13 +28,13 @@ * * @lucene.experimental */ -public class SingleIntIndexOutput extends IntIndexOutput { +public class MockSingleIntIndexOutput extends IntIndexOutput { private final IndexOutput out; final static String CODEC = "SINGLE_INTS"; final static int VERSION_START = 0; final static int VERSION_CURRENT = VERSION_START; - public SingleIntIndexOutput(Directory dir, String fileName) throws IOException { + public MockSingleIntIndexOutput(Directory dir, String fileName) throws IOException { out = dir.createOutput(fileName); CodecUtil.writeHeader(out, CODEC, VERSION_CURRENT); } Index: lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.sep; +package org.apache.lucene.index.codecs.mocksep; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -18,16 +18,20 @@ */ import org.apache.lucene.store.Directory; +import org.apache.lucene.index.codecs.sep.IntStreamFactory; +import org.apache.lucene.index.codecs.sep.IntIndexInput; +import org.apache.lucene.index.codecs.sep.IntIndexOutput; + import java.io.IOException; /** @lucene.experimental */ -public class SingleIntFactory extends IntStreamFactory { +public class MockSingleIntFactory extends IntStreamFactory { @Override public IntIndexInput openInput(Directory dir, String fileName, int readBufferSize) throws IOException { - return new SingleIntIndexInput(dir, fileName, readBufferSize); + return new MockSingleIntIndexInput(dir, fileName, readBufferSize); } @Override public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException { - return new SingleIntIndexOutput(dir, fileName); + return new MockSingleIntIndexOutput(dir, fileName); } } Index: lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java (revision 0) +++ lucene/src/test/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java (working copy) @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.sep; +package org.apache.lucene.index.codecs.mocksep; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,6 +22,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.CodecUtil; +import org.apache.lucene.index.codecs.sep.IntIndexInput; /** Reads IndexInputs written with {@link * SingleIntIndexOutput}. NOTE: this class is just for @@ -30,14 +31,15 @@ * * @lucene.experimental */ -public class SingleIntIndexInput extends IntIndexInput { +public class MockSingleIntIndexInput extends IntIndexInput { private final IndexInput in; - public SingleIntIndexInput(Directory dir, String fileName, int readBufferSize) + public MockSingleIntIndexInput(Directory dir, String fileName, int readBufferSize) throws IOException { in = dir.openInput(fileName, readBufferSize); - CodecUtil.checkHeader(in, SingleIntIndexOutput.CODEC, - SingleIntIndexOutput.VERSION_START, SingleIntIndexOutput.VERSION_START); + CodecUtil.checkHeader(in, MockSingleIntIndexOutput.CODEC, + MockSingleIntIndexOutput.VERSION_START, + MockSingleIntIndexOutput.VERSION_START); } @Override Index: lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java =================================================================== --- lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java (revision 982024) +++ lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java (working copy) @@ -20,19 +20,20 @@ import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.store.*; import org.apache.lucene.index.codecs.sep.*; +import org.apache.lucene.index.codecs.mockintblock.*; public class TestIntBlockCodec extends LuceneTestCase { public void testSimpleIntBlocks() throws Exception { Directory dir = new MockRAMDirectory(); - IntIndexOutput out = new SimpleIntBlockIndexOutput(dir, "test", 128); + IntIndexOutput out = new MockFixedIntBlockIndexOutput(dir, "test", 128); for(int i=0;i<11777;i++) { out.write(i); } out.close(); - IntIndexInput in = new SimpleIntBlockIndexInput(dir, "test", 128); + IntIndexInput in = new MockFixedIntBlockIndexInput(dir, "test", 128); IntIndexInput.Reader r = in.reader(); for(int i=0;i<11777;i++) { @@ -46,11 +47,11 @@ public void testEmptySimpleIntBlocks() throws Exception { Directory dir = new MockRAMDirectory(); - IntIndexOutput out = new SimpleIntBlockIndexOutput(dir, "test", 128); + IntIndexOutput out = new MockFixedIntBlockIndexOutput(dir, "test", 128); // write no ints out.close(); - IntIndexInput in = new SimpleIntBlockIndexInput(dir, "test", 128); + IntIndexInput in = new MockFixedIntBlockIndexInput(dir, "test", 128); in.reader(); // read no ints in.close(); Index: lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java =================================================================== --- lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (revision 982024) +++ lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (working copy) @@ -30,6 +30,9 @@ import org.apache.lucene.index.codecs.CodecProvider; import org.apache.lucene.index.codecs.Codec; import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec; +import org.apache.lucene.index.codecs.preflex.PreFlexCodec; +import org.apache.lucene.index.codecs.mocksep.MockSepCodec; +import org.apache.lucene.index.codecs.mockintblock.MockFixedIntBlockCodec; import org.junit.After; import org.junit.AfterClass; @@ -152,51 +155,81 @@ // saves default codec: we do this statically as many build indexes in @beforeClass private static String savedDefaultCodec; private static String codec; - private static Codec preFlexSav; - // returns current PreFlex codec - public static Codec installPreFlexRW() { - final Codec preFlex = CodecProvider.getDefault().lookup("PreFlex"); - if (preFlex != null) { - CodecProvider.getDefault().unregister(preFlex); + private static final String[] TEST_CODECS = new String[] {"MockSep", "MockFixedIntBlock"}; + + private static void swapCodec(Codec c) { + final CodecProvider cp = CodecProvider.getDefault(); + Codec prior = null; + try { + prior = cp.lookup(c.name); + } catch (IllegalArgumentException iae) { } - CodecProvider.getDefault().register(new PreFlexRWCodec()); - return preFlex; + if (prior != null) { + cp.unregister(prior); + } + cp.register(c); } + // returns current default codec + static String installTestCodecs() { + final CodecProvider cp = CodecProvider.getDefault(); + + savedDefaultCodec = CodecProvider.getDefaultCodec(); + String codec = TEST_CODEC; + if (codec.equals("random")) { + codec = pickRandomCodec(seedRnd); + } + CodecProvider.setDefaultCodec(codec); + + if (codec.equals("PreFlex")) { + // If we're running w/ PreFlex codec we must swap in the + // test-only PreFlexRW codec (since core PreFlex can + // only read segments): + swapCodec(new PreFlexRWCodec()); + } + + swapCodec(new MockSepCodec()); + swapCodec(new MockFixedIntBlockCodec()); + + return codec; + } + // returns current PreFlex codec - public static void restorePreFlex(Codec preFlex) { - Codec preFlexRW = CodecProvider.getDefault().lookup("PreFlex"); - if (preFlexRW != null) { - CodecProvider.getDefault().unregister(preFlexRW); + static void removeTestCodecs(String codec) { + System.out.println("remove"); + final CodecProvider cp = CodecProvider.getDefault(); + if (codec.equals("PreFlex")) { + final Codec preFlex = cp.lookup("PreFlex"); + if (preFlex != null) { + cp.unregister(preFlex); + } + cp.register(new PreFlexCodec()); } - CodecProvider.getDefault().register(preFlex); + cp.unregister(cp.lookup("MockSep")); + cp.unregister(cp.lookup("MockFixedIntBlock")); + CodecProvider.setDefaultCodec(savedDefaultCodec); } + // randomly picks from core and test codecs + static String pickRandomCodec(Random rnd) { + int idx = rnd.nextInt(CodecProvider.CORE_CODECS.length + + TEST_CODECS.length); + if (idx < CodecProvider.CORE_CODECS.length) { + return CodecProvider.CORE_CODECS[idx]; + } else { + return TEST_CODECS[idx - CodecProvider.CORE_CODECS.length]; + } + } + @BeforeClass public static void beforeClassLuceneTestCaseJ4() { - savedDefaultCodec = CodecProvider.getDefaultCodec(); - codec = TEST_CODEC; - if (codec.equals("random")) - codec = CodecProvider.CORE_CODECS[seedRnd.nextInt(CodecProvider.CORE_CODECS.length)]; - - // If we're running w/ PreFlex codec we must swap in the - // test-only PreFlexRW codec (since core PreFlex can - // only read segments): - if (codec.equals("PreFlex")) { - preFlexSav = installPreFlexRW(); - } - - CodecProvider.setDefaultCodec(codec); + codec = installTestCodecs(); } @AfterClass public static void afterClassLuceneTestCaseJ4() { - // Restore read-only PreFlex codec: - if (codec.equals("PreFlex")) { - restorePreFlex(preFlexSav); - } - CodecProvider.setDefaultCodec(savedDefaultCodec); + removeTestCodecs(codec); } // This is how we get control when errors occur. Index: lucene/src/test/org/apache/lucene/util/LuceneTestCase.java =================================================================== --- lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (revision 982024) +++ lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (working copy) @@ -36,8 +36,6 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.FieldCache.CacheEntry; import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; -import org.apache.lucene.index.codecs.CodecProvider; -import org.apache.lucene.index.codecs.Codec; /** * Base class for all Lucene unit tests. @@ -85,9 +83,7 @@ private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null; - private String savedDefaultCodec; private String codec; - private Codec preFlexSav; /** Used to track if setUp and tearDown are called correctly from subclasses */ private boolean setup; @@ -127,19 +123,7 @@ ConcurrentMergeScheduler.setTestMode(); savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount(); - savedDefaultCodec = CodecProvider.getDefaultCodec(); - - codec = TEST_CODEC; - if (codec.equals("random")) - codec = CodecProvider.CORE_CODECS[seedRnd.nextInt(CodecProvider.CORE_CODECS.length)]; - - // If we're running w/ PreFlex codec we must swap in the - // test-only PreFlexRW codec (since core PreFlex can - // only read segments): - if (codec.equals("PreFlex")) { - preFlexSav = LuceneTestCaseJ4.installPreFlexRW(); - } - CodecProvider.setDefaultCodec(codec); + codec = LuceneTestCaseJ4.installTestCodecs(); } /** @@ -165,11 +149,7 @@ assertTrue("ensure your setUp() calls super.setUp()!!!", setup); setup = false; BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount); - // Restore read-only PreFlex codec: - if (codec.equals("PreFlex")) { - LuceneTestCaseJ4.restorePreFlex(preFlexSav); - } - CodecProvider.setDefaultCodec(savedDefaultCodec); + LuceneTestCaseJ4.removeTestCodecs(codec); try { Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler); Index: lucene/src/java/org/apache/lucene/index/CompoundFileReader.java =================================================================== --- lucene/src/java/org/apache/lucene/index/CompoundFileReader.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/CompoundFileReader.java (working copy) @@ -311,6 +311,7 @@ // If there are more bytes left to copy, delegate the copy task to the // base IndexInput, in case it can do an optimized copy. if (numBytes > 0) { + base.seek(fileOffset + getFilePointer()); base.copyBytes(out, numBytes); } } Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java (working copy) @@ -59,15 +59,15 @@ boolean success = false; try { - final String docFileName = IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.DOC_EXTENSION); + final String docFileName = IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.DOC_EXTENSION); docIn = intFactory.openInput(dir, docFileName); - skipIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.SKIP_EXTENSION), readBufferSize); + skipIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.SKIP_EXTENSION), readBufferSize); if (segmentInfo.getHasProx()) { - freqIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.FREQ_EXTENSION)); - posIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.POS_EXTENSION), readBufferSize); - payloadIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.PAYLOAD_EXTENSION), readBufferSize); + freqIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.FREQ_EXTENSION)); + posIn = intFactory.openInput(dir, IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.POS_EXTENSION), readBufferSize); + payloadIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.PAYLOAD_EXTENSION), readBufferSize); } else { posIn = null; payloadIn = null; @@ -82,13 +82,13 @@ } public static void files(SegmentInfo segmentInfo, Collection files) { - files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.DOC_EXTENSION)); - files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.SKIP_EXTENSION)); + files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.DOC_EXTENSION)); + files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.SKIP_EXTENSION)); if (segmentInfo.getHasProx()) { - files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.FREQ_EXTENSION)); - files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.POS_EXTENSION)); - files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepCodec.PAYLOAD_EXTENSION)); + files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.FREQ_EXTENSION)); + files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.POS_EXTENSION)); + files.add(IndexFileNames.segmentFileName(segmentInfo.name, "", SepPostingsWriterImpl.PAYLOAD_EXTENSION)); } } Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntFactory.java (working copy) @@ -1,33 +0,0 @@ -package org.apache.lucene.index.codecs.sep; - -/** - * 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 org.apache.lucene.store.Directory; -import java.io.IOException; - -/** @lucene.experimental */ -public class SingleIntFactory extends IntStreamFactory { - @Override - public IntIndexInput openInput(Directory dir, String fileName, int readBufferSize) throws IOException { - return new SingleIntIndexInput(dir, fileName, readBufferSize); - } - @Override - public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException { - return new SingleIntIndexOutput(dir, fileName); - } -} Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java (working copy) @@ -1,109 +0,0 @@ -package org.apache.lucene.index.codecs.sep; - -/** - * 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 org.apache.lucene.store.Directory; -import org.apache.lucene.store.IndexInput; -import org.apache.lucene.util.CodecUtil; - -/** Reads IndexInputs written with {@link - * SingleIntIndexOutput}. NOTE: this class is just for - * demonstration puprposes (it is a very slow way to read a - * block of ints). - * - * @lucene.experimental - */ -public class SingleIntIndexInput extends IntIndexInput { - private final IndexInput in; - - public SingleIntIndexInput(Directory dir, String fileName, int readBufferSize) - throws IOException { - in = dir.openInput(fileName, readBufferSize); - CodecUtil.checkHeader(in, SingleIntIndexOutput.CODEC, - SingleIntIndexOutput.VERSION_START, SingleIntIndexOutput.VERSION_START); - } - - @Override - public Reader reader() throws IOException { - return new Reader((IndexInput) in.clone()); - } - - @Override - public void close() throws IOException { - in.close(); - } - - public static class Reader extends IntIndexInput.Reader { - // clone: - private final IndexInput in; - - public Reader(IndexInput in) { - this.in = in; - } - - /** Reads next single int */ - @Override - public int next() throws IOException { - return in.readVInt(); - } - } - - class Index extends IntIndexInput.Index { - private long fp; - - @Override - public void read(IndexInput indexIn, boolean absolute) - throws IOException { - if (absolute) { - fp = indexIn.readVLong(); - } else { - fp += indexIn.readVLong(); - } - } - - @Override - public void set(IntIndexInput.Index other) { - fp = ((Index) other).fp; - } - - @Override - public void seek(IntIndexInput.Reader other) throws IOException { - ((Reader) other).in.seek(fp); - } - - @Override - public String toString() { - return Long.toString(fp); - } - - @Override - public Object clone() { - Index other = new Index(); - other.fp = fp; - return other; - } - } - - @Override - public Index index() { - return new Index(); - } -} - Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/sep/SepCodec.java (working copy) @@ -1,150 +0,0 @@ -package org.apache.lucene.index.codecs.sep; - -/** - * 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.Set; - -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentWriteState; -import org.apache.lucene.index.SegmentReadState; -import org.apache.lucene.index.codecs.Codec; -import org.apache.lucene.index.codecs.FieldsConsumer; -import org.apache.lucene.index.codecs.FieldsProducer; -import org.apache.lucene.index.codecs.standard.SimpleStandardTermsIndexReader; -import org.apache.lucene.index.codecs.standard.SimpleStandardTermsIndexWriter; -import org.apache.lucene.index.codecs.standard.StandardPostingsReader; -import org.apache.lucene.index.codecs.standard.StandardPostingsWriter; -import org.apache.lucene.index.codecs.standard.StandardTermsDictReader; -import org.apache.lucene.index.codecs.standard.StandardTermsDictWriter; -import org.apache.lucene.index.codecs.standard.StandardTermsIndexReader; -import org.apache.lucene.index.codecs.standard.StandardTermsIndexWriter; -import org.apache.lucene.index.codecs.standard.StandardCodec; -import org.apache.lucene.store.Directory; -import org.apache.lucene.util.BytesRef; - -/** @lucene.experimental */ -public class SepCodec extends Codec { - - public SepCodec() { - name = "Sep"; - } - - @Override - public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { - - StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new SingleIntFactory()); - - boolean success = false; - StandardTermsIndexWriter indexWriter; - try { - indexWriter = new SimpleStandardTermsIndexWriter(state); - success = true; - } finally { - if (!success) { - postingsWriter.close(); - } - } - - success = false; - try { - FieldsConsumer ret = new StandardTermsDictWriter(indexWriter, state, postingsWriter, BytesRef.getUTF8SortedAsUnicodeComparator()); - success = true; - return ret; - } finally { - if (!success) { - try { - postingsWriter.close(); - } finally { - indexWriter.close(); - } - } - } - } - - final static String DOC_EXTENSION = "doc"; - final static String SKIP_EXTENSION = "skp"; - final static String FREQ_EXTENSION = "frq"; - final static String POS_EXTENSION = "pos"; - final static String PAYLOAD_EXTENSION = "pyl"; - - @Override - public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException { - - StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, state.segmentInfo, state.readBufferSize, new SingleIntFactory()); - - StandardTermsIndexReader indexReader; - boolean success = false; - try { - indexReader = new SimpleStandardTermsIndexReader(state.dir, - state.fieldInfos, - state.segmentInfo.name, - state.termsIndexDivisor, - BytesRef.getUTF8SortedAsUnicodeComparator()); - success = true; - } finally { - if (!success) { - postingsReader.close(); - } - } - - success = false; - try { - FieldsProducer ret = new StandardTermsDictReader(indexReader, - state.dir, - state.fieldInfos, - state.segmentInfo.name, - postingsReader, - state.readBufferSize, - BytesRef.getUTF8SortedAsUnicodeComparator(), - StandardCodec.TERMS_CACHE_SIZE); - success = true; - return ret; - } finally { - if (!success) { - try { - postingsReader.close(); - } finally { - indexReader.close(); - } - } - } - } - - @Override - public void files(Directory dir, SegmentInfo segmentInfo, Set files) { - SepPostingsReaderImpl.files(segmentInfo, files); - StandardTermsDictReader.files(dir, segmentInfo, files); - SimpleStandardTermsIndexReader.files(dir, segmentInfo, files); - } - - @Override - public void getExtensions(Set extensions) { - getSepExtensions(extensions); - } - - public static void getSepExtensions(Set extensions) { - extensions.add(DOC_EXTENSION); - extensions.add(FREQ_EXTENSION); - extensions.add(SKIP_EXTENSION); - extensions.add(POS_EXTENSION); - extensions.add(PAYLOAD_EXTENSION); - StandardTermsDictReader.getExtensions(extensions); - SimpleStandardTermsIndexReader.getIndexExtensions(extensions); - } -} \ No newline at end of file Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexOutput.java (working copy) @@ -1,84 +0,0 @@ -package org.apache.lucene.index.codecs.sep; - -/** - * 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 org.apache.lucene.store.IndexOutput; -import org.apache.lucene.store.Directory; -import org.apache.lucene.util.CodecUtil; - -import java.io.IOException; - -/** Writes ints directly to the file (not in blocks) as - * vInt. - * - * @lucene.experimental -*/ -public class SingleIntIndexOutput extends IntIndexOutput { - private final IndexOutput out; - final static String CODEC = "SINGLE_INTS"; - final static int VERSION_START = 0; - final static int VERSION_CURRENT = VERSION_START; - - public SingleIntIndexOutput(Directory dir, String fileName) throws IOException { - out = dir.createOutput(fileName); - CodecUtil.writeHeader(out, CODEC, VERSION_CURRENT); - } - - /** Write an int to the primary file */ - @Override - public void write(int v) throws IOException { - out.writeVInt(v); - } - - @Override - public Index index() { - return new Index(); - } - - @Override - public void close() throws IOException { - out.close(); - } - - private class Index extends IntIndexOutput.Index { - long fp; - long lastFP; - @Override - public void mark() { - fp = out.getFilePointer(); - } - @Override - public void set(IntIndexOutput.Index other) { - lastFP = fp = ((Index) other).fp; - } - @Override - public void write(IndexOutput indexOut, boolean absolute) - throws IOException { - if (absolute) { - indexOut.writeVLong(fp); - } else { - indexOut.writeVLong(fp - lastFP); - } - lastFP = fp; - } - @Override - public String toString() { - return Long.toString(fp); - } - } -} Index: lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java (working copy) @@ -18,6 +18,7 @@ */ import java.io.IOException; +import java.util.Set; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.FieldInfo; @@ -35,6 +36,12 @@ public final class SepPostingsWriterImpl extends StandardPostingsWriter { final static String CODEC = "SepDocFreqSkip"; + final static String DOC_EXTENSION = "doc"; + final static String SKIP_EXTENSION = "skp"; + final static String FREQ_EXTENSION = "frq"; + final static String POS_EXTENSION = "pos"; + final static String PAYLOAD_EXTENSION = "pyl"; + // Increment version to change it: final static int VERSION_START = 0; final static int VERSION_CURRENT = VERSION_START; @@ -76,24 +83,24 @@ public SepPostingsWriterImpl(SegmentWriteState state, IntStreamFactory factory) throws IOException { super(); - final String docFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.DOC_EXTENSION); + final String docFileName = IndexFileNames.segmentFileName(state.segmentName, "", DOC_EXTENSION); state.flushedFiles.add(docFileName); docOut = factory.createOutput(state.directory, docFileName); docIndex = docOut.index(); if (state.fieldInfos.hasProx()) { - final String frqFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.FREQ_EXTENSION); + final String frqFileName = IndexFileNames.segmentFileName(state.segmentName, "", FREQ_EXTENSION); state.flushedFiles.add(frqFileName); freqOut = factory.createOutput(state.directory, frqFileName); freqIndex = freqOut.index(); - final String posFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.POS_EXTENSION); + final String posFileName = IndexFileNames.segmentFileName(state.segmentName, "", POS_EXTENSION); posOut = factory.createOutput(state.directory, posFileName); state.flushedFiles.add(posFileName); posIndex = posOut.index(); // TODO: -- only if at least one field stores payloads? - final String payloadFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.PAYLOAD_EXTENSION); + final String payloadFileName = IndexFileNames.segmentFileName(state.segmentName, "", PAYLOAD_EXTENSION); state.flushedFiles.add(payloadFileName); payloadOut = state.directory.createOutput(payloadFileName); @@ -105,7 +112,7 @@ payloadOut = null; } - final String skipFileName = IndexFileNames.segmentFileName(state.segmentName, "", SepCodec.SKIP_EXTENSION); + final String skipFileName = IndexFileNames.segmentFileName(state.segmentName, "", SKIP_EXTENSION); state.flushedFiles.add(skipFileName); skipOut = state.directory.createOutput(skipFileName); @@ -284,4 +291,12 @@ } } } + + public static void getExtensions(Set extensions) { + extensions.add(DOC_EXTENSION); + extensions.add(FREQ_EXTENSION); + extensions.add(SKIP_EXTENSION); + extensions.add(POS_EXTENSION); + extensions.add(PAYLOAD_EXTENSION); + } } Index: lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/intblock/IntBlockCodec.java (working copy) @@ -1,140 +0,0 @@ -package org.apache.lucene.index.codecs.intblock; - -/** - * 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.Set; - -import org.apache.lucene.index.SegmentInfo; -import org.apache.lucene.index.SegmentWriteState; -import org.apache.lucene.index.SegmentReadState; -import org.apache.lucene.index.codecs.Codec; -import org.apache.lucene.index.codecs.FieldsConsumer; -import org.apache.lucene.index.codecs.FieldsProducer; -import org.apache.lucene.index.codecs.sep.SepCodec; -import org.apache.lucene.index.codecs.sep.SepPostingsReaderImpl; -import org.apache.lucene.index.codecs.sep.SepPostingsWriterImpl; -import org.apache.lucene.index.codecs.standard.SimpleStandardTermsIndexReader; -import org.apache.lucene.index.codecs.standard.SimpleStandardTermsIndexWriter; -import org.apache.lucene.index.codecs.standard.StandardPostingsWriter; -import org.apache.lucene.index.codecs.standard.StandardPostingsReader; -import org.apache.lucene.index.codecs.standard.StandardTermsDictReader; -import org.apache.lucene.index.codecs.standard.StandardTermsDictWriter; -import org.apache.lucene.index.codecs.standard.StandardTermsIndexReader; -import org.apache.lucene.index.codecs.standard.StandardTermsIndexWriter; -import org.apache.lucene.index.codecs.standard.StandardCodec; -import org.apache.lucene.store.Directory; -import org.apache.lucene.util.BytesRef; - -/** - * @lucene.experimental - */ -public class IntBlockCodec extends Codec { - - public IntBlockCodec() { - name = "IntBlock"; - } - - @Override - public FieldsConsumer fieldsConsumer(SegmentWriteState state) throws IOException { - StandardPostingsWriter postingsWriter = new SepPostingsWriterImpl(state, new SimpleIntBlockFactory(1024)); - - boolean success = false; - StandardTermsIndexWriter indexWriter; - try { - indexWriter = new SimpleStandardTermsIndexWriter(state); - success = true; - } finally { - if (!success) { - postingsWriter.close(); - } - } - - success = false; - try { - FieldsConsumer ret = new StandardTermsDictWriter(indexWriter, state, postingsWriter, BytesRef.getUTF8SortedAsUnicodeComparator()); - success = true; - return ret; - } finally { - if (!success) { - try { - postingsWriter.close(); - } finally { - indexWriter.close(); - } - } - } - } - - @Override - public FieldsProducer fieldsProducer(SegmentReadState state) throws IOException { - StandardPostingsReader postingsReader = new SepPostingsReaderImpl(state.dir, - state.segmentInfo, - state.readBufferSize, - new SimpleIntBlockFactory(1024)); - - StandardTermsIndexReader indexReader; - boolean success = false; - try { - indexReader = new SimpleStandardTermsIndexReader(state.dir, - state.fieldInfos, - state.segmentInfo.name, - state.termsIndexDivisor, - BytesRef.getUTF8SortedAsUnicodeComparator()); - success = true; - } finally { - if (!success) { - postingsReader.close(); - } - } - - success = false; - try { - FieldsProducer ret = new StandardTermsDictReader(indexReader, - state.dir, - state.fieldInfos, - state.segmentInfo.name, - postingsReader, - state.readBufferSize, - BytesRef.getUTF8SortedAsUnicodeComparator(), - StandardCodec.TERMS_CACHE_SIZE); - success = true; - return ret; - } finally { - if (!success) { - try { - postingsReader.close(); - } finally { - indexReader.close(); - } - } - } - } - - @Override - public void files(Directory dir, SegmentInfo segmentInfo, Set files) { - SepPostingsReaderImpl.files(segmentInfo, files); - StandardTermsDictReader.files(dir, segmentInfo, files); - SimpleStandardTermsIndexReader.files(dir, segmentInfo, files); - } - - @Override - public void getExtensions(Set extensions) { - SepCodec.getSepExtensions(extensions); - } -} Index: lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockFactory.java (working copy) @@ -1,41 +0,0 @@ -package org.apache.lucene.index.codecs.intblock; - -/** - * 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 org.apache.lucene.store.Directory; -import org.apache.lucene.index.codecs.sep.IntStreamFactory; -import org.apache.lucene.index.codecs.sep.IntIndexInput; -import org.apache.lucene.index.codecs.sep.IntIndexOutput; - -import java.io.IOException; - -/** @lucene.experimental */ -public class SimpleIntBlockFactory extends IntStreamFactory { - private final int blockSize; - public SimpleIntBlockFactory(int blockSize) { - this.blockSize = blockSize; - } - @Override - public IntIndexInput openInput(Directory dir, String fileName, int readBufferSize) throws IOException { - return new SimpleIntBlockIndexInput(dir, fileName, readBufferSize); - } - @Override - public IntIndexOutput createOutput(Directory dir, String fileName) throws IOException { - return new SimpleIntBlockIndexOutput(dir, fileName, blockSize); - } -} Index: lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java =================================================================== --- lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java (revision 982024) +++ lucene/src/java/org/apache/lucene/index/codecs/intblock/SimpleIntBlockIndexInput.java (working copy) @@ -1,68 +0,0 @@ -package org.apache.lucene.index.codecs.intblock; - -/** - * 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. - */ - -/** Naive int block API that writes vInts. This is - * expected to give poor performance; it's really only for - * testing the pluggability. One should typically use pfor instead. */ - -import org.apache.lucene.util.CodecUtil; -import org.apache.lucene.store.Directory; -import org.apache.lucene.store.IndexInput; - -import java.io.IOException; - -/** - * Don't use this class!! It naively encodes ints one vInt - * at a time. Use it only for testing. - * - * @lucene.experimental - */ -public class SimpleIntBlockIndexInput extends FixedIntBlockIndexInput { - - public SimpleIntBlockIndexInput(Directory dir, String fileName, int readBufferSize) throws IOException { - IndexInput in = dir.openInput(fileName, readBufferSize); - CodecUtil.checkHeader(in, SimpleIntBlockIndexOutput.CODEC, - SimpleIntBlockIndexOutput.VERSION_START, SimpleIntBlockIndexOutput.VERSION_START); - init(in); - } - - private static class BlockReader implements FixedIntBlockIndexInput.BlockReader { - - private final IndexInput in; - private final int[] buffer; - - public BlockReader(IndexInput in, int[] buffer) { - this.in = in; - this.buffer = buffer; - } - - public void readBlock() throws IOException { - // silly impl - for(int i=0;i