redis.clients.jedis.ZParams Java Examples

The following examples show how to use redis.clients.jedis.ZParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void zunionstore_weights(String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	t.zunionstore(destination, new ZParams().weights(weights), keys);
}
 
Example #2
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(byte[] dstkey, ZParams params, byte[]... sets) {
  Span span = helper.buildSpan("zunionstore");
  span.setTag("dstkey", Arrays.toString(dstkey));
  span.setTag("params", TracingHelper.toString(params.getParams()));
  span.setTag("sets", TracingHelper.toString(sets));
  try {
    return super.zunionstore(dstkey, params, sets);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #3
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(String dstkey, ZParams params, String... sets) {
  Span span = helper.buildSpan("zinterstore");
  span.setTag("dstkey", dstkey);
  span.setTag("params", TracingHelper.toString(params.getParams()));
  span.setTag("sets", Arrays.toString(sets));
  try {
    return super.zinterstore(dstkey, params, sets);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #4
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(byte[] dstkey, ZParams params, byte[]... sets) {
  Span span = helper.buildSpan("zinterstore");
  span.setTag("dstkey", Arrays.toString(dstkey));
  span.setTag("params", TracingHelper.toString(params.getParams()));
  span.setTag("sets", TracingHelper.toString(sets));
  try {
    return super.zinterstore(dstkey, params, sets);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #5
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(byte[] dstkey, ZParams params, byte[]... sets) {
  Span span = helper.buildSpan("zunionstore");
  span.setTag("dstkey", Arrays.toString(dstkey));
  span.setTag("params", TracingHelper.toString(params.getParams()));
  span.setTag("sets", TracingHelper.toString(sets));
  try {
    return super.zunionstore(dstkey, params, sets);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #6
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void zunionstore_weights_max(String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	t.zunionstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MAX), keys);
}
 
Example #7
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(String dstkey, ZParams params, String... sets) {
  Span span = helper.buildSpan("zunionstore");
  span.setTag("params", TracingHelper.toString(params.getParams()));
  span.setTag("sets", Arrays.toString(sets));
  try {
    return super.zunionstore(dstkey, params, sets);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #8
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(final byte[] dstkey, final ZParams params, final byte[]... sets) {
	checkArgumentsSpecification(dstkey);
	byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, sets);

	return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) {
		@Override
		public Long doExecute(Jedis connection) {
			return connection.zunionstore(dstkey, params, sets);
		}
	}.runBinary(wholeKeys.length, wholeKeys);
}
 
Example #9
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(final byte[] dstkey, final ZParams params, final byte[]... sets) {
	checkArgumentsSpecification(dstkey);
	byte[][] wholeKeys = KeyMergeUtil.merge(dstkey, sets);

	return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) {
		@Override
		public Long doExecute(Jedis connection) {
			return connection.zinterstore(dstkey, params, sets);
		}
	}.runBinary(wholeKeys.length, wholeKeys);
}
 
Example #10
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(final String dstkey, final ZParams params, final String... sets) {
	checkArgumentsSpecification(dstkey);
	String[] mergedKeys = KeyMergeUtil.merge(dstkey, sets);

	return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) {
		@Override
		public Long doExecute(Jedis connection) {
			return connection.zunionstore(dstkey, params, sets);
		}
	}.run(mergedKeys.length, mergedKeys);
}
 
Example #11
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(final String dstkey, final ZParams params, final String... sets) {
	checkArgumentsSpecification(dstkey);
	String[] mergedKeys = KeyMergeUtil.merge(dstkey, sets);

	return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) {
		@Override
		public Long doExecute(Jedis connection) {
			return connection.zinterstore(dstkey, params, sets);
		}
	}.run(mergedKeys.length, mergedKeys);
}
 
Example #12
Source File: RedisSortedSet.java    From litchi with Apache License 2.0 5 votes vote down vote up
/**
   * 计算给定的一个或多个有序集的并集,并存储在新的 key 中
   * @param dstkey
   * @param params
   * @param sets
   * @return
   */
  public Long unionstore(String dstkey, ZParams params, String... sets){
  	try {
  		return jedis.zunionstore(dstkey, params, sets);
} catch (Exception e) {
	LOGGER.error("", e);
} finally {
	if (autoClose) {
		close();
	}
}
  	return -1L;
  }
 
Example #13
Source File: RedisSortedSet.java    From litchi with Apache License 2.0 5 votes vote down vote up
/**
   * 计算给定的一个或多个有序集的交集并将结果集存储在新的有序集合 key 中
   * @param dstkey
   * @param params
   * @param sets
   * @return
   */
  public Long zinterstore(String dstkey, ZParams params, String... sets) {
  	try {
  		return jedis.zinterstore(dstkey, params, sets);
} catch (Exception e) {
	LOGGER.error("", e);
} finally {
	if (autoClose) {
		close();
	}
}
  	return -1L;
  }
 
Example #14
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void zunionstore_weights_min(String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	t.zunionstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MIN), keys);
}
 
Example #15
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(String dstkey, ZParams params, String... sets) {
  Span span = helper.buildSpan("zinterstore");
  span.setTag("dstkey", dstkey);
  span.setTag("params", TracingHelper.toString(params.getParams()));
  span.setTag("sets", Arrays.toString(sets));
  try {
    return super.zinterstore(dstkey, params, sets);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #16
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void zinterstore_weights_min(String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	t.zinterstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MIN), keys);
}
 
Example #17
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void zinterstore_weights_max(String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	t.zinterstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MAX), keys);
}
 
