This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 5fa23d0 [IOTDB-892] Replace fastjson with Gson (#1728)
5fa23d0 is described below
commit 5fa23d05fc449d63bf157a62bda6d69c9bc96e95
Author: Qi Yu <[email protected]>
AuthorDate: Sun Sep 27 11:06:09 2020 +0800
[IOTDB-892] Replace fastjson with Gson (#1728)
---
.../controller/DatabaseConnectController.java | 120 +++++++++++----------
pom.xml | 12 +--
server/pom.xml | 4 +
.../org/apache/iotdb/db/metadata/MManager.java | 2 +-
.../java/org/apache/iotdb/db/metadata/MTree.java | 61 ++++++-----
.../apache/iotdb/db/mqtt/JSONPayloadFormatter.java | 27 ++---
.../iotdb/db/integration/IoTDBMetadataFetchIT.java | 13 ++-
tsfile/pom.xml | 8 +-
.../tsfile/encoding/decoder/BitmapDecoderTest.java | 1 -
.../iotdb/tsfile/utils/TsFileGeneratorForTest.java | 8 --
.../org/apache/iotdb/tsfile/write/PerfTest.java | 13 ++-
11 files changed, 144 insertions(+), 125 deletions(-)
diff --git
a/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
b/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
index 2643c1f..ac60149 100644
---
a/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
+++
b/grafana/src/main/java/org/apache/iotdb/web/grafana/controller/DatabaseConnectController.java
@@ -25,16 +25,15 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONException;
-import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
import org.apache.iotdb.tsfile.utils.Pair;
import org.apache.iotdb.web.grafana.bean.TimeValues;
import org.apache.iotdb.web.grafana.service.DatabaseConnectService;
@@ -54,6 +53,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
public class DatabaseConnectController {
private static final Logger logger =
LoggerFactory.getLogger(DatabaseConnectController.class);
+ public static final Gson GSON = new GsonBuilder().create();
@Autowired
private DatabaseConnectService databaseConnectService;
@@ -75,8 +75,7 @@ public class DatabaseConnectController {
@RequestMapping(value = "/search")
@ResponseBody
public String metricFindQuery(HttpServletRequest request,
HttpServletResponse response) {
- Map<Integer, String> target = new HashMap<>();
- JSONObject jsonObject = new JSONObject();
+ JsonObject root = new JsonObject();
response.setStatus(200);
List<String> columnsName = new ArrayList<>();
try {
@@ -86,9 +85,10 @@ public class DatabaseConnectController {
}
Collections.sort(columnsName);
for (int i = 0; i < columnsName.size(); i++) {
- jsonObject.put( i + "", columnsName.get(i));
+ root.addProperty(String.valueOf(i), columnsName.get(i));
}
- return jsonObject.toString();
+
+ return root.toString();
}
/**
@@ -104,25 +104,30 @@ public class DatabaseConnectController {
String targetStr = "target";
response.setStatus(200);
try {
- JSONObject jsonObject = getRequestBodyJson(request);
+ JsonObject jsonObject = getRequestBodyJson(request);
+ if (Objects.isNull(jsonObject)) {
+ return null;
+ }
+
Pair<ZonedDateTime, ZonedDateTime> timeRange =
getTimeFromAndTo(jsonObject);
- JSONArray array = (JSONArray) jsonObject.get("targets"); // []
- JSONArray result = new JSONArray();
+ JsonArray array = (JsonArray) jsonObject.get("targets"); // []
+ JsonArray result = new JsonArray();
for (int i = 0; i < array.size(); i++) {
- JSONObject object = (JSONObject) array.get(i); // {}
- if (!object.containsKey(targetStr)) {
+ JsonObject object = array.get(i).getAsJsonObject(); // {}
+ if (!object.has(targetStr)) {
return "[]";
}
- String target = (String) object.get(targetStr);
+ String target = object.get(targetStr).getAsString();
String type = getJsonType(jsonObject);
- JSONObject obj = new JSONObject();
- obj.put("target", target);
+
+ JsonObject obj = new JsonObject();
+ obj.addProperty("target", target);
if (type.equals("table")) {
setJsonTable(obj, target, timeRange);
} else if (type.equals("timeserie")) {
setJsonTimeseries(obj, target, timeRange);
}
- result.add(i, obj);
+ result.add(obj);
}
logger.info("query finished");
return result.toString();
@@ -132,64 +137,65 @@ public class DatabaseConnectController {
return null;
}
- private Pair<ZonedDateTime, ZonedDateTime> getTimeFromAndTo(JSONObject
jsonObject)
- throws JSONException {
- JSONObject obj = (JSONObject) jsonObject.get("range");
- Instant from = Instant.parse((String) obj.get("from"));
- Instant to = Instant.parse((String) obj.get("to"));
+ private Pair<ZonedDateTime, ZonedDateTime> getTimeFromAndTo(JsonObject
jsonObject) {
+ JsonObject obj = jsonObject.get("range").getAsJsonObject();
+ Instant from = Instant.parse(obj.get("from").getAsString());
+ Instant to = Instant.parse(obj.get("to").getAsString());
return new Pair<>(from.atZone(ZoneId.of("Asia/Shanghai")),
to.atZone(ZoneId.of("Asia/Shanghai")));
}
- private void setJsonTable(JSONObject obj, String target,
- Pair<ZonedDateTime, ZonedDateTime> timeRange)
- throws JSONException {
+ private void setJsonTable(JsonObject obj, String target,
+ Pair<ZonedDateTime, ZonedDateTime> timeRange) {
List<TimeValues> timeValues = databaseConnectService.querySeries(target,
timeRange);
- JSONArray columns = new JSONArray();
- JSONObject column = new JSONObject();
- column.put("text", "Time");
- column.put("type", "time");
+ JsonArray columns = new JsonArray();
+ JsonObject column = new JsonObject();
+
+ column.addProperty("text", "Time");
+ column.addProperty("type", "time");
columns.add(column);
- column = new JSONObject();
- column.put("text", "Number");
- column.put("type", "number");
+
+ column = new JsonObject();
+ column.addProperty("text", "Number");
+ column.addProperty("type", "number");
columns.add(column);
- obj.put("columns", columns);
- JSONArray values = new JSONArray();
+
+ obj.add("columns", columns);
+ JsonArray values = new JsonArray();
for (TimeValues tv : timeValues) {
- JSONArray value = new JSONArray();
+ JsonArray value = new JsonArray();
value.add(tv.getTime());
- value.add(tv.getValue());
+ values.add(GSON.toJsonTree(tv.getValue()));
values.add(value);
}
- obj.put("values", values);
+
+ obj.add("values", values);
}
- private void setJsonTimeseries(JSONObject obj, String target,
- Pair<ZonedDateTime, ZonedDateTime> timeRange)
- throws JSONException {
+ private void setJsonTimeseries(JsonObject obj, String target,
+ Pair<ZonedDateTime, ZonedDateTime> timeRange) {
List<TimeValues> timeValues = databaseConnectService.querySeries(target,
timeRange);
logger.info("query size: {}", timeValues.size());
- JSONArray dataPoints = new JSONArray();
+
+ JsonArray dataPoints = new JsonArray();
for (TimeValues tv : timeValues) {
long time = tv.getTime();
Object value = tv.getValue();
- JSONArray jsonArray = new JSONArray();
- jsonArray.add(value);
+ JsonArray jsonArray = new JsonArray();
jsonArray.add(time);
+ jsonArray.add(GSON.toJsonTree(value));
dataPoints.add(jsonArray);
}
- obj.put("datapoints", dataPoints);
+ obj.add("datapoints", dataPoints);
}
/**
- * get request body JSON.
+ * get request body JsonNode.
*
* @param request http request
- * @return request JSON
- * @throws JSONException JSONException
+ * @return request JsonNode
*/
- public JSONObject getRequestBodyJson(HttpServletRequest request) throws
JSONException {
+ public JsonObject getRequestBodyJson(HttpServletRequest request) {
try {
BufferedReader br = request.getReader();
StringBuilder sb = new StringBuilder();
@@ -197,10 +203,12 @@ public class DatabaseConnectController {
while ((line = br.readLine()) != null) {
sb.append(line);
}
- return JSON.parseObject(sb.toString());
+
+ return GSON.fromJson(sb.toString(), JsonObject.class);
} catch (IOException e) {
logger.error("getRequestBodyJson failed", e);
}
+
return null;
}
@@ -209,12 +217,10 @@ public class DatabaseConnectController {
*
* @param jsonObject JSON Object
* @return type (string)
- * @throws JSONException JSONException
*/
- public String getJsonType(JSONObject jsonObject) throws JSONException {
- JSONArray array = (JSONArray) jsonObject.get("targets"); // []
- JSONObject object = (JSONObject) array.get(0); // {}
- return (String) object.get("type");
+ public String getJsonType(JsonObject jsonObject) {
+ JsonArray array = jsonObject.get("targets").getAsJsonArray(); // []
+ JsonObject object = array.get(0).getAsJsonObject(); // {}
+ return object.get("type").getAsString();
}
-
}
diff --git a/pom.xml b/pom.xml
index de1a2e6..2d46d1c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -126,7 +126,6 @@
<common.lang3.version>3.8.1</common.lang3.version>
<common.logging.version>1.1.3</common.logging.version>
<guava.version>21.0</guava.version>
- <fastjson.version>1.2.70</fastjson.version>
<jline.version>2.14.5</jline.version>
<jetty.version>9.4.24.v20191120</jetty.version>
<metrics.version>3.2.6</metrics.version>
@@ -138,6 +137,7 @@
<!-- Exclude all generated code -->
<sonar.exclusions>**/generated-sources</sonar.exclusions>
<!-- By default, the argLine is empty-->
+ <gson.version>2.8.6</gson.version>
<argLine/>
</properties>
<!--
@@ -157,11 +157,6 @@
<version>${logback.version}</version>
</dependency>
<dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- <version>${fastjson.version}</version>
- </dependency>
- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
@@ -466,6 +461,11 @@
<!-- spark uses the lastest version than hive, flink and
hadoop-->
<version>3.0.2</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<dependencies>
diff --git a/server/pom.xml b/server/pom.xml
index cbdb003..157e677 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -192,6 +192,10 @@
<version>8.5.15</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index 8d079eb..5360eef 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -93,7 +93,7 @@ import org.slf4j.LoggerFactory;
public class MManager {
private static final Logger logger = LoggerFactory.getLogger(MManager.class);
- private static final String TIME_SERIES_TREE_HEADER = "=== Timeseries Tree
===\n\n";
+ public static final String TIME_SERIES_TREE_HEADER = "=== Timeseries Tree
===\n\n";
/**
* A thread will check whether the MTree is modified lately each such
interval. Unit: second
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
index 6bd13ee..1abd0e7 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MTree.java
@@ -23,9 +23,6 @@ import static
org.apache.iotdb.db.conf.IoTDBConstant.PATH_SEPARATOR;
import static org.apache.iotdb.db.conf.IoTDBConstant.PATH_WILDCARD;
import static
org.apache.iotdb.db.query.executor.LastQueryExecutor.calculateLastPairForOneSeriesLocally;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -50,6 +47,11 @@ import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Pattern;
import java.util.stream.Stream;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBConstant;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
@@ -89,6 +91,7 @@ public class MTree implements Serializable {
private static transient ThreadLocal<Integer> offset = new ThreadLocal<>();
private static transient ThreadLocal<Integer> count = new ThreadLocal<>();
private static transient ThreadLocal<Integer> curOffset = new
ThreadLocal<>();
+ public static final Gson GSON = new
GsonBuilder().setPrettyPrinting().create();
MTree() {
this.root = new MNode(null, IoTDBConstant.PATH_ROOT);
@@ -1138,33 +1141,33 @@ public class MTree implements Serializable {
@Override
public String toString() {
- JSONObject jsonObject = new JSONObject();
- jsonObject.put(root.getName(), mNodeToJSON(root, null));
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.add(root.getName(), mNodeToJSON(root, null));
return jsonToString(jsonObject);
}
- private static String jsonToString(JSONObject jsonObject) {
- return JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat);
+ private static String jsonToString(JsonObject jsonObject) {
+ return GSON.toJson(jsonObject);
}
- private JSONObject mNodeToJSON(MNode node, String storageGroupName) {
- JSONObject jsonObject = new JSONObject();
+ private JsonObject mNodeToJSON(MNode node, String storageGroupName) {
+ JsonObject jsonObject = new JsonObject();
if (node.getChildren().size() > 0) {
if (node instanceof StorageGroupMNode) {
storageGroupName = node.getFullPath();
}
for (MNode child : node.getChildren().values()) {
- jsonObject.put(child.getName(), mNodeToJSON(child, storageGroupName));
+ jsonObject.add(child.getName(), mNodeToJSON(child, storageGroupName));
}
} else if (node instanceof MeasurementMNode) {
MeasurementMNode leafMNode = (MeasurementMNode) node;
- jsonObject.put("DataType", leafMNode.getSchema().getType());
- jsonObject.put("Encoding", leafMNode.getSchema().getEncodingType());
- jsonObject.put("Compressor", leafMNode.getSchema().getCompressor());
+ jsonObject.add("DataType",
GSON.toJsonTree(leafMNode.getSchema().getType()));
+ jsonObject.add("Encoding",
GSON.toJsonTree(leafMNode.getSchema().getEncodingType()));
+ jsonObject.add("Compressor",
GSON.toJsonTree(leafMNode.getSchema().getCompressor()));
if (leafMNode.getSchema().getProps() != null) {
- jsonObject.put("args", leafMNode.getSchema().getProps().toString());
+ jsonObject.addProperty("args",
leafMNode.getSchema().getProps().toString());
}
- jsonObject.put("StorageGroup", storageGroupName);
+ jsonObject.addProperty("StorageGroup", storageGroupName);
}
return jsonObject;
}
@@ -1173,20 +1176,20 @@ public class MTree implements Serializable {
* combine multiple metadata in string format
*/
static String combineMetadataInStrings(String[] metadataStrs) {
- JSONObject[] jsonObjects = new JSONObject[metadataStrs.length];
+ JsonObject[] jsonObjects = new JsonObject[metadataStrs.length];
for (int i = 0; i < jsonObjects.length; i++) {
- jsonObjects[i] = JSONObject.parseObject(metadataStrs[i]);
+ jsonObjects[i] = GSON.fromJson(metadataStrs[i], JsonObject.class);
}
- JSONObject root = jsonObjects[0];
+ JsonObject root = jsonObjects[0];
for (int i = 1; i < jsonObjects.length; i++) {
- root = combineJSONObjects(root, jsonObjects[i]);
+ root = combineJsonObjects(root, jsonObjects[i]);
}
return jsonToString(root);
}
- private static JSONObject combineJSONObjects(JSONObject a, JSONObject b) {
- JSONObject res = new JSONObject();
+ private static JsonObject combineJsonObjects(JsonObject a, JsonObject b) {
+ JsonObject res = new JsonObject();
Set<String> retainSet = new HashSet<>(a.keySet());
retainSet.retainAll(b.keySet());
@@ -1194,19 +1197,21 @@ public class MTree implements Serializable {
Set<String> bCha = new HashSet<>(b.keySet());
aCha.removeAll(retainSet);
bCha.removeAll(retainSet);
+
for (String key : aCha) {
- res.put(key, a.getJSONObject(key));
+ res.add(key, a.get(key));
}
+
for (String key : bCha) {
- res.put(key, b.get(key));
+ res.add(key, b.get(key));
}
for (String key : retainSet) {
- Object v1 = a.get(key);
- Object v2 = b.get(key);
- if (v1 instanceof JSONObject && v2 instanceof JSONObject) {
- res.put(key, combineJSONObjects((JSONObject) v1, (JSONObject) v2));
+ JsonElement v1 = a.get(key);
+ JsonElement v2 = b.get(key);
+ if (v1 instanceof JsonObject && v2 instanceof JsonObject) {
+ res.add(key, combineJsonObjects((JsonObject) v1, (JsonObject) v2));
} else {
- res.put(key, v1);
+ res.add(v1.getAsString(), v2);
}
}
return res;
diff --git
a/server/src/main/java/org/apache/iotdb/db/mqtt/JSONPayloadFormatter.java
b/server/src/main/java/org/apache/iotdb/db/mqtt/JSONPayloadFormatter.java
index 88e0966..b54d55b 100644
--- a/server/src/main/java/org/apache/iotdb/db/mqtt/JSONPayloadFormatter.java
+++ b/server/src/main/java/org/apache/iotdb/db/mqtt/JSONPayloadFormatter.java
@@ -17,10 +17,12 @@
*/
package org.apache.iotdb.db.mqtt;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
import io.netty.buffer.ByteBuf;
import java.nio.charset.StandardCharsets;
@@ -50,6 +52,7 @@ public class JSONPayloadFormatter implements PayloadFormatter
{
private static final String JSON_KEY_TIMESTAMPS = "timestamps";
private static final String JSON_KEY_MEASUREMENTS = "measurements";
private static final String JSON_KEY_VALUES = "values";
+ private static final Gson GSON = new GsonBuilder().create();
@Override
public List<Message> format(ByteBuf payload) {
@@ -57,27 +60,27 @@ public class JSONPayloadFormatter implements
PayloadFormatter {
return null;
}
String txt = payload.toString(StandardCharsets.UTF_8);
- JSONObject jsonObject = JSON.parseObject(txt);
+ JsonObject jsonObject = GSON.fromJson(txt, JsonObject.class);
Object timestamp = jsonObject.get(JSON_KEY_TIMESTAMP);
if (timestamp != null) {
- return Lists.newArrayList(JSON.parseObject(txt, Message.class));
+ return Lists.newArrayList(GSON.fromJson(txt, Message.class));
}
- String device = jsonObject.getString(JSON_KEY_DEVICE);
- JSONArray timestamps = jsonObject.getJSONArray(JSON_KEY_TIMESTAMPS);
- JSONArray measurements =
jsonObject.getJSONArray(JSON_KEY_MEASUREMENTS);
- JSONArray values = jsonObject.getJSONArray(JSON_KEY_VALUES);
+ String device = jsonObject.get(JSON_KEY_DEVICE).getAsString();
+ JsonArray timestamps = jsonObject.getAsJsonArray(JSON_KEY_TIMESTAMPS);
+ JsonArray measurements =
jsonObject.getAsJsonArray(JSON_KEY_MEASUREMENTS);
+ JsonArray values = jsonObject.getAsJsonArray(JSON_KEY_VALUES);
List<Message> ret = new ArrayList<>();
for (int i = 0; i < timestamps.size(); i++) {
- Long ts = timestamps.getLong(i);
+ Long ts = timestamps.get(i).getAsLong();
Message message = new Message();
message.setDevice(device);
message.setTimestamp(ts);
- message.setMeasurements(measurements.toJavaList(String.class));
-
message.setValues(((JSONArray)values.get(i)).toJavaList(String.class));
+ message.setMeasurements(GSON.fromJson(measurements, new
TypeToken<List<String>>() {}.getType()));
+ message.setValues(GSON.fromJson(values.get(i), new
TypeToken<List<String>>() {}.getType()));
ret.add(message);
}
return ret;
diff --git
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
index 24dd276..b1ac10e 100644
---
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
+++
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBMetadataFetchIT.java
@@ -18,6 +18,8 @@
*/
package org.apache.iotdb.db.integration;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
import org.apache.iotdb.db.conf.IoTDBConstant;
import org.apache.iotdb.db.utils.EnvironmentUtils;
import org.apache.iotdb.jdbc.Config;
@@ -30,6 +32,7 @@ import java.sql.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.iotdb.db.metadata.MManager.TIME_SERIES_TREE_HEADER;
import static org.junit.Assert.fail;
/**
@@ -494,6 +497,14 @@ public class IoTDBMetadataFetchIT {
+ "\t}\n"
+ "}";
- Assert.assertEquals(standard, metadataInJson);
+ //TODO Remove the constant json String.
+ // Do not depends on the sequence of property in json string if you do not
+ // explictly mark the sequence, when we use jackson, the json result may
change again
+ String rawJsonString =
metadataInJson.substring(TIME_SERIES_TREE_HEADER.length());
+ Gson gson = new Gson();
+ JsonObject actual = gson.fromJson(rawJsonString, JsonObject.class);
+ JsonObject expected =
gson.fromJson(standard.substring(TIME_SERIES_TREE_HEADER.length()),
JsonObject.class);
+
+ Assert.assertEquals(expected, actual);
}
}
diff --git a/tsfile/pom.xml b/tsfile/pom.xml
index 3e235fa..4ce12cb 100644
--- a/tsfile/pom.xml
+++ b/tsfile/pom.xml
@@ -42,10 +42,6 @@
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>fastjson</artifactId>
- </dependency>
- <dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
</dependency>
@@ -58,6 +54,10 @@
<artifactId>lz4</artifactId>
<version>1.3.0</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git
a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/BitmapDecoderTest.java
b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/BitmapDecoderTest.java
index e982eb1..d327477 100644
---
a/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/BitmapDecoderTest.java
+++
b/tsfile/src/test/java/org/apache/iotdb/tsfile/encoding/decoder/BitmapDecoderTest.java
@@ -32,7 +32,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.iotdb.tsfile.encoding.decoder.BitmapDecoder;
import org.apache.iotdb.tsfile.encoding.encoder.BitmapEncoder;
import org.apache.iotdb.tsfile.encoding.encoder.Encoder;
diff --git
a/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/TsFileGeneratorForTest.java
b/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/TsFileGeneratorForTest.java
index 2f75019..b74004a 100755
---
a/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/TsFileGeneratorForTest.java
+++
b/tsfile/src/test/java/org/apache/iotdb/tsfile/utils/TsFileGeneratorForTest.java
@@ -27,15 +27,7 @@ import java.util.Scanner;
import org.junit.Assert;
import org.junit.Ignore;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
-import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
-import org.apache.iotdb.tsfile.common.constant.JsonFormatConstant;
import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
import org.apache.iotdb.tsfile.file.header.ChunkHeader;
import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/write/PerfTest.java
b/tsfile/src/test/java/org/apache/iotdb/tsfile/write/PerfTest.java
index d8317fe..5e32a9f 100755
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/write/PerfTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/write/PerfTest.java
@@ -25,14 +25,13 @@ import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
+import com.google.gson.JsonObject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.alibaba.fastjson.JSONObject;
-
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
@@ -42,7 +41,6 @@ import
org.apache.iotdb.tsfile.exception.write.WriteProcessException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.write.TsFileWriter;
import org.apache.iotdb.tsfile.write.record.TSRecord;
import org.apache.iotdb.tsfile.write.schema.Schema;
import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
@@ -170,10 +168,11 @@ public class PerfTest {
schema.registerTimeseries(new Path("d2", "s3"),
new MeasurementSchema("s3", TSDataType.INT64,
TSEncoding.valueOf(conf.getValueEncoder())));
schema.registerTimeseries(new Path("d2", "s4"), new
MeasurementSchema("s4", TSDataType.TEXT, TSEncoding.PLAIN));
- JSONObject s4 = new JSONObject();
- s4.put(JsonFormatConstant.MEASUREMENT_UID, "s4");
- s4.put(JsonFormatConstant.DATA_TYPE, TSDataType.TEXT.toString());
- s4.put(JsonFormatConstant.MEASUREMENT_ENCODING,
TSEncoding.PLAIN.toString());
+
+ JsonObject s4 = new JsonObject();
+ s4.addProperty(JsonFormatConstant.MEASUREMENT_UID, "s4");
+ s4.addProperty(JsonFormatConstant.DATA_TYPE, TSDataType.TEXT.toString());
+ s4.addProperty(JsonFormatConstant.MEASUREMENT_ENCODING,
TSEncoding.PLAIN.toString());
return schema;
}