DATAREDIS-407 - Polishing.

Updated license header, added missing Javadoc, fix indentation and organized imports.

Original Pull Request: #166
This commit is contained in:
Christoph Strobl
2016-02-09 12:11:35 +01:00
parent 4131f501a6
commit 97b88979e7
9 changed files with 159 additions and 64 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,8 @@ package org.springframework.data.redis.core;
import java.util.Collection;
import java.util.Set;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
/**
@@ -53,9 +54,26 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
Set<TypedTuple<V>> reverseRangeByScoreWithScores(double min, double max);
Set<V> rangeByLex(RedisZSetCommands.Range range);
/**
* Get all elements with lexicographical ordering with a value between {@link Range#getMin()} and
* {@link Range#getMax()}.
*
* @param range must not be {@literal null}.
* @since 1.7
*/
Set<V> rangeByLex(Range range);
Set<V> rangeByLex(RedisZSetCommands.Range range, RedisZSetCommands.Limit limit);
/**
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
* {@link Limit#getOffset()} with lexicographical ordering having a value between {@link Range#getMin()} and
* {@link Range#getMax()}.
*
* @param range must not be {@literal null}.
* @param limit can be {@literal null}.
* @return
* @since 1.7
*/
Set<V> rangeByLex(Range range, Limit limit);
void removeRange(long start, long end);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,8 @@ import java.util.Collection;
import java.util.Set;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
/**
@@ -97,13 +98,21 @@ class DefaultBoundZSetOperations<K, V> extends DefaultBoundKeyOperations<K> impl
return ops.reverseRangeWithScores(getKey(), start, end);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.BoundZSetOperations#rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range)
*/
@Override
public Set<V> rangeByLex(RedisZSetCommands.Range range) {
return ops.rangeByLex(getKey(), range);
public Set<V> rangeByLex(Range range) {
return rangeByLex(range, null);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.BoundZSetOperations#rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
*/
@Override
public Set<V> rangeByLex(RedisZSetCommands.Range range, RedisZSetCommands.Limit limit) {
public Set<V> rangeByLex(Range range, Limit limit) {
return ops.rangeByLex(getKey(), range, limit);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,8 @@ import java.util.Set;
import org.springframework.core.convert.converter.Converter;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
/**
@@ -143,23 +144,21 @@ class DefaultZSetOperations<K, V> extends AbstractOperations<K, V> implements ZS
return deserializeTupleValues(rawValues);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.ZSetOperations#rangeByLex(java.lang.Object, org.springframework.data.redis.connection.RedisZSetCommands.Range)
*/
@Override
public Set<V> rangeByLex(K key, final RedisZSetCommands.Range range) {
final byte[] rawKey = rawKey(key);
Set<byte[]> rawValues = execute(new RedisCallback<Set<byte[]>>() {
public Set<byte[]> doInRedis(RedisConnection connection) {
return connection.zRangeByLex(rawKey, range);
}
}, true);
return deserializeValues(rawValues);
public Set<V> rangeByLex(K key, final Range range) {
return rangeByLex(key, range, null);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.core.ZSetOperations#rangeByLex(java.lang.Object, org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
*/
@Override
public Set<V> rangeByLex(K key, final RedisZSetCommands.Range range, final RedisZSetCommands.Limit limit) {
public Set<V> rangeByLex(K key, final Range range, final Limit limit) {
final byte[] rawKey = rawKey(key);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,8 @@ package org.springframework.data.redis.core;
import java.util.Collection;
import java.util.Set;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
/**
* Redis ZSet/sorted set specific operations.
@@ -55,9 +56,28 @@ public interface ZSetOperations<K, V> {
Set<TypedTuple<V>> reverseRangeWithScores(K key, long start, long end);
Set<V> rangeByLex(K key, RedisZSetCommands.Range range);
/**
* Get all elements with lexicographical ordering from {@literal ZSET} at {@code key} with a value between
* {@link Range#getMin()} and {@link Range#getMax()}.
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @since 1.7
*/
Set<V> rangeByLex(K key, Range range);
Set<V> rangeByLex(K key, RedisZSetCommands.Range range, RedisZSetCommands.Limit limit);
/**
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
* {@link Limit#getOffset()} with lexicographical ordering from {@literal ZSET} at {@code key} with a value between
* {@link Range#getMin()} and {@link Range#getMax()}.
*
* @param key must not be {@literal null}
* @param range must not be {@literal null}.
* @param limit can be {@literal null}.
* @return
* @since 1.7
*/
Set<V> rangeByLex(K key, Range range, Limit limit);
Set<V> rangeByScore(K key, double min, double max);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,8 @@ import java.util.Set;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.core.BoundZSetOperations;
import org.springframework.data.redis.core.ConvertingCursor;
import org.springframework.data.redis.core.Cursor;
@@ -116,13 +117,21 @@ public class DefaultRedisZSet<E> extends AbstractRedisCollection<E> implements R
return boundZSetOps.reverseRange(start, end);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.support.collections.RedisZSet#rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range)
*/
@Override
public Set<E> rangeByLex(RedisZSetCommands.Range range) {
public Set<E> rangeByLex(Range range) {
return boundZSetOps.rangeByLex(range);
}
/*
* (non-Javadoc)
* @see org.springframework.data.redis.support.collections.RedisZSet#rangeByLex(org.springframework.data.redis.connection.RedisZSetCommands.Range, org.springframework.data.redis.connection.RedisZSetCommands.Limit)
*/
@Override
public Set<E> rangeByLex(RedisZSetCommands.Range range, RedisZSetCommands.Limit limit) {
public Set<E> rangeByLex(Range range, Limit limit) {
return boundZSetOps.rangeByLex(range, limit);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,9 @@ import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.core.BoundZSetOperations;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
/**
@@ -33,6 +35,7 @@ import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
*
* @author Costin Leau
* @author Mark Paluch
* @auhtor Christoph Strobl
*/
public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
@@ -48,9 +51,29 @@ public interface RedisZSet<E> extends RedisCollection<E>, Set<E> {
Set<E> reverseRange(long start, long end);
Set<E> rangeByLex(RedisZSetCommands.Range range);
/**
* Get all elements with lexicographical ordering with a value between {@link Range#getMin()} and
* {@link Range#getMax()}.
*
* @param range must not be {@literal null}.
* @return
* @see BoundZSetOperations#rangeByLex(Range)
* @since 1.7
*/
Set<E> rangeByLex(Range range);
Set<E> rangeByLex(RedisZSetCommands.Range range, RedisZSetCommands.Limit limit);
/**
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
* {@link Limit#getOffset()} with lexicographical ordering having a value between {@link Range#getMin()} and
* {@link Range#getMax()}.
*
* @param range must not be {@literal null}.
* @param limit can be {@literal null}.
* @return
* @see BoundZSetOperations#rangeByLex(Range, Limit)
* @since 1.7
*/
Set<E> rangeByLex(Range range, Limit limit);
Set<E> rangeByScore(double min, double max);