Example #18
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void zinterstore_weights(String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	t.zinterstore(destination, new ZParams().weights(weights), keys);
}
 
Example #19
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private Long zunionstore_weights_min(Jedis j, String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	return j.zunionstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MIN), keys);
}
 
Example #20
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private Long zunionstore_weights_max(Jedis j, String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	return j.zunionstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MAX), keys);
}
 
Example #21
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private Long zunionstore_weights(Jedis j, String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	return j.zunionstore(destination, new ZParams().weights(weights), keys);
}
 
Example #22
Source File: SortedSetCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
public void zunionstoreParams() {
  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);

  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));
}
 
Example #23
Source File: SortedSetCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
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);

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

  assertEquals(bexpected, jedis.zrangeWithScores(SafeEncoder.encode("dst"), 0, 100));
}
 
Example #24
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private Long zinterstore_weights_min(Jedis j, String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	return j.zinterstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MIN), keys);
}
 
Example #25
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private Long zinterstore_weights_max(Jedis j, String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	return j.zinterstore(destination, new ZParams().weights(weights).aggregate(Aggregate.MAX), keys);
}
 
Example #26
Source File: DefaultRedis.java    From craft-atom with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private Long zinterstore_weights(Jedis j, String destination, Map<String, Integer> weightkeys) {
	Object[] objs = convert4zstore(weightkeys);
	String[] keys = (String[]) objs[0];
	int [] weights = (int[]) objs[1];
	return j.zinterstore(destination, new ZParams().weights(weights), keys);
}
 
Example #27
Source File: JedisAdapter.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(byte[] dstkey, ZParams params, byte[]... sets) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		return delegate.zinterstore(dstkey, params, sets);
	} finally {
		pool.returnResource(delegate);
	}
}
 
Example #28
Source File: JedisAdapter.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
public Long zinterstore(String dstkey, ZParams params, String... sets) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		return delegate.zinterstore(dstkey, params, sets);
	} finally {
		pool.returnResource(delegate);
	}
}
 
Example #29
Source File: JedisAdapter.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(byte[] dstkey, ZParams params, byte[]... sets) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		return delegate.zunionstore(dstkey, params, sets);
	} finally {
		pool.returnResource(delegate);
	}
}
 
Example #30
Source File: JedisAdapter.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
public Long zunionstore(String dstkey, ZParams params, String... sets) {
	redis.clients.jedis.Jedis delegate = pool.getResource();
	try {
		return delegate.zunionstore(dstkey, params, sets);
	} finally {
		pool.returnResource(delegate);
	}
}