redis.clients.jedis.Tuple Java Examples
The following examples show how to use
redis.clients.jedis.Tuple.
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: RedisRecordHandler.java From aws-athena-query-federation with Apache License 2.0 | 6 votes |
private void loadZSetRows(Jedis client, String keyString, BlockSpiller spiller, List<Field> fieldList) { if (fieldList.size() != 1) { throw new RuntimeException("Ambiguous field mapping, more than 1 field for ZSET value type."); } Field zfield = fieldList.get(0); String cursor = SCAN_POINTER_START; do { ScanResult<Tuple> result = client.zscan(keyString, cursor); cursor = result.getCursor(); for (Tuple nextElement : result.getResult()) { spiller.writeRows((Block block, int rowNum) -> { Object zvalue = ValueConverter.convert(zfield, nextElement.getElement()); boolean zsetMatched = block.offerValue(KEY_COLUMN_NAME, rowNum, keyString); zsetMatched &= block.offerValue(zfield.getName(), rowNum, zvalue); return zsetMatched ? 1 : 0; }); } } while (cursor != null && !END_CURSOR.equals(cursor)); }
Example #2
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrangeByScoreWithScores(key, min, max, offset, count); } 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 | 6 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } 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 | 6 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } 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 | 6 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #6
Source File: RedisClientImpl.java From nano-framework with Apache License 2.0 | 6 votes |
@Override public <T> Map<T, Double> zrangeWithScores(final String key, final long start, final long end, final TypeReference<T> type) { Assert.hasText(key); Assert.notNull(type); ShardedJedis jedis = null; try { jedis = POOL.getJedis(config.getRedisType()); final Set<Tuple> values = jedis.zrangeWithScores(key, start, end); if (!CollectionUtils.isEmpty(values)) { final Map<T, Double> newValues = Maps.newHashMap(); for (Tuple value : values) { newValues.put(parseObject(value.getElement(), type), value.getScore()); } return newValues; } return Collections.emptyMap(); } catch (final Throwable e) { throw new RedisClientException(e.getMessage(), e); } finally { POOL.close(jedis); } }
Example #7
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(byte[] key, byte[] min, byte[] max, int offset, int count) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", Arrays.toString(min)); span.setTag("max", Arrays.toString(max)); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrangeByScoreWithScores(key, min, max, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #8
Source File: TestRedisQParser.java From solr-redis with Apache License 2.0 | 6 votes |
@Test public void shouldAddTermsFromRedisOnZrevrangebyscoreCommandWithDefaultParams() throws SyntaxError, IOException { when(localParamsMock.get("command")).thenReturn("zrevrangebyscore"); when(localParamsMock.get("key")).thenReturn("simpleKey"); when(localParamsMock.get(QueryParsing.V)).thenReturn("string_field"); when(jedisMock.zrevrangeByScoreWithScores(anyString(), anyString(), anyString())) .thenReturn(new HashSet<>(Arrays.asList(new Tuple("123", (double) 1.0f), new Tuple("321", (double) 1.0f)))); when(requestMock.getSchema()).thenReturn(schema); when(schema.getQueryAnalyzer()).thenReturn(new StandardAnalyzer()); redisQParser = new RedisQParser("string_field", localParamsMock, paramsMock, requestMock, commandHandler); final Query query = redisQParser.parse(); verify(jedisMock).zrevrangeByScoreWithScores("simpleKey", "+inf", "-inf"); IndexSearcher searcher = new IndexSearcher(new MultiReader()); final Set<Term> terms = extractTerms(searcher, query); Assert.assertEquals(2, terms.size()); }
Example #9
Source File: RedisJobStore.java From redis-quartz with MIT License | 6 votes |
/** * Release triggers locked by an instance id. * * @param lockedByInstanceId the locking instance id * @param currentState the current locking state * @param newState the new trigger's state */ private void releaseLockedTriggers(String lockedByInstanceId, RedisTriggerState currentState, RedisTriggerState newState) { try (Jedis jedis = pool.getResource()) { lockPool.acquire(); Set<Tuple> triggerTuples = jedis.zrangeWithScores(currentState.getKey(), 0, -1); for (Tuple triggerTuple : triggerTuples) { if (lockedByInstanceId != null && lockedByInstanceId.equals(jedis.hget(triggerTuple.getElement(), LOCKED_BY))) { log.debug("releasing trigger: " + triggerTuple.getElement() + " from: " + currentState.getKey()); setTriggerState(newState, triggerTuple.getScore(), triggerTuple.getElement()); } } } catch (Exception ex) { log.error("could not release locked triggers in: " + currentState.getKey(), ex); } finally { lockPool.release(); } }
Example #10
Source File: RedisClusterClientImpl.java From nano-framework with Apache License 2.0 | 6 votes |
@Override public <T> Map<T, Double> zrangeWithScores(final String key, final long start, final long end, final TypeReference<T> type) { Assert.hasText(key); Assert.notNull(type); try { final Set<Tuple> tuples = cluster.zrangeWithScores(key, start, end); if (!CollectionUtils.isEmpty(tuples)) { final Map<T, Double> newValues = Maps.newHashMap(); for (Tuple tuple : tuples) { newValues.put(parseObject(tuple.getElement(), type), tuple.getScore()); } return newValues; } return Collections.emptyMap(); } catch (final Throwable e) { throw new RedisClientException(e.getMessage(), e); } }
Example #11
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #12
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 6 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); span.setTag("offset", offset); span.setTag("count", count); try { return super.zrevrangeByScoreWithScores(key, max, min, offset, count); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #13
Source File: SortedSetCommandsTest.java From cachecloud with Apache License 2.0 | 6 votes |
@Test public void zscan() { jedis.zadd("foo", 1, "a"); jedis.zadd("foo", 2, "b"); ScanResult<Tuple> result = jedis.zscan("foo", SCAN_POINTER_START); assertEquals(SCAN_POINTER_START, result.getCursor()); assertFalse(result.getResult().isEmpty()); // binary jedis.zadd(bfoo, 1, ba); jedis.zadd(bfoo, 1, bb); ScanResult<Tuple> bResult = jedis.zscan(bfoo, SCAN_POINTER_START_BINARY); assertArrayEquals(SCAN_POINTER_START_BINARY, bResult.getCursorAsBytes()); assertFalse(bResult.getResult().isEmpty()); }
Example #14
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeWithScores(final String key, final long start, final long end) { try { return toTupleSet(redis.zrange(key, start, end, "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #15
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrangeByScoreWithScores(key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #16
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, byte[] max, byte[] min) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("max", Arrays.toString(max)); span.setTag("min", Arrays.toString(min)); try { return super.zrevrangeByScoreWithScores(key, max, min); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #17
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeWithScores(final String key, final long start, final long end) { try { return toTupleSet(redis.zrevrange(key, start, end, "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #18
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(final String key, final double min, final double max, final int offset, final int count) { try { return toTupleSet(redis.zrangebyscore(key, String.valueOf(min), String.valueOf(max), "limit", String.valueOf(offset), String.valueOf(count), "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #19
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrevrangeByScoreWithScores(key, max, min); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #20
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(byte[] key, double max, double min) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrevrangeByScoreWithScores(key, max, min); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #21
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeWithScores(byte[] key, long start, long end) { Span span = helper.buildSpan("zrangeWithScores", key); span.setTag("start", start); span.setTag("end", end); try { return super.zrangeWithScores(key, start, end); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #22
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min) { Span span = helper.buildSpan("zrevrangeByScoreWithScores", key); span.setTag("max", max); span.setTag("min", min); try { return super.zrevrangeByScoreWithScores(key, max, min); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #23
Source File: RedisValueDescriptor.java From nosql4idea with Apache License 2.0 | 5 votes |
@Override public String getFormattedValue() { if (getValue() instanceof Tuple) { Tuple tupleValue = (Tuple) getValue(); return String.format("(%s, %s)", tupleValue.getElement(), tupleValue.getScore()); } return String.valueOf(getValue()); }
Example #24
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max) { Span span = helper.buildSpan("zrangeByScoreWithScores", key); span.setTag("min", min); span.setTag("max", max); try { return super.zrangeByScoreWithScores(key, min, max); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #25
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeWithScores(String key, long start, long end) { Span span = helper.buildSpan("zrevrangeWithScores", key); span.setTag("start", start); span.setTag("end", end); try { return super.zrevrangeWithScores(key, start, end); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #26
Source File: SortedSetCommandsTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void zinterstore() { jedis.zadd("foo", 1, "a"); jedis.zadd("foo", 2, "b"); jedis.zadd("bar", 2, "a"); 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)); }
Example #27
Source File: JedisMock.java From conductor with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrevrangeByScoreWithScores(final String key, final double max, final double min) { try { return toTupleSet(redis.zrevrangebyscore(key, String.valueOf(max), String.valueOf(min), "withscores")); } catch (Exception e) { throw new JedisException(e); } }
Example #28
Source File: TracingJedisCluster.java From java-redis-client with Apache License 2.0 | 5 votes |
@Override public ScanResult<Tuple> zscan(String key, String cursor) { Span span = helper.buildSpan("zscan", key); span.setTag("cursor", cursor); try { return super.zscan(key, cursor); } catch (Exception e) { onError(e, span); throw e; } finally { span.finish(); } }
Example #29
Source File: JedisAdapter.java From gameserver with Apache License 2.0 | 5 votes |
@Override public Set<Tuple> zrangeByScoreWithScores(byte[] key, double min, double max, int offset, int count) { redis.clients.jedis.Jedis delegate = pool.getResource(); try { return delegate.zrangeByScoreWithScores(key, min, max, offset, count); } finally { pool.returnResource(delegate); } }
Example #30
Source File: ResultUtil.java From solr-redis with Apache License 2.0 | 5 votes |
static Map<String, Float> tupleIteratorToMap(final Iterable<Tuple> set) { final Map<String, Float> map = new HashMap<>(); for (final Tuple tuple : set) { map.put(tuple.getElement(), (float) tuple.getScore()); } return map; }