Example usage for org.apache.lucene.store DataInput readZInt

List of usage examples for org.apache.lucene.store DataInput readZInt

Introduction

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

Prototype

public int readZInt() throws IOException 

Source Link

Document

Read a BitUtil#zigZagDecode(int) zig-zag -encoded #readVInt() variable-length integer.

Usage

From source file:com.github.cstoku.neologd.unidic.lucene.analysis.ja.dict.ConnectionCosts.java

License:Apache License

private ConnectionCosts() throws IOException {
    InputStream is = null;/*  w  ww .  j  a  v a  2  s .c  o  m*/
    short[][] costs = null;
    boolean success = false;
    try {
        is = BinaryDictionary.getClassResource(getClass(), FILENAME_SUFFIX);
        is = new BufferedInputStream(is);
        final DataInput in = new InputStreamDataInput(is);
        CodecUtil.checkHeader(in, HEADER, VERSION, VERSION);
        int forwardSize = in.readVInt();
        int backwardSize = in.readVInt();
        costs = new short[backwardSize][forwardSize];
        int accum = 0;
        for (int j = 0; j < costs.length; j++) {
            final short[] a = costs[j];
            for (int i = 0; i < a.length; i++) {
                accum += in.readZInt();
                a[i] = (short) accum;
            }
        }
        success = true;
    } finally {
        if (success) {
            IOUtils.close(is);
        } else {
            IOUtils.closeWhileHandlingException(is);
        }
    }

    this.costs = costs;
}