Package redis.clients.jedis

Examples of redis.clients.jedis.Tuple


  jedis.zadd("foo", 10d, "b");
  jedis.zadd("foo", 0.1d, "c");
  jedis.zadd("foo", 2d, "a");

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("c", 0.1d));
  expected.add(new Tuple("a", 2d));

  Set<Tuple> range = jedis.zrangeWithScores("foo", 0, 1);
  assertEquals(expected, range);

  expected.add(new Tuple("b", 10d));
  range = jedis.zrangeWithScores("foo", 0, 100);
  assertEquals(expected, range);

  // Binary
  jedis.zadd(bfoo, 1d, ba);
  jedis.zadd(bfoo, 10d, bb);
  jedis.zadd(bfoo, 0.1d, bc);
  jedis.zadd(bfoo, 2d, ba);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bc, 0.1d));
  bexpected.add(new Tuple(ba, 2d));

  Set<Tuple> brange = jedis.zrangeWithScores(bfoo, 0, 1);
  assertEquals(bexpected, brange);

  bexpected.add(new Tuple(bb, 10d));
  brange = jedis.zrangeWithScores(bfoo, 0, 100);
  assertEquals(bexpected, brange);

    }
View Full Code Here


  jedis.zadd("foo", 10d, "b");
  jedis.zadd("foo", 0.1d, "c");
  jedis.zadd("foo", 2d, "a");

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("b", 10d));
  expected.add(new Tuple("a", 2d));

  Set<Tuple> range = jedis.zrevrangeWithScores("foo", 0, 1);
  assertEquals(expected, range);

  expected.add(new Tuple("c", 0.1d));
  range = jedis.zrevrangeWithScores("foo", 0, 100);
  assertEquals(expected, range);

  // Binary
  jedis.zadd(bfoo, 1d, ba);
  jedis.zadd(bfoo, 10d, bb);
  jedis.zadd(bfoo, 0.1d, bc);
  jedis.zadd(bfoo, 2d, ba);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bb, 10d));
  bexpected.add(new Tuple(ba, 2d));

  Set<Tuple> brange = jedis.zrevrangeWithScores(bfoo, 0, 1);
  assertEquals(bexpected, brange);

  bexpected.add(new Tuple(bc, 0.1d));
  brange = jedis.zrevrangeWithScores(bfoo, 0, 100);
  assertEquals(bexpected, brange);

    }
View Full Code Here

  jedis.zadd("foo", 2d, "a");

  Set<Tuple> range = jedis.zrangeByScoreWithScores("foo", 0d, 2d);

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("c", 0.1d));
  expected.add(new Tuple("a", 2d));

  assertEquals(expected, range);

  range = jedis.zrangeByScoreWithScores("foo", 0d, 2d, 0, 1);

  expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("c", 0.1d));

  assertEquals(expected, range);

  range = jedis.zrangeByScoreWithScores("foo", 0d, 2d, 1, 1);

  expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("a", 2d));

  assertEquals(expected, range);

  // Binary

  jedis.zadd(bfoo, 1d, ba);
  jedis.zadd(bfoo, 10d, bb);
  jedis.zadd(bfoo, 0.1d, bc);
  jedis.zadd(bfoo, 2d, ba);

  Set<Tuple> brange = jedis.zrangeByScoreWithScores(bfoo, 0d, 2d);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bc, 0.1d));
  bexpected.add(new Tuple(ba, 2d));

  assertEquals(bexpected, brange);

  brange = jedis.zrangeByScoreWithScores(bfoo, 0d, 2d, 0, 1);

  bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bc, 0.1d));

  assertEquals(bexpected, brange);

  brange = jedis.zrangeByScoreWithScores(bfoo, 0d, 2d, 1, 1);

  bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(ba, 2d));

  assertEquals(bexpected, brange);

    }
View Full Code Here

  jedis.zadd("foo", 5.0d, "e");

  Set<Tuple> range = jedis.zrevrangeByScoreWithScores("foo", 3d,
    Double.NEGATIVE_INFINITY, 0, 1);
  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("c", 3.0d));

  assertEquals(expected, range);

  range = jedis.zrevrangeByScoreWithScores("foo", 3.5d,
    Double.NEGATIVE_INFINITY, 0, 2);
  expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("c", 3.0d));
  expected.add(new Tuple("b", 2.0d));

  assertEquals(expected, range);

  range = jedis.zrevrangeByScoreWithScores("foo", 3.5d,
    Double.NEGATIVE_INFINITY, 1, 1);
  expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("b", 2.0d));

  assertEquals(expected, range);

  range = jedis.zrevrangeByScoreWithScores("foo", 4d, 2d);
  expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("d", 4.0d));
  expected.add(new Tuple("c", 3.0d));
  expected.add(new Tuple("b", 2.0d));

  assertEquals(expected, range);

  // Binary
  jedis.zadd(bfoo, 1d, ba);
  jedis.zadd(bfoo, 10d, bb);
  jedis.zadd(bfoo, 0.1d, bc);
  jedis.zadd(bfoo, 2d, ba);

  Set<Tuple> brange = jedis.zrevrangeByScoreWithScores(bfoo, 2d, 0d);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bc, 0.1d));
  bexpected.add(new Tuple(ba, 2d));

  assertEquals(bexpected, brange);

  brange = jedis.zrevrangeByScoreWithScores(bfoo, 2d, 0d, 0, 1);

  bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(ba, 2d));

  assertEquals(bexpected, brange);

  brange = jedis.zrevrangeByScoreWithScores(bfoo, 2d, 0d, 1, 1);

  bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bc, 0.1d));

  assertEquals(bexpected, brange);
    }
