HBase Java API使用操作例子

封装hbase以便java调用 NULL 博文链接:https://alleyz.iteye.com/blog/2254738 立即下载
通过对HBase API的使用,下面例子举例了常见对HBase的操作,如下所示:


package net.linuxidc.www;  
  
import org.apache.Hadoop.conf.Configuration;  
import org.apache.hadoop.hbase.HBaseConfiguration;  
import org.apache.hadoop.hbase.HColumnDescriptor;  
import org.apache.hadoop.hbase.HTableDescriptor;  
import org.apache.hadoop.hbase.KeyValue;  
import org.apache.hadoop.hbase.client.HBaseAdmin;  
import org.apache.hadoop.hbase.client.HTable;  
import org.apache.hadoop.hbase.client.Result;  
import org.apache.hadoop.hbase.client.ResultScanner;  
import org.apache.hadoop.hbase.client.Scan;  
import org.apache.hadoop.hbase.io.BatchUpdate;  
  
public class HBaseDBDao {  
      
    //定义配置对象HBaseConfiguration   
    static HBaseConfiguration cfg =null;  
    static {  
        Configuration configuration = new Configuration();  
        cfg = new HBaseConfiguration(configuration);  
    }  
      
    //创建一张表,指定表名,列族   
    public static void createTable(String tableName,String columnFarily)throws Exception{  
        HBaseAdmin admin = new HBaseAdmin(cfg);  
        if(admin.tableExists(tableName)){  
            System.out.println(tableName+"不存在!");  
            System.exit(0);  
        }else{  
            HTableDescriptor  tableDesc = new HTableDescriptor(tableName);  
            tableDesc.addFamily(new HColumnDescriptor(columnFarily+":"));  
            System.out.println("创建表成功!");  
        }  
    }  
      
    //添加数据,通过HTable。和BatchUpdate为已经存在的表添加数据data   
    public static void addData(String tableName,String row,String columnFamily,String column,String data)throws Exception{  
        HTable table = new HTable(cfg,tableName);  
        BatchUpdate update = new BatchUpdate(row);  
        update.put(columnFamily+":"+column, data.getBytes());  
        table.commit(update);  
        System.out.println("添加成功!");  
    }  
      
    //显示所有数据,通过HTable Scan类获取已有表的信息   
    public static void getAllData(String tableName)throws Exception{  
        HTable table = new HTable(cfg,tableName);  
        Scan scan = new Scan();  
        ResultScanner rs = table.getScanner(scan);  
        for(Result r:rs){  
            for(KeyValue kv:r.raw()){  
                System.out.println(new String(kv.getColumn())+new String(kv.getValue()));  
            }  
        }  
    }  
      
    //测试???数   
    public static void main(String[] args){  
        try{  
            String tableName = "student";  
            HBaseDBDao.createTable(tableName, "c1");  
            HBaseDBDao.addData(tableName, "row1", "c1", "1", "this is row 1 column c1:c1");  
            HBaseDBDao.getAllData(tableName);  
        }catch(Exception e){  
            e.printStackTrace();  
        }  
    }  
}  
TAS5805MPWPR实战:数字音频功放从选型到量产全流程指南 数字音频功放将I2S数字信号直接转为PWM驱动扬声器,省去传统DAC与模拟运放链路,在高保真、低BOM与紧凑PCB之间找到平衡。其核心在于内置可编程DSP,支持多段PEQ、DRC等数字处理,通过I2C配置即可完成调音,而不占用主控算力。这类方案广泛应用于蓝牙音箱、Soundbar、智能音频模组等产品,但实际落地时常遇到I2C通信不稳定、EQ未生效、底噪超标、DC检测误触发等工程问题。从电源布局、LC滤波参数到PurePath Console工具链的使用,再到量产固件加载与故障排查,都需要系统化方法论支撑。本 阅读详情

相关推荐

ROS2 Nav2实战:解决rviz2显示no map received的3种实用方法(附详细步骤)

