Binary Sorting fixed, and under U tests.

This commit is contained in:
Yaourt
2010-11-07 18:10:07 +01:00
parent 3281bafd2e
commit 4a71dff006
2 changed files with 199 additions and 1 deletions

View File

@@ -26,8 +26,25 @@ public class SortingParams {
* @return the SortingParams Object
*/
public SortingParams by(final String pattern) {
return by(pattern.getBytes(Protocol.UTF8));
}
/**
* Sort by weight in keys.
* <p>
* Takes a pattern that is used in order to generate the key names of the
* weights used for sorting. Weight key names are obtained substituting the
* first occurrence of * with the actual value of the elements on the list.
* <p>
* The pattern for a normal key/value pair is "keyname*" and for a value in
* a hash "keyname*->fieldname".
*
* @param pattern
* @return the SortingParams Object
*/
public SortingParams by(final byte[] pattern) {
params.add(BY.raw);
params.add(pattern.getBytes(Protocol.UTF8));
params.add(pattern);
return this;
}
@@ -117,4 +134,27 @@ public class SortingParams {
}
return this;
}
/**
* Retrieving external keys from the result of the search.
* <p>
* Takes a pattern that is used in order to generate the key names of the
* result of sorting. The key names are obtained substituting the first
* occurrence of * with the actual value of the elements on the list.
* <p>
* The pattern for a normal key/value pair is "keyname*" and for a value in
* a hash "keyname*->fieldname".
* <p>
* To get the list itself use the char # as pattern.
*
* @param patterns
* @return the SortingParams Object
*/
public SortingParams get(byte[]... patterns) {
for (final byte[] pattern : patterns) {
params.add(GET.raw);
params.add(pattern);
}
return this;
}
}