HBase

Configuration conf = HBaseConfiguration.create();
conf.set("hbase.rootdir","hdfs://bd:9000/hbase");
conf.set("hbase.zookeeper.property.dataDir","/home/moon/hbase/zookeeper");
conf.set("hbase.zookeeper.quorum","bd");
conf.set("hbase.cluster.distributed","true");
Connection connection = ConnectionFactory.createConnection(conf);
HBaseAdmin admin = (HBaseAdmin)connection.getAdmin();
TableDescriptorBuilder tdb = 
TableDescriptorBuilder.newBuilder(TableName.valueOf("class"));
List<ColumnFamilyDescriptor> listColumns = new ArrayList<>();
ColumnFamilyDescriptor cfd_info =
ColumnFamilyDescriptorBuilder.newBuilder("information".getBytes()).build();
ColumnFamilyDescriptor cfd_res =
ColumnFamilyDescriptorBuilder.newBuilder("results".getBytes()).build();
listColumns.add(cfd_info);
listColumns.add(cfd_res);
tdb.setColumnFamilies(listColumns);
TableDescriptor td= tdb.build();
admin.createTable(td);
admin.close();
connection.close();

There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 19922944 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
#   JVM is running with Unscaled Compressed Oops mode in which the Java heap is
#     placed in the first 4GB address space. The Java Heap base address is the
#     maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
#     to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2994), pid=5009, tid=5016
#
# JRE version: OpenJDK Runtime Environment JBR-11.0.13.7-1751.19-jcef (11.0.13+7) (build 11.0.13+7-b1751.19)
# Java VM: OpenJDK 64-Bit Server VM JBR-11.0.13.7-1751.19-jcef (11.0.13+7-b1751.19, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /opt/idea-IC-213.5744.223/bin/core.5009)
#

---------------  S U M M A R Y ------------

Command Line: -Xms128m -Xmx750m -XX:ReservedCodeCacheSize=512m -XX:+IgnoreUnrecognizedVMOptions -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -Dsun.tools.attach.tmp.only=true -Xmx750m -XX:ErrorFile=/home/yrfmessi/java_error_in_idea_%p.log -XX:HeapDumpPath=/home/yrfmessi/java_error_in_idea_.hprof -Djb.vmOptionsFile=/home/yrfmessi/.config/JetBrains/IdeaIC2021.3/idea64.vmoptions -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.vendor.name=JetBrains -Didea.paths.selector=IdeaIC2021.3 -Didea.platform.prefix=Idea -Didea.jre.check=true -Dsplash=true com.intellij.idea.Main

Host: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, 2 cores, 1G, Ubuntu 16.04.7 LTS
Time: Mon Dec 13 23:16:07 2021 CST elapsed time: 190.875414 seconds (0d 0h 3m 10s)

---------------  T H R E A D  ---------------

Current thread (0x00007f1780128000):  VMThread "VM Thread" [stack: 0x00007f175c2d6000,0x00007f175c3d6000] [id=5016]

Stack: [0x00007f175c2d6000,0x00007f175c3d6000],  sp=0x00007f175c3d3dc0,  free space=1015k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xe664ca]

# Mapper
public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable>{
    public void map(Object key, Text value, Context context) throws 
    IOException,InterruptedException {
        Text word = new Text();
        IntWritable one = new IntWritable(1);
        StringTokenizer itr = new StringTokenizer(value.toString());
        while (itr.hasMoreTokens()) {
            word.set(itr.nextToken());
            context.write(word, one);
        } 
    } 
}
# Reduce
public static class IntSumReducer extends Reducer<Text,IntWritable,Text,IntWritable> {
    public void reduce(Text key, Iterable<IntWritable> values,Context context) 
    throws IOException, InterruptedException {
        int sum = 0;
        for (IntWritable val : values)
            sum += val.get();
        private IntWritable result = new IntWritable();
        result.set(sum);
        context.write(key, result);
    } 
}
# WordCount
public static void main(String[] args) throws Exception {
    Configuration conf = new Configuration();
    String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
    if (otherArgs.length != 2) {
        System.err.println("Usage: wordcount <in> <out>");
        System.exit(2); 
    }
    Job job = Job.getInstance(conf, "word count");
    job.setJarByClass(WordCount.class);
    job.setMapperClass(TokenizerMapper.class);
    job.setReducerClass(IntSumReducer.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);
    FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
    FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
    System.exit(job.waitForCompletion(true) ? 0 : 1);
}

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值