private MyRecordWriter getMyRecordWriter(JobConf jobConf) throws IOException { String hbaseTableName = jobConf.get(HBaseSerDe.HBASE_TABLE_NAME); jobConf.set(TableOutputFormat.OUTPUT_TABLE, hbaseTableName); final boolean walEnabled = HiveConf.getBoolVar( jobConf, HiveConf.ConfVars.HIVE_HBASE_WAL_ENABLED); final Connection conn = ConnectionFactory.createConnection(HBaseConfiguration.create(jobConf)); final BufferedMutator table = conn.getBufferedMutator(TableName.valueOf(hbaseTableName)); return new MyRecordWriter(table, conn, walEnabled); }
@Override public org.apache.hadoop.mapred.RecordWriter<ImmutableBytesWritable, Object> getRecordWriter( FileSystem fileSystem, JobConf jobConf, String name, Progressable progressable) throws IOException { String hbaseTableName = jobConf.get(HBaseSerDe.HBASE_TABLE_NAME); jobConf.set(TableOutputFormat.OUTPUT_TABLE, hbaseTableName); final boolean walEnabled = HiveConf.getBoolVar( jobConf, HiveConf.ConfVars.HIVE_HBASE_WAL_ENABLED); final HTable table = new HTable(HBaseConfiguration.create(jobConf), hbaseTableName); table.setAutoFlush(false); return new MyRecordWriter(table,walEnabled); }
@Override public void write(Writable w) throws IOException { write(null, w); }
@Override public void close(boolean abort) throws IOException { close(null); } }