2012-03-08 3 views
0

각 행 12 열 및 각 열에 8 개의 한정자가있는 테이블을 만들었습니다. 내가 완전한 행을 읽으려고하면 행 1에서 1에 대한 올바른 값을 반환하지만 null을 반환합니다. 1 : 2 2에서 10까지 모든 열을 올바르게 읽습니다. plz이 문제를 해결하는 방법 메신저 읽기에이 코드를 사용합니다 .... 루프 내부에 있습니다 thar가 fron 1 ~ 12를 실행합니다.액세스 hbase 테이블에서 Java

train[0][i] = Double.parseDouble(Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("1")))); 
train[1][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("2")))); 
train[2][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("3")))); 
System.out.println("train" + i + ": " + train[2][i]); 
train[3][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("4")))); 
train[4][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("5")))); 
train[5][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("6")))); 


train[6][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("7")))); 
train[7][i] = Double.parseDouble (Bytes.toString (r.getValue(Bytes.toBytes(Integer.toString(i)), Bytes.toBytes("8")))); 

답변

0

이 데이터를 여러 열 패밀리에 적용 할 이유가 없습니다. 그것은 하나의 열에 모든 것을 넣을 수 있고 "i_j"와 같은 주소 지정 체계를 사용할 수 있습니다. 여기서 i와 j는 색인으로 바뀝니다. 여러 열 패밀리에 항목을 배치하는 문제는 각 열 패밀리가 자체 저장소 파일을 가져 와서 더 많은 클러스터 리소스를 사용한다는 것입니다. 또한 컬럼 패밀리 이름에 최소 바이트 수를 사용하는 것도 고려하십시오.

여기서 문제는 데이터를 테이블에 삽입하는 코드와 테이블에서 데이터를 검색하는 코드를 모두 보지 않고는 진단 할 수 없습니다. 물론, 당신은 선을 그렇게 gratuitously 반복 할 필요가 없습니다. 다음과 같이 간단한 것을 시도하십시오.

byte[] column_family = Bytes.toBytes("a"); 
for (int i = 0; i < MAX_I; i++) { 
    for (int j = 0; j < MAX_J; j++) { 
    train[i][j] = Double.parseDouble(Bytes.toString(r.getValue(column_family, Bytes.toBytes(i+"_"+j); 
    System.out.println("train["+i+"]["+j+"]: "+train[i][j]); 
    } 
}