本文整理汇总了Java中org.apache.hadoop.io.file.tfile.TFile.Reader.getMetaBlock方法的典型用法代码示例。如果您正苦于以下问题:Java Reader.getMetaBlock方法的具体用法?Java Reader.getMetaBlock怎么用?Java Reader.getMetaBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.io.file.tfile.TFile.Reader
的用法示例。
在下文中一共展示了Reader.getMetaBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFailureGetNonExistentMetaBlock
import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@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();
}
示例2: readNumMetablocks
import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
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();
}
}
示例3: someReadingWithMetaBlock
import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
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();
}