本文针对ROS2 Nav2导航栈中rviz2显示“no map received”的常见问题,提供了三种核心解决方案。深入剖析了问题根源在于ROS2生命周期节点管理、QoS策略不匹配及坐标系设置错误,并分别通过手动配置流程、集成生命周期管理器以及调优QoS策略与固化rviz2配置,给出了详细的实战步骤,确保地图数据可靠显示。

j0k1l2m3n的博客 422

Hbase java API 的调用例子

1、首先要在项目中导入Hbase依赖的jar包 2、修改windows中的 C:\Windows\System32\drivers\etc\hosts 10.49.85.152 master 10.49.85.182 slaver1 10.49.85.183 slaver2 3、Java API import java.io.IOException; impor...

WILL的博客 1061

【Benchmark 性能测试全指南:从核心原理到 CINEBENCH 实战解析】

本文深度拆解基准测试(Benchmark)的底层逻辑,详解数据集、工作负载、度量指标三大核心要素,分步演示测试流程与统计分析要点。结合 CINEBENCH R23 实战案例,揭秘 CPU 性能评估方法论,助你掌握系统性能量化与优化的核心技能。

rong_ha_ha的博客 6330

hbase的java API基本操作大全

package com.yilian.util; import java.io.File; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; ...

hanyong4719的博客 1071

当Kmer遇到多倍体:复杂基因组Survey分析中的避坑指南

本文针对小麦、棉花等多倍体及高杂合复杂基因组的Survey分析,深入解析了Kmer分布图解读中的常见陷阱。文章重点探讨了如何超越理想二倍体模型,利用Smudgeplot等工具准确判断基因组倍性,并提供了从参数优化、污染判断到结果验证的全流程实战指南,帮助研究者规避错误,获得更准确的基因组大小、杂合度等关键信息。

yhn45678901的博客 1010

深入解析经典蓝牙连接:从HCI命令到LMP协议的完整流程

本文深入解析经典蓝牙连接的完整流程,从设备发现、寻呼建立物理链路,到安全配对与加密的每一步。通过对照HCI LOG与AIR LOG,详细拆解了HCI命令与LMP协议报文的对应关系,帮助开发者精准定位连接问题,掌握蓝牙调试的核心方法。

weixin_29260291的博客 460

hbase java api操作导入数据

使用hbase存储名人数据集,数据集由名人文字信息以及名人图片组成。 名人文字信息使用scrapy框架从wiki百科上爬取并保存在csv格式中。 图片信息从百度图片上爬取每人30张保存在以该名人姓名命名的文件夹中 因此本文包含以下几个方面: - 爬取文本的爬虫 - 爬取图片的爬虫 - 将数据导入hbasescrapy 爬取wiki百科首先新建scrapy项目 然后在settings

py_mxy的博客 2858

10xGenomics Loupe Browser实战指南:从数据导入到细胞注释全流程解析

本文提供了10xGenomics Loupe Browser的实战指南,详细解析了从数据导入到细胞注释的全流程。作为一款强大的可视化工具,Loupe Browser能帮助研究者直观探索单细胞测序数据,通过交互式操作进行细胞选择、差异基因分析和细胞类型注释,是单细胞数据分析入门和结果验证的高效平台。

blue42的博客 454

HBase之——通过Java API与HBase交互

不多说,直接上代码,大家自己看代码分析: import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; imp

冰河的专栏 6271

Orange3实战教程:文本挖掘---主题建模

主题建模通过LDA、LSI或HDP算法分析文档集合,自动发现隐含主题结构。组件输入为文档语料库,输出包括带主题权重的语料库、主题词分布及完整主题数据。不同算法特性各异:LSI允许正负权重但解释性较弱,LDA更易解释,HDP参数复杂需谨慎设置。结果可结合词云、热力图等可视化工具分析主题特征及分布。示例显示如何通过预处理文本、选择算法(如提取5个LDA主题),并利用MDS和箱线图探索主题间关系及关键词分布。

err2008的专栏 366

ABB机器人刷功能选项全一篇就够——不怕丢失程序和IO配置数据

ABB机器人刷功能选项

m0_66701835的博客 1260

hbase api java举例_HBase Java API使用操作例子

通过对HBase API的使用,下面例子举例了常见对HBase的操作,如下所示: package net.linuxidc.www; import org.apache.Hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.had...

