lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1137639 [1/4] - in /lucene/dev/branches/LUCENE2793: lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/ lucene/contrib/misc/src/java/org/apache/lucene/store/ lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/ap...
Date Mon, 20 Jun 2011 14:28:29 GMT
Author: simonw
Date: Mon Jun 20 14:28:24 2011
New Revision: 1137639

URL: http://svn.apache.org/viewvc?rev=1137639&view=rev
Log:
LUCENE-2793: initial commit from patch

Added:
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IOContext.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergeInfo.java
Modified:
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosReader.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosWriter.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsDictReader.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java
    lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CheckIndex.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldInfos.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergePolicy.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/NormsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/PerFieldCodecWrapper.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfos.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentNorms.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentReadState.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentWriteState.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/StoredFieldsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/TermVectorsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/TermVectorsTermsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/TermVectorsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/BlockTermsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/DefaultDocValuesProducer.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/DefaultSegmentInfosWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/FixedGapTermsIndexReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/FixedGapTermsIndexWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/SegmentInfosReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/SegmentInfosWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/VariableGapTermsIndexReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/VariableGapTermsIndexWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/memory/MemoryCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/preflex/PreFlexCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/preflex/PreFlexFields.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/preflex/TermInfosReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/pulsing/PulsingCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/sep/IntStreamFactory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsReaderImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/sep/SepPostingsWriterImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/simpletext/SimpleTextFieldsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/simpletext/SimpleTextFieldsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardPostingsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/codecs/standard/StandardPostingsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/Bytes.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/FixedDerefBytesImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/FixedSortedBytesImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/FixedStraightBytesImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/Floats.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/Ints.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/IntsImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/VarDerefBytesImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/VarSortedBytesImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/values/VarStraightBytesImpl.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/BufferedIndexInput.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/Directory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/FSDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/MMapDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/NIOFSDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/RAMDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/store/SimpleFSDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/util/BitVector.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockFixedIntBlockCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mockintblock/MockVariableIntBlockCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mockrandom/MockRandomCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntFactory.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexInput.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSingleIntIndexOutput.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/preflexrw/PreFlexFieldsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/preflexrw/PreFlexRWCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/index/codecs/preflexrw/TermInfosWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java
    lucene/dev/branches/LUCENE2793/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestCodecs.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestCompoundFile.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestDoc.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexInput.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestMultiReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/TestTermVectorsWriter.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/index/codecs/intblock/TestIntBlockCodec.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/search/TestBoolean2.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/store/TestCopyBytes.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/store/TestDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/store/TestMultiMMap.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/store/TestRAMDirectory.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/util/TestBitVector.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java
    lucene/dev/branches/LUCENE2793/lucene/src/test/org/apache/lucene/util/packed/TestPackedInts.java
    lucene/dev/branches/LUCENE2793/solr/src/java/org/apache/solr/core/RefCntRamDirectory.java

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingCodec.java Mon Jun 20 14:28:24 2011
@@ -94,11 +94,12 @@ public class AppendingCodec extends Code
   @Override
   public FieldsProducer fieldsProducer(SegmentReadState state)
           throws IOException {
-    PostingsReaderBase docsReader = new StandardPostingsReader(state.dir, state.segmentInfo, state.readBufferSize, state.codecId);
+    PostingsReaderBase docsReader = new StandardPostingsReader(state.dir, state.segmentInfo, state.context, state.codecId);
     TermsIndexReaderBase indexReader;
 
     boolean success = false;
     try {
+      //nocommit we should pass the IOContext down to the TermIndexReader
       indexReader = new AppendingTermsIndexReader(state.dir,
               state.fieldInfos,
               state.segmentInfo.name,
@@ -116,7 +117,7 @@ public class AppendingCodec extends Code
       FieldsProducer ret = new AppendingTermsDictReader(indexReader,
               state.dir, state.fieldInfos, state.segmentInfo.name,
               docsReader,
-              state.readBufferSize,
+              state.context,
               StandardCodec.TERMS_CACHE_SIZE,
               state.codecId);
       success = true;

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosReader.java Mon Jun 20 14:28:24 2011
@@ -20,6 +20,7 @@ package org.apache.lucene.index.codecs.a
 import java.io.IOException;
 
 import org.apache.lucene.index.CorruptIndexException;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.codecs.DefaultSegmentInfosReader;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
@@ -33,9 +34,9 @@ public class AppendingSegmentInfosReader
   }
 
   @Override
-  public IndexInput openInput(Directory dir, String segmentsFileName)
+  public IndexInput openInput(Directory dir, String segmentsFileName, IOContext context)
           throws IOException {
-    return dir.openInput(segmentsFileName);
+    return dir.openInput(segmentsFileName, context);
   }
 
 }

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosWriter.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosWriter.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingSegmentInfosWriter.java Mon Jun 20 14:28:24 2011
@@ -19,6 +19,7 @@ package org.apache.lucene.index.codecs.a
 
 import java.io.IOException;
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.codecs.DefaultSegmentInfosWriter;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexOutput;
@@ -26,9 +27,9 @@ import org.apache.lucene.store.IndexOutp
 public class AppendingSegmentInfosWriter extends DefaultSegmentInfosWriter {
 
   @Override
-  protected IndexOutput createOutput(Directory dir, String segmentsFileName)
+  protected IndexOutput createOutput(Directory dir, String segmentsFileName, IOContext context)
           throws IOException {
-    return dir.createOutput(segmentsFileName);
+    return dir.createOutput(segmentsFileName, context);
   }
 
   @Override

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsDictReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsDictReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsDictReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsDictReader.java Mon Jun 20 14:28:24 2011
@@ -20,6 +20,7 @@ package org.apache.lucene.index.codecs.a
 import java.io.IOException;
 
 import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.codecs.PostingsReaderBase;
 import org.apache.lucene.index.codecs.BlockTermsReader;
 import org.apache.lucene.index.codecs.BlockTermsWriter;
@@ -32,9 +33,9 @@ public class AppendingTermsDictReader ex
 
   public AppendingTermsDictReader(TermsIndexReaderBase indexReader,
           Directory dir, FieldInfos fieldInfos, String segment,
-          PostingsReaderBase postingsReader, int readBufferSize,
+          PostingsReaderBase postingsReader, IOContext context,
           int termsCacheSize, int codecId) throws IOException {
-    super(indexReader, dir, fieldInfos, segment, postingsReader, readBufferSize,
+    super(indexReader, dir, fieldInfos, segment, postingsReader, context,
           termsCacheSize, codecId);
   }
   

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/index/codecs/appending/AppendingTermsIndexReader.java Mon Jun 20 14:28:24 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.Comparator;
 
 import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.codecs.FixedGapTermsIndexReader;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
@@ -32,7 +33,7 @@ public class AppendingTermsIndexReader e
   public AppendingTermsIndexReader(Directory dir, FieldInfos fieldInfos,
           String segment, int indexDivisor, Comparator<BytesRef> termComp, int codecId)
           throws IOException {
-    super(dir, fieldInfos, segment, indexDivisor, termComp, codecId);
+    super(dir, fieldInfos, segment, indexDivisor, termComp, codecId, IOContext.DEFAULT);
   }
   
   @Override

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java Mon Jun 20 14:28:24 2011
@@ -25,6 +25,7 @@ import java.io.FileOutputStream;
 import java.nio.ByteBuffer;
 import java.nio.channels.FileChannel;
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.store.Directory; // javadoc
 import org.apache.lucene.store.NativeFSLockFactory; // javadoc
 
@@ -69,15 +70,17 @@ public class DirectIOLinuxDirectory exte
   }
 
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, IOContext context) throws IOException {
     ensureOpen();
-    return new DirectIOLinuxIndexInput(new File(getDirectory(), name), forcedBufferSize == 0 ? bufferSize : forcedBufferSize);
+    //nocommit - use buffer based on IOContext
+    return new DirectIOLinuxIndexInput(new File(getDirectory(), name), forcedBufferSize == 0 ? BufferedIndexInput.BUFFER_SIZE : forcedBufferSize);
   }
 
   @Override
-  public IndexOutput createOutput(String name) throws IOException {
+  public IndexOutput createOutput(String name,IOContext context) throws IOException {
     ensureOpen();
     ensureCanWrite(name);
+    //nocommit - use buffer based on IOContext
     return new DirectIOLinuxIndexOutput(new File(getDirectory(), name), forcedBufferSize == 0 ? BufferedIndexOutput.BUFFER_SIZE : forcedBufferSize);
   }
 

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java Mon Jun 20 14:28:24 2011
@@ -24,8 +24,10 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.lucene.index.ConcurrentMergeScheduler;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.IndexWriter;       // javadocs
+import org.apache.lucene.index.MergeInfo;
 import org.apache.lucene.index.MergePolicy;
 import org.apache.lucene.index.MergeScheduler;
 import org.apache.lucene.store.RAMDirectory;      // javadocs
@@ -193,17 +195,17 @@ public class NRTCachingDirectory extends
   }
 
   @Override
-  public IndexOutput createOutput(String name) throws IOException {
+  public IndexOutput createOutput(String name, IOContext context) throws IOException {
     if (VERBOSE) {
       System.out.println("nrtdir.createOutput name=" + name);
     }
-    if (doCacheWrite(name)) {
+    if (doCacheWrite(name, context)) {
       if (VERBOSE) {
         System.out.println("  to cache");
       }
-      return cache.createOutput(name);
+      return cache.createOutput(name, context);
     } else {
-      return delegate.createOutput(name);
+      return delegate.createOutput(name, context);
     }
   }
 
@@ -219,7 +221,7 @@ public class NRTCachingDirectory extends
   }
 
   @Override
-  public synchronized IndexInput openInput(String name) throws IOException {
+  public synchronized IndexInput openInput(String name, IOContext context) throws IOException {
     if (VERBOSE) {
       System.out.println("nrtdir.openInput name=" + name);
     }
@@ -227,18 +229,9 @@ public class NRTCachingDirectory extends
       if (VERBOSE) {
         System.out.println("  from cache");
       }
-      return cache.openInput(name);
+      return cache.openInput(name, context);
     } else {
-      return delegate.openInput(name);
-    }
-  }
-
-  @Override
-  public synchronized IndexInput openInput(String name, int bufferSize) throws IOException {
-    if (cache.fileExists(name)) {
-      return cache.openInput(name, bufferSize);
-    } else {
-      return delegate.openInput(name, bufferSize);
+      return delegate.openInput(name, context);
     }
   }
 
@@ -271,18 +264,19 @@ public class NRTCachingDirectory extends
 
   /** Subclass can override this to customize logic; return
    *  true if this file should be written to the RAMDirectory. */
-  protected boolean doCacheWrite(String name) {
-    final MergePolicy.OneMerge merge = merges.get(Thread.currentThread());
+  protected boolean doCacheWrite(String name, IOContext context) {
+    final MergeInfo merge = context.mergeInfo;
     //System.out.println(Thread.currentThread().getName() + ": CACHE check merge=" + merge + " size=" + (merge==null ? 0 : merge.estimatedMergeBytes));
     return !name.equals(IndexFileNames.SEGMENTS_GEN) && (merge == null || merge.estimatedMergeBytes <= maxMergeSizeBytes) && cache.sizeInBytes() <= maxCachedBytes;
   }
 
   private void unCache(String fileName) throws IOException {
     final IndexOutput out;
+    IOContext context = IOContext.DEFAULT;
     synchronized(this) {
       if (!delegate.fileExists(fileName)) {
         assert cache.fileExists(fileName);
-        out = delegate.createOutput(fileName);
+        out = delegate.createOutput(fileName, context);
       } else {
         out = null;
       }
@@ -291,7 +285,7 @@ public class NRTCachingDirectory extends
     if (out != null) {
       IndexInput in = null;
       try {
-        in = cache.openInput(fileName);
+        in = cache.openInput(fileName, context);
         in.copyBytes(out, in.length());
       } finally {
         IOUtils.closeSafely(false, in, out);

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java Mon Jun 20 14:28:24 2011
@@ -19,6 +19,8 @@ package org.apache.lucene.store;
 
 import java.io.File;
 import java.io.IOException;
+
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.store.Directory; // javadoc
 import org.apache.lucene.store.NativeFSLockFactory; // javadoc
 
@@ -67,9 +69,10 @@ public class WindowsDirectory extends FS
   }
 
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, IOContext context) throws IOException {
     ensureOpen();
-    return new WindowsIndexInput(new File(getDirectory(), name), Math.max(bufferSize, DEFAULT_BUFFERSIZE));
+    //nocommit - use buffer based on IOContext
+    return new WindowsIndexInput(new File(getDirectory(), name), DEFAULT_BUFFERSIZE);
   }
   
   protected static class WindowsIndexInput extends BufferedIndexInput {

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java Mon Jun 20 14:28:24 2011
@@ -27,6 +27,7 @@ import org.apache.lucene.document.Field.
 import org.apache.lucene.document.Field.TermVector;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.Fields;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
@@ -124,8 +125,8 @@ public class TestAppendingCodec extends 
     }
 
     @Override
-    public IndexOutput createOutput(String name) throws IOException {
-      return new AppendingIndexOutputWrapper(super.createOutput(name));
+    public IndexOutput createOutput(String name, IOContext context) throws IOException {
+      return new AppendingIndexOutputWrapper(super.createOutput(name, context));
     }
     
   }

Modified: lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/contrib/misc/src/test/org/apache/lucene/store/TestNRTCachingDirectory.java Mon Jun 20 14:28:24 2011
@@ -24,6 +24,7 @@ import java.util.List;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
@@ -114,7 +115,7 @@ public class TestNRTCachingDirectory ext
 
   public void testDeleteFile() throws Exception {
     Directory dir = new NRTCachingDirectory(newDirectory(), 2.0, 25.0);
-    dir.createOutput("foo.txt").close();
+    dir.createOutput("foo.txt", IOContext.DEFAULT).close();
     dir.deleteFile("foo.txt");
     assertEquals(0, dir.listAll().length);
     dir.close();

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/BufferedDeletesStream.java Mon Jun 20 14:28:24 2011
@@ -224,7 +224,8 @@ class BufferedDeletesStream {
 
         // Lock order: IW -> BD -> RP
         assert readerPool.infoIsLive(info);
-        final SegmentReader reader = readerPool.get(info, false);
+        //nocommit is IOContext.DEFAULT the right thing to do here?
+        final SegmentReader reader = readerPool.get(info, false, IOContext.DEFAULT);
         int delCount = 0;
         final boolean segAllDeletes;
         try {
@@ -273,7 +274,8 @@ class BufferedDeletesStream {
         if (coalescedDeletes != null) {
           // Lock order: IW -> BD -> RP
           assert readerPool.infoIsLive(info);
-          SegmentReader reader = readerPool.get(info, false);
+          //nocommit is IOContext.DEFAULT the right thing to do here?
+          SegmentReader reader = readerPool.get(info, false, IOContext.DEFAULT);
           int delCount = 0;
           final boolean segAllDeletes;
           try {

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CheckIndex.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CheckIndex.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CheckIndex.java Mon Jun 20 14:28:24 2011
@@ -25,6 +25,8 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.document.AbstractField;  // for javadocs
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IOContext.Context;
+import org.apache.lucene.index.MergePolicy.OneMerge;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.DefaultSegmentInfosWriter;
 import org.apache.lucene.index.codecs.PerDocValues;
@@ -342,7 +344,7 @@ public class CheckIndex {
     final String segmentsFileName = sis.getCurrentSegmentFileName();
     IndexInput input = null;
     try {
-      input = dir.openInput(segmentsFileName);
+      input = dir.openInput(segmentsFileName, IOContext.DEFAULT);
     } catch (Throwable t) {
       msg("ERROR: could not open segments file in directory");
       if (infoStream != null)
@@ -479,7 +481,7 @@ public class CheckIndex {
         }
         if (infoStream != null)
           infoStream.print("    test: open reader.........");
-        reader = SegmentReader.get(true, info, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR);
+        reader = SegmentReader.get(true, info, IndexReader.DEFAULT_TERMS_INDEX_DIVISOR, IOContext.DEFAULT);
 
         segInfoStat.openReaderPassed = true;
 

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileReader.java Mon Jun 20 14:28:24 2011
@@ -36,8 +36,6 @@ import java.io.IOException;
  */
 public class CompoundFileReader extends Directory {
   
-  private int readBufferSize;
-  
   private static final class FileEntry {
     long offset;
     long length;
@@ -49,21 +47,16 @@ public class CompoundFileReader extends 
   
   private IndexInput stream;
   private HashMap<String,FileEntry> entries = new HashMap<String,FileEntry>();
-  
-  public CompoundFileReader(Directory dir, String name) throws IOException {
-    this(dir, name, BufferedIndexInput.BUFFER_SIZE);
-  }
-  
-  public CompoundFileReader(Directory dir, String name, int readBufferSize) throws IOException {
+
+  public CompoundFileReader(Directory dir, String name, IOContext context) throws IOException {
     assert !(dir instanceof CompoundFileReader) : "compound file inside of compound file: " + name;
     directory = dir;
     fileName = name;
-    this.readBufferSize = readBufferSize;
     
     boolean success = false;
     
     try {
-      stream = dir.openInput(name, readBufferSize);
+      stream = dir.openInput(name, context);
       
       // read the first VInt. If it is negative, it's the version number
       // otherwise it's the count (pre-3.1 indexes)
@@ -141,13 +134,7 @@ public class CompoundFileReader extends 
   }
   
   @Override
-  public synchronized IndexInput openInput(String id) throws IOException {
-    // Default to readBufferSize passed in when we were opened
-    return openInput(id, readBufferSize);
-  }
-  
-  @Override
-  public synchronized IndexInput openInput(String id, int readBufferSize) throws IOException {
+  public synchronized IndexInput openInput(String id, IOContext context) throws IOException {
     if (stream == null)
       throw new IOException("Stream closed");
     
@@ -155,8 +142,8 @@ public class CompoundFileReader extends 
     final FileEntry entry = entries.get(id);
     if (entry == null)
       throw new IOException("No sub-file with id " + id + " found (files: " + entries.keySet() + ")");
-    
-    return new CSIndexInput(stream, entry.offset, entry.length, readBufferSize);
+    // nocommit set read buffer size based on IOContext
+    return new CSIndexInput(stream, entry.offset, entry.length, BufferedIndexInput.BUFFER_SIZE);
   }
   
   /** Returns an array of strings, one for each file in the directory. */
@@ -209,7 +196,7 @@ public class CompoundFileReader extends 
   /** Not implemented
    * @throws UnsupportedOperationException */
   @Override
-  public IndexOutput createOutput(String name) {
+  public IndexOutput createOutput(String name, IOContext context) {
     throw new UnsupportedOperationException();
   }
   

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java Mon Jun 20 14:28:24 2011
@@ -76,22 +76,23 @@ public final class CompoundFileWriter {
     // switch to a new format!
     static final int FORMAT_CURRENT = FORMAT_NO_SEGMENT_PREFIX;
 
-    private Directory directory;
-    private String fileName;
-    private HashSet<String> ids;
-    private LinkedList<FileEntry> entries;
+    private final Directory directory;
+    private final String fileName;
+    private final IOContext context;
+    private final HashSet<String> ids;
+    private final LinkedList<FileEntry> entries;
     private boolean merged = false;
-    private MergeState.CheckAbort checkAbort;
+    private final MergeState.CheckAbort checkAbort;
 
     /** Create the compound stream in the specified file. The file name is the
      *  entire name (no extensions are added).
      *  @throws NullPointerException if <code>dir</code> or <code>name</code> is null
      */
-    public CompoundFileWriter(Directory dir, String name) {
-      this(dir, name, null);
+    public CompoundFileWriter(Directory dir, String name, IOContext context) {
+      this(dir, name, context, null);
     }
 
-    CompoundFileWriter(Directory dir, String name, MergeState.CheckAbort checkAbort) {
+    CompoundFileWriter(Directory dir, String name, IOContext context, MergeState.CheckAbort checkAbort) {
         if (dir == null)
             throw new NullPointerException("directory cannot be null");
         if (name == null)
@@ -101,6 +102,7 @@ public final class CompoundFileWriter {
         fileName = name;
         ids = new HashSet<String>();
         entries = new LinkedList<FileEntry>();
+        this.context = context;
     }
 
     /** Returns the directory of the compound file. */
@@ -164,7 +166,7 @@ public final class CompoundFileWriter {
         merged = true;
 
         // open the compound stream
-        IndexOutput os = directory.createOutput(fileName);
+        IndexOutput os = directory.createOutput(fileName, context);
         IOException priorException = null;
         try {
             // Write the Version info - must be a VInt because CFR reads a VInt
@@ -228,7 +230,7 @@ public final class CompoundFileWriter {
    * output stream.
    */
   private void copyFile(FileEntry source, IndexOutput os) throws IOException {
-    IndexInput is = source.dir.openInput(source.file);
+    IndexInput is = source.dir.openInput(source.file, context);
     try {
       long startPtr = os.getFilePointer();
       long length = is.length();

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DirectoryReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DirectoryReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DirectoryReader.java Mon Jun 20 14:28:24 2011
@@ -34,6 +34,7 @@ import org.apache.lucene.document.FieldS
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.Lock;
 import org.apache.lucene.store.LockObtainFailedException;
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.PerDocValues;
 import org.apache.lucene.util.Bits;
@@ -121,7 +122,7 @@ class DirectoryReader extends IndexReade
     for (int i = sis.size()-1; i >= 0; i--) {
       boolean success = false;
       try {
-        readers[i] = SegmentReader.get(readOnly, sis.info(i), termInfosIndexDivisor);
+        readers[i] = SegmentReader.get(readOnly, sis.info(i), termInfosIndexDivisor, IOContext.READ);
         readers[i].readerFinishedListeners = readerFinishedListeners;
         success = true;
       } finally {
@@ -170,7 +171,8 @@ class DirectoryReader extends IndexReade
       try {
         final SegmentInfo info = infos.info(i);
         assert info.dir == dir;
-        final SegmentReader reader = writer.readerPool.getReadOnlyClone(info, true, termInfosIndexDivisor);
+        final SegmentReader reader = writer.readerPool.getReadOnlyClone(info, true, termInfosIndexDivisor,
+                                                                        IOContext.READ);
         if (reader.numDocs() > 0 || writer.getKeepFullyDeletedSegments()) {
           reader.readerFinishedListeners = readerFinishedListeners;
           readers.add(reader);
@@ -254,7 +256,7 @@ class DirectoryReader extends IndexReade
           assert !doClone;
 
           // this is a new reader; in case we hit an exception we can close it safely
-          newReader = SegmentReader.get(readOnly, infos.info(i), termInfosIndexDivisor);
+          newReader = SegmentReader.get(readOnly, infos.info(i), termInfosIndexDivisor, IOContext.READ);
           newReader.readerFinishedListeners = readerFinishedListeners;
         } else {
           newReader = newReaders[i].reopenSegment(infos.info(i), doClone, readOnly);

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java Mon Jun 20 14:28:24 2011
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DocumentsWriterDeleteQueue.DeleteSlice;
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.search.SimilarityProvider;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BitVector;
@@ -428,7 +429,7 @@ public class DocumentsWriterPerThread {
     assert deleteSlice == null : "all deletes must be applied in prepareFlush";
     flushState = new SegmentWriteState(infoStream, directory, segment, fieldInfos,
         numDocsInRAM, writer.getConfig().getTermIndexInterval(),
-        fieldInfos.buildSegmentCodecs(true), pendingDeletes);
+        fieldInfos.buildSegmentCodecs(true), pendingDeletes, new IOContext(Context.FLUSH));
     final double startMBUsed = parent.flushControl.netBytes() / 1024. / 1024.;
     // Apply delete-by-docID now (delete-byDocID only
     // happens when an exception is hit processing that

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldInfos.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldInfos.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldInfos.java Mon Jun 20 14:28:24 2011
@@ -271,7 +271,7 @@ public final class FieldInfos implements
    */
   public FieldInfos(Directory d, String name) throws IOException {
     this((FieldNumberBiMap)null, null); // use null here to make this FIs Read-Only
-    final IndexInput input = d.openInput(name);
+    final IndexInput input = d.openInput(name, IOContext.READONCE);
     try {
       read(input, name);
     } finally {
@@ -564,7 +564,7 @@ public final class FieldInfos implements
   }
 
   public void write(Directory d, String name) throws IOException {
-    IndexOutput output = d.createOutput(name);
+    IndexOutput output = d.createOutput(name, IOContext.READONCE);
     try {
       write(output);
     } finally {

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsReader.java Mon Jun 20 14:28:24 2011
@@ -25,6 +25,8 @@ import org.apache.lucene.document.FieldS
 import org.apache.lucene.document.FieldSelectorResult;
 import org.apache.lucene.document.Fieldable;
 import org.apache.lucene.document.NumericField;
+import org.apache.lucene.index.IOContext.Context;
+import org.apache.lucene.index.MergePolicy.OneMerge;
 import org.apache.lucene.store.AlreadyClosedException;
 import org.apache.lucene.store.BufferedIndexInput;
 import org.apache.lucene.store.Directory;
@@ -81,7 +83,7 @@ public final class FieldsReader implemen
   /** Verifies that the code version which wrote the segment is supported. */
   public static void checkCodeVersion(Directory dir, String segment) throws IOException {
     final String indexStreamFN = IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_INDEX_EXTENSION);
-    IndexInput idxStream = dir.openInput(indexStreamFN, 1024);
+    IndexInput idxStream = dir.openInput(indexStreamFN, IOContext.DEFAULT);
     
     try {
       int format = idxStream.readInt();
@@ -110,18 +112,18 @@ public final class FieldsReader implemen
   }
   
   public FieldsReader(Directory d, String segment, FieldInfos fn) throws IOException {
-    this(d, segment, fn, BufferedIndexInput.BUFFER_SIZE, -1, 0);
+    this(d, segment, fn, IOContext.DEFAULT, -1, 0);
   }
 
-  public FieldsReader(Directory d, String segment, FieldInfos fn, int readBufferSize, int docStoreOffset, int size) throws IOException {
+  public FieldsReader(Directory d, String segment, FieldInfos fn, IOContext context, int docStoreOffset, int size) throws IOException {
     boolean success = false;
     isOriginal = true;
     try {
       fieldInfos = fn;
 
-      cloneableFieldsStream = d.openInput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_EXTENSION), readBufferSize);
+      cloneableFieldsStream = d.openInput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_EXTENSION), context);
       final String indexStreamFN = IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_INDEX_EXTENSION);
-      cloneableIndexStream = d.openInput(indexStreamFN, readBufferSize);
+      cloneableIndexStream = d.openInput(indexStreamFN, context);
       
       format = cloneableIndexStream.readInt();
 

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsWriter.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsWriter.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/FieldsWriter.java Mon Jun 20 14:28:24 2011
@@ -65,14 +65,14 @@ final class FieldsWriter {
   private IndexOutput fieldsStream;
   private IndexOutput indexStream;
 
-  FieldsWriter(Directory directory, String segment) throws IOException {
+  FieldsWriter(Directory directory, String segment, IOContext context) throws IOException {
     this.directory = directory;
     this.segment = segment;
 
     boolean success = false;
     try {
-      fieldsStream = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_EXTENSION));
-      indexStream = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_INDEX_EXTENSION));
+      fieldsStream = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_EXTENSION), context);
+      indexStream = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.FIELDS_INDEX_EXTENSION), context);
 
       fieldsStream.writeInt(FORMAT_CURRENT);
       indexStream.writeInt(FORMAT_CURRENT);

Added: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IOContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IOContext.java?rev=1137639&view=auto
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IOContext.java (added)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IOContext.java Mon Jun 20 14:28:24 2011
@@ -0,0 +1,73 @@
+package org.apache.lucene.index;
+
+/**
+ * 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.
+ */
+
+/**
+ * IOContext holds additional details on the merge/search context. A IOContext
+ * object can never be initialized as null as passed as a parameter to either
+ * {@link #org.apache.lucene.store.Directory.openInput()} or
+ * {@link #org.apache.lucene.store.Directory.createInput()}
+ */
+public class IOContext {
+
+  /**
+   * Context is a enumerator which specifies the context in which the Directory is being used for.
+   */
+  public enum Context {MERGE,READ,FLUSH,DEFAULT};
+  
+  /**
+   * An object of a enumerator Context type
+   */
+  public final Context context;
+  
+  public final MergeInfo mergeInfo;
+  
+  public final boolean readOnce;
+  
+  public static final IOContext DEFAULT = new IOContext(Context.DEFAULT);
+  
+  public static final IOContext READONCE = new IOContext(true);
+  
+  public static final IOContext READ = new IOContext(false);
+  
+  public IOContext () {
+    this(false);
+  }
+  
+  public IOContext(Context context) {
+    this(context, null);    
+  }
+  
+  private IOContext(boolean readOnce) {
+    this.context = Context.READ;
+    this.mergeInfo = null;    
+    this.readOnce = readOnce;
+  }
+  
+  public IOContext (MergeInfo mergeInfo) {    
+    this(Context.MERGE, mergeInfo);
+  }
+
+  private IOContext (Context context, MergeInfo mergeInfo ) {
+    assert context != Context.MERGE || mergeInfo != null;
+    this.context = context;
+    this.readOnce = false;
+    this.mergeInfo = mergeInfo;
+  }
+  
+}
\ No newline at end of file

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexReader.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexReader.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexReader.java Mon Jun 20 14:28:24 2011
@@ -21,6 +21,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.FieldSelector;
 import org.apache.lucene.search.FieldCache; // javadocs
 import org.apache.lucene.search.Similarity;
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.codecs.Codec;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.PerDocValues;
@@ -1433,13 +1434,14 @@ public abstract class IndexReader implem
 
     Directory dir = null;
     CompoundFileReader cfr = null;
+    IOContext context = IOContext.READ;
 
     try {
       File file = new File(filename);
       String dirname = file.getAbsoluteFile().getParent();
       filename = file.getName();
       dir = FSDirectory.open(new File(dirname));
-      cfr = new CompoundFileReader(dir, filename);
+      cfr = new CompoundFileReader(dir, filename, context);
 
       String [] files = cfr.listAll();
       ArrayUtil.mergeSort(files);   // sort the array of filename so that the output is more readable
@@ -1449,7 +1451,7 @@ public abstract class IndexReader implem
 
         if (extract) {
           System.out.println("extract " + files[i] + " with " + len + " bytes to local directory...");
-          IndexInput ii = cfr.openInput(files[i]);
+          IndexInput ii = cfr.openInput(files[i], context);
 
           FileOutputStream f = new FileOutputStream(files[i]);
 

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/IndexWriter.java Mon Jun 20 14:28:24 2011
@@ -39,7 +39,9 @@ import org.apache.lucene.analysis.Analyz
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DocumentsWriterPerThread.FlushedSegment;
 import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
+import org.apache.lucene.index.MergePolicy.OneMerge;
 import org.apache.lucene.index.PayloadProcessorProvider.DirPayloadProcessor;
 import org.apache.lucene.index.SegmentCodecs.SegmentCodecsBuilder;
 import org.apache.lucene.index.codecs.CodecProvider;
@@ -592,8 +594,8 @@ public class IndexWriter implements Clos
      * enrolled in the pool, so you should simply close()
      * it when you're done (ie, do not call release()).
      */
-    public synchronized SegmentReader getReadOnlyClone(SegmentInfo info, boolean doOpenStores, int termInfosIndexDivisor) throws IOException {
-      SegmentReader sr = get(info, doOpenStores, BufferedIndexInput.BUFFER_SIZE, termInfosIndexDivisor);
+    public synchronized SegmentReader getReadOnlyClone(SegmentInfo info, boolean doOpenStores, int termInfosIndexDivisor, IOContext context) throws IOException {
+      SegmentReader sr = get(info, doOpenStores, context, termInfosIndexDivisor);
       try {
         return (SegmentReader) sr.clone(true);
       } finally {
@@ -609,8 +611,8 @@ public class IndexWriter implements Clos
      * @param doOpenStores
      * @throws IOException
      */
-    public synchronized SegmentReader get(SegmentInfo info, boolean doOpenStores) throws IOException {
-      return get(info, doOpenStores, BufferedIndexInput.BUFFER_SIZE, config.getReaderTermsIndexDivisor());
+    public synchronized SegmentReader get(SegmentInfo info, boolean doOpenStores, IOContext context) throws IOException {
+      return get(info, doOpenStores, context, config.getReaderTermsIndexDivisor());
     }
 
     /**
@@ -624,18 +626,20 @@ public class IndexWriter implements Clos
      * @param termsIndexDivisor
      * @throws IOException
      */
-    public synchronized SegmentReader get(SegmentInfo info, boolean doOpenStores, int readBufferSize, int termsIndexDivisor) throws IOException {
+    public synchronized SegmentReader get(SegmentInfo info, boolean doOpenStores, IOContext context, int termsIndexDivisor) throws IOException {
 
-      if (poolReaders) {
-        readBufferSize = BufferedIndexInput.BUFFER_SIZE;
-      }
+      //      if (poolReaders) {
+      //        readBufferSize = BufferedIndexInput.BUFFER_SIZE;
+      //      }
+      
+      // nocommit context should be part of the key used to cache that reader in the pool.
 
       SegmentReader sr = readerMap.get(info);
       if (sr == null) {
         // TODO: we may want to avoid doing this while
         // synchronized
         // Returns a ref, which we xfer to readerMap:
-        sr = SegmentReader.get(false, info.dir, info, readBufferSize, doOpenStores, termsIndexDivisor);
+        sr = SegmentReader.get(false, info.dir, info, doOpenStores, termsIndexDivisor, context);
         sr.readerFinishedListeners = readerFinishedListeners;
 
         if (info.dir == directory) {
@@ -2183,6 +2187,8 @@ public class IndexWriter implements Clos
     SegmentInfo newSegment = flushedSegment.segmentInfo;
 
     setDiagnostics(newSegment, "flush");
+    
+    IOContext context = new IOContext(Context.FLUSH);
 
     boolean success = false;
     try {
@@ -2190,7 +2196,7 @@ public class IndexWriter implements Clos
         String compoundFileName = IndexFileNames.segmentFileName(newSegment.name, "", IndexFileNames.COMPOUND_FILE_EXTENSION);
         message("creating compound file " + compoundFileName);
         // Now build compound file
-        CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, compoundFileName);
+        CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, compoundFileName, context);
         for(String fileName : newSegment.files()) {
           cfsWriter.addFile(fileName);
         }
@@ -2222,7 +2228,7 @@ public class IndexWriter implements Clos
           // shortly-to-be-opened SegmentReader and let it
           // carry the changes; there's no reason to use
           // filesystem as intermediary here.
-          flushedSegment.deletedDocuments.write(directory, delFileName);
+          flushedSegment.deletedDocuments.write(directory, delFileName, context);
           success2 = true;
         } finally {
           if (!success2) {
@@ -2391,11 +2397,13 @@ public class IndexWriter implements Clos
                 // optimize case only for segments that don't share doc stores
                 && versionComparator.compare(info.getVersion(), "3.1") >= 0;
           }
-
+          
+          IOContext context = new IOContext(new MergeInfo(info.docCount, info.sizeInBytes(true), true, false));
+          
           if (createCFS) {
-            copySegmentIntoCFS(info, newSegName);
+            copySegmentIntoCFS(info, newSegName, context);
           } else {
-            copySegmentAsIs(info, newSegName, dsNames, dsFilesCopied);
+            copySegmentAsIs(info, newSegName, dsNames, dsFilesCopied, context);
           }
 
           infos.add(info);
@@ -2454,7 +2462,7 @@ public class IndexWriter implements Clos
 
       for (IndexReader reader : readers)      // add new indexes
         merger.add(reader);
-
+      // nocommit - we should pass a MergeInfo here into merge to create corresponding IOContext instances?
       int docCount = merger.merge();                // merge 'em
 
       final FieldInfos fieldInfos = merger.fieldInfos();
@@ -2475,7 +2483,8 @@ public class IndexWriter implements Clos
 
       // Now create the compound file if needed
       if (useCompoundFile) {
-        merger.createCompoundFile(mergedName + ".cfs", info);
+        IOContext context = new IOContext(new MergeInfo(info.docCount, info.sizeInBytes(true), true, false));
+        merger.createCompoundFile(mergedName + ".cfs", info, context);
 
         // delete new non cfs files directly: they were never
         // registered with IFD
@@ -2499,10 +2508,10 @@ public class IndexWriter implements Clos
   }
 
   /** Copies the segment into the IndexWriter's directory, as a compound segment. */
-  private void copySegmentIntoCFS(SegmentInfo info, String segName) throws IOException {
+  private void copySegmentIntoCFS(SegmentInfo info, String segName, IOContext context) throws IOException {
     String segFileName = IndexFileNames.segmentFileName(segName, "", IndexFileNames.COMPOUND_FILE_EXTENSION);
     Collection<String> files = info.files();
-    CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, segFileName);
+    CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, segFileName, context);
     for (String file : files) {
       String newFileName = segName + IndexFileNames.stripSegmentName(file);
       if (!IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION)
@@ -2510,7 +2519,7 @@ public class IndexWriter implements Clos
         cfsWriter.addFile(file, info.dir);
       } else {
         assert !directory.fileExists(newFileName): "file \"" + newFileName + "\" already exists";
-        info.dir.copy(directory, file, newFileName);
+        info.dir.copy(directory, file, newFileName, context);
       }
     }
     
@@ -2524,7 +2533,7 @@ public class IndexWriter implements Clos
   
   /** Copies the segment files as-is into the IndexWriter's directory. */
   private void copySegmentAsIs(SegmentInfo info, String segName,
-      Map<String, String> dsNames, Set<String> dsFilesCopied)
+      Map<String, String> dsNames, Set<String> dsFilesCopied, IOContext context)
       throws IOException {
     // Determine if the doc store of this segment needs to be copied. It's
     // only relevant for segments that share doc store with others,
@@ -2560,7 +2569,7 @@ public class IndexWriter implements Clos
       }
       
       assert !directory.fileExists(newFileName): "file \"" + newFileName + "\" already exists";
-      info.dir.copy(directory, file, newFileName);
+      info.dir.copy(directory, file, newFileName, context);
     }
     
     info.setDocStore(info.getDocStoreOffset(), newDsName, info.getDocStoreIsCompoundFile());
@@ -3416,6 +3425,8 @@ public class IndexWriter implements Clos
     int mergedDocCount = 0;
 
     List<SegmentInfo> sourceSegments = merge.segments;
+    
+    IOContext context = new IOContext(merge.getMergeInfo());
 
     SegmentMerger merger = new SegmentMerger(directory, config.getTermIndexInterval(), mergedName, merge,
                                              payloadProcessorProvider, merge.info.getFieldInfos());
@@ -3439,7 +3450,7 @@ public class IndexWriter implements Clos
         // Hold onto the "live" reader; we will use this to
         // commit merged deletes
         final SegmentReader reader = readerPool.get(info, true,
-                                                    MERGE_READ_BUFFER_SIZE,
+                                                    context,
                                                     -config.getReaderTermsIndexDivisor());
         merge.readers.add(reader);
 
@@ -3493,7 +3504,7 @@ public class IndexWriter implements Clos
           if (infoStream != null) {
             message("create compound file " + compoundFileName);
           }
-          merger.createCompoundFile(compoundFileName, merge.info);
+          merger.createCompoundFile(compoundFileName, merge.info, new IOContext(merge.getMergeInfo()));
           success = true;
         } catch (IOException ioe) {
           synchronized(this) {
@@ -3563,7 +3574,9 @@ public class IndexWriter implements Clos
       // keep deletes (it's costly to open entire reader
       // when we just need deletes)
 
-      final SegmentReader mergedReader = readerPool.get(merge.info, loadDocStores, BufferedIndexInput.BUFFER_SIZE, termsIndexDivisor);
+      // nocommit  should we use another flag "isMergedSegment" or a "READ" context here?
+      
+      final SegmentReader mergedReader = readerPool.get(merge.info, loadDocStores, context, termsIndexDivisor);
       try {
         if (poolReaders && mergedSegmentWarmer != null) {
           mergedSegmentWarmer.warm(mergedReader);

Added: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergeInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergeInfo.java?rev=1137639&view=auto
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergeInfo.java (added)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergeInfo.java Mon Jun 20 14:28:24 2011
@@ -0,0 +1,35 @@
+package org.apache.lucene.index;
+/**
+ * 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.
+ */
+//nocommit javadoc
+public class MergeInfo {
+  
+  public int totalDocCount;
+  
+  public long estimatedMergeBytes;  // used by IndexWriter
+  
+  boolean isExternal;               // used by IndexWriter
+  
+  boolean optimize;                 // used by IndexWriter
+
+  public MergeInfo(int totalDocCount, long estimatedMergeBytes, boolean isExternal, boolean optimize) {
+    this.totalDocCount = totalDocCount;
+    this.estimatedMergeBytes = estimatedMergeBytes;
+    this.isExternal = isExternal;
+    this.optimize = optimize;
+  }
+}
\ No newline at end of file

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergePolicy.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergePolicy.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/MergePolicy.java Mon Jun 20 14:28:24 2011
@@ -189,6 +189,10 @@ public abstract class MergePolicy implem
       }
       return total;
     }
+    
+    public MergeInfo getMergeInfo() {
+      return new MergeInfo(totalDocCount, estimatedMergeBytes, isExternal, optimize);
+    }    
   }
 
   /**

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/NormsWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/NormsWriter.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/NormsWriter.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/NormsWriter.java Mon Jun 20 14:28:24 2011
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
 
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.util.IOUtils;
 
@@ -49,7 +50,7 @@ final class NormsWriter extends Inverted
     }
 
     final String normsFileName = IndexFileNames.segmentFileName(state.segmentName, "", IndexFileNames.NORMS_EXTENSION);
-    IndexOutput normsOut = state.directory.createOutput(normsFileName);
+    IndexOutput normsOut = state.directory.createOutput(normsFileName, state.context);
     boolean success = false;
     try {
       normsOut.writeBytes(SegmentNorms.NORMS_HEADER, 0, SegmentNorms.NORMS_HEADER.length);

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/PerFieldCodecWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/PerFieldCodecWrapper.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/PerFieldCodecWrapper.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/PerFieldCodecWrapper.java Mon Jun 20 14:28:24 2011
@@ -99,7 +99,7 @@ final class PerFieldCodecWrapper extends
     private final Map<String, FieldsProducer> codecs = new HashMap<String, FieldsProducer>();
 
     public FieldsReader(Directory dir, FieldInfos fieldInfos, SegmentInfo si,
-        int readBufferSize, int indexDivisor) throws IOException {
+        IOContext context, int indexDivisor) throws IOException {
 
       final Map<Codec, FieldsProducer> producers = new HashMap<Codec, FieldsProducer>();
       boolean success = false;
@@ -111,7 +111,7 @@ final class PerFieldCodecWrapper extends
             Codec codec = segmentCodecs.codecs[fi.getCodecId()];
             if (!producers.containsKey(codec)) {
               producers.put(codec, codec.fieldsProducer(new SegmentReadState(dir,
-                                                                             si, fieldInfos, readBufferSize, indexDivisor, fi.getCodecId())));
+                                                                             si, fieldInfos, context, indexDivisor, fi.getCodecId())));
             }
             codecs.put(fi.name, producers.get(codec));
           }
@@ -187,7 +187,7 @@ final class PerFieldCodecWrapper extends
   public FieldsProducer fieldsProducer(SegmentReadState state)
       throws IOException {
     return new FieldsReader(state.dir, state.fieldInfos, state.segmentInfo,
-        state.readBufferSize, state.termsIndexDivisor);
+        state.context, state.termsIndexDivisor);
   }
 
   @Override
@@ -212,14 +212,14 @@ final class PerFieldCodecWrapper extends
   @Override
   public PerDocValues docsProducer(SegmentReadState state) throws IOException {
     return new PerDocProducers(state.dir, state.fieldInfos, state.segmentInfo,
-    state.readBufferSize, state.termsIndexDivisor);
+    state.context, state.termsIndexDivisor);
   }
   
   private final class PerDocProducers extends PerDocValues {
     private final TreeMap<String, PerDocValues> codecs = new TreeMap<String, PerDocValues>();
 
     public PerDocProducers(Directory dir, FieldInfos fieldInfos, SegmentInfo si,
-        int readBufferSize, int indexDivisor) throws IOException {
+        IOContext context, int indexDivisor) throws IOException {
       final Map<Codec, PerDocValues> producers = new HashMap<Codec, PerDocValues>();
       boolean success = false;
       try {
@@ -229,7 +229,7 @@ final class PerFieldCodecWrapper extends
             Codec codec = segmentCodecs.codecs[fi.getCodecId()];
             if (!producers.containsKey(codec)) {
               producers.put(codec, codec.docsProducer(new SegmentReadState(dir,
-                si, fieldInfos, readBufferSize, indexDivisor, fi.getCodecId())));
+                si, fieldInfos, context, indexDivisor, fi.getCodecId())));
             }
             codecs.put(fi.name, producers.get(codec));
           }

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentCoreReaders.java Mon Jun 20 14:28:24 2011
@@ -45,7 +45,7 @@ final class SegmentCoreReaders {
 
   final Directory dir;
   final Directory cfsDir;
-  final int readBufferSize;
+  final IOContext context;
   final int termsIndexDivisor;
   
   private final SegmentReader owner;
@@ -57,7 +57,7 @@ final class SegmentCoreReaders {
 
   
   
-  SegmentCoreReaders(SegmentReader owner, Directory dir, SegmentInfo si, int readBufferSize, int termsIndexDivisor) throws IOException {
+  SegmentCoreReaders(SegmentReader owner, Directory dir, SegmentInfo si, IOContext context, int termsIndexDivisor) throws IOException {
     
     if (termsIndexDivisor == 0) {
       throw new IllegalArgumentException("indexDivisor must be < 0 (don't load terms index) or greater than 0 (got 0)");
@@ -65,7 +65,7 @@ final class SegmentCoreReaders {
     
     segment = si.name;
     final SegmentCodecs segmentCodecs = si.getSegmentCodecs();
-    this.readBufferSize = readBufferSize;
+    this.context = context;
     this.dir = dir;
     
     boolean success = false;
@@ -73,7 +73,7 @@ final class SegmentCoreReaders {
     try {
       Directory dir0 = dir;
       if (si.getUseCompoundFile()) {
-        cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(segment, "", IndexFileNames.COMPOUND_FILE_EXTENSION), readBufferSize);
+        cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(segment, "", IndexFileNames.COMPOUND_FILE_EXTENSION), context);
         dir0 = cfsReader;
       }
       cfsDir = dir0;
@@ -82,7 +82,7 @@ final class SegmentCoreReaders {
       
       this.termsIndexDivisor = termsIndexDivisor;
       final Codec codec = segmentCodecs.codec();
-      final SegmentReadState segmentReadState = new SegmentReadState(cfsDir, si, fieldInfos, readBufferSize, termsIndexDivisor);
+      final SegmentReadState segmentReadState = new SegmentReadState(cfsDir, si, fieldInfos, context, termsIndexDivisor);
       // Ask codec for its Fields
       fields = codec.fieldsProducer(segmentReadState);
       assert fields != null;
@@ -163,7 +163,7 @@ final class SegmentCoreReaders {
           assert storeCFSReader == null;
           storeCFSReader = new CompoundFileReader(dir,
               IndexFileNames.segmentFileName(si.getDocStoreSegment(), "", IndexFileNames.COMPOUND_FILE_STORE_EXTENSION),
-              readBufferSize);
+              context);
           storeDir = storeCFSReader;
           assert storeDir != null;
         } else {
@@ -175,7 +175,7 @@ final class SegmentCoreReaders {
         // was not used, but then we are asked to open doc
         // stores after the segment has switched to CFS
         if (cfsReader == null) {
-          cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(segment, "", IndexFileNames.COMPOUND_FILE_EXTENSION), readBufferSize);
+          cfsReader = new CompoundFileReader(dir, IndexFileNames.segmentFileName(segment, "", IndexFileNames.COMPOUND_FILE_EXTENSION), context);
         }
         storeDir = cfsReader;
         assert storeDir != null;
@@ -185,7 +185,7 @@ final class SegmentCoreReaders {
       }
       
       final String storesSegment = si.getDocStoreSegment();
-      fieldsReaderOrig = new FieldsReader(storeDir, storesSegment, fieldInfos, readBufferSize,
+      fieldsReaderOrig = new FieldsReader(storeDir, storesSegment, fieldInfos, context,
           si.getDocStoreOffset(), si.docCount);
       
       // Verify two sources of "maxDoc" agree:
@@ -194,7 +194,7 @@ final class SegmentCoreReaders {
       }
       
       if (si.getHasVectors()) { // open term vector files only as needed
-        termVectorsReaderOrig = new TermVectorsReader(storeDir, storesSegment, fieldInfos, readBufferSize, si.getDocStoreOffset(), si.docCount);
+        termVectorsReaderOrig = new TermVectorsReader(storeDir, storesSegment, fieldInfos, context, si.getDocStoreOffset(), si.docCount);
       }
     }
   }

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfo.java Mon Jun 20 14:28:24 2011
@@ -245,7 +245,7 @@ public final class SegmentInfo implement
       }
       final Directory dirToTest;
       if (isCompoundFile) {
-        dirToTest = new CompoundFileReader(dir, IndexFileNames.segmentFileName(storesSegment, "", ext));
+        dirToTest = new CompoundFileReader(dir, IndexFileNames.segmentFileName(storesSegment, "", ext), IOContext.READONCE);
       } else {
         dirToTest = dir;
       }
@@ -264,7 +264,7 @@ public final class SegmentInfo implement
       Directory dir0 = dir;
       if (isCompoundFile && checkCompoundFile) {
         dir0 = new CompoundFileReader(dir, IndexFileNames.segmentFileName(name,
-            "", IndexFileNames.COMPOUND_FILE_EXTENSION));
+            "", IndexFileNames.COMPOUND_FILE_EXTENSION), IOContext.READONCE);
       }
       try {
         fieldInfos = new FieldInfos(dir0, IndexFileNames.segmentFileName(name,

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfos.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfos.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentInfos.java Mon Jun 20 14:28:24 2011
@@ -32,6 +32,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.lucene.index.FieldInfos.FieldNumberBiMap;
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.codecs.CodecProvider;
 import org.apache.lucene.index.codecs.DefaultSegmentInfosWriter;
 import org.apache.lucene.index.codecs.SegmentInfosReader;
@@ -254,7 +255,7 @@ public final class SegmentInfos implemen
 
     try {
       SegmentInfosReader infosReader = codecs.getSegmentInfosReader();
-      infosReader.read(directory, segmentFileName, codecs, this);
+      infosReader.read(directory, segmentFileName, codecs, this, IOContext.READ);
       success = true;
     }
     finally {
@@ -322,7 +323,7 @@ public final class SegmentInfos implemen
 
     try {
       SegmentInfosWriter infosWriter = codecs.getSegmentInfosWriter();
-      segnOutput = infosWriter.writeInfos(directory, segmentFileName, this);
+      segnOutput = infosWriter.writeInfos(directory, segmentFileName, this, IOContext.DEFAULT);
       infosWriter.prepareCommit(segnOutput);
       pendingSegnOutput = segnOutput;
       success = true;
@@ -597,7 +598,7 @@ public final class SegmentInfos implemen
           for(int i=0;i<defaultGenFileRetryCount;i++) {
             IndexInput genInput = null;
             try {
-              genInput = directory.openInput(IndexFileNames.SEGMENTS_GEN);
+              genInput = directory.openInput(IndexFileNames.SEGMENTS_GEN, IOContext.READONCE);
             } catch (FileNotFoundException e) {
               if (infoStream != null) {
                 message("segments.gen open: FileNotFoundException " + e);
@@ -814,7 +815,7 @@ public final class SegmentInfos implemen
   }
   
   private final long writeGlobalFieldMap(FieldNumberBiMap map, Directory dir, String name) throws IOException {
-    final IndexOutput output = dir.createOutput(name);
+    final IndexOutput output = dir.createOutput(name, IOContext.READONCE);
     boolean success = false;
     long version;
     try {
@@ -843,7 +844,7 @@ public final class SegmentInfos implemen
   
   private void readGlobalFieldMap(FieldNumberBiMap map, Directory dir) throws IOException {
     final String name = getGlobalFieldNumberName(lastGlobalFieldMapVersion);
-    final IndexInput input = dir.openInput(name);
+    final IndexInput input = dir.openInput(name, IOContext.READONCE);
     try {
       map.read(input);
     } finally {
@@ -934,7 +935,7 @@ public final class SegmentInfos implemen
     }
 
     try {
-      IndexOutput genOutput = dir.createOutput(IndexFileNames.SEGMENTS_GEN);
+      IndexOutput genOutput = dir.createOutput(IndexFileNames.SEGMENTS_GEN, IOContext.READONCE);
       try {
         genOutput.writeInt(FORMAT_SEGMENTS_GEN_CURRENT);
         genOutput.writeLong(generation);

Modified: lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentMerger.java?rev=1137639&r1=1137638&r2=1137639&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentMerger.java (original)
+++ lucene/dev/branches/LUCENE2793/lucene/src/java/org/apache/lucene/index/SegmentMerger.java Mon Jun 20 14:28:24 2011
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.List;
 
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.IOContext.Context;
 import org.apache.lucene.index.IndexReader.FieldOption;
 import org.apache.lucene.index.MergePolicy.MergeAbortedException;
 import org.apache.lucene.index.codecs.Codec;
@@ -127,12 +128,12 @@ final class SegmentMerger {
    * deletion files, this SegmentInfo must not reference such files when this
    * method is called, because they are not allowed within a compound file.
    */
-  final Collection<String> createCompoundFile(String fileName, final SegmentInfo info)
+  final Collection<String> createCompoundFile(String fileName, final SegmentInfo info, IOContext context)
           throws IOException {
 
     // Now merge all added files
     Collection<String> files = info.files();
-    CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, fileName, checkAbort);
+    CompoundFileWriter cfsWriter = new CompoundFileWriter(directory, fileName, context, checkAbort);
     for (String file : files) {
       assert !IndexFileNames.matchesExtension(file, IndexFileNames.DELETES_EXTENSION) 
                 : ".del file is not allowed in .cfs: " + file;
@@ -232,8 +233,8 @@ final class SegmentMerger {
     int docCount = 0;
 
     setMatchingSegmentReaders();
-
-    final FieldsWriter fieldsWriter = new FieldsWriter(directory, segment);
+    // nocommit - should we rather use IOContext.MERGE here?
+    final FieldsWriter fieldsWriter = new FieldsWriter(directory, segment, IOContext.DEFAULT);
 
     try {
       int idx = 0;
@@ -268,8 +269,8 @@ final class SegmentMerger {
       // entering the index.  See LUCENE-1282 for
       // details.
       throw new RuntimeException("mergeFields produced an invalid result: docCount is " + docCount + " but fdx file size is " + fdxFileLength + " file=" + fileName + " file exists?=" + directory.fileExists(fileName) + "; now aborting this merge to prevent index corruption");
-
-    segmentWriteState = new SegmentWriteState(null, directory, segment, fieldInfos, docCount, termIndexInterval, codecInfo, null);
+    //nocommit if Merge then what to initialize OneMerge with ?
+    segmentWriteState = new SegmentWriteState(null, directory, segment, fieldInfos, docCount, termIndexInterval, codecInfo, null, IOContext.DEFAULT);
 
     return docCount;
   }
@@ -354,8 +355,9 @@ final class SegmentMerger {
    * @throws IOException
    */
   private final void mergeVectors() throws IOException {
+    //nocommit Putting MERGE context here would lead to assert error. What should MergeInfo be initialized with here?
     TermVectorsWriter termVectorsWriter =
-      new TermVectorsWriter(directory, segment, fieldInfos);
+      new TermVectorsWriter(directory, segment, fieldInfos, new IOContext(Context.DEFAULT));
 
     try {
       int idx = 0;
@@ -614,7 +616,8 @@ final class SegmentMerger {
       for (FieldInfo fi : fieldInfos) {
         if (fi.isIndexed && !fi.omitNorms) {
           if (output == null) {
-            output = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.NORMS_EXTENSION));
+            //nocommit Putting MERGE context here would lead to assert error. What should MergeInfo be initialized with here?
+            output = directory.createOutput(IndexFileNames.segmentFileName(segment, "", IndexFileNames.NORMS_EXTENSION), new IOContext(Context.DEFAULT));
             output.writeBytes(SegmentNorms.NORMS_HEADER, SegmentNorms.NORMS_HEADER.length);
           }
           for (IndexReader reader : readers) {



Mime
View raw message