Skip to content

Redis e2e tests extension#1451

Open
aszyrej wants to merge 2 commits intomasterfrom
redis-e2e-extension
Open

Redis e2e tests extension#1451
aszyrej wants to merge 2 commits intomasterfrom
redis-e2e-extension

Conversation

@aszyrej
Copy link
Collaborator

@aszyrej aszyrej commented Feb 19, 2026

Redis e2e tests now cover HASH, PATTERN and SET commands.
RedisData class has been refactored so that a key-value map is used in heuristic calculations.
Set intersection heuristic calculation has been refactored and now includes a distance calculation for each key to the set keys stored in Redis.

private Map<String, RedisValueData> createRedisInfoForIntersection(List<String> commandKeys, ReflectionBasedRedisClient redisClient) {
Set<String> keySet = redisClient.getKeysByType(REDIS_SET_TYPE);

Map<String, RedisValueData> redisData = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment explaining what the what is the key and what is the value.

private Map<String, RedisValueData> createRedisInfoForAllKeys(ReflectionBasedRedisClient redisClient) {
Set<String> keys = redisClient.getAllKeys();
List<RedisInfo> redisData = new ArrayList<>();
Map<String, RedisValueData> redisData = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment

Set<String> keys = redisClient.getKeysByType(type);
List<RedisInfo> redisData = new ArrayList<>();
keys.forEach(key -> redisData.add(new RedisInfo(key)));
Map<String, RedisValueData> redisData = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment

Set<String> keys = redisClient.getKeysByType(REDIS_HASH_TYPE);
List<RedisInfo> redisData = new ArrayList<>();
keys.forEach(key -> redisData.add(new RedisInfo(key, redisClient.getHashFields(key))));
Map<String, RedisValueData> redisData = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see previous comment

private String key;
private String type;
public class RedisValueData {
private Map<String, String> fields;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment explaining what the what is the key and what is the value.


if (i == 0) {
currentIntersection = new HashSet<>(set);
double d0 = currentIntersection.isEmpty() ? MAX_REDIS_DISTANCE : 0d;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d0 and 0d are misleading variable names and values

@@ -256,12 +290,11 @@ private RedisDistanceWithMetrics calculateDistanceForIntersection(
: 0d;

total += di;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a more declarative variable name than "di"

String field = redisCommand.extractArgs().get(1);
List<RedisInfo> redisInfo = createRedisInfoForKeysByField(field, redisClient);
return calculator.computeDistance(redisCommand, redisInfo);
Map<String, RedisValueData> redisValueData = createRedisInfoForKeysByField(redisClient);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this mapping be encapsulated into a representation of the data stored in the Redis Database?

String targetKey,
String targetField,
List<RedisInfo> keys
Map<String, RedisValueData> keys
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not seem to be Redis keys only

int evaluated = 0;

for (RedisInfo k : keys) {
for (String key : keys.keySet()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is weird, the keyset of the keys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants