Example usage for org.apache.hadoop.io BytesWritable getCapacity

List of usage examples for org.apache.hadoop.io BytesWritable getCapacity

Introduction

In this page you can find the example usage for org.apache.hadoop.io BytesWritable getCapacity.

Prototype

public int getCapacity() 

Source Link

Document

Get the capacity, which is the maximum size that could handled without resizing the backing storage.

Usage

From source file:com.liveramp.cascading_ext.Bytes.java

License:Apache License

public static byte[] getBytes(BytesWritable bw) {
    if (bw.getCapacity() == bw.getLength()) {
        return bw.getBytes();
    } else {//from w  w w.j a v a2s .c o  m
        return copyBytes(bw);
    }
}

From source file:voldemort.store.readonly.mr.utils.HadoopUtils.java

License:Apache License

/**
 * Tag the BytesWritable with an integer at the END
 *///  w  w  w. j  a v a  2s .co  m
public static void appendTag(BytesWritable writable, int tag) {
    int size = writable.getLength();

    if (writable.getCapacity() < size + 4) {
        // BytesWritable preserves old values
        writable.setCapacity(size + 4);
    }

    ByteUtils.writeInt(writable.getBytes(), tag, size);
    writable.setSize(size + 4);
}