Skip to content

Commit

Permalink
added overloaded version of setKeys which takes an iterable
Browse files Browse the repository at this point in the history
  • Loading branch information
zznate committed Nov 15, 2010
1 parent e8ddfc1 commit e7d591b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -29,7 +29,7 @@
public final class ThriftMultigetSliceQuery<K, N, V> extends AbstractSliceQuery<K, N, V, Rows<K, N, V>>
implements MultigetSliceQuery<K, N, V> {

private Collection<K> keys;
private Iterable<K> keys;

public ThriftMultigetSliceQuery(Keyspace k,
Serializer<K> keySerializer,
Expand All @@ -43,6 +43,13 @@ public MultigetSliceQuery<K, N, V> setKeys(K... keys) {
this.keys = Arrays.asList(keys);
return this;
}

@Override
public MultigetSliceQuery<K, N, V> setKeys(Iterable<K> keys) {
this.keys = keys;
return this;
}


@Override
public QueryResult<Rows<K, N,V>> execute() {
Expand All @@ -53,11 +60,13 @@ public QueryResult<Rows<K, N,V>> execute() {
new KeyspaceOperationCallback<Rows<K, N,V>>() {
@Override
public Rows<K, N,V> doInKeyspace(KeyspaceService ks) throws HectorException {
List<K> keysList = new ArrayList<K>();
keysList.addAll(keys);
List<ByteBuffer> keysList = new ArrayList<ByteBuffer>();
for (K k : keys) {
keysList.add(keySerializer.toByteBuffer(k));
}
ColumnParent columnParent = new ColumnParent(columnFamilyName);
Map<K, List<Column>> thriftRet = keySerializer.fromBytesMap(
ks.multigetSlice(keySerializer.toBytesList(keysList), columnParent, getPredicate()));
ks.multigetSlice(keysList, columnParent, getPredicate()));
return new RowsImpl<K, N, V>(thriftRet, columnNameSerializer, valueSerializer);
}
}), this);
Expand Down
Expand Up @@ -12,6 +12,8 @@
public interface MultigetSliceQuery<K, N, V> extends Query<Rows<K, N, V>> {

MultigetSliceQuery<K, N, V> setKeys(K... keys);

MultigetSliceQuery<K, N, V> setKeys(Iterable<K> keys);

/**
* Sets the column names to be retrieved by this query
Expand Down

0 comments on commit e7d591b

Please sign in to comment.