分享

生成HFile以及入库到HBase

pig2 2014-8-2 11:54:08 发表于 实操演练 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 3 31226
问题导读:
1.如何通过mr生成HFile
2.改进后的HFileOutputFormat有什么新增特性?
3.HFile入库到HBase如何入库到HBase








一、MR生成HFile文件
  1. package insert.tools.hfile;
  2. import java.io.IOException;
  3. import org.apache.hadoop.conf.Configuration;
  4. import org.apache.hadoop.fs.Path;
  5. import org.apache.hadoop.hbase.HBaseConfiguration;
  6. import org.apache.hadoop.hbase.KeyValue;
  7. import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
  8. import org.apache.hadoop.hbase.mapreduce.KeyValueSortReducer;
  9. import org.apache.hadoop.hbase.util.Bytes;
  10. import org.apache.hadoop.io.LongWritable;
  11. import org.apache.hadoop.io.Text;
  12. import org.apache.hadoop.mapreduce.Job;
  13. import org.apache.hadoop.mapreduce.Mapper;
  14. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
  15. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  16. public class TestHFileToHBase {
  17.         public static class TestHFileToHBaseMapper extends Mapper {
  18.                 @Override
  19.                 protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
  20.                         String[] values = value.toString().split("/t", 2);
  21.                         byte[] row = Bytes.toBytes(values[0]);
  22.                         ImmutableBytesWritable k = new ImmutableBytesWritable(row);
  23.                         KeyValue kvProtocol = new KeyValue(row, "PROTOCOLID".getBytes(), "PROTOCOLID".getBytes(), values[1]
  24.                                         .getBytes());
  25.                         context.write(k, kvProtocol);
  26.                         // KeyValue kvSrcip = new KeyValue(row, "SRCIP".getBytes(),
  27.                         // "SRCIP".getBytes(), values[1].getBytes());
  28.                         // context.write(k, kvSrcip);
  29. //                         HFileOutputFormat.getRecordWriter
  30.                 }
  31.         }
  32.         public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
  33.                 Configuration conf = HBaseConfiguration.create();
  34.                 Job job = new Job(conf, "TestHFileToHBase");
  35.                 job.setJarByClass(TestHFileToHBase.class);
  36.                 job.setOutputKeyClass(ImmutableBytesWritable.class);
  37.                 job.setOutputValueClass(KeyValue.class);
  38.                 job.setMapperClass(TestHFileToHBaseMapper.class);
  39.                 job.setReducerClass(KeyValueSortReducer.class);
  40. //                job.setOutputFormatClass(org.apache.hadoop.hbase.mapreduce.HFileOutputFormat.class);
  41.                 job.setOutputFormatClass(HFileOutputFormat.class);
  42.                 // job.setNumReduceTasks(4);
  43.                 // job.setPartitionerClass(org.apache.hadoop.hbase.mapreduce.SimpleTotalOrderPartitioner.class);
  44.                 // HBaseAdmin admin = new HBaseAdmin(conf);
  45. //                HTable table = new HTable(conf, "hua");
  46.                  HFileOutputFormat.configureIncrementalLoad(job, table);
  47.                 FileInputFormat.addInputPath(job, new Path(args[0]));
  48.                 FileOutputFormat.setOutputPath(job, new Path(args[1]));
  49.                 System.exit(job.waitForCompletion(true) ? 0 : 1);
  50.         }
  51. }
复制代码

二、改进后的HFileOutputFormat

