Examples of ZParams


Examples of redis.clients.jedis.ZParams

    {
        Map<String,Integer> bonusEcpm = new HashMap<String,Integer>();
        Set<String> words = tokenize(content);
        for (String word : words){
            String wordBonus = zintersect(
                trans, 30, new ZParams().weights(0, 1), matched, word);
            bonusEcpm.put(wordBonus, 1);
        }

        if (bonusEcpm.size() > 0){

            String[] keys = new String[bonusEcpm.size()];
            int[] weights = new int[bonusEcpm.size()];
            int index = 0;
            for (Map.Entry<String,Integer> bonus : bonusEcpm.entrySet()){
                keys[index] = bonus.getKey();
                weights[index] = bonus.getValue();
                index++;
            }

            ZParams minParams = new ZParams().aggregate(ZParams.Aggregate.MIN).weights(weights);
            String minimum = zunion(trans, 30, minParams, keys);

            ZParams maxParams = new ZParams().aggregate(ZParams.Aggregate.MAX).weights(weights);
            String maximum = zunion(trans, 30, maxParams, keys);

            String result = zunion(
                trans, 30, new ZParams().weights(2, 1, 1), base, minimum, maximum);
            return new Pair<Set<String>,String>(words, result);
        }
        return new Pair<Set<String>,String>(words, base);
    }
View Full Code Here

Examples of redis.clients.jedis.ZParams

            weights[i] = 1;
        }

        Transaction trans = conn.multi();
        String jobScores = zunion(
            trans, 30, new ZParams().weights(weights), keys);
        String finalResult = zintersect(
            trans, 30, new ZParams().weights(-1, 1), jobScores, "jobs:req");
        trans.exec();

        return conn.zrangeByScore("idx:" + finalResult, 0, 0);
    }
View Full Code Here

Examples of redis.clients.jedis.ZParams

        String tkey = UUID.randomUUID().toString();
        pipe.zadd(tkey, userId, "max");
        pipe.zunionstore(
            "location:max",
            new ZParams().aggregate(ZParams.Aggregate.MAX),
            tkey,
            "location:max");
        pipe.del(tkey);
        pipe.sync();
    }
View Full Code Here

Examples of redis.clients.jedis.ZParams

            trans.zadd(tkey1, value, "min");
            trans.zadd(tkey2, value, "max");

            trans.zunionstore(
                destination,
                new ZParams().aggregate(ZParams.Aggregate.MIN),
                destination, tkey1);
            trans.zunionstore(
                destination,
                new ZParams().aggregate(ZParams.Aggregate.MAX),
                destination, tkey2);

            trans.del(tkey1, tkey2);
            trans.zincrby(destination, 1, "count");
            trans.zincrby(destination, value, "sum");
View Full Code Here

Examples of redis.clients.jedis.ZParams

    }

    public List<Map<String,String>> getGroupArticles(Jedis conn, String group, int page, String order) {
        String key = order + group;
        if (!conn.exists(key)) {
            ZParams params = new ZParams().aggregate(ZParams.Aggregate.MAX);
            conn.zinterstore(key, params, "group:" + group, order);
            conn.expire(key, 60);
        }
        return getArticles(conn, page, key);
    }
View Full Code Here

Examples of redis.clients.jedis.ZParams

    }
  }

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

      if (isPipelined()) {
        pipeline(new JedisResult(pipeline.zinterstore(destKey, zparams, sets)));
        return null;
      }
View Full Code Here

Examples of redis.clients.jedis.ZParams

    }
  }

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

      if (isPipelined()) {
        pipeline(new JedisResult(pipeline.zunionstore(destKey, zparams, sets)));
        return null;
      }
View Full Code Here

Examples of redis.clients.jedis.ZParams

        String rkey = index.cat(Seek.QUERIES).cat(query)
                .cat(Seek.QUERIES_RESULT).cat(String.valueOf(Thread.currentThread().getId())).key();
        String rkeyCached = index.cat(Seek.QUERIES).cat(query)
                .cat(Seek.QUERIES_RESULT).key();

        ZParams zparams = new ZParams();
        zparams.aggregate(Aggregate.MAX);
        ShardedJedis jedis = Seek.getPool().getResource();
        Jedis shard = jedis.getShard(shardKey);
        try {
            long tstart = System.nanoTime();
            List<String> result = null;
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.