Example usage for org.apache.spark.unsafe.types UTF8String numBytes

List of usage examples for org.apache.spark.unsafe.types UTF8String numBytes

Introduction

In this page you can find the example usage for org.apache.spark.unsafe.types UTF8String numBytes.

Prototype

int numBytes

To view the source code for org.apache.spark.unsafe.types UTF8String numBytes.

Click Source Link

Usage

From source file:com.github.sadikovi.riff.stats.UTF8Statistics.java

License:Open Source License

/**
 * Return deep copy of UTF8String, this method forcefully copies `getBytes()` bytes in
 * UTF8String, since it does not return copy when backed by single array.
 * Clone is null safe, and would return null for null input.
 * @param str UTF8 string to clone/*from   w  ww.  ja va 2 s  .c o m*/
 * @return copy
 */
private UTF8String clone(UTF8String str) {
    if (str == null)
        return null;
    byte[] bytes = new byte[str.numBytes()];
    System.arraycopy(str.getBytes(), 0, bytes, 0, bytes.length);
    return UTF8String.fromBytes(bytes);
}