Caused by: java.io.IOException: Added a key not lexically larger than previous.

來源:互聯網
上載者:User

標籤:url   use   ddc   pre   tor   esc   values   incr   遇到   

為了重複這個實驗,遇到不少坑

https://www.iteblog.com/archives/1889.html

/** * Created by Administrator on 2017/8/18. */public class IteblogBulkLoadDriver {    public static class IteblogBulkLoadMapper extends Mapper<LongWritable, Text, StringWriter, Put> {        protected void map(LongWritable key, Text value, Context context) throws InterruptedException, IOException {            if(value==null) {                return;            }            String line = value.toString();            String[] items = line.split("\\^");            if(items.length<3){                items = line.split("\\^");            }            if(items.length<3){                System.out.println("================less 3");                return;            }            System.out.println(line);            String rowKey = items[0]+items[1];            Put put = new Put(Bytes.toBytes(items[0]));   //ROWKEY            put.addColumn("cf".getBytes(), "url".getBytes(), items[1].getBytes());            put.addColumn("cf".getBytes(), "name".getBytes(), items[2].getBytes());            context.write(new StringWriter().append(rowKey), put);        }    }    public static class HBaseHFileReducer extends            Reducer<StringWriter, Put, ImmutableBytesWritable, Put> {        protected void reduce(StringWriter key, Iterable<Put> values,                              Context context) throws IOException, InterruptedException {            String value = "";            ImmutableBytesWritable k  = new ImmutableBytesWritable(key.toString().getBytes());            Put val = values.iterator().next();            context.write(k, val);        }    }    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {//              String SRC_PATH= "hdfs:/slave1:8020/maats5/pay/logdate=20170906";//              String DESC_PATH= "hdfs:/slave1:8020/maats5_test/pay/logdate=20170906";            String SRC_PATH= args[0];            String DESC_PATH=args[1];            Configuration conf = HBaseConnectionFactory.config;            conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");            Job job=Job.getInstance(conf);            job.setJarByClass(IteblogBulkLoadDriver.class);            job.setMapperClass(IteblogBulkLoadMapper.class);            job.setMapOutputKeyClass(StringWriter.class);            job.setMapOutputValueClass(Put.class);            job.setReducerClass(HBaseHFileReducer.class);            job.setOutputFormatClass(HFileOutputFormat2.class);            HTable table = new HTable(conf,"maatstest");            HFileOutputFormat2.configureIncrementalLoad(job,table,table.getRegionLocator());            FileInputFormat.addInputPath(job,new Path(SRC_PATH));            FileOutputFormat.setOutputPath(job,new Path(DESC_PATH));            System.exit(job.waitForCompletion(true)?0:1);        }    }

 

 

 

When using the bulkloader (LoadIncrementalHFiles, doBulkLoad) you can only add items that are "lexically ordered", ie. you need to make sure that the items you add are sorted by the row-id.

https://stackoverflow.com/questions/25860114/hfile-creation-added-a-key-not-lexically-larger-than-previous-key

 http://ganliang13.iteye.com/blog/1884921

Caused by: java.io.IOException: Added a key not lexically larger than previous.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.