in src/main/java/com/aliyun/openservices/paifeaturestore/datasource/FeatureDBClient.java [310:341]
public void writeFeatureDB(List<Map<String, Object>> data, String database, String schema, String table) throws Exception {
InsertMode insertMode = InsertMode.Unknown;
for (Map<String, Object> item : data) {
if (item.containsKey("__insert_mode__")) {
insertMode = (InsertMode) item.get("__insert_mode__");
item.remove("__insert_mode__");
}
}
String url = String.format("%s/api/v1/tables/%s/%s/%s/write", address, database, schema, table );
Map<String, Object> map = new HashMap<>();
map.put("content", data);
map.put("write_mode", insertMode);
String requestBody = gson.toJson(map);
RequestBody body = RequestBody.create(requestBody, JSON);
Request request = new Request.Builder()
.url(url)
.post(body)
.addHeader("Authorization", token)
.addHeader("Auth", signature)
.build();
try(Response response = this.httpclient.newCall(request).execute()) {
if (!response.isSuccessful() || response.code() != 200) {
int errorCode = response.code();
try (InputStream errorStream = response.body().byteStream()) {
String errorMessage = IOUtils.readStreamAsString(errorStream, "UTF-8");
throw new HttpException(errorCode, errorMessage);
}
}
}
}