Index: lucene/src/java/org/apache/lucene/index/IOContext.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/IOContext.java	(revision 0)
+++ lucene/src/java/org/apache/lucene/index/IOContext.java	(revision 0)
@@ -0,0 +1,30 @@
+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.
+ */
+public class IOContext {
+  
+  public enum Context {merge,search};
+  public int bufferSize;
+  public boolean DIRECT=false;
+  public boolean SEQUENTIAL=false;
+}
+  
Index: lucene/src/java/org/apache/lucene/store/NIOFSDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/NIOFSDirectory.java	(revision 1128825)
+++ lucene/src/java/org/apache/lucene/store/NIOFSDirectory.java	(working copy)
@@ -23,6 +23,7 @@
 import java.nio.channels.ClosedChannelException; // javadoc @link
 import java.nio.channels.FileChannel;
 import java.util.concurrent.Future; // javadoc
+import org.apache.lucene.index.IOContext;
 
 /**
  * An {@link FSDirectory} implementation that uses java.nio's FileChannel's
@@ -73,7 +74,7 @@
 
   /** Creates an IndexInput for the file with the given name. */
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, int bufferSize,IOContext context) throws IOException {
     ensureOpen();
     return new NIOFSIndexInput(new File(getDirectory(), name), bufferSize, getReadChunkSize());
   }
@@ -178,4 +179,5 @@
       }
     }
   }
+
 }
Index: lucene/src/java/org/apache/lucene/store/MMapDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/MMapDirectory.java	(revision 1128825)
+++ lucene/src/java/org/apache/lucene/store/MMapDirectory.java	(working copy)
@@ -31,6 +31,7 @@
 import java.security.PrivilegedActionException;
 import java.lang.reflect.Method;
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.util.Constants;
 
 /** File-based {@link Directory} implementation that uses
@@ -201,7 +202,7 @@
 
   /** Creates an IndexInput for the file with the given name. */
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, int bufferSize,IOContext context) throws IOException {
     ensureOpen();
     File f = new File(getDirectory(), name);
     RandomAccessFile raf = new RandomAccessFile(f, "r");
@@ -477,4 +478,5 @@
       }
     }
   }
+
 }
Index: lucene/src/java/org/apache/lucene/store/Directory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/Directory.java	(revision 1128825)
+++ lucene/src/java/org/apache/lucene/store/Directory.java	(working copy)
@@ -22,6 +22,7 @@
 import java.io.Closeable;
 import java.util.Collection; // for javadocs
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.util.IOUtils;
 
 /** A Directory is a flat list of files.  Files may be written once, when they
@@ -52,7 +53,7 @@
    * Returns an array of strings, one for each file in the directory.
    * 
    * @throws NoSuchDirectoryException if the directory is not prepared for any
-   *         write operations (such as {@link #createOutput(String)}).
+   *         write operations (such as {@link #createOutput(String,IOContext)}).
    * @throws IOException in case of other IO errors
    */
   public abstract String[] listAll() throws IOException;
@@ -87,7 +88,7 @@
 
   /** Creates a new, empty file in the directory with the given name.
       Returns a stream writing this file. */
-  public abstract IndexOutput createOutput(String name)
+  public abstract IndexOutput createOutput(String name,IOContext context)
        throws IOException;
 
   /**
@@ -104,7 +105,7 @@
   public abstract void sync(Collection<String> names) throws IOException;
 
   /** Returns a stream reading an existing file. */
-  public abstract IndexInput openInput(String name)
+  public abstract IndexInput openInput(String name,IOContext context)
     throws IOException;
 
   /** Returns a stream reading an existing file, with the
@@ -114,8 +115,8 @@
    * parameter are {@link FSDirectory} and {@link
    * org.apache.lucene.index.CompoundFileReader}.
   */
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
-    return openInput(name);
+  public IndexInput openInput(String name,int bufferSize, IOContext context) throws IOException {
+    return openInput(name,context);
   }
 
   /** Construct a {@link Lock}.
@@ -199,9 +200,9 @@
    * <b>NOTE:</b> this method does not check whether <i>dest<i> exist and will
    * overwrite it if it does.
    */
