org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner#seekTo ( )源码实例Demo

下面列出了org.apache.hadoop.io.file.tfile.TFile.Reader.Scanner#seekTo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hadoop   文件: TestTFileByteArrays.java
private void checkBlockIndex(int recordIndex, int blockIndexExpected) throws IOException {
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  scanner.seekTo(composeSortedKey(KEY, recordIndex).getBytes());
  Assert.assertEquals(blockIndexExpected, scanner.currentLocation
      .getBlockIndex());
  scanner.close();
  reader.close();
}
 
源代码2 项目: big-c   文件: TestTFileByteArrays.java
private void checkBlockIndex(int recordIndex, int blockIndexExpected) throws IOException {
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  scanner.seekTo(composeSortedKey(KEY, recordIndex).getBytes());
  Assert.assertEquals(blockIndexExpected, scanner.currentLocation
      .getBlockIndex());
  scanner.close();
  reader.close();
}
 
源代码3 项目: RDFS   文件: TestTFileByteArrays.java
private void checkBlockIndex(int recordIndex, int blockIndexExpected) throws IOException {
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  scanner.seekTo(composeSortedKey(KEY, recordIndex).getBytes());
  Assert.assertEquals(blockIndexExpected, scanner.currentLocation
      .getBlockIndex());
  scanner.close();
  reader.close();
}
 
源代码4 项目: hadoop-gpu   文件: TestTFileByteArrays.java
private void checkBlockIndex(int count, int recordIndex,
    int blockIndexExpected) throws IOException {
  Reader reader = new Reader(fs.open(path), fs.getFileStatus(path).getLen(), conf);
  Scanner scanner = reader.createScanner();
  scanner.seekTo(composeSortedKey(KEY, count, recordIndex).getBytes());
  Assert.assertEquals(blockIndexExpected, scanner.currentLocation
      .getBlockIndex());
  scanner.close();
  reader.close();
}
 
源代码5 项目: hadoop   文件: TestTFile.java
/**
 * test none codecs
 */
