Java 类org.apache.hadoop.hbase.io.hfile.HFile.Reader 实例源码

项目:ditb    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  HFileContext  context = new HFileContextBuilder().build();
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f)
      .withFileContext(context).create();
  writeSomeRecords(w, 0, 100, false);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf, conf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:ditb    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  HFileContext meta = new HFileContextBuilder()
                      .withCompression(AbstractHFileWriter.compressionByName(compress))
                      .withBlockSize(minBlockSize).build();
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withFileContext(meta)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf, conf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:ditb    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    HFileContext meta = new HFileContextBuilder().withCompression(compressAlgo)
                        .withBlockSize(minBlockSize).build();
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withFileContext(meta)
        .create();
    KeyValue kv = new KeyValue("foo".getBytes(), "f1".getBytes(), null, "value".getBytes());
    writer.append(kv);
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf, conf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:LCIndex-HBase-0.94.16    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:LCIndex-HBase-0.94.16    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:pbase    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  HFileContext  context = new HFileContextBuilder().build();
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f)
      .withFileContext(context).create();
  writeSomeRecords(w, 0, 100, false);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf, conf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:pbase    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  HFileContext meta = new HFileContextBuilder()
                      .withCompression(AbstractHFileWriter.compressionByName(compress))
                      .withBlockSize(minBlockSize).build();
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withFileContext(meta)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf, conf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:pbase    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    HFileContext meta = new HFileContextBuilder().withCompression(compressAlgo)
                        .withBlockSize(minBlockSize).build();
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withFileContext(meta)
        .create();
    KeyValue kv = new KeyValue("foo".getBytes(), "f1".getBytes(), null, "value".getBytes());
    writer.append(kv);
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf, conf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:HIndex    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  HFileContext  context = new HFileContextBuilder().build();
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f)
      .withFileContext(context).create();
  writeSomeRecords(w, 0, 100, false);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf, conf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:HIndex    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  HFileContext meta = new HFileContextBuilder()
                      .withCompression(AbstractHFileWriter.compressionByName(compress))
                      .withBlockSize(minBlockSize).build();
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withFileContext(meta)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf, conf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:HIndex    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    HFileContext meta = new HFileContextBuilder().withCompression(compressAlgo)
                        .withBlockSize(minBlockSize).build();
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withFileContext(meta)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf, conf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:IRIndex    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:IRIndex    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:IRIndex    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:hbase    文件:TestHFile.java   
/**
 * Create 0-length hfile and show that it fails
 */
@Test
public void testCorrupt0LengthHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, testName.getMethodName());
  FSDataOutputStream fsos = fs.create(f);
  fsos.close();

  try {
    Reader r = HFile.createReader(fs, f, cacheConf, true, conf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:hbase    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
@Test
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, testName.getMethodName());
  HFileContext  context = new HFileContextBuilder().build();
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f)
      .withFileContext(context).create();
  writeSomeRecords(w, 0, 100, false);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf, true, conf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:hbase    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  HFileContext meta = new HFileContextBuilder()
                      .withCompression(HFileWriterImpl.compressionByName(compress))
                      .withBlockSize(minBlockSize).build();
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withFileContext(meta)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf, conf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:hbase    文件:TestHFile.java   
@Test
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo :
      HBaseCommonTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    HFileContext meta = new HFileContextBuilder().withCompression(compressAlgo)
                        .withBlockSize(minBlockSize).build();
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withFileContext(meta)
        .create();
    KeyValue kv = new KeyValue("foo".getBytes(), "f1".getBytes(), null, "value".getBytes());
    writer.append(kv);
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf, true, conf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:PyroDB    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  HFileContext  context = new HFileContextBuilder().build();
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f)
      .withFileContext(context).create();
  writeSomeRecords(w, 0, 100, false);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf, conf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:PyroDB    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  HFileContext meta = new HFileContextBuilder()
                      .withCompression(AbstractHFileWriter.compressionByName(compress))
                      .withBlockSize(minBlockSize).build();
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withFileContext(meta)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf, conf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:PyroDB    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    HFileContext meta = new HFileContextBuilder().withCompression(compressAlgo)
                        .withBlockSize(minBlockSize).build();
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withFileContext(meta)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf, conf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:c5    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:c5    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:c5    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:HBase-Research    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:HBase-Research    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:HBase-Research    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:hbase-0.94.8-qod    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:hbase-0.94.8-qod    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:hbase-0.94.8-qod    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:hbase-0.94.8-qod    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:hbase-0.94.8-qod    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:hbase-0.94.8-qod    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:DominoHBase    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:DominoHBase    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:DominoHBase    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}
项目:hindex    文件:TestHFile.java   
/**
 * Create a truncated hfile and verify that exception thrown.
 */
public void testCorruptTruncatedHFile() throws IOException {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path f = new Path(ROOT_DIR, getName());
  Writer w = HFile.getWriterFactory(conf, cacheConf).withPath(this.fs, f).create();
  writeSomeRecords(w, 0, 100);
  w.close();

  Path trunc = new Path(f.getParent(), "trucated");
  truncateFile(fs, w.getPath(), trunc);

  try {
    Reader r = HFile.createReader(fs, trunc, cacheConf);
  } catch (CorruptHFileException che) {
    // Expected failure
    return;
  }
  fail("Should have thrown exception");
}
项目:hindex    文件:TestHFile.java   
private void metablocks(final String compress) throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  Path mFile = new Path(ROOT_DIR, "meta.hfile");
  FSDataOutputStream fout = createFSOutput(mFile);
  Writer writer = HFile.getWriterFactory(conf, cacheConf)
      .withOutputStream(fout)
      .withBlockSize(minBlockSize)
      .withCompression(compress)
      .create();
  someTestingWithMetaBlock(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(mFile);
  Reader reader = HFile.createReaderFromStream(mFile, fs.open(mFile),
      this.fs.getFileStatus(mFile).getLen(), cacheConf);
  reader.loadFileInfo();
  // No data -- this should return false.
  assertFalse(reader.getScanner(false, false).seekTo());
  someReadingWithMetaBlock(reader);
  fs.delete(mFile, true);
  reader.close();
  fin.close();
}
项目:hindex    文件:TestHFile.java   
public void testNullMetaBlocks() throws Exception {
  if (cacheConf == null) cacheConf = new CacheConfig(conf);
  for (Compression.Algorithm compressAlgo : 
      HBaseTestingUtility.COMPRESSION_ALGORITHMS) {
    Path mFile = new Path(ROOT_DIR, "nometa_" + compressAlgo + ".hfile");
    FSDataOutputStream fout = createFSOutput(mFile);
    Writer writer = HFile.getWriterFactory(conf, cacheConf)
        .withOutputStream(fout)
        .withBlockSize(minBlockSize)
        .withCompression(compressAlgo)
        .create();
    writer.append("foo".getBytes(), "value".getBytes());
    writer.close();
    fout.close();
    Reader reader = HFile.createReader(fs, mFile, cacheConf);
    reader.loadFileInfo();
    assertNull(reader.getMetaBlock("non-existant", false));
  }
}