Skip to content
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

Bsb/v0.9.7 #521

Merged
merged 9 commits into from
Oct 23, 2024
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ inherited from the parent poms):
<path>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down Expand Up @@ -504,7 +504,7 @@ repositories {

```groovy
ext {
redisOmVersion = '0.9.6'
redisOmVersion = '0.9.7'
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions demos/roms-documents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -141,7 +141,7 @@
<path>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion demos/roms-hashes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
2 changes: 1 addition & 1 deletion demos/roms-permits/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<dependency>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion demos/roms-vss/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring-parent</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
<name>redis-om-spring-parent</name>
<packaging>pom</packaging>

Expand Down
7 changes: 3 additions & 4 deletions redis-om-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>com.redis.om</groupId>
<artifactId>redis-om-spring</artifactId>
<version>0.9.6</version>
<version>0.9.7</version>
<packaging>jar</packaging>

<name>redis-om-spring</name>
Expand Down Expand Up @@ -372,10 +372,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
<release>17</release>
<encoding>${project.build.sourceEncoding}</encoding>
<parameters>true</parameters>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
prefix = "redis.om.spring", ignoreInvalidFields = true
)
public class RedisOMProperties {
public static final String ROMS_VERSION = "0.9.6";
public static final String ROMS_VERSION = "0.9.7";
public static final int MAX_SEARCH_RESULTS = 10000;
public static final double DEFAULT_DISTANCE = 0.0005;
public static final Metrics DEFAULT_DISTANCE_METRIC = Metrics.MILES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import com.redis.om.spring.serialization.gson.GsonListOfType;
import com.redis.om.spring.util.ObjectUtils;
import com.redis.om.spring.vectorize.Embedder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.PropertyAccessor;
Expand Down Expand Up @@ -51,6 +53,7 @@
import org.springframework.util.ReflectionUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.json.Path2;
import redis.clients.jedis.search.Query;
import redis.clients.jedis.search.SearchResult;
Expand All @@ -64,8 +67,10 @@
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;

import static com.redis.om.spring.util.ObjectUtils.*;
Expand All @@ -74,6 +79,8 @@
public class SimpleRedisDocumentRepository<T, ID> extends SimpleKeyValueRepository<T, ID>
implements RedisDocumentRepository<T, ID> {

private final static Logger logger = LoggerFactory.getLogger(SimpleRedisDocumentRepository.class);

protected final RedisModulesOperations<String> modulesOperations;
protected final EntityInformation<T, ID> metadata;
protected final KeyValueOperations operations;
Expand Down Expand Up @@ -172,6 +179,7 @@ public boolean setExpiration(ID id, Long expiration, TimeUnit timeUnit) {
public <S extends T> List<S> saveAll(Iterable<S> entities) {
Assert.notNull(entities, "The given Iterable of entities must not be null!");
List<S> saved = new ArrayList<>();
List<Object> entityIds = new ArrayList<>();

try (Jedis jedis = modulesOperations.client().getJedis().get()) {
Pipeline pipeline = jedis.pipelined();
Expand All @@ -188,6 +196,8 @@ public <S extends T> List<S> saveAll(Iterable<S> entities) {
.getProperty(Objects.requireNonNull(keyValueEntity.getIdProperty()));
keyValueEntity.getPropertyAccessor(entity).setProperty(keyValueEntity.getIdProperty(), id);

entityIds.add(id);

String keyspace = keyValueEntity.getKeySpace();
byte[] objectKey = createKey(keyspace, Objects.requireNonNull(id).toString());

Expand Down Expand Up @@ -215,7 +225,22 @@ public <S extends T> List<S> saveAll(Iterable<S> entities) {

saved.add(entity);
}
pipeline.sync();

List<Object> responses = pipeline.syncAndReturnAll();

// Process responses using streams to avoid iterator issues
if (responses != null && !responses.isEmpty()) {
long failedCount = IntStream.range(0, Math.min(responses.size(), entityIds.size()))
.filter(i -> responses.get(i) instanceof JedisDataException)
.peek(i -> logger.warn("Failed JSON.SET command for entity with id: {} Error: {}",
entityIds.get(i),
((JedisDataException) responses.get(i)).getMessage()))
.count();

if (failedCount > 0) {
logger.warn("Total failed JSON.SET commands: {}", failedCount);
}
}
}

return saved;
Expand Down
Loading