2014-04-20 2 views
1

은 내가검색 Java API를 사용하는 Hbase 레코드?

Put put = new Put(Bytes.toBytes("rowkey")); 
    put.add(Bytes.toBytes("family1"), Bytes.toBytes("qualifier1"), 
      Bytes.toBytes("this is test record")); 

이 내 GET 구현

하다 내가 값을 전달

HTable table = new HTable(conf, tableName); 
Put put = new Put(Bytes.toBytes(rowKey)); 
put.add(Bytes.toBytes(family), Bytes.toBytes(qualifier), 
     Bytes.toBytes(value)); 
table.put(put); 

코드 아래 사용하여 저장하는 기록이다 기록 값에베이스와 자바

에서 내 응용 프로그램을 검색 할

Get get = new Get(Bytes.toBytes("rowkey")); 
      String[] family = { "row1" }; 
get.addColumn(Bytes.toBytes("family1"),Bytes.toBytes("qualifier1")); 
Result rs = table.get(get); 

이제이 레코드를 검색하고 싶습니다. "이것은 테스트 기록"값입니다.

이 기록을 찾는데 도와주세요. HTableput() 방법과 Put 클래스와 유사 HTableget() 방법 및 가져 오기 클래스에서

답변

2

사용하여 필터를 사용하면 요소의 하나에서 검색을 할 수 당신은 나를 위해

FilterList flist = new FilterList(); 

flist.addFilter(new RowFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes("Predicatevalue")))); 
flist.addFilter(new QualifierFilter(CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes("Subject value")))); 
flist.addFilter(new ValueFilter(CompareOp.EQUAL,new BinaryComparator(Bytes.toBytes("Objectvalue")))); 

SubstringComparator BinaryComparator이 작품을 다른 조합 를 전달할 수 있습니다.

1

봐.

+0

예 검색 결과로 얻을 수 있지만 값으로 행을 검색하는 방법은 "테스트 레코드"입니다. – jayesh

+0

필터를 사용할 수 있습니다. – mashuai

+0

한 가지 예를 들려 줄 수 있습니까? – jayesh

관련 문제