/// <summary>test DBInputFormat class.</summary> /// <remarks>test DBInputFormat class. Class should split result for chunks</remarks> /// <exception cref="System.Exception"/> public virtual void TestDBInputFormat() { JobConf configuration = new JobConf(); SetupDriver(configuration); DBInputFormat <DBInputFormat.NullDBWritable> format = new DBInputFormat <DBInputFormat.NullDBWritable >(); format.SetConf(configuration); format.SetConf(configuration); DBInputFormat.DBInputSplit splitter = new DBInputFormat.DBInputSplit(1, 10); Reporter reporter = Org.Mockito.Mockito.Mock <Reporter>(); RecordReader <LongWritable, DBInputFormat.NullDBWritable> reader = format.GetRecordReader (splitter, configuration, reporter); configuration.SetInt(MRJobConfig.NumMaps, 3); InputSplit[] lSplits = format.GetSplits(configuration, 3); NUnit.Framework.Assert.AreEqual(5, lSplits[0].GetLength()); NUnit.Framework.Assert.AreEqual(3, lSplits.Length); // test reader .Some simple tests NUnit.Framework.Assert.AreEqual(typeof(LongWritable), reader.CreateKey().GetType( )); NUnit.Framework.Assert.AreEqual(0, reader.GetPos()); NUnit.Framework.Assert.AreEqual(0, reader.GetProgress(), 0.001); reader.Close(); }
/// <param name="split">The InputSplit to read data for</param> /// <exception cref="Java.Sql.SQLException"></exception> protected internal DBRecordReader(DBInputFormat <T> _enclosing, DBInputFormat.DBInputSplit split, Type inputClass, JobConf job, Connection conn, DBConfiguration dbConfig, string cond, string[] fields, string table) : base(split, inputClass, job, conn, dbConfig, cond, fields, table) { this._enclosing = _enclosing; }
/// <summary>The constructor is kept to be compatible with M/R 1.x</summary> /// <param name="split">The InputSplit to read data for</param> /// <exception cref="Java.Sql.SQLException"/> protected internal DBRecordReader(DBInputFormat <T> _enclosing, DBInputFormat.DBInputSplit split, Type inputClass, JobConf job) : base(split, inputClass, job, this._enclosing.connection, this._enclosing.dbConf , this._enclosing.conditions, this._enclosing.fieldNames, this._enclosing.tableName ) { this._enclosing = _enclosing; }
/// <summary> /// <inheritDoc/> /// /// </summary> /// <exception cref="System.IO.IOException"/> public virtual InputSplit[] GetSplits(JobConf job, int chunks) { IList <InputSplit> newSplits = base.GetSplits(Job.GetInstance(job)); InputSplit[] ret = new InputSplit[newSplits.Count]; int i = 0; foreach (InputSplit s in newSplits) { DBInputFormat.DBInputSplit split = (DBInputFormat.DBInputSplit)s; ret[i++] = new DBInputFormat.DBInputSplit(split.GetStart(), split.GetEnd()); } return(ret); }