View Full Code Here

  long result = jedis.zunionstore("dst", "foo", "bar");

  assertEquals(2, result);

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("b", new Double(4)));
  expected.add(new Tuple("a", new Double(3)));

  assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));

  // Binary
  jedis.zadd(bfoo, 1, ba);
  jedis.zadd(bfoo, 2, bb);
  jedis.zadd(bbar, 2, ba);
  jedis.zadd(bbar, 2, bb);

  long bresult = jedis.zunionstore(SafeEncoder.encode("dst"), bfoo, bbar);

  assertEquals(2, bresult);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bb, new Double(4)));
  bexpected.add(new Tuple(ba, new Double(3)));

  assertEquals(bexpected,
    jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
    }
View Full Code Here

  long result = jedis.zunionstore("dst", params, "foo", "bar");

  assertEquals(2, result);

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("b", new Double(9)));
  expected.add(new Tuple("a", new Double(7)));

  assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));

  // Binary
  jedis.zadd(bfoo, 1, ba);
  jedis.zadd(bfoo, 2, bb);
  jedis.zadd(bbar, 2, ba);
  jedis.zadd(bbar, 2, bb);

  ZParams bparams = new ZParams();
  bparams.weights(2, 2.5);
  bparams.aggregate(ZParams.Aggregate.SUM);
  long bresult = jedis.zunionstore(SafeEncoder.encode("dst"), bparams,
    bfoo, bbar);

  assertEquals(2, bresult);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(bb, new Double(9)));
  bexpected.add(new Tuple(ba, new Double(7)));

  assertEquals(bexpected,
    jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
    }
View Full Code Here

  long result = jedis.zinterstore("dst", "foo", "bar");

  assertEquals(1, result);

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("a", new Double(3)));

  assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));

  // Binary
  jedis.zadd(bfoo, 1, ba);
  jedis.zadd(bfoo, 2, bb);
  jedis.zadd(bbar, 2, ba);

  long bresult = jedis.zinterstore(SafeEncoder.encode("dst"), bfoo, bbar);

  assertEquals(1, bresult);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(ba, new Double(3)));

  assertEquals(bexpected,
    jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
    }
View Full Code Here

  long result = jedis.zinterstore("dst", params, "foo", "bar");

  assertEquals(1, result);

  Set<Tuple> expected = new LinkedHashSet<Tuple>();
  expected.add(new Tuple("a", new Double(7)));

  assertEquals(expected, jedis.zrangeWithScores("dst", 0, 100));

  // Binary
  jedis.zadd(bfoo, 1, ba);
  jedis.zadd(bfoo, 2, bb);
  jedis.zadd(bbar, 2, ba);

  ZParams bparams = new ZParams();
  bparams.weights(2, 2.5);
  bparams.aggregate(ZParams.Aggregate.SUM);
  long bresult = jedis.zinterstore(SafeEncoder.encode("dst"), bparams,
    bfoo, bbar);

  assertEquals(1, bresult);

  Set<Tuple> bexpected = new LinkedHashSet<Tuple>();
  bexpected.add(new Tuple(ba, new Double(7)));

  assertEquals(bexpected,
    jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
    }
View Full Code Here

    jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
    }

    @Test
    public void tupleCompare() {
  Tuple t1 = new Tuple("foo", 1d);
  Tuple t2 = new Tuple("bar", 2d);

  assertEquals(-1, t1.compareTo(t2));
  assertEquals(1, t2.compareTo(t1));
  assertEquals(0, t2.compareTo(t2));
    }
View Full Code Here

   
    int index = row-start;
    if(index == -1)
      return new String[]{"", ""};
    if(index < page.length){
      Tuple tuple = (Tuple) page[index];
      values = new String[]{String.valueOf(tuple.getScore()), tuple.getElement()};
    }
   
    return values;
  }
View Full Code Here

TOP

Related Classes of redis.clients.jedis.Tuple

Copyright © 2018 www.massapicom. 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.