關於spring整合hbase

2021-06-23 09:58:53 字數 1091 閱讀 4940

2.      專案中引入spring-data-hadoop jar包。

4.      配置xml檔案 配置內容如下所示:

<?xml version="1.0" encoding="utf-8"?>

xmlns:xsi=""xmlns:hdp=""

xsi:schemalocation="

/spring-hadoop.xsd">

fs.default.name=hdfs:

zk-port="2181"/>

以上就是xml檔案配置內容:

5.寫方法測試

public static void main(stringagrs) {

//在xml配置檔案中找到htemplate

beanfactoryfactory = (beanfactory) context;

hbasetemplatehtemplate = (hbasetemplate) factory.getbean("htemplate");

//使用find方法查詢  test2為表名 ,zb為列族名稱及family

//result為得到的結果集

publicstring maprow(result result, int rownum) throws exception {

//迴圈行

for(keyvalue kv : result.raw()) {

//得到列族組成列qualifier

stringkey = new string(kv.getqualifier());

//得到值

stringvalue = new string(kv.getvalue());

system.out.println(key+ "= "

+bytes.tostring(value.getbytes()));

returnnull;

得到結果:

jd= 13

wd= 13

jd= 73

wd= 73

jd= 80

wd= 80

jd= 54

wd= 34

jd= 42

wd= 42

和hbase對映 hbase整合hive

hive提供了與hbase的整合,是的能夠在hbase表上使用hive sql語句進行查詢 插入操作以及進行join和union等複雜查詢 同時也可以將hive表中的資料對映到hbase中。當我們在使用hive時候,在資料量多的時候就會發現非常的慢,乙個簡單的sql都要半天,其實我們追尋他的原因很簡...

Hive Hive 整合對映 HBase

五 hbase 只提供了簡單的基於 key 值的快速查詢能力,沒法進行大量的條件查詢,對於資料分析來說,不太友好。hive 整合 hbase 為使用者提供一種 sqlonhbase 的方法。hive 與 hbase 整合的實現是利用兩者本身對外的 api 介面互相通訊來完成的,其具體工作交由 hiv...

spring 整合Junit,整合web

l 匯入jar包 基本 4 1 測試 spring test.jar 1.讓junit通知spring載入配置檔案 2.讓spring容器自動進行注入 l 修改測試類 package com.hcx import org.junit.test import org.junit.runner.runw...