Java Code Examples for java.nio.MappedByteBuffer#asIntBuffer()
The following examples show how to use
java.nio.MappedByteBuffer#asIntBuffer() .
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 |
@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 |
@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 |
@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 |
@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; }