org.apache.blur.lucene.warmup
Class IndexWarmup

java.lang.Object
  extended by org.apache.blur.lucene.warmup.IndexWarmup

public class IndexWarmup
extends Object

IndexWarmup is used to pre-read portions of the index by field. Usage:

int maxSampleSize = 1000;
Directory dir = FSDirectory.open(new File("/path/index"));
dir = new TraceableDirectory(dir);
DirectoryReader reader = DirectoryReader.open(dir);

IndexWarmup indexWarmup = new IndexWarmup(new AtomicBoolean());
Map<String, List<IndexTracerResult>> sampleIndex = indexWarmup.sampleIndex(reader, "");
indexWarmup.warm(reader, sampleIndex, "uuid", null);
indexWarmup.warm(reader, sampleIndex, "test", "test");
indexWarmup.warm(reader, sampleIndex, "nothing", null);
indexWarmup.warm(reader, sampleIndex, "id2", "tst");


Constructor Summary
IndexWarmup(java.util.concurrent.atomic.AtomicBoolean isClosed, java.util.concurrent.atomic.AtomicBoolean stop, int maxSampleSize)
           
IndexWarmup(java.util.concurrent.atomic.AtomicBoolean isClosed, java.util.concurrent.atomic.AtomicBoolean stop, int maxSampleSize, long maxBytesPerSec)
           
 
Method Summary
static void disableRunTrace()
           
static void enableRunTrace()
           
 void getFilePositionsToWarm(org.apache.lucene.index.IndexReader reader, List<IndexTracerResult> traces, String fieldName, String context, Map<String,org.apache.lucene.util.OpenBitSet> filePartsToWarm, int blockSize)
           
 void getFilePositionsToWarm(org.apache.lucene.index.IndexReader reader, Map<String,List<IndexTracerResult>> sampleIndex, String fieldName, String context, Map<String,org.apache.lucene.util.OpenBitSet> filePartsToWarm, int blockSize)
           
static String getSampleFileName(String segmentName)
           
static boolean isRunTrace()
           
 Map<String,List<IndexTracerResult>> sampleIndex(org.apache.lucene.index.AtomicReader atomicReader, String context)
           
 Map<String,List<IndexTracerResult>> sampleIndex(org.apache.lucene.index.IndexReader reader, String context)
           
 void warmFile(org.apache.lucene.index.IndexReader reader, Map<String,List<IndexTracerResult>> sampleIndex, String fieldName, String context)
           
 void warmFile(org.apache.lucene.index.IndexReader indexReader, Map<String,org.apache.lucene.util.OpenBitSet> filePartsToWarm, String context, int blockSize, int bufferSize)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexWarmup

public IndexWarmup(java.util.concurrent.atomic.AtomicBoolean isClosed,
                   java.util.concurrent.atomic.AtomicBoolean stop,
                   int maxSampleSize,
                   long maxBytesPerSec)

IndexWarmup

public IndexWarmup(java.util.concurrent.atomic.AtomicBoolean isClosed,
                   java.util.concurrent.atomic.AtomicBoolean stop,
                   int maxSampleSize)
Method Detail

isRunTrace

public static boolean isRunTrace()

enableRunTrace

public static void enableRunTrace()

disableRunTrace

public static void disableRunTrace()

warmFile

public void warmFile(org.apache.lucene.index.IndexReader reader,
                     Map<String,List<IndexTracerResult>> sampleIndex,
                     String fieldName,
                     String context)
              throws IOException
Throws:
IOException

getFilePositionsToWarm

public void getFilePositionsToWarm(org.apache.lucene.index.IndexReader reader,
                                   Map<String,List<IndexTracerResult>> sampleIndex,
                                   String fieldName,
                                   String context,
                                   Map<String,org.apache.lucene.util.OpenBitSet> filePartsToWarm,
                                   int blockSize)
                            throws IOException
Throws:
IOException

getFilePositionsToWarm

public void getFilePositionsToWarm(org.apache.lucene.index.IndexReader reader,
                                   List<IndexTracerResult> traces,
                                   String fieldName,
                                   String context,
                                   Map<String,org.apache.lucene.util.OpenBitSet> filePartsToWarm,
                                   int blockSize)
                            throws IOException
Throws:
IOException

sampleIndex

public Map<String,List<IndexTracerResult>> sampleIndex(org.apache.lucene.index.IndexReader reader,
                                                       String context)
                                                throws IOException
Throws:
IOException

sampleIndex

public Map<String,List<IndexTracerResult>> sampleIndex(org.apache.lucene.index.AtomicReader atomicReader,
                                                       String context)
                                                throws IOException
Throws:
IOException

getSampleFileName

public static String getSampleFileName(String segmentName)

warmFile

public void warmFile(org.apache.lucene.index.IndexReader indexReader,
                     Map<String,org.apache.lucene.util.OpenBitSet> filePartsToWarm,
                     String context,
                     int blockSize,
                     int bufferSize)
              throws IOException
Throws:
IOException


Copyright © 2012-2014 The Apache Software Foundation. All Rights Reserved.