저는 Cassandra와 협력 중이며 Hector 클라이언트를 사용하여 Cassandra 데이터베이스의 데이터를 읽고 업셋합니다. 나는 hector 클라이언트를 사용하여 Cassandra 데이터베이스에서 데이터를 검색하려고하는데, 하나의 열만 검색하려는 경우이를 수행 할 수 있습니다.Hector 클라이언트를 사용하여 Cassandra에서 여러 열 값을 검색하십시오.
이제 rowKey as 1011
에 대한 데이터를 검색하려고하지만 columnNames와 함께 문자열 모음으로 검색하려고합니다. 다음은 헥터를 사용하여 카산드라 데이터베이스에서 데이터를 검색합니다 내 API는 당신이 내 위의 방법을 참조하면, 내가 특정 rowKey
과 column c1
에 대한 카산드라 데이터베이스에서 데이터를 검색하는 것을 시도하고있다
public Map<String, String> getAttributes(String rowKey, Collection<String> attributeNames, String columnFamily) {
final Cluster cluster = CassandraHectorConnection.getInstance().getCluster();
final Keyspace keyspace = CassandraHectorConnection.getInstance().getKeyspace();
try {
ColumnQuery<String, String, String> columnQuery = HFactory
.createStringColumnQuery(keyspace)
.setColumnFamily(columnFamily).setKey(rowKey)
.setName("c1");
QueryResult<HColumn<String, String>> result = columnQuery.execute();
System.out.println("Column Name from cassandra: " + result.get().getName() + "Column value from cassandra: " + result.get().getValue());
} catch (HectorException e) {
LOG.error("Exception in CassandraHectorClient::getAttributes " +e+ ", RowKey = " +rowKey+ ", Attribute Names = " +attributeNames);
} finally {
cluster.getConnectionManager().shutdown();
}
return null;
}
클라이언트 -입니다. 이제 특정 rowKey에 대한 열을 수집하기 위해 Cassandra 데이터베이스에서 데이터를 검색하려고합니다. 나는 여러 열뿐만 같은 rowKey에 대한 데이터를 검색 할 this-
같은 것을 의미
. Hector 클라이언트를 사용하여 어떻게이 작업을 수행 할 수 있습니까? 그리고 모든 열에 대한 데이터를 검색하고 내가 찾고있는 개별 열 데이터를 찾기 위해 반복하고 싶지 않습니다.