Skip to content

DATAREDIS-664 - Adapt to ID type changes in KV module. #256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATAREDIS-664-SNAPSHOT</version>

<name>Spring Data Redis</name>

Expand All @@ -16,7 +16,7 @@
</parent>

<properties>
<springdata.keyvalue>2.0.0.BUILD-SNAPSHOT</springdata.keyvalue>
<springdata.keyvalue>2.0.0.DATAKV-187-SNAPSHOT</springdata.keyvalue>
<jta>1.1</jta>
<beanutils>1.9.2</beanutils>
<xstream>1.4.8</xstream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.springframework.data.redis.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -196,9 +195,10 @@ protected RedisKeyValueAdapter() {}

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#put(java.io.Serializable, java.lang.Object, java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#put(java.lang.Object, java.lang.Object, java.lang.String)
*/
public Object put(final Serializable id, final Object item, final Serializable keyspace) {
@Override
public Object put(final Object id, final Object item, final String keyspace) {

final RedisData rdo = item instanceof RedisData ? (RedisData) item : new RedisData();
if (!(item instanceof RedisData)) {
Expand Down Expand Up @@ -265,9 +265,10 @@ public Object doInRedis(RedisConnection connection) throws DataAccessException {

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#contains(java.io.Serializable, java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#contains(java.lang.Object, java.lang.String)
*/
public boolean contains(final Serializable id, final Serializable keyspace) {
@Override
public boolean contains(final Object id, final String keyspace) {

Boolean exists = redisOps.execute(new RedisCallback<Boolean>() {

Expand All @@ -282,19 +283,19 @@ public Boolean doInRedis(RedisConnection connection) throws DataAccessException

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#get(java.io.Serializable, java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#get(java.lang.Object, java.lang.String)
*/
public Object get(Serializable id, Serializable keyspace) {
@Override
public Object get(Object id, String keyspace) {
return get(id, keyspace, Object.class);
}

/**
* @param id
* @param keyspace
* @param type
* @return
/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#get(java.lang.Object, java.lang.String, java.lang.Class)
*/
public <T> T get(Serializable id, Serializable keyspace, Class<T> type) {
@Override
public <T> T get(Object id, String keyspace, Class<T> type) {

String stringId = asString(id);
String stringKeyspace = asString(keyspace);
Expand All @@ -318,17 +319,19 @@ public Map<byte[], byte[]> doInRedis(RedisConnection connection) throws DataAcce

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#delete(java.io.Serializable, java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#delete(java.lang.Object, java.lang.String)
*/
public Object delete(final Serializable id, final Serializable keyspace) {
@Override
public Object delete(final Object id, final String keyspace) {
return delete(id, keyspace, Object.class);
}

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.AbstractKeyValueAdapter#delete(java.io.Serializable, java.io.Serializable, java.lang.Class)
* @see org.springframework.data.keyvalue.core.AbstractKeyValueAdapter#delete(java.lang.Object, java.lang.String, java.lang.Class)
*/
public <T> T delete(final Serializable id, final Serializable keyspace, final Class<T> type) {
@Override
public <T> T delete(final Object id, final String keyspace, final Class<T> type) {

final byte[] binId = toBytes(id);
final byte[] binKeyspace = toBytes(keyspace);
Expand Down Expand Up @@ -358,13 +361,14 @@ public Void doInRedis(RedisConnection connection) throws DataAccessException {

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#getAllOf(java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#getAllOf(java.lang.String)
*/
public List<?> getAllOf(final Serializable keyspace) {
@Override
public List<?> getAllOf(final String keyspace) {
return getAllOf(keyspace, -1, -1);
}

public List<?> getAllOf(final Serializable keyspace, long offset, int rows) {
public List<?> getAllOf(final String keyspace, long offset, int rows) {

final byte[] binKeyspace = toBytes(keyspace);

Expand Down Expand Up @@ -397,9 +401,10 @@ public Set<byte[]> doInRedis(RedisConnection connection) throws DataAccessExcept

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#deleteAllOf(java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#deleteAllOf(java.lang.String)
*/
public void deleteAllOf(final Serializable keyspace) {
@Override
public void deleteAllOf(final String keyspace) {

redisOps.execute(new RedisCallback<Void>() {

Expand All @@ -415,17 +420,19 @@ public Void doInRedis(RedisConnection connection) throws DataAccessException {

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#entries(java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#entries(java.lang.String)
*/
public CloseableIterator<Entry<Serializable, Object>> entries(Serializable keyspace) {
@Override
public CloseableIterator<Entry<Object, Object>> entries(String keyspace) {
throw new UnsupportedOperationException("Not yet implemented");
}

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#count(java.io.Serializable)
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#count(java.lang.String)
*/
public long count(final Serializable keyspace) {
@Override
public long count(final String keyspace) {

Long count = redisOps.execute(new RedisCallback<Long>() {

Expand Down Expand Up @@ -592,7 +599,7 @@ public void clear() {
// nothing to do
}

private String asString(Serializable value) {
private String asString(Object value) {
return value instanceof String ? (String) value
: getConverter().getConversionService().convert(value, String.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
Expand All @@ -15,7 +15,6 @@
*/
package org.springframework.data.redis.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -114,10 +113,10 @@ public List<T> doInRedis(RedisKeyValueAdapter adapter) {

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.KeyValueTemplate#insert(java.io.Serializable, java.lang.Object)
* @see org.springframework.data.keyvalue.core.KeyValueTemplate#insert(java.lang.Object, java.lang.Object)
*/
@Override
public void insert(final Serializable id, final Object objectToInsert) {
public void insert(final Object id, final Object objectToInsert) {

if (objectToInsert instanceof PartialUpdate) {
doPartialUpdate((PartialUpdate<?>) objectToInsert);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.springframework.data.redis.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -72,12 +71,12 @@ public RedisQueryEngine(CriteriaAccessor<RedisOperationChain> criteriaAccessor,

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.io.Serializable, java.lang.Class)
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.lang.String, java.lang.Class)
*/
@Override
@SuppressWarnings("unchecked")
public <T> Collection<T> execute(final RedisOperationChain criteria, final Comparator<?> sort, final long offset,
final int rows, final Serializable keyspace, Class<T> type) {
final int rows, final String keyspace, Class<T> type) {

if (criteria == null
|| (CollectionUtils.isEmpty(criteria.getOrSismember()) && CollectionUtils.isEmpty(criteria.getSismember()))
Expand Down Expand Up @@ -151,20 +150,20 @@ public Map<byte[], Map<byte[], byte[]>> doInRedis(RedisConnection connection) th

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.io.Serializable)
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.lang.String)
*/
@Override
public Collection<?> execute(final RedisOperationChain criteria, Comparator<?> sort, long offset, int rows,
final Serializable keyspace) {
final String keyspace) {
return execute(criteria, sort, offset, rows, keyspace, Object.class);
}

/*
* (non-Javadoc)
* @see org.springframework.data.keyvalue.core.QueryEngine#count(java.lang.Object, java.io.Serializable)
* @see org.springframework.data.keyvalue.core.QueryEngine#count(java.lang.Object, java.lang.String)
*/
@Override
public long count(final RedisOperationChain criteria, final Serializable keyspace) {
public long count(final RedisOperationChain criteria, final String keyspace) {

if (criteria == null) {
return this.getAdapter().count(keyspace);
Expand Down