Support null sortParams in Lettuce and SRP sort
DATAREDIS-217
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user