Java Code Examples for org.apache.hadoop.io.file.tfile.TFile.Reader#getFirstKey()
The following examples show how to use
org.apache.hadoop.io.file.tfile.TFile.Reader#getFirstKey() .
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: TestTFileSeek.java From hadoop with Apache License 2.0 | 5 votes |
public void seekTFile() throws IOException { int miss = 0; long totalBytes = 0; FSDataInputStream fsdis = fs.open(path); Reader reader = new Reader(fsdis, fs.getFileStatus(path).getLen(), conf); KeySampler kSampler = new KeySampler(rng, reader.getFirstKey(), reader.getLastKey(), keyLenGen); Scanner scanner = reader.createScanner(); BytesWritable key = new BytesWritable(); BytesWritable val = new BytesWritable(); timer.reset(); timer.start(); for (int i = 0; i < options.seekCount; ++i) { kSampler.next(key); scanner.lowerBound(key.get(), 0, key.getSize()); if (!scanner.atEnd()) { scanner.entry().get(key, val); totalBytes += key.getSize(); totalBytes += val.getSize(); } else { ++miss; } } timer.stop(); double duration = (double) timer.read() / 1000; // in us. System.out.printf( "time: %s...avg seek: %s...%d hit...%d miss...avg I/O size: %.2fKB\n", timer.toString(), NanoTimer.nanoTimeToString(timer.read() / options.seekCount), options.seekCount - miss, miss, (double) totalBytes / 1024 / (options.seekCount - miss)); }
Example 2
Source File: TestTFileSeek.java From big-c with Apache License 2.0 | 5 votes |
public void seekTFile() throws IOException { int miss = 0; long totalBytes = 0; FSDataInputStream fsdis = fs.open(path); Reader reader = new Reader(fsdis, fs.getFileStatus(path).getLen(), conf); KeySampler kSampler = new KeySampler(rng, reader.getFirstKey(), reader.getLastKey(), keyLenGen); Scanner scanner = reader.createScanner(); BytesWritable key = new BytesWritable(); BytesWritable val = new BytesWritable(); timer.reset(); timer.start(); for (int i = 0; i < options.seekCount; ++i) { kSampler.next(key); scanner.lowerBound(key.get(), 0, key.getSize()); if (!scanner.atEnd()) { scanner.entry().get(key, val); totalBytes += key.getSize(); totalBytes += val.getSize(); } else { ++miss; } } timer.stop(); double duration = (double) timer.read() / 1000; // in us. System.out.printf( "time: %s...avg seek: %s...%d hit...%d miss...avg I/O size: %.2fKB\n", timer.toString(), NanoTimer.nanoTimeToString(timer.read() / options.seekCount), options.seekCount - miss, miss, (double) totalBytes / 1024 / (options.seekCount - miss)); }
Example 3
Source File: TestTFileSeek.java From RDFS with Apache License 2.0 | 5 votes |
public void seekTFile() throws IOException { int miss = 0; long totalBytes = 0; FSDataInputStream fsdis = fs.open(path); Reader reader = new Reader(fsdis, fs.getFileStatus(path).getLen(), conf); KeySampler kSampler = new KeySampler(rng, reader.getFirstKey(), reader.getLastKey(), keyLenGen); Scanner scanner = reader.createScanner(); BytesWritable key = new BytesWritable(); BytesWritable val = new BytesWritable(); timer.reset(); timer.start(); for (int i = 0; i < options.seekCount; ++i) { kSampler.next(key); scanner.lowerBound(key.get(), 0, key.getSize()); if (!scanner.atEnd()) { scanner.entry().get(key, val); totalBytes += key.getSize(); totalBytes += val.getSize(); } else { ++miss; } } timer.stop(); double duration = (double) timer.read() / 1000; // in us. System.out.printf( "time: %s...avg seek: %s...%d hit...%d miss...avg I/O size: %.2fKB\n", timer.toString(), NanoTimer.nanoTimeToString(timer.read() / options.seekCount), options.seekCount - miss, miss, (double) totalBytes / 1024 / (options.seekCount - miss)); }
Example 4
Source File: TestTFileSeek.java From hadoop-gpu with Apache License 2.0 | 5 votes |
public void seekTFile() throws IOException { int miss = 0; long totalBytes = 0; FSDataInputStream fsdis = fs.open(path); Reader reader = new Reader(fsdis, fs.getFileStatus(path).getLen(), conf); KeySampler kSampler = new KeySampler(rng, reader.getFirstKey(), reader.getLastKey(), keyLenGen); Scanner scanner = reader.createScanner(); BytesWritable key = new BytesWritable(); BytesWritable val = new BytesWritable(); timer.reset(); timer.start(); for (int i = 0; i < options.seekCount; ++i) { kSampler.next(key); scanner.lowerBound(key.get(), 0, key.getSize()); if (!scanner.atEnd()) { scanner.entry().get(key, val); totalBytes += key.getSize(); totalBytes += val.getSize(); } else { ++miss; } } timer.stop(); double duration = (double) timer.read() / 1000; // in us. System.out.printf( "time: %s...avg seek: %s...%d hit...%d miss...avg I/O size: %.2fKB\n", timer.toString(), NanoTimer.nanoTimeToString(timer.read() / options.seekCount), options.seekCount - miss, miss, (double) totalBytes / 1024 / (options.seekCount - miss)); }