void basicWithSomeCodec(String codec) throws IOException {
  Path ncTFile = new Path(ROOT, "basic.tfile");
  FSDataOutputStream fout = createFSOutput(ncTFile);
  Writer writer = new Writer(fout, minBlockSize, codec, "memcmp", conf);
  writeRecords(writer);
  fout.close();
  FSDataInputStream fin = fs.open(ncTFile);
  Reader reader =
      new Reader(fs.open(ncTFile), fs.getFileStatus(ncTFile).getLen(), conf);

  Scanner scanner = reader.createScanner();
  readAllRecords(scanner);
  scanner.seekTo(getSomeKey(50));
  assertTrue("location lookup failed", scanner.seekTo(getSomeKey(50)));
  // read the key and see if it matches
  byte[] readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(getSomeKey(50),
      readKey));

  scanner.seekTo(new byte[0]);
  byte[] val1 = readValue(scanner);
  scanner.seekTo(new byte[0]);
  byte[] val2 = readValue(scanner);
  assertTrue(Arrays.equals(val1, val2));
  
  // check for lowerBound
  scanner.lowerBound(getSomeKey(50));
  assertTrue("locaton lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(50)));

  // check for upper bound
  scanner.upperBound(getSomeKey(50));
  assertTrue("location lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(51)));

  scanner.close();
  // test for a range of scanner
  scanner = reader.createScannerByKey(getSomeKey(10), getSomeKey(60));
  readAndCheckbytes(scanner, 10, 50);
  assertFalse(scanner.advance());
  scanner.close();
  reader.close();
  fin.close();
  fs.delete(ncTFile, true);
}
 
源代码6 项目: hadoop   文件: TestTFileByteArrays.java
Location locate(Scanner scanner, byte[] key) throws IOException {
  if (scanner.seekTo(key) == true) {
    return scanner.currentLocation;
  }
  return scanner.endLocation;
}
 
源代码7 项目: big-c   文件: TestTFile.java
/**
 * test none codecs
 */
void basicWithSomeCodec(String codec) throws IOException {
  Path ncTFile = new Path(ROOT, "basic.tfile");
  FSDataOutputStream fout = createFSOutput(ncTFile);
  Writer writer = new Writer(fout, minBlockSize, codec, "memcmp", conf);
  writeRecords(writer);
  fout.close();
  FSDataInputStream fin = fs.open(ncTFile);
  Reader reader =
      new Reader(fs.open(ncTFile), fs.getFileStatus(ncTFile).getLen(), conf);

  Scanner scanner = reader.createScanner();
  readAllRecords(scanner);
  scanner.seekTo(getSomeKey(50));
  assertTrue("location lookup failed", scanner.seekTo(getSomeKey(50)));
  // read the key and see if it matches
  byte[] readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(getSomeKey(50),
      readKey));

  scanner.seekTo(new byte[0]);
  byte[] val1 = readValue(scanner);
  scanner.seekTo(new byte[0]);
  byte[] val2 = readValue(scanner);
  assertTrue(Arrays.equals(val1, val2));
  
  // check for lowerBound
  scanner.lowerBound(getSomeKey(50));
  assertTrue("locaton lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(50)));

  // check for upper bound
  scanner.upperBound(getSomeKey(50));
  assertTrue("location lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(51)));

  scanner.close();
  // test for a range of scanner
  scanner = reader.createScannerByKey(getSomeKey(10), getSomeKey(60));
  readAndCheckbytes(scanner, 10, 50);
  assertFalse(scanner.advance());
  scanner.close();
  reader.close();
  fin.close();
  fs.delete(ncTFile, true);
}
 
源代码8 项目: big-c   文件: TestTFileByteArrays.java
Location locate(Scanner scanner, byte[] key) throws IOException {
  if (scanner.seekTo(key) == true) {
    return scanner.currentLocation;
  }
  return scanner.endLocation;
}
 
源代码9 项目: RDFS   文件: TestTFile.java
/**
 * test none codecs
 */
void basicWithSomeCodec(String codec) throws IOException {
  Path ncTFile = new Path(ROOT, "basic.tfile");
  FSDataOutputStream fout = createFSOutput(ncTFile);
  Writer writer = new Writer(fout, minBlockSize, codec, "memcmp", conf);
  writeRecords(writer);
  fout.close();
  FSDataInputStream fin = fs.open(ncTFile);
  Reader reader =
      new Reader(fs.open(ncTFile), fs.getFileStatus(ncTFile).getLen(), conf);

  Scanner scanner = reader.createScanner();
  readAllRecords(scanner);
  scanner.seekTo(getSomeKey(50));
  assertTrue("location lookup failed", scanner.seekTo(getSomeKey(50)));
  // read the key and see if it matches
  byte[] readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(getSomeKey(50),
      readKey));

  scanner.seekTo(new byte[0]);
  byte[] val1 = readValue(scanner);
  scanner.seekTo(new byte[0]);
  byte[] val2 = readValue(scanner);
  assertTrue(Arrays.equals(val1, val2));
  
  // check for lowerBound
  scanner.lowerBound(getSomeKey(50));
  assertTrue("locaton lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(50)));

  // check for upper bound
  scanner.upperBound(getSomeKey(50));
  assertTrue("location lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(51)));

  scanner.close();
  // test for a range of scanner
  scanner = reader.createScannerByKey(getSomeKey(10), getSomeKey(60));
  readAndCheckbytes(scanner, 10, 50);
  assertFalse(scanner.advance());
  scanner.close();
  reader.close();
  fin.close();
  fs.delete(ncTFile, true);
}
 
源代码10 项目: RDFS   文件: TestTFileByteArrays.java
Location locate(Scanner scanner, byte[] key) throws IOException {
  if (scanner.seekTo(key) == true) {
    return scanner.currentLocation;
  }
  return scanner.endLocation;
}
 
源代码11 项目: hadoop-gpu   文件: TestTFile.java
/**
 * test none codecs
 */
void basicWithSomeCodec(String codec) throws IOException {
  Path ncTFile = new Path(ROOT, "basic.tfile");
  FSDataOutputStream fout = createFSOutput(ncTFile);
  Writer writer = new Writer(fout, minBlockSize, codec, "memcmp", conf);
  writeRecords(writer);
  fout.close();
  FSDataInputStream fin = fs.open(ncTFile);
  Reader reader =
      new Reader(fs.open(ncTFile), fs.getFileStatus(ncTFile).getLen(), conf);

  Scanner scanner = reader.createScanner();
  readAllRecords(scanner);
  scanner.seekTo(getSomeKey(50));
  assertTrue("location lookup failed", scanner.seekTo(getSomeKey(50)));
  // read the key and see if it matches
  byte[] readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(getSomeKey(50),
      readKey));

  scanner.seekTo(new byte[0]);
  byte[] val1 = readValue(scanner);
  scanner.seekTo(new byte[0]);
  byte[] val2 = readValue(scanner);
  assertTrue(Arrays.equals(val1, val2));
  
  // check for lowerBound
  scanner.lowerBound(getSomeKey(50));
  assertTrue("locaton lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(50)));

  // check for upper bound
  scanner.upperBound(getSomeKey(50));
  assertTrue("location lookup failed", scanner.currentLocation
      .compareTo(reader.end()) < 0);
  readKey = readKey(scanner);
  assertTrue("seeked key does not match", Arrays.equals(readKey,
      getSomeKey(51)));

  scanner.close();
  // test for a range of scanner
  scanner = reader.createScanner(getSomeKey(10), getSomeKey(60));
  readAndCheckbytes(scanner, 10, 50);
  assertFalse(scanner.advance());
  scanner.close();
  reader.close();
  fin.close();
  fs.delete(ncTFile, true);
}
 
源代码12 项目: hadoop-gpu   文件: TestTFileByteArrays.java
Location locate(Scanner scanner, byte[] key) throws IOException {
  if (scanner.seekTo(key) == true) {
    return scanner.currentLocation;
  }
  return scanner.endLocation;
}