Example usage for org.apache.cassandra.io.util Memory setLong

List of usage examples for org.apache.cassandra.io.util Memory setLong

Introduction

In this page you can find the example usage for org.apache.cassandra.io.util Memory setLong.

Prototype

public void setLong(long offset, long l) 

Source Link

Usage

From source file:com.fullcontact.cassandra.io.compress.CompressionMetadata.java

License:Apache License

/**
 * Read offsets of the individual chunks from the given input.
 *
 * @param input Source of the data.//from   w w  w .  j  a  va2s .c  o  m
 * @return collection of the chunk offsets.
 */
private Memory readChunkOffsets(DataInput input) {
    try {
        int chunkCount = input.readInt();
        Memory offsets = Memory.allocate(chunkCount * 8);

        for (int i = 0; i < chunkCount; i++) {
            try {
                offsets.setLong(i * 8, input.readLong());
            } catch (EOFException e) {
                String msg = String.format("Corrupted Index File %s: read %d but expected %d chunks.",
                        indexFilePath, i, chunkCount);
                throw new CorruptSSTableException(new IOException(msg, e), indexFilePath);
            }
        }

        return offsets;
    } catch (IOException e) {
        throw new FSReadError(e, indexFilePath);
    }
}