我正在尝试将attributeNames
which is a传递collection of string
给setColumnNames
接受string array
.
public Map<String, String> getAttributes(String rowKey, Collection<String> attributeNames, String columnFamily) {
try {
SliceQuery<String, String, String> query = HFactory.createSliceQuery(keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get()).
setKey(rowKey).setColumnFamily(columnFamily).setColumnNames(attributeNames);
} catch (HectorException e) {
LOG.error("Exception in CassandraHectorClient::getAttributes " +e+ ", RowKey = " +rowKey+ ", Attribute Names = " +attributeNames);
}
return null;
}
定义为setColumnNames
SliceQuery<K, N, V> setColumnNames(N... columnNames);
我每次都会遇到这个异常-
The method setColumnNames(String...) in the type SliceQuery<String,String,String> is not applicable for the arguments (Collection<String>)
如何在 Java 中将字符串集合转换为字符串数组?任何想法?