Skip to content

Commit 85a3135

Browse files
authored
code refactoring + add unit test [memory module] (opensearch-project#4086)
* code refactoring Signed-off-by: Dhrubo Saha <[email protected]> * add more unit tests and bug fix Signed-off-by: Dhrubo Saha <[email protected]> --------- Signed-off-by: Dhrubo Saha <[email protected]>
1 parent b8da642 commit 85a3135

14 files changed

+3168
-1389
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.ml.action.memorycontainer.memory;
7+
8+
/**
9+
* Helper class to store fact search results
10+
*/
11+
public class FactSearchResult {
12+
private final String id;
13+
private final String text;
14+
private final float score;
15+
16+
public FactSearchResult(String id, String text, float score) {
17+
this.id = id;
18+
this.text = text;
19+
this.score = score;
20+
}
21+
22+
public String getId() {
23+
return id;
24+
}
25+
26+
public String getText() {
27+
return text;
28+
}
29+
30+
public float getScore() {
31+
return score;
32+
}
33+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright OpenSearch Contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.opensearch.ml.action.memorycontainer.memory;
7+
8+
import org.opensearch.ml.common.memorycontainer.MemoryType;
9+
10+
/**
11+
* Helper class to track memory info for response building
12+
*/
13+
public class MemoryInfo {
14+
private String memoryId;
15+
private final String content;
16+
private final MemoryType type;
17+
private final boolean includeInResponse;
18+
19+
public MemoryInfo(String memoryId, String content, MemoryType type, boolean includeInResponse) {
20+
this.memoryId = memoryId;
21+
this.content = content;
22+
this.type = type;
23+
this.includeInResponse = includeInResponse;
24+
}
25+
26+
public String getMemoryId() {
27+
return memoryId;
28+
}
29+
30+
public void setMemoryId(String memoryId) {
31+
this.memoryId = memoryId;
32+
}
33+
34+
public String getContent() {
35+
return content;
36+
}
37+
38+
public MemoryType getType() {
39+
return type;
40+
}
41+
42+
public boolean isIncludeInResponse() {
43+
return includeInResponse;
44+
}
45+
}

0 commit comments

Comments
 (0)