源码中的HFileOutputFormat只适合一次生成一个列族的HFile,改进后的HFileOutputFormat适合同时多列族生成HFile文件。有add标签的是在源码上添加代码,有revise标签的是在源码上增加代码。参考:https://review.cloudera.org/r/12 ... 977#file17977line93

  1. /**
  2. * Copyright 2009 The Apache Software Foundation
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one
  5. * or more contributor license agreements.  See the NOTICE file
  6. * distributed with this work for additional information
  7. * regarding copyright ownership.  The ASF licenses this file
  8. * to you under the Apache License, Version 2.0 (the
  9. * "License"); you may not use this file except in compliance
  10. * with the License.  You may obtain a copy of the License at
  11. *
  12. *     http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. package insert.tools.hfile;
  21. import java.io.IOException;
  22. import java.net.URI;
  23. import java.net.URISyntaxException;
  24. import java.util.ArrayList;
  25. import java.util.List;
  26. import java.util.Map;
  27. import java.util.TreeMap;
  28. import java.util.TreeSet;
  29. import org.apache.hadoop.conf.Configuration;
  30. import org.apache.hadoop.filecache.DistributedCache;
  31. import org.apache.hadoop.fs.FileSystem;
  32. import org.apache.hadoop.fs.Path;
  33. import org.apache.hadoop.hbase.HConstants;
  34. import org.apache.hadoop.hbase.KeyValue;
  35. import org.apache.hadoop.hbase.client.HTable;
  36. import org.apache.hadoop.hbase.client.Put;
  37. import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
  38. import org.apache.hadoop.hbase.io.hfile.Compression;
  39. import org.apache.hadoop.hbase.io.hfile.HFile;
  40. import org.apache.hadoop.hbase.mapreduce.KeyValueSortReducer;
  41. import org.apache.hadoop.hbase.mapreduce.hadoopbackport.TotalOrderPartitioner;
  42. import org.apache.hadoop.hbase.regionserver.StoreFile;
  43. import org.apache.hadoop.hbase.util.Bytes;
  44. import org.apache.hadoop.io.NullWritable;
  45. import org.apache.hadoop.io.SequenceFile;
  46. import org.apache.hadoop.mapreduce.Job;
  47. import org.apache.hadoop.mapreduce.RecordWriter;
  48. import org.apache.hadoop.mapreduce.TaskAttemptContext;
  49. import org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter;
  50. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
  51. import org.apache.commons.logging.Log;
  52. import org.apache.commons.logging.LogFactory;
  53. import com.google.common.base.Preconditions;
  54. /**
  55. * Writes HFiles. Passed KeyValues must arrive in order. Currently, can only
  56. * write files to a single column family at a time. Multiple column families
  57. * requires coordinating keys cross family. Writes current time as the sequence
  58. * id for the file. Sets the major compacted attribute on created hfiles.
  59. *
  60. * @see KeyValueSortReducer
  61. */
  62. public class HFileOutputFormat extends
  63.                 FileOutputFormat {
  64.         static Log LOG = LogFactory.getLog(HFileOutputFormat.class);
  65.         public RecordWriter getRecordWriter(
  66.                         final TaskAttemptContext context) throws IOException,
  67.                         InterruptedException {
  68.                 // Get the path of the temporary output file
  69.                 final Path outputPath = FileOutputFormat.getOutputPath(context);
  70.                 final Path outputdir = new FileOutputCommitter(outputPath, context)
  71.                                 .getWorkPath();
  72.                 Configuration conf = context.getConfiguration();
  73.                 final FileSystem fs = outputdir.getFileSystem(conf);
  74.                 // These configs. are from hbase-*.xml
  75.                 // revise
  76.                 // final long maxsize = conf.getLong("hbase.hregion.max.filesize",
  77.                 // 268435456);
  78.                 // final int blocksize = conf.getInt("hfile.min.blocksize.size", 65536);
  79.                 final long maxsize = conf.getLong("hbase.hregion.max.filesize",
  80.                                 HConstants.DEFAULT_MAX_FILE_SIZE);
  81.                 final int blocksize = conf.getInt("hfile.min.blocksize.size",
  82.                                 HFile.DEFAULT_BLOCKSIZE);
  83.                 // -revise
  84.                 // Invented config. Add to hbase-*.xml if other than default
  85.                 // compression.
  86.                 final String compression = conf.get("hfile.compression",
  87.                                 Compression.Algorithm.NONE.getName());
  88.                 return new RecordWriter() {
  89.                         // Map of families to writers and how much has been output on the
  90.                         // writer.
  91.                         private final Map<byte[], WriterLength> writers = new TreeMap<byte[], WriterLength>(
  92.                                         Bytes.BYTES_COMPARATOR);
  93.                         private byte[] previousRow = HConstants.EMPTY_BYTE_ARRAY;
  94.                         private final byte[] now = Bytes
  95.                                         .toBytes(System.currentTimeMillis());
  96.                         // add
  97.                         private boolean rollRequested = false;
  98.                         // -add
  99.                         public void write(ImmutableBytesWritable row, KeyValue kv)
  100.                                         throws IOException {
  101.                                 // add
  102.                                 // null input == user explicitly wants to flush
  103.                                 if (row == null && kv == null) {
  104.                                         rollWriters();
  105.                                         return;
  106.                                 }
  107.                                 byte[] rowKey = kv.getRow();
  108.                                 // -add
  109.                                 long length = kv.getLength();
  110.                                 byte[] family = kv.getFamily();
  111.                                 WriterLength wl = this.writers.get(family);
  112.                                 // revise
  113.                                 // if (wl == null
  114.                                 // || ((length + wl.written) >= maxsize)
  115.                                 // && Bytes.compareTo(this.previousRow, 0,
  116.                                 // this.previousRow.length, kv.getBuffer(), kv
  117.                                 // .getRowOffset(), kv.getRowLength()) != 0) {
  118.                                 // // Get a new writer.
  119.                                 // Path basedir = new Path(outputdir, Bytes.toString(family));
  120.                                 // if (wl == null) {
  121.                                 // wl = new WriterLength();
  122.                                 // this.writers.put(family, wl);
  123.                                 // if (this.writers.size() > 1)
  124.                                 // throw new IOException("One family only");
  125.                                 // // If wl == null, first file in family. Ensure family
  126.                                 // // dir exits.
  127.                                 // if (!fs.exists(basedir))
  128.                                 // fs.mkdirs(basedir);
  129.                                 // }
  130.                                 // wl.writer = getNewWriter(wl.writer, basedir);
  131.                                 // LOG
  132.                                 // .info("Writer="
  133.                                 // + wl.writer.getPath()
  134.                                 // + ((wl.written == 0) ? "" : ", wrote="
  135.                                 // + wl.written));
  136.                                 // wl.written = 0;
  137.                                 // }
  138.                                 // If this is a new column family, verify that the directory
  139.                                 // exists
  140.                                 if (wl == null) {
  141.                                         fs.mkdirs(new Path(outputdir, Bytes.toString(family)));
  142.                                 }
  143.                                 // If any of the HFiles for the column families has reached
  144.                                 // maxsize, we need to roll all the writers
  145.                                 if (wl != null && wl.written + length >= maxsize) {
  146.                                         this.rollRequested = true;
  147.                                 }
  148.                                 // This can only happen once a row is finished though
  149.                                 if (rollRequested
  150.                                                 && Bytes.compareTo(this.previousRow, rowKey) != 0) {
  151.                                         rollWriters();
  152.                                 }
  153.                                 // create a new HLog writer, if necessary
  154.                                 if (wl == null || wl.writer == null) {
  155.                                         wl = getNewWriter(family);
  156.                                 }
  157.                                 // we now have the proper HLog writer. full steam ahead
  158.                                 // -revise
  159.                                 kv.updateLatestStamp(this.now);
  160.                                 wl.writer.append(kv);
  161.                                 wl.written += length;
  162.                                 // Copy the row so we know when a row transition.
  163.                                 // revise
  164.                                 // this.previousRow = kv.getRow();
  165.                                 this.previousRow = rowKey;
  166.                                 // -revise
  167.                         }
  168.                         // revise
  169.                         // /*
  170.                         // * Create a new HFile.Writer. Close current if there is one.
  171.                         // *
  172.                         // * @param writer
  173.                         // *
  174.                         // * @param familydir
  175.                         // *
  176.                         // * @return A new HFile.Writer.
  177.                         // *
  178.                         // * @throws IOException
  179.                         // */
  180.                         // private HFile.Writer getNewWriter(final HFile.Writer writer,
  181.                         // final Path familydir) throws IOException {
  182.                         // close(writer);
  183.                         // return new HFile.Writer(fs, StoreFile.getUniqueFile(fs,
  184.                         // familydir), blocksize, compression,
  185.                         // KeyValue.KEY_COMPARATOR);
  186.                         // }
  187.                         private void rollWriters() throws IOException {
  188.                                 for (WriterLength wl : this.writers.values()) {
  189.                                         if (wl.writer != null) {
  190.                                                 LOG.info("Writer="
  191.                                                                 + wl.writer.getPath()
  192.                                                                 + ((wl.written == 0) ? "" : ", wrote="
  193.                                                                                 + wl.written));
  194.                                                 close(wl.writer);
  195.                                         }
  196.                                         wl.writer = null;
  197.                                         wl.written = 0;
  198.                                 }
  199.                                 this.rollRequested = false;
  200.                         }
  201.                         /*
  202.                          * Create a new HFile.Writer.
  203.                          *
  204.                          * @param family
  205.                          *
  206.                          * @return A WriterLength, containing a new HFile.Writer.
  207.                          *
  208.                          * @throws IOException
  209.                          */
  210.                         private WriterLength getNewWriter(byte[] family) throws IOException {
  211.                                 WriterLength wl = new WriterLength();
  212.                                 Path familydir = new Path(outputdir, Bytes.toString(family));
  213.                                 wl.writer = new HFile.Writer(fs, StoreFile.getUniqueFile(fs,
  214.                                                 familydir), blocksize, compression,
  215.                                                 KeyValue.KEY_COMPARATOR);
  216.                                 this.writers.put(family, wl);
  217.                                 return wl;
  218.                         }
  219.                         // -revise
  220.                         private void close(final HFile.Writer w) throws IOException {
  221.                                 if (w != null) {
  222.                                         w.appendFileInfo(StoreFile.BULKLOAD_TIME_KEY, Bytes
  223.                                                         .toBytes(System.currentTimeMillis()));
  224.                                         w.appendFileInfo(StoreFile.BULKLOAD_TASK_KEY, Bytes
  225.                                                         .toBytes(context.getTaskAttemptID().toString()));
  226.                                         w.appendFileInfo(StoreFile.MAJOR_COMPACTION_KEY, Bytes
  227.                                                         .toBytes(true));
  228.                                         w.close();
  229.                                 }
  230.                         }
  231.                         // revise
  232.                         // public void close(TaskAttemptContext c) throws IOException,
  233.                         // InterruptedException {
  234.                         // for (Map.Entry e : this.writers
  235.                         // .entrySet()) {
  236.                         // close(e.getValue().writer);
  237.                         // }
  238.                         // }
  239.                         public void close(TaskAttemptContext c) throws IOException,
  240.                                         InterruptedException {
  241.                                 for (WriterLength wl : this.writers.values()) {
  242.                                         close(wl.writer);
  243.                                 }
  244.                         }
  245.                         // -revise
  246.                 };
  247.         }
  248.         /*
  249.          * Data structure to hold a Writer and amount of data written on it.
  250.          */
  251.         static class WriterLength {
  252.                 long written = 0;
  253.                 HFile.Writer writer = null;
  254.         }
  255.         /**
  256.          * Return the start keys of all of the regions in this table, as a list of
  257.          * ImmutableBytesWritable.
  258.          */
  259.         private static List getRegionStartKeys(HTable table)
  260.                         throws IOException {
  261.                 byte[][] byteKeys = table.getStartKeys();
  262.                 ArrayList ret = new ArrayList(
  263.                                 byteKeys.length);
  264.                 for (byte[] byteKey : byteKeys) {
  265.                         ret.add(new ImmutableBytesWritable(byteKey));
  266.                 }
  267.                 return ret;
  268.         }
  269.         /**
  270.          * Write out a SequenceFile that can be read by TotalOrderPartitioner that
  271.          * contains the split points in startKeys.
  272.          *
  273.          * @param partitionsPath
  274.          *            output path for SequenceFile
  275.          * @param startKeys
  276.          *            the region start keys
  277.          */
  278.         private static void writePartitions(Configuration conf,
  279.                         Path partitionsPath, List startKeys)
  280.                         throws IOException {
  281.                 Preconditions.checkArgument(!startKeys.isEmpty(), "No regions passed");
  282.                 // We're generating a list of split points, and we don't ever
  283.                 // have keys < the first region (which has an empty start key)
  284.                 // so we need to remove it. Otherwise we would end up with an
  285.                 // empty reducer with index 0
  286.                 TreeSet sorted = new TreeSet(
  287.                                 startKeys);
  288.                 ImmutableBytesWritable first = sorted.first();
  289.                 Preconditions
  290.                                 .checkArgument(
  291.                                                 first.equals(HConstants.EMPTY_BYTE_ARRAY),
  292.                                                 "First region of table should have empty start key. Instead has: %s",
  293.                                                 Bytes.toStringBinary(first.get()));
  294.                 sorted.remove(first);
  295.                 // Write the actual file
  296.                 FileSystem fs = partitionsPath.getFileSystem(conf);
  297.                 SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf,
  298.                                 partitionsPath, ImmutableBytesWritable.class,
  299.                                 NullWritable.class);
  300.                 try {
  301.                         for (ImmutableBytesWritable startKey : sorted) {
  302.                                 writer.append(startKey, NullWritable.get());
  303.                         }
  304.                 } finally {
  305.                         writer.close();
  306.                 }
  307.         }
  308.         /**
  309.          * Configure a MapReduce Job to perform an incremental load into the given
  310.          * table. This
  311.          *
  312.          *
  313. Inspects the table to configure a total order partitioner
  314.          *
  315. Uploads the partitions file to the cluster and adds it to the
  316.          * DistributedCache
  317.          *
  318. Sets the number of reduce tasks to match the current number of
  319.          * regions
  320.          *
  321. Sets the output key/value class to match HFileOutputFormat's
  322.          * requirements
  323.          *
  324. Sets the reducer up to perform the appropriate sorting (either
  325.          * KeyValueSortReducer or PutSortReducer)
  326.          *
  327.          * The user should be sure to set the map output value class to either
  328.          * KeyValue or Put before running this function.
  329.          */
  330.         public static void configureIncrementalLoad(Job job, HTable table)
  331.                         throws IOException {
  332.                 Configuration conf = job.getConfiguration();
  333.                 job.setPartitionerClass(TotalOrderPartitioner.class);
  334.                 job.setOutputKeyClass(ImmutableBytesWritable.class);
  335.                 job.setOutputValueClass(KeyValue.class);
  336.                 job.setOutputFormatClass(HFileOutputFormat.class);
  337.                 // Based on the configured map output class, set the correct reducer to
  338.                 // properly
  339.                 // sort the incoming values.
  340.                 // TODO it would be nice to pick one or the other of these formats.
  341.                 if (KeyValue.class.equals(job.getMapOutputValueClass())) {
  342.                         job.setReducerClass(KeyValueSortReducer.class);
  343.                 } else if (Put.class.equals(job.getMapOutputValueClass())) {
  344.                         job.setReducerClass(PutSortReducer.class);
  345.                 } else {
  346.                         LOG.warn("Unknown map output value type:"
  347.                                         + job.getMapOutputValueClass());
  348.                 }
  349.                 LOG.info("Looking up current regions for table " + table);
  350.                 List startKeys = getRegionStartKeys(table);
  351.                 LOG.info("Configuring " + startKeys.size() + " reduce partitions "
  352.                                 + "to match current region count");
  353.                 job.setNumReduceTasks(startKeys.size());
  354.                 Path partitionsPath = new Path(job.getWorkingDirectory(), "partitions_"
  355.                                 + System.currentTimeMillis());
  356.                 LOG.info("Writing partition information to " + partitionsPath);
  357.                 FileSystem fs = partitionsPath.getFileSystem(conf);
  358.                 writePartitions(conf, partitionsPath, startKeys);
  359.                 partitionsPath.makeQualified(fs);
  360.                 URI cacheUri;
  361.                 try {
  362.                         cacheUri = new URI(partitionsPath.toString() + "#"
  363.                                         + TotalOrderPartitioner.DEFAULT_PATH);
  364.                 } catch (URISyntaxException e) {
  365.                         throw new IOException(e);
  366.                 }
  367.                 DistributedCache.addCacheFile(cacheUri, conf);
  368.                 DistributedCache.createSymlink(conf);
  369.                 LOG.info("Incremental table output configured.");
  370.         }
  371. }
