Skip to content

Commit 608b29c

Browse files
ppjgitilayaperumalg
authored andcommitted
small code improvements/clean-ups, deleted unused method 'withEmbedding' from SimpleVectorStoreContent class
Signed-off-by: pavel <[email protected]>
1 parent 29fde4f commit 608b29c

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

Diff for: spring-ai-core/src/main/java/org/springframework/ai/vectorstore/SimpleVectorStoreContent.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.ai.vectorstore;
1818

1919
import java.util.Arrays;
20-
import java.util.Collections;
2120
import java.util.HashMap;
2221
import java.util.Map;
2322
import java.util.Objects;
@@ -100,7 +99,7 @@ public SimpleVectorStoreContent(String id, String text, Map<String, Object> meta
10099

101100
this.id = id;
102101
this.text = text;
103-
this.metadata = Collections.unmodifiableMap(new HashMap<>(metadata));
102+
this.metadata = Map.copyOf(metadata);
104103
this.embedding = Arrays.copyOf(embedding, embedding.length);
105104
}
106105

@@ -110,6 +109,7 @@ public SimpleVectorStoreContent(String id, String text, Map<String, Object> meta
110109
* @return a new instance with the updated embedding
111110
* @throws IllegalArgumentException if embedding is null or empty
112111
*/
112+
@Deprecated(forRemoval = true, since = "1.0.0-M7")
113113
public SimpleVectorStoreContent withEmbedding(float[] embedding) {
114114
Assert.notNull(embedding, "embedding must not be null");
115115
Assert.isTrue(embedding.length > 0, "embedding vector must not be empty");

Diff for: spring-ai-core/src/main/java/org/springframework/ai/vectorstore/filter/FilterExpressionBuilder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
* }</pre>
5050
*
5151
*
52-
* This builder DSL mimics the common https://www.baeldung.com/hibernate-criteria-queries
52+
* This builder DSL mimics the common
53+
* <a href="https://www.baeldung.com/hibernate-criteria-queries">Criteria Queries</a>
5354
* syntax.
5455
*
5556
* @author Christian Tzolov

Diff for: spring-ai-core/src/main/java/org/springframework/ai/vectorstore/filter/FilterExpressionTextParser.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.Map;
2222
import java.util.concurrent.ConcurrentHashMap;
2323
import java.util.concurrent.CopyOnWriteArrayList;
24-
import java.util.stream.Collectors;
2524

2625
import org.antlr.v4.runtime.ANTLRErrorStrategy;
2726
import org.antlr.v4.runtime.BailErrorStrategy;
@@ -46,7 +45,7 @@
4645
*
4746
* The vector-store agnostic, filter expression language is defined by a formal ANTLR4
4847
* grammar (Filters.g4). The language looks and feels like a subset of the well known SQL
49-
* WHERE filter expressions. For example you can use the parser like this:
48+
* WHERE filter expressions. For example, you can use the parser like this:
5049
*
5150
* <pre>{@code
5251
*
@@ -151,7 +150,7 @@ public Filter.Expression parse(String textFilterExpression) {
151150
return filterExpression;
152151
}
153152
catch (ParseCancellationException e) {
154-
var msg = this.errorListener.errorMessages.stream().collect(Collectors.joining());
153+
var msg = String.join("", this.errorListener.errorMessages);
155154
var rootCause = NestedExceptionUtils.getRootCause(e);
156155
throw new FilterExpressionParseException(msg, rootCause);
157156
}

Diff for: spring-ai-core/src/main/java/org/springframework/ai/vectorstore/filter/converter/PineconeFilterExpressionConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* Converts {@link Expression} into Pinecone metadata filter expression format.
25-
* (https://docs.pinecone.io/docs/metadata-filtering)
25+
* (<a href="https://docs.pinecone.io/docs/metadata-filtering">Metadata filtering</a>)
2626
*
2727
* @author Christian Tzolov
2828
*/
@@ -58,7 +58,7 @@ private String getOperationSymbol(Expression exp) {
5858
@Override
5959
protected void doKey(Key key, StringBuilder context) {
6060
var identifier = (hasOuterQuotes(key.key())) ? removeOuterQuotes(key.key()) : key.key();
61-
context.append("\"" + identifier + "\": ");
61+
context.append("\"").append(identifier).append("\": ");
6262
}
6363

6464
}

Diff for: spring-ai-core/src/main/java/org/springframework/ai/vectorstore/filter/converter/PrintFilterExpressionConverter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class PrintFilterExpressionConverter extends AbstractFilterExpressionConv
2929

3030
public void doExpression(Expression expression, StringBuilder context) {
3131
this.convertOperand(expression.left(), context);
32-
context.append(" " + expression.type() + " ");
32+
context.append(" ").append(expression.type()).append(" ");
3333
this.convertOperand(expression.right(), context);
3434

3535
}

0 commit comments

Comments
 (0)