Example usage for org.apache.lucene.store IndexInput readShort

List of usage examples for org.apache.lucene.store IndexInput readShort

Introduction

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

Prototype

public short readShort() throws IOException 

Source Link

Document

Reads two bytes and returns a short.

Usage

From source file:com.bah.lucene.blockcache_v2.CacheIndexInputTest.java

License:Apache License

public static void readRandomDataShort(IndexInput baseInput, IndexInput testInput, Random random,
        int sampleSize) throws IOException {
    assertEquals(baseInput.length(), testInput.length());
    int fileLength = (int) baseInput.length();
    for (int i = 0; i < sampleSize; i++) {
        int position = random.nextInt(fileLength - 2);
        baseInput.seek(position);/*from  w  w  w .  j  ava 2  s  . c  o  m*/
        short i1 = baseInput.readShort();
        testInput.seek(position);
        short i2 = testInput.readShort();
        assertEquals("Read [" + i + "] The position is [" + position + "]", i1, i2);
    }
}

From source file:org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectoryTest.java

License:Apache License

private void assertClosed(IndexInput input) throws IOException {
    try {//w  w w  .j ava 2  s .c  o m
        input.length();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.seek(0);
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.getFilePointer();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readInt();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readShort();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readLong();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readByte();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readString();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readStringSet();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readStringStringMap();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readVInt();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readVLong();
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readBytes(null, 0, 0);
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
    try {
        input.readBytes(null, 0, 0, false);
        fail("cannot use IndexInput once closed");
    } catch (AlreadyClosedException e) {
        // expected exception
    }
}