复制代码




三、MR生成HFile的注意事项

1. 无论是map还是reduce作为最终的输出结果,输出的key和value的类型应该是: 或者< ImmutableBytesWritable, Put>。

2. Map或者reduce的输出类型是KeyValue 或Put对应KeyValueSortReducer或PutSortReducer。

3. MR例子中job.setOutputFormatClass(HFileOutputFormat.class); HFileOutputFormat是改进后的mr,可适用于多列族同时生成HFile文件,源码中只适合一次对单列族组织成HFile文件。

4. MR例子中HFileOutputFormat.configureIncrementalLoad(job, table);自动对job进行配置,SimpleTotalOrderPartitioner是需要先对key进行整体排序,然后划分到每个reduce中,保证每一个reducer中的的key最小最大值区间范围,是不会有交集的。

因为入库到HBase的时候,作为一个整体的Region,key是绝对有序的。

5. MR例子中最后生成HFile存储在HDFS上,输出路径下的子目录是各个列族。如果对HFile进行入库HBase,相当于move HFile到HBase的Region中,HFile子目录的列族内容没有了。

四、HFile入库到HBase

  1. import org.apache.hadoop.hbase.client.HTable;
  2. import org.apache.hadoop.hbase.mapreduce.LoadIncrementalHFiles;
  3. import org.apache.hadoop.hbase.util.Bytes;
  4. public class TestLoadIncrementalHFileToHBase {
  5.         // private static final byte[] TABLE = Bytes.toBytes("hua");
  6.         // private static final byte[] QUALIFIER = Bytes.toBytes("PROTOCOLID");
  7.         // private static final byte[] FAMILY = Bytes.toBytes("PROTOCOLID");
  8.         public static void main(String[] args) throws IOException {
  9.                 Configuration conf = HBaseConfiguration.create();
  10. //                byte[] TABLE = Bytes.toBytes("hua");
  11.                 byte[] TABLE = Bytes.toBytes(args[0]);
  12.                 HTable table = new HTable(TABLE);
  13.                 LoadIncrementalHFiles loader = new LoadIncrementalHFiles(conf);
  14.                 loader.doBulkLoad(new Path(args[1]), table);
  15. //                loader.doBulkLoad(new Path("/hua/testHFileResult/"), table);
  16.         }
  17. }
