From a85dcf17897edb71c25c584ec05c9df21d05e960 Mon Sep 17 00:00:00 2001 From: RoronoaZoro1665 Date: Fri, 16 Dec 2016 14:14:52 +0800 Subject: [PATCH] HBASE-17325 - Add batch delete capability to ImportTsv --- .../main/java/org/apache/hadoop/hbase/mapreduce/CellCreator.java | 8 ++++++++ .../main/java/org/apache/hadoop/hbase/mapreduce/ImportTsv.java | 2 ++ 2 files changed, 10 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCreator.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCreator.java index 001f64d..b886183 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCreator.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/CellCreator.java @@ -123,6 +123,14 @@ public class CellCreator { public Cell create(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength, long timestamp, byte[] value, int voffset, int vlength, List tags) throws IOException { + +// return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, +// qlength, timestamp, KeyValue.Type.Put, value, voffset, vlength, tags); + boolean bulk_delete_key = this.visExpResolver.getConf().getBoolean(ImportTsv.BULK_DELETE_KEY,false); + if(bulk_delete_key){ + return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, + qlength, timestamp, KeyValue.Type.DeleteFamily, value, voffset, vlength, tags); + } return new KeyValue(row, roffset, rlength, family, foffset, flength, qualifier, qoffset, qlength, timestamp, KeyValue.Type.Put, value, voffset, vlength, tags); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/ImportTsv.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/ImportTsv.java index 39085df..32d7eef 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/ImportTsv.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/ImportTsv.java @@ -83,6 +83,7 @@ public class ImportTsv extends Configured implements Tool { public final static String MAPPER_CONF_KEY = "importtsv.mapper.class"; public final static String BULK_OUTPUT_CONF_KEY = "importtsv.bulk.output"; + public final static String BULK_DELETE_KEY = "importtsv.bulk.delete"; public final static String TIMESTAMP_CONF_KEY = "importtsv.timestamp"; public final static String JOB_NAME_CONF_KEY = "mapreduce.job.name"; // TODO: the rest of these configs are used exclusively by TsvImporterMapper. @@ -679,6 +680,7 @@ public class ImportTsv extends Configured implements Tool { "By default importtsv will load data directly into HBase. To instead generate\n" + "HFiles of data to prepare for a bulk data load, pass the option:\n" + " -D" + BULK_OUTPUT_CONF_KEY + "=/path/for/output\n" + + " -D" + BULK_DELETE_KEY + "=false switch to bulk delete\n" + " Note: if you do not use this option, then the target table must already exist in HBase\n" + "\n" + "Other options that may be specified with -D include:\n" + -- 1.9.1