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

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

Introduction

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

Prototype

public void writeBytes(byte[] b, int length) throws IOException 

Source Link

Document

Writes an array of bytes.

Usage

From source file:it.agilelab.bigdata.spark.search.impl.BigChunksRAMOutputStream.java

License:Apache License

/** Copy the current contents of this buffer to the named output. */
public void writeTo(DataOutput out) throws IOException {
    flush();/* w  w w  .  j a v a 2 s .  c  o m*/
    final long end = file.length;
    long pos = 0;
    int buffer = 0;
    while (pos < end) {
        int length = BUFFER_SIZE;
        long nextPos = pos + length;
        if (nextPos > end) { // at the last buffer
            length = (int) (end - pos);
        }
        out.writeBytes(file.getBuffer(buffer++), length);
        pos = nextPos;
    }
}