Skip to content

Conversation

@aszyrej
Copy link
Collaborator

@aszyrej aszyrej commented Oct 10, 2025

Added distance calculation for several Redis Commands.

RedisCommand class holds an attribute for each one that should have an heuristic value computation.

@aszyrej aszyrej requested a review from jgaleotti October 10, 2025 03:02
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
@aszyrej aszyrej requested a review from arcuri82 October 21, 2025 19:04
}

case HGETALL: {
List<RedisInfo> redisInfo = createRedisInfoForKeysByType("hash", redisClient);
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace "hash" with string constant

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added constant Strings.

}

case GET: {
List<RedisInfo> redisInfo = createRedisInfoForKeysByType("string", redisClient);
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace all "...." string constants with constant definitions

}

default:
return new RedisDistanceWithMetrics(1d, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace 1d with constant value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added constant value for MAX_REDIS_DISTANCE in RedisHeuristicCalculator, and that is the value imported in RedisHandler.


public class RedisHeuristicsCalculator {

public static final double MAX_DISTANCE = 1d;
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename to MAX_REDIS_DISTANCE

* @param redisPattern the Redis glob-style pattern (e.g., "h?llo*", "user:[0-9]*")
* @return a valid Java regex string equivalent to the Redis pattern.
*/
private static String redisPatternToRegex(String redisPattern) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to a RedisUtils class, add test cases to check all cases are considered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added RedisUtils and RedisUtilsTests


import java.util.Set;

public class RedisInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add javadoc of this class, what is its purpose?

// Parser rules have first letter in lower-case

pattern : disjunction;
pattern : disjunction EOF;
Copy link
Collaborator

Choose a reason for hiding this comment

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

There have been changes to this file in master. Please pull changes and merge them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Merged master to this branch

// Parser rules have first letter in lower-case

pattern : disjunction;
pattern : disjunction EOF;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as before

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Merged master to this branch

aszyrej and others added 16 commits October 24, 2025 11:00
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
# Conflicts:
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/internal/db/RedisHandler.java
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisClient.java
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisHeuristicsCalculator.java
#	client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/redis/RedisHandlerIntegrationTest.java
#	client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/redis/RedisHeuristicsCalculatorTest.java
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
# Conflicts:
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/internal/db/RedisHandler.java
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisClient.java
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisHeuristicsCalculator.java
#	client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/redis/RedisHandlerIntegrationTest.java
#	client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/redis/RedisHeuristicsCalculatorTest.java
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
# Conflicts:
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/internal/db/RedisHandler.java
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisClient.java
#	client-java/controller/src/main/java/org/evomaster/client/java/controller/redis/RedisHeuristicsCalculator.java
#	client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/redis/RedisHandlerIntegrationTest.java
#	client-java/controller/src/test/java/org/evomaster/client/java/controller/internal/db/redis/RedisHeuristicsCalculatorTest.java
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
…s Handler now creates a generic structure with Redis data. Also Redis client is using redis-data no more. It now uses Lettuce with refflection
@aszyrej aszyrej requested a review from jgaleotti October 27, 2025 04:50
@@ -0,0 +1,16 @@
package org.evomaster.client.java.controller.internal.db;
Copy link
Collaborator

Choose a reason for hiding this comment

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

as more files are added to internal/db, should refactor, and have subfolders for internal/db/redis, internal/db/mongo and internal/db/opensearch

* This class will link a given RedisCommand to the result of the distance calculation for that commmand.
*/
public class RedisCommandEvaluation {
public final RedisCommand redisCommand;
Copy link
Collaborator

Choose a reason for hiding this comment

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

those should be private, with public getters. usually, we have public fields only for DTOs

*/
public class RedisDistanceWithMetrics {
public final double redisDistance; // A number between 0 and 1.
public final int numberOfEvaluatedKeys;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be private

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.

4 participants