Examples of SortingParams


Examples of org.idevlab.rjc.SortingParams

  }

  @Override
  public List<byte[]> sort(byte[] key, SortParameters params) {

    SortingParams sortParams = RjcUtils.convertSortParams(params);
    final String stringKey = RjcUtils.decode(key);

    try {
      if (isPipelined()) {
        if (sortParams != null) {
View Full Code Here

Examples of org.idevlab.rjc.SortingParams

  }

  @Override
  public Long sort(byte[] key, SortParameters params, byte[] sortKey) {

    SortingParams sortParams = RjcUtils.convertSortParams(params);
    final String stringKey = RjcUtils.decode(key);
    final String stringSortKey = RjcUtils.decode(sortKey);

    try {
      if (isPipelined()) {
View Full Code Here

Examples of org.idevlab.rjc.SortingParams

    }
    return DecodeUtils.convertToList(keys);
  }

  static SortingParams convertSortParams(SortParameters params) {
    SortingParams rjcSort = null;

    if (params != null) {
      rjcSort = new SortingParams();

      byte[] byPattern = params.getByPattern();
      if (byPattern != null) {
        rjcSort.by(DecodeUtils.decode(byPattern));
      }
      byte[][] getPattern = params.getGetPattern();

      if (getPattern != null && getPattern.length > 0) {
        for (byte[] bs : getPattern) {
          rjcSort.get(DecodeUtils.decode(bs));
        }
      }
      Range limit = params.getLimit();
      if (limit != null) {
        rjcSort.limit((int) limit.getStart(), (int) limit.getCount());
      }
      Order order = params.getOrder();
      if (order != null && order.equals(Order.DESC)) {
        rjcSort.desc();
      }
      Boolean isAlpha = params.isAlphabetic();
      if (isAlpha != null && isAlpha) {
        rjcSort.alpha();
      }
    }
    return rjcSort;
  }
View Full Code Here

Examples of redis.clients.jedis.SortingParams

  jedis.set("bar1", "3");
  jedis.set("bar2", "2");
  jedis.set("bar3", "1");

  SortingParams sp = new SortingParams();
  sp.by("bar*");

  List<String> result = jedis.sort("foo", sp);

  List<String> expected = new ArrayList<String>();
  expected.add("3");
  expected.add("2");
  expected.add("1");

  assertEquals(expected, result);

  // Binary
  jedis.lpush(bfoo, b2);
  jedis.lpush(bfoo, b3);
  jedis.lpush(bfoo, b1);

  jedis.set(bbar1, b3);
  jedis.set(bbar2, b2);
  jedis.set(bbar3, b1);

  SortingParams bsp = new SortingParams();
  bsp.by(bbarstar);

  List<byte[]> bresult = jedis.sort(bfoo, bsp);

  List<byte[]> bexpected = new ArrayList<byte[]>();
  bexpected.add(b3);
View Full Code Here

Examples of redis.clients.jedis.SortingParams

    public void sortDesc() {
  jedis.lpush("foo", "3");
  jedis.lpush("foo", "2");
  jedis.lpush("foo", "1");

  SortingParams sp = new SortingParams();
  sp.desc();

  List<String> result = jedis.sort("foo", sp);

  List<String> expected = new ArrayList<String>();
  expected.add("3");
  expected.add("2");
  expected.add("1");

  assertEquals(expected, result);

  // Binary
  jedis.lpush(bfoo, b3);
  jedis.lpush(bfoo, b2);
  jedis.lpush(bfoo, b1);

  SortingParams bsp = new SortingParams();
  bsp.desc();

  List<byte[]> bresult = jedis.sort(bfoo, bsp);

  List<byte[]> bexpected = new ArrayList<byte[]>();
  bexpected.add(b3);
View Full Code Here

Examples of redis.clients.jedis.SortingParams

    public void sortLimit() {
  for (int n = 10; n > 0; n--) {
      jedis.lpush("foo", String.valueOf(n));
  }

  SortingParams sp = new SortingParams();
  sp.limit(0, 3);

  List<String> result = jedis.sort("foo", sp);

  List<String> expected = new ArrayList<String>();
  expected.add("1");
  expected.add("2");
  expected.add("3");

  assertEquals(expected, result);

  // Binary
  jedis.rpush(bfoo, new byte[] { (byte) '4' });
  jedis.rpush(bfoo, new byte[] { (byte) '3' });
  jedis.rpush(bfoo, new byte[] { (byte) '2' });
  jedis.rpush(bfoo, new byte[] { (byte) '1' });

  SortingParams bsp = new SortingParams();
  bsp.limit(0, 3);

  List<byte[]> bresult = jedis.sort(bfoo, bsp);

  List<byte[]> bexpected = new ArrayList<byte[]>();
  bexpected.add(b1);
View Full Code Here

Examples of redis.clients.jedis.SortingParams

    public void sortAlpha() {
  jedis.lpush("foo", "1");
  jedis.lpush("foo", "2");
  jedis.lpush("foo", "10");

  SortingParams sp = new SortingParams();
  sp.alpha();

  List<String> result = jedis.sort("foo", sp);

  List<String> expected = new ArrayList<String>();
  expected.add("1");
  expected.add("10");
  expected.add("2");

  assertEquals(expected, result);

  // Binary
  jedis.lpush(bfoo, b1);
  jedis.lpush(bfoo, b2);
  jedis.lpush(bfoo, b10);

  SortingParams bsp = new SortingParams();
  bsp.alpha();

  List<byte[]> bresult = jedis.sort(bfoo, bsp);

  List<byte[]> bexpected = new ArrayList<byte[]>();
  bexpected.add(b1);
View Full Code Here

Examples of redis.clients.jedis.SortingParams

  jedis.set("car1", "car1");
  jedis.set("car2", "car2");
  jedis.set("car10", "car10");

  SortingParams sp = new SortingParams();
  sp.get("car*", "bar*");

  List<String> result = jedis.sort("foo", sp);

  List<String> expected = new ArrayList<String>();
  expected.add("car1");
  expected.add("bar1");
  expected.add("car2");
  expected.add("bar2");
  expected.add("car10");
  expected.add("bar10");

  assertEquals(expected, result);

  // Binary
  jedis.lpush(bfoo, b1);
  jedis.lpush(bfoo, b2);
  jedis.lpush(bfoo, b10);

  jedis.set(bbar1, bbar1);
  jedis.set(bbar2, bbar2);
  jedis.set(bbar10, bbar10);

  jedis.set(bcar1, bcar1);
  jedis.set(bcar2, bcar2);
  jedis.set(bcar10, bcar10);

  SortingParams bsp = new SortingParams();
  bsp.get(bcarstar, bbarstar);

  List<byte[]> bresult = jedis.sort(bfoo, bsp);

  List<byte[]> bexpected = new ArrayList<byte[]>();
  bexpected.add(bcar1);
View Full Code Here

Examples of redis.clients.jedis.SortingParams

  }

  @Override
  protected void command() {
    jedis.select(db);
    SortingParams sp = new SortingParams();
    sp.alpha();
    sp.limit(start, end-start);
    page = jedis.sort(key, sp);
   
  }
View Full Code Here

Examples of redis.clients.jedis.SortingParams

  }

  @Override
  public List<byte[]> sort(byte[] key, SortParameters params) {

    SortingParams sortParams = JedisUtils.convertSortParams(params);

    try {
      if (isQueueing()) {
        if (sortParams != null) {
          transaction.sort(key, sortParams);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.