weixin_39622332的博客 148

假新闻检测论文分享(30)MMDFND: Multi-modal Multi-Domain Fake News Detection

现有的假新闻检测方法通常集中在单一领域的新闻上,如健康或政治。然而,社交媒体上的新闻往往来自多个领域,这给单一领域的假新闻检测方法带来了两个主要挑战:数据稀缺性:处理较小、单一领域的新闻数据集时,由于训练数据的稀缺,模型的有效性显著下降。跨领域检测的准确性下降:单一领域的假新闻检测方法在跨领域新闻数据集上的准确性大幅降低。缓解领域间模态语义偏差:通过DPLE网络提取跨领域和领域特定的知识,缓解了不同领域间文本和图像的语义差异。

weixin_41964296的博客 671

java API 操作 hbase 数据库(这不是简单的例子,是可以用于运营系统的高性能源码)

这不是简单的例子,是可以用于运营系统的高性能源码(例:http://htok.net/web),可根据实际需求稍加升级后直接使用

轻松互联网开发,Easy do it,大数据,hadoop,hbase,vertica,java开发 2910

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HBase使用例子

通过编码(java)的形式对HBase进行一系列的管理涉及到对表的管理、数据的操作等。 1、 对表的创建、删除、显示以及修改等,可以用HBaseAdmin, 一旦创建了表,那么可以通过HTable的 实例来访问表,每次可以往表里增加数据。 2、 插入数据 创建一个Put对 象,在这个Put对象里可以指定要给哪个列增加数据,以及当前的时间戳等值,然后通过调用HTable.put(Put)来 提

原创学无止尽 2555

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

java操作HBase模板

使用idea建立quickstart模板的Maven工程 自动导包后,删除不需要的test ps:把工程的三个地方的jdk统一成1.8版本 在pom.xml里添加如下依赖: <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client</artifactId> <version>2.3.5</version

fengjian的博客 1143

hbase java批量插入_Hbase之批量数据写入

/*** Created by similarface on 16/8/16.*/import java.io.IOException;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.hbase.HBaseConfiguration;import org.apache.hadoop.hbase.TableNa...

weixin_30978387的博客 796

HBase(操作API)

HBase操作API,伪分布式 package org.xiaowu.test; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import o...

weixin_39140724的博客 220

Jave操作HBase

import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hado

luoyuchuan的专栏 573

Hbase之使用回调函数进行批处理操作

import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.*; import org.apac...

weixin_33966095的博客 248

Homework - HBase Shell, Java Client and MapReduce Job

Env: Single Node with CentOS 6.2 x86_64, 2 processors, 4Gb memory CDH4.3 with Cloudera Manager 4.5 HBase 0.94.6-cdh4.3.0  HBase 0.94.6-cdh4.3.0  HBase shell exercise: [root@n8 ~]# hbase shel...

George's dev dream port 266

HBase入门

HBase入门部分内容参考于http://www.nabble.com/Re%3A-Map-Reduce-over-HBase---sample-code-p18253120.html HBase 是Hadoop的一个子项目,HBase采用了Google BigTable的稀疏的,面向列的数据库实现方式的理论,建立在hadoop的hdfs上,一方面里用了hdfs的高可靠性和可伸缩行,另外一方面里...

weixin_30817749的博客 77

实验四 HBase开发:使用java操作HBase

一、实验目的 熟悉HBase数据库操作常用的Java API 二、实验平台 操作系统:CentOS 8 Hadoop版本:3.2.3 HBase版本:2.4.12 jdk版本:1.8 Java IDE:eclipse 三、实验过程 1. 创建表

Lilianach的博客 2万+

HBase的Java API操作

HBase的Java API操作代码,实现增删改查,过滤功能

qq_40078490的博客 2764

Hbase Java API操作

Hbase Java API操作,对于创建项目和操作表,表数据的方法

m0_72168501的博客 3227
上一篇: adoop上路_15-HBase0.98.0入门
下一篇: HBase总结(十二)Java API 与HBase交互实例
codepython
博客等级 码龄20年 125粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值