Package org.apache.hadoop.hbase.io.hfile.bucket

Examples of org.apache.hadoop.hbase.io.hfile.bucket.FileIOEngine


  @Test
  public void testFileIOEngine() throws IOException {
    int size = 2 * 1024 * 1024; // 2 MB
    String filePath = "testFileIOEngine";
    try {
      FileIOEngine fileIOEngine = new FileIOEngine(filePath, size);
      for (int i = 0; i < 50; i++) {
        int len = (int) Math.floor(Math.random() * 100);
        long offset = (long) Math.floor(Math.random() * size % (size - len));
        byte[] data1 = new byte[len];
        for (int j = 0; j < data1.length; ++j) {
          data1[j] = (byte) (Math.random() * 255);
        }
        byte[] data2 = new byte[len];
        fileIOEngine.write(ByteBuffer.wrap(data1), offset);
        fileIOEngine.read(ByteBuffer.wrap(data2), offset);
        for (int j = 0; j < data1.length; ++j) {
          assertTrue(data1[j] == data2[j]);
        }
      }
    } finally {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.io.hfile.bucket.FileIOEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.