色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

hbase讀取數(shù)據(jù)怎么轉換json

錢淋西2年前24瀏覽0評論

hbase讀取數(shù)據(jù)怎么轉換json?

代碼示例:

Configuration conf = hbaseConfiguration.create();

conf.set("hbase.zookeeper.quorum", "hadoop1,hadoop2,hadoop3");

HTable table = new HTable(conf, "DataCollection1");

System.out.println("scan1");

Scan scan1 = new Scan();

new PrefixFilter(Bytes.toBytes("row"));

Filter filter3= new PrefixFilter(Bytes.toBytes("2017-01-01"));

scan1.setFilter(filter3);

scan1.setMaxVersions();

ResultScanner scanner1 = table.getScanner(scan1);

System.out.println("scan2");

int count=0;

jsonArray array = new JSONArray();

for (Result r : scanner1) {

System.out.println("sssss");

JSONObject mapOfColValues = new JSONObject();// 創(chuàng)建json對象就是一個{name:wp}

for (KeyValue kv : r.raw()) {

System.out.println(String.format("row:%s, family:%s, qualifier:%s, qualifiervalue:%s, timestamp:%s.",

Bytes.toString(kv.getRow()),

Bytes.toString(kv.getFamily()),

Bytes.toString(kv.getQualifier()),

Bytes.toString(kv.getValue()),

kv.getTimestamp()));

mapOfColValues.put(Bytes.toString(kv.getQualifier()),Bytes.toString(kv.getValue()));

}

array.add(mapOfColValues);

count++;

System.out.println(count);

}

scanner1.close();

table.close();

//pool.close();

System.out.println(count);

System.out.println("-------------finished----------------");

php json嵌入數(shù)組,hbase讀取數(shù)據(jù)怎么轉換json