/// <exception cref="System.IO.IOException"/> private static void ReadTest(FileSystem fs, RandomDatum[] data, string file) { RandomDatum v = new RandomDatum(); int sample = (int)Math.Sqrt(data.Length); Random random = new Random(); Log.Info("reading " + sample + " records"); SetFile.Reader reader = new SetFile.Reader(fs, file, conf); for (int i = 0; i < sample; i++) { if (!reader.Seek(data[random.Next(data.Length)])) { throw new RuntimeException("wrong value at " + i); } } reader.Close(); Log.Info("done reading " + data.Length); }
/// <summary> /// test /// <c>SetFile.Reader</c> /// methods /// next(), get() in combination /// </summary> public virtual void TestSetFileAccessMethods() { try { FileSystem fs = FileSystem.GetLocal(conf); int size = 10; WriteData(fs, size); SetFile.Reader reader = CreateReader(fs); Assert.True("testSetFileWithConstruction1 error !!!", reader.Next (new IntWritable(0))); // don't know why reader.get(i) return i+1 Assert.Equal("testSetFileWithConstruction2 error !!!", new IntWritable (size / 2 + 1), reader.Get(new IntWritable(size / 2))); NUnit.Framework.Assert.IsNull("testSetFileWithConstruction3 error !!!", reader.Get (new IntWritable(size * 2))); } catch (Exception) { Fail("testSetFileWithConstruction error !!!"); } }