diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/cluster/IginxWorker.java b/core/src/main/java/cn/edu/tsinghua/iginx/cluster/IginxWorker.java index 737b98130..0a5021a03 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/cluster/IginxWorker.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/cluster/IginxWorker.java @@ -62,7 +62,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -178,7 +178,7 @@ public Status addStorageEngines(AddStorageEnginesReq req) { return RpcUtils.ACCESS_DENY; } List storageEngines = req.getStorageEngines(); - List storageEngineMetas = new ArrayList<>(); + LinkedList storageEngineMetas = new LinkedList<>(); Map checkConnectionMethods = new HashMap<>(); String[] driverInfos = ConfigDescriptor.getInstance().getConfig().getDatabaseClassNames().split(","); @@ -219,7 +219,7 @@ public Status addStorageEngines(AddStorageEnginesReq req) { Status status = RpcUtils.SUCCESS; // 检测是否与已有的存储单元冲突 List currentStorageEngines = metaManager.getStorageEngineList(); - List duplicatedStorageEngine = new ArrayList<>(); + List duplicatedStorageEngine = new LinkedList<>(); for (StorageEngineMeta storageEngine: storageEngineMetas) { for (StorageEngineMeta currentStorageEngine: currentStorageEngines) { if (currentStorageEngine.getIp().equals(storageEngine.getIp()) && currentStorageEngine.getPort() == storageEngine.getPort()) { @@ -238,7 +238,7 @@ public Status addStorageEngines(AddStorageEnginesReq req) { status.setMessage("unexpected repeated add"); } if (!storageEngineMetas.isEmpty()) { - storageEngineMetas.get(storageEngineMetas.size() - 1).setLastOfBatch(true); // 每一批最后一个是 true,表示需要进行扩容 + storageEngineMetas.getLast().setLastOfBatch(true); // 每一批最后一个是 true,表示需要进行扩容 } if (!metaManager.addStorageEngines(storageEngineMetas)) { status = RpcUtils.FAILURE; diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java index 215881765..79aeaa533 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/metadata/DefaultMetaManager.java @@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.LinkedList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -105,7 +106,7 @@ private DefaultMetaManager() { break; } - storageEngineChangeHooks = Collections.synchronizedList(new ArrayList<>()); + storageEngineChangeHooks = Collections.synchronizedList(new LinkedList<>()); try { initIginx(); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/query/expression/BooleanExpression.java b/core/src/main/java/cn/edu/tsinghua/iginx/query/expression/BooleanExpression.java index c1f8b416a..252c5ed1c 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/query/expression/BooleanExpression.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/query/expression/BooleanExpression.java @@ -20,6 +20,7 @@ import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.LinkedList; import java.util.Deque; import java.util.List; import java.util.Map; @@ -28,7 +29,7 @@ public class BooleanExpression { private String boolExpression; private List postfixExpression; private TreeNode root; - private List timeseries = new ArrayList<>(); + private List timeseries = new LinkedList<>(); public BooleanExpression(String str) { boolExpression = str; diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/rest/insert/DataPointsParser.java b/core/src/main/java/cn/edu/tsinghua/iginx/rest/insert/DataPointsParser.java index 09b580a34..c2cfa0b3a 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/rest/insert/DataPointsParser.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/rest/insert/DataPointsParser.java @@ -33,6 +33,7 @@ import java.io.Reader; import java.util.ArrayList; +import java.util.LinkedList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -46,7 +47,7 @@ public class DataPointsParser { private final IMetaManager metaManager = DefaultMetaManager.getInstance(); private Reader inputStream = null; private ObjectMapper mapper = new ObjectMapper(); - private List metricList = new ArrayList<>(); + private List metricList = new LinkedList<>(); private RestSession session = new RestSession(); public DataPointsParser() { @@ -347,4 +348,4 @@ DataType findType(List values) { } return DataType.DOUBLE; } -} \ No newline at end of file +} diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryMetric.java b/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryMetric.java index be93af362..c0da6acde 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryMetric.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryMetric.java @@ -21,6 +21,7 @@ import cn.edu.tsinghua.iginx.rest.query.aggregator.QueryAggregator; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -29,7 +30,7 @@ public class QueryMetric { private String name; private Long limit; private Map> tags = new TreeMap(); - private List aggregators = new ArrayList<>(); + private List aggregators = new LinkedList<>(); private Boolean annotation = false; private AnnotationLimit annotationLimit; diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryResult.java b/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryResult.java index dc623eba9..483f779c0 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryResult.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/QueryResult.java @@ -262,7 +262,7 @@ private String sampleSizeToString(int num) { private Map> getTagsFromPaths(String name, List paths) throws Exception { List> dup = new ArrayList<>(); Map> ret = new TreeMap<>(); - Map pos2path = new TreeMap<>(); + Map pos2path = new HashMap<>(); Map metricschema = metaManager.getSchemaMapping(name); if (metricschema == null) { throw new Exception("No metadata found"); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/aggregator/QueryAggregatorSaveAs.java b/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/aggregator/QueryAggregatorSaveAs.java index b3679d62d..0d4aabc35 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/aggregator/QueryAggregatorSaveAs.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/rest/query/aggregator/QueryAggregatorSaveAs.java @@ -25,6 +25,7 @@ import cn.edu.tsinghua.iginx.session.SessionQueryDataSet; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; public class QueryAggregatorSaveAs extends QueryAggregator { @@ -35,7 +36,7 @@ public QueryAggregatorSaveAs() { @Override public QueryResultDataset doAggregate(RestSession session, List paths, long startTimestamp, long endTimestamp) { DataPointsParser parser = new DataPointsParser(); - List metrics = new ArrayList<>(); + List metrics = new LinkedList<>(); Metric ins = new Metric(); String name = paths.get(0).split("\\.")[paths.get(0).split("\\.").length - 1]; ins.setName(getMetric_name()); diff --git a/core/src/main/java/cn/edu/tsinghua/iginx/sql/operator/SelectOperator.java b/core/src/main/java/cn/edu/tsinghua/iginx/sql/operator/SelectOperator.java index 52c099d11..ac03a6e1c 100644 --- a/core/src/main/java/cn/edu/tsinghua/iginx/sql/operator/SelectOperator.java +++ b/core/src/main/java/cn/edu/tsinghua/iginx/sql/operator/SelectOperator.java @@ -16,6 +16,7 @@ import cn.edu.tsinghua.iginx.utils.RpcUtils; import java.util.ArrayList; +import java.util.LinkedList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -41,7 +42,7 @@ public class SelectOperator extends Operator { public SelectOperator() { this.operatorType = OperatorType.SELECT; this.queryType = QueryType.Unknown; - selectedFuncsAndPaths = new ArrayList<>(); + selectedFuncsAndPaths = new LinkedList<>(); funcTypeSet = new HashSet<>(); fromPath = ""; startTime = Long.MIN_VALUE; diff --git a/jdbc/src/main/java/cn/edu/tsinghua/iginx/jdbc/IginXPreparedStatement.java b/jdbc/src/main/java/cn/edu/tsinghua/iginx/jdbc/IginXPreparedStatement.java index 46211fdcb..928e51203 100644 --- a/jdbc/src/main/java/cn/edu/tsinghua/iginx/jdbc/IginXPreparedStatement.java +++ b/jdbc/src/main/java/cn/edu/tsinghua/iginx/jdbc/IginXPreparedStatement.java @@ -13,7 +13,7 @@ public class IginXPreparedStatement extends IginXStatement implements PreparedStatement { private String sql; - private final Map params = new LinkedHashMap<>(); + private final Map params = new HashMap<>(); public IginXPreparedStatement(IginXConnection connection, Session session, String sql) { super(connection, session); diff --git a/session/src/main/java/cn/edu/tsinghua/iginx/session/LastQueryDataSet.java b/session/src/main/java/cn/edu/tsinghua/iginx/session/LastQueryDataSet.java index d475895a6..ca46b0d66 100644 --- a/session/src/main/java/cn/edu/tsinghua/iginx/session/LastQueryDataSet.java +++ b/session/src/main/java/cn/edu/tsinghua/iginx/session/LastQueryDataSet.java @@ -22,6 +22,7 @@ import cn.edu.tsinghua.iginx.thrift.LastQueryResp; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import static cn.edu.tsinghua.iginx.utils.ByteUtils.getLongArrayFromByteBuffer; @@ -36,7 +37,7 @@ public class LastQueryDataSet { } LastQueryDataSet(LastQueryResp resp) { - points = new ArrayList<>(); + points = new LinkedList<>(); List paths = resp.getPaths(); List dataTypes = resp.getDataTypeList(); long[] timestamps = getLongArrayFromByteBuffer(resp.timestamps);