Package org.apache.hadoop.io.simpleseekableformat

Examples of org.apache.hadoop.io.simpleseekableformat.InterleavedInputStream$MetaDataConsumer


          UtilsForTests.assertArrayEquals("MetaData section", metaDataExpected, metaData);
        }
    };

    // Read from the interleaved data, and verify the data
    InterleavedInputStream inputStream = new InterleavedInputStream(
        new ByteArrayInputStream(interleaved.toByteArray()), metaBlockLength,
        dataBlockLength, myMetaDataConsumer);
    if (readSize == 0) {
      byte[] expected = new byte[1];
      for (int d = 0; d < totalDataLength; d++) {
        UtilsForTests.nextBytes(dataRandom2, expected);
        Assert.assertEquals("Data section byte " + d,
            expected[0] < 0 ? expected[0] + 256 : expected[0],
            inputStream.read());
      }
    } else {
      int read = 0;
      // Note: DataInputStream.close() will close underlying stream, but we are OK because
      // it's ByteArrayInputStream which has a dummy close().
      DataInputStream dataInputStream = new DataInputStream(inputStream);
      while (read < totalDataLength) {
        int toRead = Math.min(readSize, totalDataLength - read);
        byte[] expected = new byte[toRead];
        UtilsForTests.nextBytes(dataRandom2, expected);
        byte[] actual = new byte[toRead];
        dataInputStream.readFully(actual);
        UtilsForTests.assertArrayEquals("Data section", expected, actual);
        read += toRead;
      }
    }

    // Verify EOF
    Assert.assertEquals(-1, inputStream.read());
    byte[] temp = new byte[100];
    Assert.assertEquals(-1, inputStream.read(temp));
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.io.simpleseekableformat.InterleavedInputStream$MetaDataConsumer

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.