Java Code Examples for com.google.common.io.Files#map()

The following examples show how to use com.google.common.io.Files#map() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileSerializationBenchmark.java    From imhotep with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(int[] a, File file) throws IOException {
    MappedByteBuffer buffer = Files.map(file, FileChannel.MapMode.READ_WRITE, a.length * 4);
    buffer.order(ByteOrder.BIG_ENDIAN);
    IntBuffer intBuffer = buffer.asIntBuffer();
    for (int i = 0; i < a.length; ++i) {
        intBuffer.put(i, a[i]);
    }
}
 
Example 2
Source File: FileSerializationBenchmark.java    From imhotep with Apache License 2.0 5 votes vote down vote up
@Override
public int[] deserialize(File file) throws IOException {
    MappedByteBuffer buffer = Files.map(file, FileChannel.MapMode.READ_ONLY, file.length());
    buffer.order(ByteOrder.BIG_ENDIAN);
    IntBuffer intBuffer = buffer.asIntBuffer();
    int[] ret = new int[(int)(file.length() / 4)];
    intBuffer.get(ret);
    return ret;
}
 
Example 3
Source File: FileSerializationBenchmark.java    From imhotep with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(int[] a, File file) throws IOException {
    MappedByteBuffer buffer = Files.map(file, FileChannel.MapMode.READ_WRITE, a.length * 4);
    buffer.order(ByteOrder.LITTLE_ENDIAN);
    IntBuffer intBuffer = buffer.asIntBuffer();
    for (int i = 0; i < a.length; ++i) {
        intBuffer.put(i, a[i]);
    }
}
 
Example 4
Source File: FileSerializationBenchmark.java    From imhotep with Apache License 2.0 5 votes vote down vote up
@Override
public int[] deserialize(File file) throws IOException {
    MappedByteBuffer buffer = Files.map(file, FileChannel.MapMode.READ_ONLY, file.length());
    buffer.order(ByteOrder.LITTLE_ENDIAN);
    IntBuffer intBuffer = buffer.asIntBuffer();
    int[] ret = new int[(int)(file.length() / 4)];
    intBuffer.get(ret);
    return ret;
}
 
Example 5
Source File: FragmentData.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public FragmentData(FragmentMetaInfo fragmentMetaInfo, File fragmentDataFile) throws IOException {
    this.dictionaryMap = Maps.newConcurrentMap();
    this.fragmentMetaInfo = fragmentMetaInfo;
    this.fragmentDataFile = fragmentDataFile;
    this.dataBuffer = Files.map(fragmentDataFile, FileChannel.MapMode.READ_ONLY);
}