You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ca...@apache.org on 2019/01/23 09:19:48 UTC
[incubator-iotdb] branch fix_sonar updated: fix the sonar problem
in query control, dataset, executor and fill package
This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch fix_sonar
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/fix_sonar by this push:
new 575f690 fix the sonar problem in query control, dataset, executor and fill package
new 537a1d3 Merge branch 'fix_sonar' of github.com:apache/incubator-iotdb into fix_sonar
575f690 is described below
commit 575f6902dac74b6779bef98a89b5fcc4a77a2ea1
Author: CGF <cg...@foxmail.com>
AuthorDate: Wed Jan 23 16:50:23 2019 +0800
fix the sonar problem in query control, dataset, executor and fill package
---
.../iotdb/db/query/control/FileReaderManager.java | 8 +++-----
.../db/query/control/OpenedFilePathsManager.java | 3 +--
.../db/query/control/QueryDataSourceManager.java | 3 +++
.../iotdb/db/query/control/QueryTokenManager.java | 5 ++---
.../dataset/EngineDataSetWithoutTimeGenerator.java | 12 +++++-------
.../iotdb/db/query/executor/EngineQueryRouter.java | 20 ++++++++------------
.../iotdb/db/query/factory/SeriesReaderFactory.java | 14 +++-----------
.../org/apache/iotdb/db/query/fill/LinearFill.java | 21 ++-------------------
.../apache/iotdb/db/query/fill/PreviousFill.java | 18 +++---------------
9 files changed, 30 insertions(+), 74 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java b/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
index 5f3ae53..8905086 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/control/FileReaderManager.java
@@ -26,7 +26,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.iotdb.db.concurrent.IoTDBThreadPoolFactory;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.StartupException;
import org.apache.iotdb.db.service.IService;
import org.apache.iotdb.db.service.ServiceType;
import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
@@ -145,7 +144,6 @@ public class FileReaderManager implements IService {
* This method is used when the given file path is deleted.
*/
public synchronized void closeFileAndRemoveReader(String filePath) throws IOException {
- System.out.println(fileReaderMap.containsKey(filePath));
if (fileReaderMap.containsKey(filePath)) {
referenceMap.remove(filePath);
fileReaderMap.get(filePath).close();
@@ -173,7 +171,8 @@ public class FileReaderManager implements IService {
}
@Override
- public void start() throws StartupException {
+ public void start() {
+ // Do nothing
}
@Override
@@ -196,7 +195,6 @@ public class FileReaderManager implements IService {
}
private static class FileReaderManagerHelper {
-
- public static FileReaderManager INSTANCE = new FileReaderManager();
+ private static final FileReaderManager INSTANCE = new FileReaderManager();
}
}
\ No newline at end of file
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/control/OpenedFilePathsManager.java b/iotdb/src/main/java/org/apache/iotdb/db/query/control/OpenedFilePathsManager.java
index 4dc177f..7bd48ba 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/control/OpenedFilePathsManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/control/OpenedFilePathsManager.java
@@ -109,7 +109,6 @@ public class OpenedFilePathsManager {
}
private static class OpenedFilePathsManagerHelper {
-
- public static OpenedFilePathsManager INSTANCE = new OpenedFilePathsManager();
+ private static final OpenedFilePathsManager INSTANCE = new OpenedFilePathsManager();
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryDataSourceManager.java b/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryDataSourceManager.java
index 2b1ff81..2824a9f 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryDataSourceManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryDataSourceManager.java
@@ -32,6 +32,9 @@ public class QueryDataSourceManager {
private static FileNodeManager fileNodeManager = FileNodeManager.getInstance();
+ private QueryDataSourceManager() {
+ }
+
public static QueryDataSource getQueryDataSource(long jobId, Path selectedPath)
throws FileNodeManagerException {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryTokenManager.java b/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryTokenManager.java
index 4e2a901..df3ee24 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryTokenManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/control/QueryTokenManager.java
@@ -110,7 +110,7 @@ public class QueryTokenManager {
public void beginQueryOfGivenQueryPaths(long jobId, List<Path> queryPaths)
throws FileNodeManagerException {
Set<String> deviceIdSet = new HashSet<>();
- queryPaths.forEach((path) -> deviceIdSet.add(path.getDevice()));
+ queryPaths.forEach(path -> deviceIdSet.add(path.getDevice()));
for (String deviceId : deviceIdSet) {
putQueryTokenForCurrentRequestThread(jobId, deviceId,
@@ -168,7 +168,6 @@ public class QueryTokenManager {
}
private static class QueryTokenManagerHelper {
-
- public static QueryTokenManager INSTANCE = new QueryTokenManager();
+ private static final QueryTokenManager INSTANCE = new QueryTokenManager();
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithoutTimeGenerator.java b/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithoutTimeGenerator.java
index 77e6344..4c0ccb7 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithoutTimeGenerator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/dataset/EngineDataSetWithoutTimeGenerator.java
@@ -28,22 +28,20 @@ import org.apache.iotdb.db.utils.TimeValuePair;
import org.apache.iotdb.db.utils.TsPrimitiveType;
import org.apache.iotdb.tsfile.exception.write.UnSupportedDataTypeException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.read.common.BatchData;
import org.apache.iotdb.tsfile.read.common.Field;
import org.apache.iotdb.tsfile.read.common.Path;
import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
+/**
+ * TODO implement this class as TsFile DataSetWithoutTimeGenerator
+ */
public class EngineDataSetWithoutTimeGenerator extends QueryDataSet {
private List<IReader> readers;
private TimeValuePair[] cacheTimeValueList;
- private List<BatchData> batchDataList;
-
- private List<Boolean> hasDataRemaining;
-
private PriorityQueue<Long> timeHeap;
private Set<Long> timeSet;
@@ -80,8 +78,8 @@ public class EngineDataSetWithoutTimeGenerator extends QueryDataSet {
}
@Override
- public boolean hasNext() throws IOException {
- return timeHeap.size() > 0;
+ public boolean hasNext() {
+ return !timeHeap.isEmpty();
}
@Override
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/executor/EngineQueryRouter.java b/iotdb/src/main/java/org/apache/iotdb/db/query/executor/EngineQueryRouter.java
index 187b47a..c6feee1 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/executor/EngineQueryRouter.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/executor/EngineQueryRouter.java
@@ -31,8 +31,6 @@ import org.apache.iotdb.tsfile.read.expression.IExpression;
import org.apache.iotdb.tsfile.read.expression.QueryExpression;
import org.apache.iotdb.tsfile.read.expression.util.ExpressionOptimizer;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Query entrance class of IoTDB query process. All query clause will be transformed to physical
@@ -40,14 +38,12 @@ import org.slf4j.LoggerFactory;
*/
public class EngineQueryRouter {
- private static final Logger LOGGER = LoggerFactory.getLogger(EngineQueryRouter.class);
-
/**
* Each unique jdbc request(query, aggregation or others job) has an unique job id. This job id
* will always be maintained until the request is closed. In each job, the unique file will be
* only opened once to avoid too many opened files error.
*/
- private AtomicLong jobId = new AtomicLong();
+ private AtomicLong jobIdGenerator = new AtomicLong();
/**
* execute physical plan.
@@ -55,9 +51,9 @@ public class EngineQueryRouter {
public QueryDataSet query(QueryExpression queryExpression)
throws IOException, FileNodeManagerException {
- long jobId = getNextJobId();
- QueryTokenManager.getInstance().setJobIdForCurrentRequestThread(jobId);
- OpenedFilePathsManager.getInstance().setJobIdForCurrentRequestThread(jobId);
+ long nextJobId = getNextJobId();
+ QueryTokenManager.getInstance().setJobIdForCurrentRequestThread(nextJobId);
+ OpenedFilePathsManager.getInstance().setJobIdForCurrentRequestThread(nextJobId);
if (queryExpression.hasQueryFilter()) {
try {
@@ -68,11 +64,11 @@ public class EngineQueryRouter {
if (optimizedExpression.getType() == GLOBAL_TIME) {
EngineExecutorWithoutTimeGenerator engineExecutor =
new EngineExecutorWithoutTimeGenerator(
- jobId, queryExpression);
+ nextJobId, queryExpression);
return engineExecutor.executeWithGlobalTimeFilter();
} else {
EngineExecutorWithTimeGenerator engineExecutor = new EngineExecutorWithTimeGenerator(
- jobId,
+ nextJobId,
queryExpression);
return engineExecutor.execute();
}
@@ -83,7 +79,7 @@ public class EngineQueryRouter {
} else {
try {
EngineExecutorWithoutTimeGenerator engineExecutor = new EngineExecutorWithoutTimeGenerator(
- jobId,
+ nextJobId,
queryExpression);
return engineExecutor.executeWithoutFilter();
} catch (PathErrorException e) {
@@ -93,6 +89,6 @@ public class EngineQueryRouter {
}
private synchronized long getNextJobId() {
- return jobId.incrementAndGet();
+ return jobIdGenerator.incrementAndGet();
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/factory/SeriesReaderFactory.java b/iotdb/src/main/java/org/apache/iotdb/db/query/factory/SeriesReaderFactory.java
index 0a43b46..674e744 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/factory/SeriesReaderFactory.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/factory/SeriesReaderFactory.java
@@ -117,18 +117,11 @@ public class SeriesReaderFactory {
}
}
- // TODO add External Sort when needed
- // timeValuePairReaders = externalSortJobEngine.
- // executeWithGlobalTimeFilter(timeValuePairReaders);
-
+ // TODO add external sort when needed
return unSeqMergeReader;
}
- public PriorityMergeReader createUnSeqMergeReaderByTime(
- OverflowSeriesDataSource overflowSeriesDataSource,
- Filter filter) {
- return null;
- }
+ // TODO createUnSeqMergeReaderByTime a method with filter
/**
* This method is used to construct reader for merge process in IoTDB. To merge only one TsFile
@@ -175,7 +168,6 @@ public class SeriesReaderFactory {
}
private static class SeriesReaderFactoryHelper {
-
- private static SeriesReaderFactory INSTANCE = new SeriesReaderFactory();
+ private static final SeriesReaderFactory INSTANCE = new SeriesReaderFactory();
}
}
\ No newline at end of file
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java b/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
index 3ecdad2..8095b13 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/fill/LinearFill.java
@@ -29,9 +29,6 @@ public class LinearFill extends IFill {
private long beforeRange;
private long afterRange;
-
- private Path path;
-
private BatchData result;
public LinearFill(long beforeRange, long afterRange) {
@@ -42,10 +39,9 @@ public class LinearFill extends IFill {
/**
* Constructor of LinearFill.
*/
- public LinearFill(Path path, TSDataType dataType, long queryTime, long beforeRange,
+ public LinearFill(TSDataType dataType, long queryTime, long beforeRange,
long afterRange) {
super(dataType, queryTime);
- this.path = path;
this.beforeRange = beforeRange;
this.afterRange = afterRange;
result = new BatchData(dataType, true, true);
@@ -69,24 +65,11 @@ public class LinearFill extends IFill {
@Override
public IFill copy(Path path) {
- return new LinearFill(path, dataType, queryTime, beforeRange, afterRange);
+ return new LinearFill(dataType, queryTime, beforeRange, afterRange);
}
@Override
public BatchData getFillResult() throws ProcessorException, IOException, PathErrorException {
- long beforeTime;
- if (beforeRange == -1) {
- beforeTime = 0;
- } else {
- beforeTime = queryTime - beforeRange;
- }
- long afterTime;
- if (afterRange == -1) {
- afterTime = Long.MAX_VALUE;
- } else {
- afterTime = queryTime + afterRange;
- }
-
return result;
}
}
\ No newline at end of file
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/query/fill/PreviousFill.java b/iotdb/src/main/java/org/apache/iotdb/db/query/fill/PreviousFill.java
index ff80386..2c66c74 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/query/fill/PreviousFill.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/query/fill/PreviousFill.java
@@ -18,9 +18,6 @@
*/
package org.apache.iotdb.db.query.fill;
-import java.io.IOException;
-import org.apache.iotdb.db.exception.PathErrorException;
-import org.apache.iotdb.db.exception.ProcessorException;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.common.BatchData;
import org.apache.iotdb.tsfile.read.common.Path;
@@ -29,13 +26,10 @@ public class PreviousFill extends IFill {
private long beforeRange;
- private Path path;
-
private BatchData result;
- public PreviousFill(Path path, TSDataType dataType, long queryTime, long beforeRange) {
+ public PreviousFill(TSDataType dataType, long queryTime, long beforeRange) {
super(dataType, queryTime);
- this.path = path;
this.beforeRange = beforeRange;
result = new BatchData(dataType, true, true);
}
@@ -46,7 +40,7 @@ public class PreviousFill extends IFill {
@Override
public IFill copy(Path path) {
- return new PreviousFill(path, dataType, queryTime, beforeRange);
+ return new PreviousFill(dataType, queryTime, beforeRange);
}
public long getBeforeRange() {
@@ -54,13 +48,7 @@ public class PreviousFill extends IFill {
}
@Override
- public BatchData getFillResult() throws ProcessorException, IOException, PathErrorException {
- long beforeTime;
- if (beforeRange == -1) {
- beforeTime = 0;
- } else {
- beforeTime = queryTime - beforeRange;
- }
+ public BatchData getFillResult() {
return result;
}
}