Example usage for org.apache.lucene.store DataOutput writeVLong

List of usage examples for org.apache.lucene.store DataOutput writeVLong

Introduction

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

Prototype

public final void writeVLong(long i) throws IOException 

Source Link

Document

Writes an long in a variable-length format.

Usage

From source file:com.lucure.core.codec.LucurePostingsWriter.java

License:Apache License

@Override
public void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState _state,
        boolean absolute) throws IOException {
    IntBlockTermState state = (IntBlockTermState) _state;
    if (absolute) {
        lastState = emptyState;// w  ww. ja v a 2s.  c  o m
    }
    longs[0] = state.docStartFP - lastState.docStartFP;
    if (fieldHasPositions) {
        longs[1] = state.posStartFP - lastState.posStartFP;
        if (fieldHasPayloads || fieldHasOffsets) {
            longs[2] = state.payStartFP - lastState.payStartFP;
        }
    }
    if (state.singletonDocID != -1) {
        out.writeVInt(state.singletonDocID);
    }
    if (fieldHasPositions) {
        if (state.lastPosBlockOffset != -1) {
            out.writeVLong(state.lastPosBlockOffset);
        }
    }
    if (state.skipOffset != -1) {
        out.writeVLong(state.skipOffset);
    }
    lastState = state;
}

From source file:com.sindicetech.siren.index.codecs.siren10.Siren10PostingsWriter.java

License:Open Source License

@Override
public void encodeTerm(final long[] longs, final DataOutput out, final FieldInfo fieldInfo,
        final BlockTermState _state, final boolean absolute) throws IOException {
    Siren10TermState state = (Siren10TermState) _state;

    if (absolute) {
        lastSkipFP = 0;/*  w ww .j  a v  a 2 s .co  m*/
        lastState = state;
    }

    // write block count stat
    // logger.debug("Write blockCount: {}", state.blockCount);
    out.writeVInt(state.blockCount);

    lastState.docIndex.copyFrom(state.docIndex, false);
    lastState.docIndex.write(out, absolute);

    if (state.skipFP != -1) {
        if (absolute) {
            out.writeVLong(state.skipFP);
        } else {
            out.writeVLong(state.skipFP - lastSkipFP);
        }
        lastSkipFP = state.skipFP;
    }
}