/// <exception cref="System.IO.IOException"/> public virtual void SeekTFile() { int miss = 0; long totalBytes = 0; FSDataInputStream fsdis = fs.Open(path); TFile.Reader reader = new TFile.Reader(fsdis, fs.GetFileStatus(path).GetLen(), conf ); KeySampler kSampler = new KeySampler(rng, reader.GetFirstKey(), reader.GetLastKey (), keyLenGen); TFile.Reader.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.Console.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)); }
/// <exception cref="System.IO.IOException"/> protected override void SetUp() { if (options == null) { options = new TestTFileSeek.MyOptions(new string[0]); } conf = new Configuration(); conf.SetInt("tfile.fs.input.buffer.size", options.fsInputBufferSize); conf.SetInt("tfile.fs.output.buffer.size", options.fsOutputBufferSize); path = new Path(new Path(options.rootDir), options.file); fs = path.GetFileSystem(conf); timer = new NanoTimer(false); rng = new Random(options.seed); keyLenGen = new RandomDistribution.Zipf(new Random(rng.NextLong()), options.minKeyLen , options.maxKeyLen, 1.2); RandomDistribution.DiscreteRNG valLenGen = new RandomDistribution.Flat(new Random (rng.NextLong()), options.minValLength, options.maxValLength); RandomDistribution.DiscreteRNG wordLenGen = new RandomDistribution.Flat(new Random (rng.NextLong()), options.minWordLen, options.maxWordLen); kvGen = new KVGenerator(rng, true, keyLenGen, valLenGen, wordLenGen, options.dictSize ); }