Skip to content

Commit c9a6a91

Browse files
author
anyihao
committed
2.3.1
1 parent 7312d09 commit c9a6a91

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ You can use **Apache Maven** or **Gradle**/**Grails** to download the SDK.
2424
<dependency>
2525
<groupId>com.tencent.tcvectordb</groupId>
2626
<artifactId>vectordatabase-sdk-java</artifactId>
27-
<version>2.3.0</version>
27+
<version>2.3.1</version>
2828
</dependency>
2929
```
3030

3131
- Gradle/Grails
3232

3333
```gradle
34-
compile 'com.tencent.tcvectordb:vectordatabase-sdk-java:2.3.0'
34+
compile 'com.tencent.tcvectordb:vectordatabase-sdk-java:2.3.1'
3535
```
3636

3737
### Examples

tcvectordb/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ You can use **Apache Maven** or **Gradle**/**Grails** to download the SDK.
2424
<dependency>
2525
<groupId>com.tencent.tcvectordb</groupId>
2626
<artifactId>vectordatabase-sdk-java</artifactId>
27-
<version>2.3.0</version>
27+
<version>2.3.1</version>
2828
</dependency>
2929
```
3030

3131
- Gradle/Grails
3232

3333
```gradle
34-
compile 'com.tencent.tcvectordb:vectordatabase-sdk-java:2.3.0'
34+
compile 'com.tencent.tcvectordb:vectordatabase-sdk-java:2.3.1'
3535
```
3636

3737
### Examples

tcvectordb/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.tencent.tcvectordb</groupId>
66
<artifactId>vectordatabase-sdk-java</artifactId>
7-
<version>2.3.0</version>
7+
<version>2.3.1</version>
88
<packaging>jar</packaging>
99

1010
<name>vectordatabase-sdk-java</name>

tcvectordb/src/main/java/com/tencent/tcvectordb/service/HttpStub.java

+4-16
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public class HttpStub implements Stub {
6666
private ConnectParam connectParam;
6767
private OkHttpClient client;
6868
private Headers.Builder headersBuilder;
69-
private ObjectMapper mapper = new ObjectMapper();
7069
private static final MediaType JSON =
7170
MediaType.parse("application/json; charset=utf-8");
7271
private static final Logger logger = LoggerFactory.getLogger(HttpStub.class.getName());
@@ -140,13 +139,7 @@ public List<String> listDatabases() {
140139
if (dbsJson == null) {
141140
return new ArrayList<>();
142141
}
143-
try {
144-
return mapper.readValue(dbsJson.toString(), new TypeReference<List<String>>() {
145-
});
146-
} catch (JsonProcessingException ex) {
147-
throw new VectorDBException(String.format(
148-
"VectorDBServer response error: can't parse databases=%s", dbsJson));
149-
}
142+
return JsonUtils.collectionDeserializer(dbsJson.toString(), new TypeReference<List<String>>(){});
150143
}
151144

152145
@Override
@@ -157,13 +150,8 @@ public Map<String, DataBaseType> listDatabaseInfos() {
157150
if (dbsJson == null) {
158151
return new HashMap<>();
159152
}
160-
try {
161-
return mapper.readValue(dbsJson.toString(), new TypeReference<Map<String, DataBaseType>>() {
162-
});
163-
} catch (JsonProcessingException ex) {
164-
throw new VectorDBException(String.format(
165-
"VectorDBServer response error: can't parse databases=%s", dbsJson));
166-
}
153+
return JsonUtils.collectionDeserializer(dbsJson.toString(), new TypeReference<Map<String, DataBaseType>>() {
154+
});
167155
}
168156

169157
@Override
@@ -979,7 +967,7 @@ private JsonNode parseResponse(Response response) throws IOException {
979967
"VectorDBServer error: not Successful, http code=%s, message=%s, result=%s",
980968
response.code(), response.message(), resStr));
981969
}
982-
JsonNode jsonNode = mapper.readTree(resStr);
970+
JsonNode jsonNode = JsonUtils.parseToJsonNode(resStr);
983971
int code = jsonNode.get("code").asInt();
984972
if (code != 0) {
985973
throw new VectorDBException(String.format(

tcvectordb/src/main/java/com/tencent/tcvectordb/utils/JsonUtils.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,17 @@ private JsonUtils() {
3838

3939
private static final String DATE_FORMAT_STR_ISO8601_CH = "yyyy-MM-dd HH:mm:ss";
4040
private static final ObjectMapper DESERIALIZE_IGNORE_KEY_MAPPER = new ObjectMapper();
41-
private static final ObjectMapper PARAMS_DESERIALIZE_MAPPER = new ObjectMapper();
4241
private static final ObjectMapper SERIALIZE_MAPPER = new ObjectMapper();
4342

4443

4544
static {
4645
DESERIALIZE_IGNORE_KEY_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
4746
DESERIALIZE_IGNORE_KEY_MAPPER.setDateFormat(new SimpleDateFormat(DATE_FORMAT_STR_ISO8601_CH));
48-
PARAMS_DESERIALIZE_MAPPER.setDateFormat(new SimpleDateFormat(DATE_FORMAT_STR_ISO8601_CH));
4947

5048
SimpleModule module = new SimpleModule();
5149
module.addDeserializer(ParamsSerializer.class, new ParamsDeserialize());
5250
module.addDeserializer(Embedding.class, new EmbeddingDeserialize());
53-
PARAMS_DESERIALIZE_MAPPER.registerModule(module);
51+
DESERIALIZE_IGNORE_KEY_MAPPER.registerModule(module);
5452
}
5553

5654
/**
@@ -119,7 +117,7 @@ public static JsonNode parseToJsonNode(String jsonStr) {
119117
*/
120118
public static <T> T collectionDeserializer(String jsonStr, TypeReference<T> clz) {
121119
try {
122-
return PARAMS_DESERIALIZE_MAPPER.readValue(jsonStr, clz);
120+
return DESERIALIZE_IGNORE_KEY_MAPPER.readValue(jsonStr, clz);
123121
} catch (JsonProcessingException e) {
124122
throw new ParamException(String.format(
125123
"can't parse content=%s", jsonStr), e);

0 commit comments

Comments
 (0)