Java Code Examples for org.apache.hadoop.io.file.tfile.TFile.Reader#getMetaBlock()

The following examples show how to use org.apache.hadoop.io.file.tfile.TFile.Reader#getMetaBlock() . 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: TestTFileByteArrays.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureGetNonExistentMetaBlock() throws IOException {
  if (skip)
    return;
  writer.append("keyX".getBytes(), "valueX".getBytes());

  // create a new metablock
  DataOutputStream outMeta =
      writer.prepareMetaBlock("testX", Compression.Algorithm.GZ.getName());
  outMeta.write(123);
  outMeta.write("foo".getBytes());
  outMeta.close();
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  DataInputStream mb = reader.getMetaBlock("testX");
  Assert.assertNotNull(mb);
  mb.close();
  try {
    DataInputStream mbBad = reader.getMetaBlock("testY");
    Assert.fail("Error on handling non-existent metablocks.");
  } catch (Exception e) {
    // noop, expecting exceptions
  }
  reader.close();
}
 
Example 2
Source File: TestTFileByteArrays.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureGetNonExistentMetaBlock() throws IOException {
  if (skip)
    return;
  writer.append("keyX".getBytes(), "valueX".getBytes());

  // create a new metablock
  DataOutputStream outMeta =
      writer.prepareMetaBlock("testX", Compression.Algorithm.GZ.getName());
  outMeta.write(123);
  outMeta.write("foo".getBytes());
  outMeta.close();
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  DataInputStream mb = reader.getMetaBlock("testX");
  Assert.assertNotNull(mb);
  mb.close();
  try {
    DataInputStream mbBad = reader.getMetaBlock("testY");
    Assert.fail("Error on handling non-existent metablocks.");
  } catch (Exception e) {
    // noop, expecting exceptions
  }
  reader.close();
}
 
Example 3
Source File: TestTFileByteArrays.java    From RDFS with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureGetNonExistentMetaBlock() throws IOException {
  if (skip)
    return;
  writer.append("keyX".getBytes(), "valueX".getBytes());

  // create a new metablock
  DataOutputStream outMeta =
      writer.prepareMetaBlock("testX", Compression.Algorithm.GZ.getName());
  outMeta.write(123);
  outMeta.write("foo".getBytes());
  outMeta.close();
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  DataInputStream mb = reader.getMetaBlock("testX");
  Assert.assertNotNull(mb);
  mb.close();
  try {
    DataInputStream mbBad = reader.getMetaBlock("testY");
    Assert.fail("Error on handling non-existent metablocks.");
  } catch (Exception e) {
    // noop, expecting exceptions
  }
  reader.close();
}
 
Example 4
Source File: TestTFile.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void readNumMetablocks(Reader reader, int n) throws IOException {
  int len = ("something to test" + 0).getBytes().length;
  for (int i = 0; i < n; i++) {
    DataInputStream din = reader.getMetaBlock("TfileMeta" + i);
    byte b[] = new byte[len];
    din.readFully(b);
    assertTrue("faield to match metadata", Arrays.equals(
        ("something to test" + i).getBytes(), b));
    din.close();
  }
}
 
Example 5
Source File: TestTFile.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void someReadingWithMetaBlock(Reader reader) throws IOException {
  DataInputStream din = null;
  readNumMetablocks(reader, 10);
  try {
    din = reader.getMetaBlock("NO ONE");
    assertTrue(false);
  }
  catch (MetaBlockDoesNotExist me) {
    // should catch
  }
  din = reader.getMetaBlock("TFileMeta100");
  int read = din.read();
  assertTrue("check for status", (read == -1));
  din.close();
}
 
Example 6
Source File: TestTFile.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void readNumMetablocks(Reader reader, int n) throws IOException {
  int len = ("something to test" + 0).getBytes().length;
  for (int i = 0; i < n; i++) {
    DataInputStream din = reader.getMetaBlock("TfileMeta" + i);
    byte b[] = new byte[len];
    din.readFully(b);
    assertTrue("faield to match metadata", Arrays.equals(
        ("something to test" + i).getBytes(), b));
    din.close();
  }
}
 
Example 7
Source File: TestTFile.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void someReadingWithMetaBlock(Reader reader) throws IOException {
  DataInputStream din = null;
  readNumMetablocks(reader, 10);
  try {
    din = reader.getMetaBlock("NO ONE");
    assertTrue(false);
  }
  catch (MetaBlockDoesNotExist me) {
    // should catch
  }
  din = reader.getMetaBlock("TFileMeta100");
  int read = din.read();
  assertTrue("check for status", (read == -1));
  din.close();
}
 
Example 8
Source File: TestTFile.java    From RDFS with Apache License 2.0 5 votes vote down vote up
private void readNumMetablocks(Reader reader, int n) throws IOException {
  int len = ("something to test" + 0).getBytes().length;
  for (int i = 0; i < n; i++) {
    DataInputStream din = reader.getMetaBlock("TfileMeta" + i);
    byte b[] = new byte[len];
    din.readFully(b);
    assertTrue("faield to match metadata", Arrays.equals(
        ("something to test" + i).getBytes(), b));
    din.close();
  }
}
 
Example 9
Source File: TestTFile.java    From RDFS with Apache License 2.0 5 votes vote down vote up
private void someReadingWithMetaBlock(Reader reader) throws IOException {
  DataInputStream din = null;
  readNumMetablocks(reader, 10);
  try {
    din = reader.getMetaBlock("NO ONE");
    assertTrue(false);
  }
  catch (MetaBlockDoesNotExist me) {
    // should catch
  }
  din = reader.getMetaBlock("TFileMeta100");
  int read = din.read();
  assertTrue("check for status", (read == -1));
  din.close();
}
 
Example 10
Source File: TestTFile.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
private void readNumMetablocks(Reader reader, int n) throws IOException {
  int len = ("something to test" + 0).getBytes().length;
  for (int i = 0; i < n; i++) {
    DataInputStream din = reader.getMetaBlock("TfileMeta" + i);
    byte b[] = new byte[len];
    din.readFully(b);
    assertTrue("faield to match metadata", Arrays.equals(
        ("something to test" + i).getBytes(), b));
    din.close();
  }
}
 
Example 11
Source File: TestTFile.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
private void someReadingWithMetaBlock(Reader reader) throws IOException {
  DataInputStream din = null;
  readNumMetablocks(reader, 10);
  try {
    din = reader.getMetaBlock("NO ONE");
    assertTrue(false);
  }
  catch (MetaBlockDoesNotExist me) {
    // should catch
  }
  din = reader.getMetaBlock("TFileMeta100");
  int read = din.read();
  assertTrue("check for status", (read == -1));
  din.close();
}
 
Example 12
Source File: TestTFileByteArrays.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
public void testFailureGetNonExistentMetaBlock() throws IOException {
  if (skip)
    return;
  writer.append("keyX".getBytes(), "valueX".getBytes());

  // create a new metablock
  DataOutputStream outMeta =
      writer.prepareMetaBlock("testX", Compression.Algorithm.GZ.getName());
  outMeta.write(123);
  outMeta.write("foo".getBytes());
  outMeta.close();
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  DataInputStream mb = reader.getMetaBlock("testX");
  Assert.assertNotNull(mb);
  mb.close();
  try {
    DataInputStream mbBad = reader.getMetaBlock("testY");
    Assert.assertNull(mbBad);
    Assert.fail("Error on handling non-existent metablocks.");
  }
  catch (Exception e) {
    // noop, expecting exceptions
  }
  reader.close();
}