复制代码

五、HFile入库到HBase注意事项

1. 通过HBase中 LoadIncrementalHFiles的doBulkLoad方法,对生成的HFile文件入库,入库的第一个参数是表名,第二个参数是HFile的路径(以上MR生成HFile的输出路径),也可一个个列族录入到HBase中对应的表列族。

2. 如何入库的相关链接:

http://hbase.apache.org/docs/r0.89.20100726/bulk-loads.html

http://hbase.apache.org/docs/r0. ... e-summary.html#bulk

http://genius-bai.javaeye.com/blog/641927

3. 入库分为代码入库以及脚本入库。代码入库有两种,一种是

hadoop jar hbase-VERSION.jar completebulkload /myoutput mytable;

另外一种是通过以上的TestLoadIncrementalHFileToHBase类。

脚本入库为:jruby  $HBASE_HOME/bin/loadtable.rb  hbase-mytable  hadoop-hbase-hfile-outputdir。








已有(3)人评论

跳转到指定楼层
zqh_2014 发表于 2014-11-11 13:52:57
第一种MR生成HFile,有详细的资料吗?目前在HDFS上有一个txt文件,然后在eclipse运行代码,会有异常:
Exception in thread "main" java.lang.IllegalArgumentException: No regions passed
        at org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.writePartitions(HFileOutputFormat2.java:307)
        at org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.configurePartitioner(HFileOutputFormat2.java:527)
        at org.apache.hadoop.hbase.mapreduce.HFileOutputFormat2.configureIncrementalLoad(HFileOutputFormat2.java:391)
        at org.apache.hadoop.hbase.mapreduce.HFileOutputFormat.configureIncrementalLoad(HFileOutputFormat.java:88)
        at TestHFileToHBase.main(TestHFileToHBase.java:73)

回复

使用道具 举报

howtodown 发表于 2014-11-11 18:47:34
zqh_2014 发表于 2014-11-11 13:52
第一种MR生成HFile,有详细的资料吗?目前在HDFS上有一个txt文件,然后在eclipse运行代码,会有异常:
Exc ...
可参考下面三个,都是这方面的资料
MapReduce生成HFile入库到HBase
HFile文件格式与HBase读写

MapReduce生成HFile入库到HBase及源码分析

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条