当前位置: 首页>>代码示例>>Java>>正文


Java Reader.close方法代码示例

本文整理汇总了Java中org.apache.hadoop.io.file.tfile.TFile.Reader.close方法的典型用法代码示例。如果您正苦于以下问题:Java Reader.close方法的具体用法?Java Reader.close怎么用?Java Reader.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.io.file.tfile.TFile.Reader的用法示例。


在下文中一共展示了Reader.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unsortedWithSomeCodec

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
void unsortedWithSomeCodec(String codec) throws IOException {
  Path uTfile = new Path(ROOT, "unsorted.tfile");
  FSDataOutputStream fout = createFSOutput(uTfile);
  Writer writer = new Writer(fout, minBlockSize, codec, null, conf);
  writeRecords(writer);
  writer.close();
  fout.close();
  FSDataInputStream fin = fs.open(uTfile);
  Reader reader =
      new Reader(fs.open(uTfile), fs.getFileStatus(uTfile).getLen(), conf);

  Scanner scanner = reader.createScanner();
  readAllRecords(scanner);
  scanner.close();
  reader.close();
  fin.close();
  fs.delete(uTfile, true);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:TestTFile.java

示例2: readValueWithoutKey

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
private void readValueWithoutKey(int recordIndex)
    throws IOException {
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);

  Scanner scanner =
      reader.createScannerByKey(composeSortedKey(KEY, recordIndex)
          .getBytes(), null);

  byte[] vbuf1 = new byte[BUF_SIZE];
  int vlen1 = scanner.entry().getValueLength();
  scanner.entry().getValue(vbuf1);
  Assert.assertEquals(new String(vbuf1, 0, vlen1), VALUE + recordIndex);

  if (scanner.advance() && !scanner.atEnd()) {
    byte[] vbuf2 = new byte[BUF_SIZE];
    int vlen2 = scanner.entry().getValueLength();
    scanner.entry().getValue(vbuf2);
    Assert.assertEquals(new String(vbuf2, 0, vlen2), VALUE
        + (recordIndex + 1));
  }

  scanner.close();
  reader.close();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestTFileByteArrays.java

示例3: testFailureScannerWithKeys

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
public void testFailureScannerWithKeys() throws IOException {
  Reader reader =
      new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Assert.assertFalse(reader.isSorted());
  Assert.assertEquals((int) reader.getEntryCount(), 4);

  try {
    Scanner scanner =
        reader.createScannerByKey("aaa".getBytes(), "zzz".getBytes());
    Assert
        .fail("Failed to catch creating scanner with keys on unsorted file.");
  }
  catch (RuntimeException e) {
  }
  finally {
    reader.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestTFileUnsortedByteArrays.java

示例4: testFailureReadValueManyTimes

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testFailureReadValueManyTimes() throws IOException {
  if (skip)
    return;
  writeRecords(5);

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();

  byte[] vbuf = new byte[BUF_SIZE];
  int vlen = scanner.entry().getValueLength();
  scanner.entry().getValue(vbuf);
  Assert.assertEquals(new String(vbuf, 0, vlen), VALUE + 0);
  try {
    scanner.entry().getValue(vbuf);
    Assert.fail("Cannot get the value mlutiple times.");
  } catch (Exception e) {
    // noop, expecting exceptions
  }

  scanner.close();
  reader.close();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:TestTFileByteArrays.java

示例5: testFailureNegativeOffset_2

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testFailureNegativeOffset_2() throws IOException {
  if (skip)
    return;
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  try {
    scanner.lowerBound("keyX".getBytes(), -1, 4);
    Assert.fail("Error on handling negative offset.");
  } catch (Exception e) {
    // noop, expecting exceptions
  } finally {
    reader.close();
    scanner.close();
  }
  closeOutput();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:TestTFileByteArrays.java

示例6: testFailureNegativeLength_2

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testFailureNegativeLength_2() throws IOException {
  if (skip)
    return;
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  try {
    scanner.lowerBound("keyX".getBytes(), 0, -1);
    Assert.fail("Error on handling negative length.");
  } catch (Exception e) {
    // noop, expecting exceptions
  } finally {
    scanner.close();
    reader.close();
  }
  closeOutput();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:TestTFileByteArrays.java

示例7: readValueBeforeKey

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
private void readValueBeforeKey(int recordIndex)
    throws IOException {
  Reader reader =
      new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner =
      reader.createScannerByKey(composeSortedKey(KEY, recordIndex)
          .getBytes(), null);

  try {
    byte[] vbuf = new byte[BUF_SIZE];
    int vlen = scanner.entry().getValueLength();
    scanner.entry().getValue(vbuf);
    Assert.assertEquals(new String(vbuf, 0, vlen), VALUE + recordIndex);

    byte[] kbuf = new byte[BUF_SIZE];
    int klen = scanner.entry().getKeyLength();
    scanner.entry().getKey(kbuf);
    Assert.assertEquals(new String(kbuf, 0, klen), composeSortedKey(KEY,
        recordIndex));
  } finally {
    scanner.close();
    reader.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestTFileByteArrays.java

示例8: testFailureScannerWithKeys

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testFailureScannerWithKeys() throws IOException {
  Reader reader =
      new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Assert.assertFalse(reader.isSorted());
  Assert.assertEquals((int) reader.getEntryCount(), 4);

  try {
    Scanner scanner =
        reader.createScannerByKey("aaa".getBytes(), "zzz".getBytes());
    Assert
        .fail("Failed to catch creating scanner with keys on unsorted file.");
  }
  catch (RuntimeException e) {
  }
  finally {
    reader.close();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:TestTFileUnsortedByteArrays.java

示例9: testFailureNegativeOffset

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testFailureNegativeOffset() throws IOException {
  if (skip)
    return;
  writeRecords(2, true, true);

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  byte[] buf = new byte[K];
  try {
    scanner.entry().getKey(buf, -1);
    fail("Failed to handle key negative offset.");
  }
  catch (Exception e) {
    // noop, expecting exceptions
  }
  finally {
  }
  scanner.close();
  reader.close();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:22,代码来源:TestTFileStreams.java

示例10: testFailureNegativeOffset

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
public void testFailureNegativeOffset() throws IOException {
  if (skip)
    return;
  writeRecords(2, true, true);

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  byte[] buf = new byte[K];
  try {
    scanner.entry().getKey(buf, -1);
    Assert.fail("Failed to handle key negative offset.");
  }
  catch (Exception e) {
    // noop, expecting exceptions
  }
  finally {
  }
  scanner.close();
  reader.close();
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:21,代码来源:TestTFileStreams.java

示例11: 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();
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:27,代码来源:TestTFileByteArrays.java

示例12: readKeyWithoutValue

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
private void readKeyWithoutValue(int recordIndex)
    throws IOException {
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner =
      reader.createScannerByKey(composeSortedKey(KEY, recordIndex)
          .getBytes(), null);

  try {
    // read the indexed key
    byte[] kbuf1 = new byte[BUF_SIZE];
    int klen1 = scanner.entry().getKeyLength();
    scanner.entry().getKey(kbuf1);
    Assert.assertEquals(new String(kbuf1, 0, klen1), composeSortedKey(KEY,
        recordIndex));

    if (scanner.advance() && !scanner.atEnd()) {
      // read the next key following the indexed
      byte[] kbuf2 = new byte[BUF_SIZE];
      int klen2 = scanner.entry().getKeyLength();
      scanner.entry().getKey(kbuf2);
      Assert.assertEquals(new String(kbuf2, 0, klen2), composeSortedKey(KEY,
          recordIndex + 1));
    }
  } finally {
    scanner.close();
    reader.close();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestTFileByteArrays.java

示例13: testNoDataEntry

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testNoDataEntry() throws IOException {
  if (skip) 
    return;
  closeOutput();

  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Assert.assertTrue(reader.isSorted());
  Scanner scanner = reader.createScanner();
  Assert.assertTrue(scanner.atEnd());
  scanner.close();
  reader.close();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:14,代码来源:TestTFileByteArrays.java

示例14: testLocate

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
@Test
public void testLocate() throws IOException {
  if (skip)
    return;
  writeRecords(3 * records1stBlock);
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  locate(scanner, composeSortedKey(KEY, 2).getBytes());
  locate(scanner, composeSortedKey(KEY, records1stBlock - 1).getBytes());
  locate(scanner, composeSortedKey(KEY, records1stBlock).getBytes());
  Location locX = locate(scanner, "keyX".getBytes());
  Assert.assertEquals(scanner.endLocation, locX);
  scanner.close();
  reader.close();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:16,代码来源:TestTFileByteArrays.java

示例15: readRecords

import org.apache.hadoop.io.file.tfile.TFile.Reader; //导入方法依赖的package包/类
static void readRecords(FileSystem fs, Path path, int count,
    Configuration conf) throws IOException {
  Reader reader =
      new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();

  try {
    for (int nx = 0; nx < count; nx++, scanner.advance()) {
      Assert.assertFalse(scanner.atEnd());
      // Assert.assertTrue(scanner.next());

      byte[] kbuf = new byte[BUF_SIZE];
      int klen = scanner.entry().getKeyLength();
      scanner.entry().getKey(kbuf);
      Assert.assertEquals(new String(kbuf, 0, klen), composeSortedKey(KEY,
          nx));

      byte[] vbuf = new byte[BUF_SIZE];
      int vlen = scanner.entry().getValueLength();
      scanner.entry().getValue(vbuf);
      Assert.assertEquals(new String(vbuf, 0, vlen), VALUE + nx);
    }

    Assert.assertTrue(scanner.atEnd());
    Assert.assertFalse(scanner.advance());
  } finally {
    scanner.close();
    reader.close();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:31,代码来源:TestTFileByteArrays.java


注:本文中的org.apache.hadoop.io.file.tfile.TFile.Reader.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。