Support null sortParams in Lettuce and SRP sort

DATAREDIS-217
This commit is contained in:
Jennifer Hickey
2013-07-15 13:39:42 -07:00
parent 95e8fbff27
commit 11e4b03dcb
5 changed files with 55 additions and 24 deletions

View File

@@ -105,6 +105,10 @@ abstract class LettuceUtils {
static SortArgs sort(SortParameters params) {
SortArgs args = new SortArgs();
if(params == null) {
return args;
}
if (params.getByPattern() != null) {
args.by(new String(params.getByPattern(), Charsets.ASCII));
}

View File

@@ -247,34 +247,36 @@ abstract class SrpUtils {
static Object[] sortParams(SortParameters params, byte[] sortKey) {
List<byte[]> arrays = new ArrayList<byte[]>();
if (params.getByPattern() != null) {
arrays.add(BY);
arrays.add(params.getByPattern());
}
if (params.getLimit() != null) {
arrays.add(limit(params.getLimit().getStart(), params.getLimit().getCount()));
}
if (params.getGetPattern() != null) {
byte[][] pattern = params.getGetPattern();
for (byte[] bs : pattern) {
arrays.add(GET);
arrays.add(bs);
if(params != null) {
if (params.getByPattern() != null) {
arrays.add(BY);
arrays.add(params.getByPattern());
}
}
if (params.getOrder() != null) {
arrays.add(params.getOrder().name().getBytes(Charsets.UTF_8));
}
if (params.getLimit() != null) {
arrays.add(limit(params.getLimit().getStart(), params.getLimit().getCount()));
}
if (params.isAlphabetic()) {
arrays.add(ALPHA);
}
if (params.getGetPattern() != null) {
byte[][] pattern = params.getGetPattern();
for (byte[] bs : pattern) {
arrays.add(GET);
arrays.add(bs);
}
}
if (sortKey != null) {
arrays.add(STORE);
arrays.add(sortKey);
if (params.getOrder() != null) {
arrays.add(params.getOrder().name().getBytes(Charsets.UTF_8));
}
if (params.isAlphabetic()) {
arrays.add(ALPHA);
}
if (sortKey != null) {
arrays.add(STORE);
arrays.add(sortKey);
}
}
return arrays.toArray();