@Override
 protected List<WordBean> fillList(Set<Tuple> returnedSet) {
   ArrayList<WordBean> list = new ArrayList<WordBean>();
   for (Tuple entry : returnedSet) {
     WordBean word = new WordBean();
     word.setWord(entry.getElement());
     word.setCount((int) entry.getScore());
     list.add(word);
     LOGGER.log(
         Level.INFO, "Word {0} with Value {1}", new Object[] {word.getWord(), word.getCount()});
   }
   return list;
 }
  @Test
  public void zrevrangeWithScores() {
    Map<String, Double> scoreMembers = new LinkedHashMap<String, Double>();
    scoreMembers.put("member1", 1D);
    scoreMembers.put("member2", 2D);
    scoreMembers.put("member3", 3D);
    Assert.assertEquals(3, redis.zadd(key, scoreMembers).intValue());

    Set<Tuple> set = redis.zrevrangeWithScores(key, 0, -1);
    Assert.assertEquals(3, set.size());

    Tuple tuple = set.iterator().next();
    Assert.assertEquals("member3", tuple.getElement());
    Assert.assertEquals(3D, tuple.getScore(), 0);
  }
예제 #3
0
파일: Tuple.java 프로젝트: TruSphere/jedis
 public int compareTo(Tuple other) {
   if (this.score == other.getScore() || Arrays.equals(this.element, other.element)) return 0;
   else return this.score < other.getScore() ? -1 : 1;
 }