### Eclipse Workspace Patch 1.0 #P hbase-trunk-rw Index: src/java/org/apache/hadoop/hbase/mapreduce/Export.java =================================================================== --- src/java/org/apache/hadoop/hbase/mapreduce/Export.java (revision 901238) +++ src/java/org/apache/hadoop/hbase/mapreduce/Export.java (working copy) @@ -77,8 +77,11 @@ */ public static Job createSubmittableJob(Configuration conf, String[] args) throws IOException { - String tableName = args[0]; - Path outputDir = new Path(args[1]); + int argsPos = 0; + boolean compress = args[0].equals("-z") || args[0].equals("--compress"); + if (compress) argsPos++; + String tableName = args[argsPos++]; + Path outputDir = new Path(args[argsPos++]); Cluster mrCluster = new Cluster(conf); Job job = Job.getInstance(mrCluster, conf); job.setJobName(NAME + "_" + tableName); @@ -86,21 +89,29 @@ // TODO: Allow passing filter and subset of rows/columns. Scan s = new Scan(); // Optional arguments. - int versions = args.length > 2? Integer.parseInt(args[2]): 1; + int versions = args.length > (compress ? 3 : 2) ? + Integer.parseInt(args[argsPos++]) : 1; s.setMaxVersions(versions); - long startTime = args.length > 3? Long.parseLong(args[3]): 0L; - long endTime = args.length > 4? Long.parseLong(args[4]): Long.MAX_VALUE; + long startTime = args.length > (compress ? 4 : 3) ? + Long.parseLong(args[argsPos++]) : 0L; + long endTime = args.length > (compress ? 5 : 4) ? + Long.parseLong(args[argsPos++]) : Long.MAX_VALUE; s.setTimeRange(startTime, endTime); - Log.info("verisons=" + versions + ", starttime=" + startTime + - ", endtime=" + endTime); + Log.info("versions=" + versions + ", starttime=" + startTime + + ", endtime=" + endTime + ", compress=" + compress); TableMapReduceUtil.initTableMapperJob(tableName, s, Exporter.class, null, null, job); - // No reducers. Just write straight to output files. + // No reducers. Just write straight to output files. job.setNumReduceTasks(0); job.setOutputFormatClass(SequenceFileOutputFormat.class); job.setOutputKeyClass(ImmutableBytesWritable.class); job.setOutputValueClass(Result.class); FileOutputFormat.setOutputPath(job, outputDir); + if (compress) { + FileOutputFormat.setCompressOutput(job, true); + FileOutputFormat.setOutputCompressorClass(job, + org.apache.hadoop.io.compress.GzipCodec.class); + } return job; } @@ -111,8 +122,9 @@ if (errorMsg != null && errorMsg.length() > 0) { System.err.println("ERROR: " + errorMsg); } - System.err.println("Usage: Export [ " + - "[ []]]"); + System.err.println("Usage: Export [-z|--compress] [ " + + "[ []]]\n"); + System.err.println("\t\t-z|--compress\tEnable compression of output files"); } /**