-  public void copy(Directory to, String src, String dest) throws IOException {
-    IndexOutput os = to.createOutput(dest);
-    IndexInput is = openInput(src);
+  public void copy(Directory to, String src, String dest,IOContext context) throws IOException {
+    IndexOutput os = to.createOutput(dest,context);
+    IndexInput is = openInput(src,context);
     IOException priorException = null;
     try {
       is.copyBytes(os, is.length());
Index: lucene/src/java/org/apache/lucene/store/RAMDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/RAMDirectory.java	(revision 1128825)
+++ lucene/src/java/org/apache/lucene/store/RAMDirectory.java	(working copy)
@@ -27,6 +27,8 @@
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.apache.lucene.index.IOContext;
+
 /**
  * A memory-resident {@link Directory} implementation.  Locking
  * implementation is by default the {@link SingleInstanceLockFactory}
@@ -38,7 +40,7 @@
   
   // *****
   // Lock acquisition sequence:  RAMDirectory, then RAMFile
-  // *****
+  // ***** 
 
   /** Constructs an empty {@link Directory}. */
   public RAMDirectory() {
@@ -65,14 +67,14 @@
    * @param dir a <code>Directory</code> value
    * @exception IOException if an error occurs
    */
-  public RAMDirectory(Directory dir) throws IOException {
-    this(dir, false);
+  public RAMDirectory(Directory dir,IOContext context) throws IOException {
+    this(dir, false,context);    
   }
   
-  private RAMDirectory(Directory dir, boolean closeDir) throws IOException {
+  private RAMDirectory(Directory dir, boolean closeDir,IOContext context) throws IOException {
     this();
     for (String file : dir.listAll()) {
-      dir.copy(this, file, file);
+      dir.copy(this, file, file,context);
     }
     if (closeDir) {
       dir.close();
@@ -149,7 +151,7 @@
 
   /** Creates a new, empty file in the directory with the given name. Returns a stream writing this file. */
   @Override
-  public IndexOutput createOutput(String name) throws IOException {
+  public IndexOutput createOutput(String name,IOContext context) throws IOException {
     ensureOpen();
     RAMFile file = newRAMFile();
     RAMFile existing = fileMap.remove(name);
@@ -176,7 +178,7 @@
 
   /** Returns a stream reading an existing file. */
   @Override
-  public IndexInput openInput(String name) throws IOException {
+  public IndexInput openInput(String name,IOContext context) throws IOException {
     ensureOpen();
     RAMFile file = fileMap.get(name);
     if (file == null) {
Index: lucene/src/java/org/apache/lucene/store/SimpleFSDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/SimpleFSDirectory.java	(revision 1128825)
+++ lucene/src/java/org/apache/lucene/store/SimpleFSDirectory.java	(working copy)
@@ -21,6 +21,8 @@
 import java.io.IOException;
 import java.io.RandomAccessFile;
 
+import org.apache.lucene.index.IOContext;
+
 /** A straightforward implementation of {@link FSDirectory}
  *  using java.io.RandomAccessFile.  However, this class has
  *  poor concurrent performance (multiple threads will
@@ -51,7 +53,7 @@
 
   /** Creates an IndexInput for the file with the given name. */
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, int bufferSize,IOContext context) throws IOException {
     ensureOpen();
     return new SimpleFSIndexInput(new File(directory, name), bufferSize, getReadChunkSize());
   }
Index: lucene/src/java/org/apache/lucene/store/FSDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/FSDirectory.java	(revision 1128825)
+++ lucene/src/java/org/apache/lucene/store/FSDirectory.java	(working copy)
@@ -31,6 +31,7 @@
 import java.util.Set;
 import java.util.concurrent.Future;
 
+import org.apache.lucene.index.IOContext;
 import org.apache.lucene.util.ThreadInterruptedException;
 import org.apache.lucene.util.Constants;
 
@@ -297,7 +298,7 @@
 
   /** Creates an IndexOutput for the file with the given name. */
   @Override
-  public IndexOutput createOutput(String name) throws IOException {
+  public IndexOutput createOutput(String name,IOContext context) throws IOException {
     ensureOpen();
 
     ensureCanWrite(name);
@@ -332,9 +333,9 @@
 
   // Inherit javadoc
   @Override
-  public IndexInput openInput(String name) throws IOException {
+  public IndexInput openInput(String name,IOContext context) throws IOException {
     ensureOpen();
-    return openInput(name, BufferedIndexInput.BUFFER_SIZE);
+    return openInput(name, BufferedIndexInput.BUFFER_SIZE,context);
   }
 
   /**
Index: lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java
===================================================================
--- lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java	(revision 1128825)
+++ lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java	(working copy)
@@ -19,6 +19,8 @@
 
 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,7 +69,7 @@
   }
 
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, int bufferSize,IOContext context) throws IOException {
     ensureOpen();
     return new WindowsIndexInput(new File(getDirectory(), name), Math.max(bufferSize, DEFAULT_BUFFERSIZE));
   }
Index: lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java
===================================================================
--- lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java	(revision 1128825)
+++ lucene/contrib/misc/src/java/org/apache/lucene/store/NRTCachingDirectory.java	(working copy)
@@ -24,6 +24,7 @@
 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.MergePolicy;
@@ -81,6 +82,8 @@
 
 public class NRTCachingDirectory extends Directory {
 
+  private final IOContext context=new IOContext();
+  
   private final RAMDirectory cache = new RAMDirectory();
 
   private final Directory delegate;
@@ -158,7 +161,7 @@
   }
 
   @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);
     }
@@ -166,9 +169,9 @@
       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);
     }
   }
 
@@ -184,7 +187,7 @@
   }
 
   @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);
     }
@@ -192,18 +195,18 @@
       if (VERBOSE) {
         System.out.println("  from cache");
       }
-      return cache.openInput(name);
+      return cache.openInput(name,context);
     } else {
-      return delegate.openInput(name);
+      return delegate.openInput(name,context);
     }
   }
 
   @Override
-  public synchronized IndexInput openInput(String name, int bufferSize) throws IOException {
+  public synchronized IndexInput openInput(String name, int bufferSize,IOContext context) throws IOException {
     if (cache.fileExists(name)) {
-      return cache.openInput(name, bufferSize);
+      return cache.openInput(name, bufferSize,context);
     } else {
-      return delegate.openInput(name, bufferSize);
+      return delegate.openInput(name, bufferSize,context);
     }
   }
 
@@ -257,7 +260,7 @@
     synchronized(this) {
       if (!delegate.fileExists(fileName)) {
         assert cache.fileExists(fileName);
-        out = delegate.createOutput(fileName);
+        out = delegate.createOutput(fileName,context);
       } else {
         out = null;
       }
@@ -266,7 +269,7 @@
     if (out != null) {
       IndexInput in = null;
       try {
-        in = cache.openInput(fileName);
+        in = cache.openInput(fileName,context);
         in.copyBytes(out, in.length());
       } finally {
         IOUtils.closeSafely(in, out);
Index: lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
===================================================================
--- lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java	(revision 1128825)
+++ lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java	(working copy)
@@ -25,6 +25,7 @@
 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,13 +70,13 @@
   }
 
   @Override
-  public IndexInput openInput(String name, int bufferSize) throws IOException {
+  public IndexInput openInput(String name, int bufferSize,IOContext context) throws IOException {
     ensureOpen();
     return new DirectIOLinuxIndexInput(new File(getDirectory(), name), forcedBufferSize == 0 ? bufferSize : forcedBufferSize);
   }
 
   @Override
-  public IndexOutput createOutput(String name) throws IOException {
+  public IndexOutput createOutput(String name,IOContext context) throws IOException {
     ensureOpen();
     ensureCanWrite(name);
     return new DirectIOLinuxIndexOutput(new File(getDirectory(), name), forcedBufferSize == 0 ? BufferedIndexOutput.BUFFER_SIZE : forcedBufferSize);
