/// <summary>Initializes the map-part of the job with the appropriate input settings. /// </summary> /// <param name="job">The map-reduce job</param> /// <param name="inputClass"> /// the class object implementing DBWritable, which is the /// Java object holding tuple fields. /// </param> /// <param name="tableName">The table to read data from</param> /// <param name="conditions"> /// The condition which to select data with, /// eg. '(updated > 20070101 AND length > 0)' /// </param> /// <param name="orderBy">the fieldNames in the orderBy clause.</param> /// <param name="fieldNames">The field names in the table</param> /// <seealso cref="DBInputFormat{T}.SetInput(Org.Apache.Hadoop.Mapreduce.Job, System.Type{T}, string, string) /// "/> public static void SetInput(Job job, Type inputClass, string tableName, string conditions , string orderBy, params string[] fieldNames) { job.SetInputFormatClass(typeof(DBInputFormat)); DBConfiguration dbConf = new DBConfiguration(job.GetConfiguration()); dbConf.SetInputClass(inputClass); dbConf.SetInputTableName(tableName); dbConf.SetInputFieldNames(fieldNames); dbConf.SetInputConditions(conditions); dbConf.SetInputOrderBy(orderBy); }
/// <summary>test generate sql script for OracleDBRecordReader.</summary> /// <exception cref="System.Exception"/> public virtual void TestOracleDBRecordReader() { DBInputFormat.DBInputSplit splitter = new DBInputFormat.DBInputSplit(1, 10); Configuration configuration = new Configuration(); Connection connect = DriverForTest.GetConnection(); DBConfiguration dbConfiguration = new DBConfiguration(configuration); dbConfiguration.SetInputOrderBy("Order"); string[] fields = new string[] { "f1", "f2" }; OracleDBRecordReader <DBInputFormat.NullDBWritable> recorder = new OracleDBRecordReader <DBInputFormat.NullDBWritable>(splitter, typeof(DBInputFormat.NullDBWritable), configuration , connect, dbConfiguration, "condition", fields, "table"); NUnit.Framework.Assert.AreEqual("SELECT * FROM (SELECT a.*,ROWNUM dbif_rno FROM ( SELECT f1, f2 FROM table WHERE condition ORDER BY Order ) a WHERE rownum <= 10 ) WHERE dbif_rno > 1" , recorder.GetSelectQuery()); }