Skip to content

Commit f4a2aa9

Browse files
sunyuhan1998ilayaperumalg
authored andcommitted
refactor: Refactored the initializeContainer method of CosmosDBVectorStore: 1. Removed all parameters from the method signature, as they are already accessible via instance properties. 2. Eliminated meaningless reassignments of method parameters.
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
1 parent 4a4808d commit f4a2aa9

File tree

1 file changed

+3
-7
lines changed
  • vector-stores/spring-ai-azure-cosmos-db-store/src/main/java/org/springframework/ai/vectorstore/cosmosdb

1 file changed

+3
-7
lines changed

vector-stores/spring-ai-azure-cosmos-db-store/src/main/java/org/springframework/ai/vectorstore/cosmosdb/CosmosDBVectorStore.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,27 @@ protected CosmosDBVectorStore(Builder builder) {
128128
logger.error("Error creating database: {}", e.getMessage());
129129
}
130130

131-
initializeContainer(this.containerName, this.databaseName, this.vectorStoreThroughput, this.vectorDimensions,
132-
this.partitionKeyPath);
131+
initializeContainer();
133132
}
134133

135134
public static Builder builder(CosmosAsyncClient cosmosClient, EmbeddingModel embeddingModel) {
136135
return new Builder(cosmosClient, embeddingModel);
137136
}
138137

139-
private void initializeContainer(String containerName, String databaseName, int vectorStoreThroughput,
140-
long vectorDimensions, String partitionKeyPath) {
138+
private void initializeContainer() {
141139

142140
// Set defaults if not provided
143141
if (this.vectorStoreThroughput == 0) {
144142
this.vectorStoreThroughput = 400;
145-
vectorStoreThroughput = this.vectorStoreThroughput;
146143
}
147144
if (this.partitionKeyPath == null) {
148145
this.partitionKeyPath = "/id";
149-
partitionKeyPath = this.partitionKeyPath;
150146
}
151147

152148
// handle hierarchical partition key
153149
PartitionKeyDefinition subPartitionKeyDefinition = new PartitionKeyDefinition();
154150
List<String> pathsFromCommaSeparatedList = new ArrayList<>();
155-
String[] subPartitionKeyPaths = partitionKeyPath.split(",");
151+
String[] subPartitionKeyPaths = this.partitionKeyPath.split(",");
156152
Collections.addAll(pathsFromCommaSeparatedList, subPartitionKeyPaths);
157153
if (subPartitionKeyPaths.length > 1) {
158154
subPartitionKeyDefinition.setPaths(pathsFromCommaSeparatedList);

0 commit comments

Comments
 (0)