Examples of ZParams


Examples of org.idevlab.rjc.ZParams

  @Override
  public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
    String stringKey = RjcUtils.decode(destKey);
    String[] stringKeys = RjcUtils.decodeMultiple(sets);

    ZParams zparams = RjcUtils.toZParams(aggregate, weights);

    try {
      if (isPipelined()) {
        pipeline.zinterstore(stringKey, zparams, stringKeys);
        return null;
View Full Code Here

Examples of org.idevlab.rjc.ZParams

  @Override
  public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
    String stringKey = RjcUtils.decode(destKey);
    String[] stringKeys = RjcUtils.decodeMultiple(destKey);

    ZParams zparams = RjcUtils.toZParams(aggregate, weights);

    try {
      if (isPipelined()) {
        pipeline.zunionstore(stringKey, zparams, stringKeys);
        return null;
View Full Code Here

Examples of org.idevlab.rjc.ZParams

    }
    return null;
  }

  static ZParams toZParams(Aggregate aggregate, int[] weights) {
    return new ZParams().weights(weights).aggregate(ZParams.Aggregate.valueOf(aggregate.name()));
  }
View Full Code Here

Examples of redis.clients.jedis.ZParams

  jedis.zadd("foo", 1, "a");
  jedis.zadd("foo", 2, "b");
  jedis.zadd("bar", 2, "a");
  jedis.zadd("bar", 2, "b");

  ZParams params = new ZParams();
  params.weights(2, 2.5);
  params.aggregate(ZParams.Aggregate.SUM);
  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);
View Full Code Here

Examples of redis.clients.jedis.ZParams

    public void zintertoreParams() {
  jedis.zadd("foo", 1, "a");
  jedis.zadd("foo", 2, "b");
  jedis.zadd("bar", 2, "a");

  ZParams params = new ZParams();
  params.weights(2, 2.5);
  params.aggregate(ZParams.Aggregate.SUM);
  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);
View Full Code Here

Examples of redis.clients.jedis.ZParams

  }

  @Override
  public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
    try {
      ZParams zparams = new ZParams().weights(weights).aggregate(
          redis.clients.jedis.ZParams.Aggregate.valueOf(aggregate.name()));

      if (isQueueing()) {
        transaction.zinterstore(destKey, zparams, sets);
        return null;
View Full Code Here

Examples of redis.clients.jedis.ZParams

  }

  @Override
  public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
    try {
      ZParams zparams = new ZParams().weights(weights).aggregate(
          redis.clients.jedis.ZParams.Aggregate.valueOf(aggregate.name()));

      if (isQueueing()) {
        transaction.zunionstore(destKey, zparams, sets);
        return null;
View Full Code Here

Examples of redis.clients.jedis.ZParams

        Transaction trans = conn.multi();
        trans.zremrangeByScore(
            semname.getBytes(),
            "-inf".getBytes(),
            String.valueOf(now - timeout).getBytes());
        ZParams params = new ZParams();
        params.weights(1, 0);
        trans.zinterstore(czset, params, czset, semname);
        trans.incr(ctr);
        List<Object> results = trans.exec();
        int counter = ((Long)results.get(results.size() - 1)).intValue();
View Full Code Here

Examples of redis.clients.jedis.ZParams

        int voteWeight = weights.containsKey("vote") ? weights.get("vote") : 0;

        String[] keys = new String[]{id, "sort:update", "sort:votes"};
        Transaction trans = conn.multi();
        id = zintersect(
            trans, ttl, new ZParams().weights(0, updateWeight, voteWeight), keys);

        trans.zcard("idx:" + id);
        if (desc) {
            trans.zrevrange("idx:" + id, start, start + num - 1);
        }else{
View Full Code Here

Examples of redis.clients.jedis.ZParams

        Transaction trans = conn.multi();

        String matchedAds = matchLocation(trans, locations);

        String baseEcpm = zintersect(
            trans, 30, new ZParams().weights(0, 1), matchedAds, "ad:value:");

        Pair<Set<String>,String> result = finishScoring(
            trans, matchedAds, baseEcpm, content);

        trans.incr("ads:served:");
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.