List of usage examples for org.apache.hadoop.mapreduce.lib.db DBInputFormat setInput
public static void setInput(Job job, Class<? extends DBWritable> inputClass, String inputQuery, String inputCountQuery)
From source file:link.neolink.datamonster.Datamonster.java
License:Apache License
/** * Mapper configuration, with a dataset from SQL * * @param query/*w w w. j ava2 s . c o m*/ * The SQL Query * @param mapper * The mapper class */ public void mapperConfiguration(String query, Class<? extends Mapper> mapper) { if (this.inType != Type.MAGIC) { System.err.println("Input type already defined."); System.exit(-1); } if (this.dataWritable == null) { System.err.println("No DataWritable(s) found, you need to call setDataWritable() before!."); System.exit(-1); } this.inType = Type.SELECT; this.job.setMapperClass(mapper); this.job.setMapOutputKeyClass(Text.class); this.job.setMapOutputValueClass(this.dataWritable); this.job.setInputFormatClass(DBInputFormat.class); if (this.inputWritable != null) { DBInputFormat.setInput(this.job, this.inputWritable, query, "SELECT COUNT(*) FROM (" + query + ") AS query_count"); } else if (this.ioWritable != null) { DBInputFormat.setInput(this.job, this.ioWritable, query, "SELECT COUNT(*) FROM (" + query + ") AS query_count"); } else { System.err.println("Input is SQL, but no input Writable class defined"); System.exit(-1); } }