Example usage for org.apache.lucene.store IOContext IOContext

List of usage examples for org.apache.lucene.store IOContext IOContext

Introduction

In this page you can find the example usage for org.apache.lucene.store IOContext IOContext.

Prototype

public IOContext(MergeInfo mergeInfo) 

Source Link

Usage

From source file:com.github.lucene.store.database.DatabaseDirectoryITest.java

License:Apache License

@Test
public void createInput_whenFileNotFound_shouldReturnIndexInputWhenZeroLength() throws IOException {
    final IndexInput indexInput = directory.openInput("notfound", new IOContext(Context.READ));
    Assert.assertEquals(0l, indexInput.length());
}

From source file:com.github.lucene.store.database.DatabaseDirectoryITest.java

License:Apache License

@Test
public void createInput_whenFileFound_shouldReturnIndexInputWhenZeroLength() throws IOException {
    addContentIndexOutput(directory, "test1", "TEST STRING", Context.FLUSH);
    final IndexInput indexInput = directory.openInput("test1", new IOContext(Context.READ));
    Assert.assertNotEquals(0l, indexInput.length());
}

From source file:com.github.lucene.store.database.DatabaseDirectoryITest.java

License:Apache License

private void addContentIndexOutput(final Directory directory, final String fileName, final String content,
        final Context context) throws IOException {
    IOContext ioContext = null;//from w  ww. ja  v a 2  s .  co  m
    switch (context) {
    case FLUSH:
        ioContext = new IOContext(new FlushInfo(1, 1));
        break;
    case MERGE:
        ioContext = new IOContext(new MergeInfo(1, 1, false, 1));
        break;
    default:
        ioContext = new IOContext(context);
        break;
    }
    final IndexOutput indexOutput = directory.createOutput(fileName, ioContext);
    indexOutput.writeString(content);
    indexOutput.close();
}

From source file:org.apache.solr.store.blockcache.BlockDirectoryTest.java

License:Apache License

/**
 * Verify the configuration options for the block cache are handled
 * appropriately./*  w  w w.j a v a2 s. c  o  m*/
 */
@Test
public void ensureCacheConfigurable() throws Exception {
    IOContext mergeContext = new IOContext(new MergeInfo(1, 1, false, 1));

    BlockDirectory d = directory;
    assertTrue(d.useReadCache("", IOContext.DEFAULT));
    assertTrue(d.useWriteCache("", IOContext.DEFAULT));
    assertFalse(d.useWriteCache("", mergeContext));

    d = new BlockDirectory("test", directory, mapperCache, null, true, false);
    assertTrue(d.useReadCache("", IOContext.DEFAULT));
    assertFalse(d.useWriteCache("", IOContext.DEFAULT));
    assertFalse(d.useWriteCache("", mergeContext));

    d = new BlockDirectory("test", directory, mapperCache, null, false, true);
    assertFalse(d.useReadCache("", IOContext.DEFAULT));
    assertTrue(d.useWriteCache("", IOContext.DEFAULT));
    assertFalse(d.useWriteCache("", mergeContext));
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.LuceneConfigurationTest.java

License:Mozilla Public License

public @Bean Directory trainingSetDirectory() throws IOException {
    FSDirectory directory = FSDirectory.open(Paths.get(trainingSetCollectionPath));
    return new RAMDirectory(directory, new IOContext(Context.DEFAULT));
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.config.LuceneConfigurationTest.java

License:Mozilla Public License

public @Bean Directory iaViewDirectory() throws IOException {
    FSDirectory directory = FSDirectory.open(Paths.get(iaviewCollectionPath));
    return new RAMDirectory(directory, new IOContext(Context.DEFAULT));
}