This is an automated email from the ASF dual-hosted git repository.
hxd 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 c0c571f Fix sonar problems by Beyyes (#33)
c0c571f is described below
commit c0c571f54b168128ead09aec920b256c3fe2c11d
Author: Beyyes <[email protected]>
AuthorDate: Sat Feb 16 10:23:11 2019 +0800
Fix sonar problems by Beyyes (#33)
* fix sonar problem in
iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv
* Update Readme.md, replace old badge
* fix sonar problem in auth package
* fix sonar problem in auth package
* fix sonar problem of iotdb concurrent package and conf package
* fix sonar problem in db conf and service
* delete reset lock exception in HashLock
* fix code problem in User.java
* fix sonar problem in IoTDBDescriptor
* fix sonar problem in conf and engine package
* add log error info for class BasicAuthorizer
* modify log info for BasicAuthorizer
* fix the log error format
* fix problem about logger and examine whether a string is empty
* logger -> LOGGER
* replace string.isEmpty() with "".equal()
---
Readme.md | 2 +-
.../org/apache/iotdb/cli/tool/CsvTestDataGen.java | 52 +---
.../java/org/apache/iotdb/cli/tool/ExportCsv.java | 16 +-
.../java/org/apache/iotdb/cli/tool/ImportCsv.java | 73 +++---
.../org/apache/iotdb/db/auth/AuthException.java | 4 -
.../org/apache/iotdb/db/auth/AuthorityChecker.java | 6 +-
.../iotdb/db/auth/authorizer/BasicAuthorizer.java | 19 +-
.../db/auth/authorizer/LocalFileAuthorizer.java | 1 -
.../apache/iotdb/db/auth/entity/PathPrivilege.java | 33 ++-
.../java/org/apache/iotdb/db/auth/entity/Role.java | 25 +-
.../java/org/apache/iotdb/db/auth/entity/User.java | 56 ++--
.../iotdb/db/auth/role/LocalFileRoleAccessor.java | 2 +-
.../iotdb/db/auth/user/BasicUserManager.java | 9 +-
.../iotdb/db/auth/user/LocalFileUserAccessor.java | 5 +-
.../org/apache/iotdb/db/concurrent/HashLock.java | 17 +-
.../IoTDBDefaultThreadExceptionHandler.java | 3 -
.../db/concurrent/IoTDBThreadPoolFactory.java | 5 +-
.../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 28 +-
.../org/apache/iotdb/db/conf/IoTDBConstant.java | 11 +-
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 75 +++---
.../iotdb/db/conf/directories/Directories.java | 7 +-
.../strategy/MinDirOccupiedSpaceFirstStrategy.java | 4 +-
.../MinFolderOccupiedSpaceFirstStrategy.java | 4 +-
.../db/engine/bufferwrite/FileNodeConstants.java | 1 -
.../engine/cache/RowGroupBlockMetaDataCache.java | 2 +-
.../db/engine/filenode/TimeIntervalTsFile.java | 287 +++++++++++++++++++++
.../db/engine/memcontrol/RecordMemController.java | 5 +
.../db/engine/overflow/io/OverflowProcessor.java | 1 +
.../org/apache/iotdb/db/service/JMXService.java | 4 +-
.../org/apache/iotdb/db/service/StartupChecks.java | 8 +-
.../java/org/apache/iotdb/db/utils/AuthUtils.java | 2 +-
iotdb/src/test/java/PerformanceTest.java | 161 ------------
mvnw.sh | 1 +
33 files changed, 512 insertions(+), 417 deletions(-)
diff --git a/Readme.md b/Readme.md
index d3ef294..e5680dd 100644
--- a/Readme.md
+++ b/Readme.md
@@ -21,7 +21,7 @@
# IoTDB
[](https://www.travis-ci.org/apache/incubator-iotdb)
-[](https://codecov.io/gh/thulab/iotdb)
+[](https://codecov.io/gh/thulab/incubator-iotdb)
[](https://github.com/apache/incubator-iotdb/releases)
[](https://www.apache.org/licenses/LICENSE-2.0.html)

diff --git
a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
index ea7cfce..d4af847 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/CsvTestDataGen.java
@@ -51,28 +51,7 @@ public class CsvTestDataGen {
public static String isoDataGen() {
String path = System.getProperties().getProperty(USER_DIR) +
"/src/test/resources/iso.csv";
File file = new File(path);
-
- try {
- if (!file.exists()) {
- file.createNewFile();
- }
- bw = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream(file)));
- for (String str : iso) {
- bw.write(str + "\n");
- }
- bw.flush();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- bw.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ writeDataFrom(file);
return path;
}
@@ -85,28 +64,7 @@ public class CsvTestDataGen {
String path =
System.getProperties().getProperty(USER_DIR) +
"/src/test/resources/defaultLong.csv";
File file = new File(path);
- try {
- if (!file.exists()) {
- file.createNewFile();
- }
- bw = new BufferedWriter(new OutputStreamWriter(new
FileOutputStream(file)));
- for (String str : defaultLong) {
- bw.write(str + "\n");
- }
- bw.flush();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- try {
- bw.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
+ writeDataFrom(file);
return path;
}
@@ -119,6 +77,11 @@ public class CsvTestDataGen {
String path =
System.getProperties().getProperty(USER_DIR) +
"/src/test/resources/userSelfDefine.csv";
File file = new File(path);
+ writeDataFrom(file);
+ return path;
+ }
+
+ private static void writeDataFrom(File file) {
try {
if (!file.exists()) {
file.createNewFile();
@@ -141,7 +104,6 @@ public class CsvTestDataGen {
e.printStackTrace();
}
}
- return path;
}
public static void main(String[] args) {
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
index 47b7435..3292ec8 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ExportCsv.java
@@ -73,7 +73,7 @@ public class ExportCsv extends AbstractCsvTool {
HelpFormatter hf = new HelpFormatter();
hf.setOptionComparator(null); // avoid reordering
hf.setWidth(MAX_HELP_CONSOLE_WIDTH);
- CommandLine commandLine = null;
+ CommandLine commandLine;
CommandLineParser parser = new DefaultParser();
if (args == null || args.length == 0) {
@@ -139,9 +139,7 @@ public class ExportCsv extends AbstractCsvTool {
} catch (ArgsErrorException e) {
e.printStackTrace();
} finally {
- if (reader != null) {
- reader.close();
- }
+ reader.close();
if (connection != null) {
connection.close();
}
@@ -217,8 +215,8 @@ public class ExportCsv extends AbstractCsvTool {
}
private static void dumpFromSqlFile(String filePath) throws IOException {
- try (BufferedReader reader = new BufferedReader(new
FileReader(filePath));){
- String sql = null;
+ try (BufferedReader reader = new BufferedReader(new FileReader(filePath))){
+ String sql;
int index = 0;
while ((sql = reader.readLine()) != null) {
try {
@@ -240,7 +238,7 @@ public class ExportCsv extends AbstractCsvTool {
*/
private static void dumpResult(String sql, int index)
throws SQLException {
- BufferedWriter writer = null;
+ BufferedWriter writer;
final String path = targetDirectory + DUMP_FILE_NAME + index + ".csv";
try {
File tf = new File(path);
@@ -320,9 +318,7 @@ public class ExportCsv extends AbstractCsvTool {
} catch (IOException e) {
System.out.println(e.getMessage());
}
- if (statement != null) {
- statement.close();
- }
+ statement.close();
}
}
diff --git a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
index 813ebb9..9abb5f7 100644
--- a/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
+++ b/iotdb-cli/src/main/java/org/apache/iotdb/cli/tool/ImportCsv.java
@@ -48,6 +48,8 @@ import org.apache.iotdb.cli.exception.ArgsErrorException;
import org.apache.iotdb.jdbc.Config;
import org.apache.iotdb.jdbc.IoTDBConnection;
import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* read a CSV formatted data File and insert all the data into IoTDB.
@@ -56,6 +58,8 @@ import org.apache.thrift.TException;
*/
public class ImportCsv extends AbstractCsvTool {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ImportCsv.class);
+
private static final String FILE_ARGS = "f";
private static final String FILE_NAME = "file or folder";
private static final String FILE_SUFFIX = "csv";
@@ -264,17 +268,16 @@ public class ImportCsv extends AbstractCsvTool {
file.getAbsolutePath(), errorFile.getAbsolutePath()));
}
} catch (SQLException e) {
- e.printStackTrace();
+ System.out.println("[ERROR] Sql statement can not be closed ! " +
e.getMessage());
} catch (IOException e) {
- e.printStackTrace();
+ System.out.println("[ERROR] Close file error ! " + e.getMessage());
}
}
}
private static List<String> createInsertSQL(String line, Map<String, String>
timeseriesToType,
Map<String, ArrayList<Integer>> deviceToColumn,
- List<String> colInfo, List<String> headInfo)
- throws IOException {
+ List<String> colInfo, List<String> headInfo) {
String[] data = line.split(",", headInfo.size() + 1);
List<String> sqls = new ArrayList<>();
Iterator<Map.Entry<String, ArrayList<Integer>>> it =
deviceToColumn.entrySet().iterator();
@@ -283,27 +286,27 @@ public class ImportCsv extends AbstractCsvTool {
StringBuilder sbd = new StringBuilder();
ArrayList<Integer> colIndex = entry.getValue();
sbd.append("insert into " + entry.getKey() + "(timestamp");
- int skipcount = 0;
+ int skipCount = 0;
for (int j = 0; j < colIndex.size(); ++j) {
- if (data[entry.getValue().get(j) + 1].equals("")) {
- skipcount++;
+ if ("".equals(data[entry.getValue().get(j) + 1])) {
+ skipCount++;
continue;
}
sbd.append(", " + colInfo.get(colIndex.get(j)));
}
// define every device null value' number, if the number equal the
// sensor number, the insert operation stop
- if (skipcount == entry.getValue().size()) {
+ if (skipCount == entry.getValue().size()) {
continue;
}
- // TODO when timestampsStr is empty,
+ // TODO when timestampsStr is empty
String timestampsStr = data[0];
- sbd.append(") values(").append(timestampsStr.trim().equals("")
+ sbd.append(") values(").append(timestampsStr.trim().isEmpty()
? "NO TIMESTAMP" : timestampsStr);
for (int j = 0; j < colIndex.size(); ++j) {
- if (data[entry.getValue().get(j) + 1].equals("")) {
+ if ("".equals(data[entry.getValue().get(j) + 1])) {
continue;
}
if
(timeseriesToType.get(headInfo.get(colIndex.get(j))).equals(STRING_DATA_TYPE)) {
@@ -386,28 +389,11 @@ public class ImportCsv extends AbstractCsvTool {
File file = new File(filename);
if (file.isFile()) {
- if (file.getName().endsWith(FILE_SUFFIX)) {
- loadDataFromCSV(file, 1);
- } else {
- System.out.println(
- "[WARN] File " + file.getName() + " should ends with '.csv' "
- + "if you want to import");
- }
+ importFromSingleFile(file);
} else if (file.isDirectory()) {
- int i = 1;
- for (File f : file.listFiles()) {
- if (f.isFile()) {
- if (f.getName().endsWith(FILE_SUFFIX)) {
- loadDataFromCSV(f, i);
- i++;
- } else {
- System.out.println(
- "[WARN] File " + f.getName() + " should ends with '.csv' "
- + "if you want to import");
- }
- }
- }
+ importFromDirectory(file);
}
+
} catch (ClassNotFoundException e) {
System.out.println(
"[ERROR] Failed to dump data because cannot find TsFile JDBC Driver,
"
@@ -423,6 +409,31 @@ public class ImportCsv extends AbstractCsvTool {
connection.close();
}
}
+ }
+ private static void importFromSingleFile(File file) {
+ if (file.getName().endsWith(FILE_SUFFIX)) {
+ loadDataFromCSV(file, 1);
+ } else {
+ System.out.println(
+ "[WARN] File " + file.getName() + " should ends with '.csv' "
+ + "if you want to import");
+ }
+ }
+
+ private static void importFromDirectory(File file) {
+ int i = 1;
+ for (File subFile : file.listFiles()) {
+ if (subFile.isFile()) {
+ if (subFile.getName().endsWith(FILE_SUFFIX)) {
+ loadDataFromCSV(subFile, i);
+ i++;
+ } else {
+ System.out.println(
+ "[WARN] File " + subFile.getName() + " should ends with
'.csv' "
+ + "if you want to import");
+ }
+ }
+ }
}
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthException.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthException.java
index f8c581e..cd40803 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthException.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthException.java
@@ -27,10 +27,6 @@ public class AuthException extends Exception {
private static final long serialVersionUID = 5091102941209301301L;
- public AuthException(String format, String userName, String roleName) {
- super();
- }
-
public AuthException(String message) {
super(message);
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
index 5c3124d..79baccb 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/AuthorityChecker.java
@@ -33,6 +33,10 @@ public class AuthorityChecker {
private static final String SUPER_USER = IoTDBConstant.ADMIN_NAME;
private static final Logger logger =
LoggerFactory.getLogger(AuthorityChecker.class);
+ private AuthorityChecker() {
+
+ }
+
/**
* check permission.
*
@@ -58,7 +62,7 @@ public class AuthorityChecker {
// a user can modify his own password
return true;
}
- if (paths.size() > 0) {
+ if (!paths.isEmpty()) {
for (Path path : paths) {
if (!checkOnePath(username, path, permission)) {
return false;
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
index 1477846..f050696 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/BasicAuthorizer.java
@@ -37,8 +37,9 @@ import org.slf4j.LoggerFactory;
public abstract class BasicAuthorizer implements IAuthorizer, IService {
- private static final Logger logger =
LoggerFactory.getLogger(BasicAuthorizer.class);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(BasicAuthorizer.class);
private static final Set<Integer> ADMIN_PRIVILEGES;
+ private static final String NO_SUCH_ROLE_EXCEPTION = "No such role : %s";
static {
ADMIN_PRIVILEGES = new HashSet<>();
@@ -59,7 +60,7 @@ public abstract class BasicAuthorizer implements IAuthorizer,
IService {
protected void init() throws AuthException {
userManager.reset();
roleManager.reset();
- logger.info("Initialization of Authorizer completes");
+ LOGGER.info("Initialization of Authorizer completes");
}
@Override
@@ -84,13 +85,14 @@ public abstract class BasicAuthorizer implements
IAuthorizer, IService {
@Override
public boolean grantPrivilegeToUser(String username, String path, int
privilegeId)
throws AuthException {
+ String newPath = path;
if (IoTDBConstant.ADMIN_NAME.equals(username)) {
throw new AuthException("Invalid operation, administrator already has
all privileges");
}
if (!PrivilegeType.isPathRelevant(privilegeId)) {
- path = IoTDBConstant.PATH_ROOT;
+ newPath = IoTDBConstant.PATH_ROOT;
}
- return userManager.grantPrivilegeToUser(username, path, privilegeId);
+ return userManager.grantPrivilegeToUser(username, newPath, privilegeId);
}
@Override
@@ -122,7 +124,7 @@ public abstract class BasicAuthorizer implements
IAuthorizer, IService {
try {
userManager.revokeRoleFromUser(roleName, user);
} catch (AuthException e) {
- logger.warn(
+ LOGGER.warn(
"Error encountered when revoking a role {} from user {} after
deletion, because {}",
roleName, user, e);
}
@@ -153,14 +155,14 @@ public abstract class BasicAuthorizer implements
IAuthorizer, IService {
public boolean grantRoleToUser(String roleName, String username) throws
AuthException {
Role role = roleManager.getRole(roleName);
if (role == null) {
- throw new AuthException(String.format("No such role : %s", roleName));
+ throw new AuthException(String.format(NO_SUCH_ROLE_EXCEPTION, roleName));
}
// the role may be deleted before it ts granted to the user, so a double
check is necessary.
boolean success = userManager.grantRoleToUser(roleName, username);
if (success) {
role = roleManager.getRole(roleName);
if (role == null) {
- throw new AuthException(String.format("No such role : %s", roleName));
+ throw new AuthException(String.format(NO_SUCH_ROLE_EXCEPTION,
roleName));
} else {
return true;
}
@@ -173,7 +175,7 @@ public abstract class BasicAuthorizer implements
IAuthorizer, IService {
public boolean revokeRoleFromUser(String roleName, String username) throws
AuthException {
Role role = roleManager.getRole(roleName);
if (role == null) {
- throw new AuthException(String.format("No such role : %s", roleName));
+ throw new AuthException(String.format(NO_SUCH_ROLE_EXCEPTION, roleName));
}
return userManager.revokeRoleFromUser(roleName, username);
}
@@ -238,6 +240,7 @@ public abstract class BasicAuthorizer implements
IAuthorizer, IService {
try {
init();
} catch (AuthException e) {
+ LOGGER.error("Auth authentication error : ", e);
throw new StartupException(e.getMessage());
}
}
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
index 652d379..f631bb7 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/auth/authorizer/LocalFileAuthorizer.java
@@ -48,7 +48,6 @@ public class LocalFileAuthorizer extends BasicAuthorizer {
}
private static class InstanceHolder {
-
private static LocalFileAuthorizer instance;
static {
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
index 7f95e9e..11579fe 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/PathPrivilege.java
@@ -34,10 +34,24 @@ public class PathPrivilege {
private String path;
/**
+ * This field records how many times this privilege is referenced during a
life cycle (from being
+ * loaded to being discarded). When serialized to a file, this determines
the order of
+ * serialization. The higher this values is, the sooner this privilege will
be serialized. As a
+ * result, the hot privileges will be in the first place so that the hit
time will decrease when
+ * being queried.
+ */
+ private AtomicInteger referenceCnt = new AtomicInteger(0);
+
+ /**
* Sort PathPrivilege by referenceCnt in descent order.
*/
- public static final Comparator<PathPrivilege> referenceDescentSorter = (o1,
o2) -> -Integer.
- compare(o1.referenceCnt.get(), o2.referenceCnt.get());
+ public static final Comparator<PathPrivilege> REFERENCE_DESCENT_SORTER =
(o1, o2) -> -Integer.
+ compare(o1.referenceCnt.get(), o2.referenceCnt.get());
+
+ public PathPrivilege(String path) {
+ this.path = path;
+ this.privileges = new HashSet<>();
+ }
public Set<Integer> getPrivileges() {
return privileges;
@@ -63,20 +77,6 @@ public class PathPrivilege {
this.referenceCnt = referenceCnt;
}
- /**
- * This field records how many times this privilege is referenced during a
life cycle (from being
- * loaded to being discarded). When serialized to a file, this determines
the order of
- * serialization. The higher this values is, the sooner this privilege will
be serialized. As a
- * result, the hot privileges will be in the first place so that the hit
time will decrease when
- * being queried.
- */
- private AtomicInteger referenceCnt = new AtomicInteger(0);
-
- public PathPrivilege(String path) {
- this.path = path;
- this.privileges = new HashSet<>();
- }
-
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -91,7 +91,6 @@ public class PathPrivilege {
@Override
public int hashCode() {
-
return Objects.hash(privileges, path);
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/Role.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/Role.java
index d034ee0..db3a498 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/Role.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/Role.java
@@ -32,6 +32,15 @@ public class Role {
private String name;
private List<PathPrivilege> privilegeList;
+ public Role() {
+ // empty constructor
+ }
+
+ public Role(String name) {
+ this.name = name;
+ this.privilegeList = new ArrayList<>();
+ }
+
public String getName() {
return name;
}
@@ -48,24 +57,16 @@ public class Role {
this.privilegeList = privilegeList;
}
- public Role() {
- }
-
- public Role(String name) {
- this.name = name;
- this.privilegeList = new ArrayList<>();
- }
-
public boolean hasPrivilege(String path, int privilegeId) {
return AuthUtils.hasPrivilege(path, privilegeId, privilegeList);
}
- public void addPrivilege(String path, int privilgeId) {
- AuthUtils.addPrivilege(path, privilgeId, privilegeList);
+ public void addPrivilege(String path, int privilegeId) {
+ AuthUtils.addPrivilege(path, privilegeId, privilegeList);
}
- public void removePrivilege(String path, int privilgeId) {
- AuthUtils.removePrivilege(path, privilgeId, privilegeList);
+ public void removePrivilege(String path, int privilegeId) {
+ AuthUtils.removePrivilege(path, privilegeId, privilegeList);
}
/**
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/User.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/User.java
index b877f75..6109180 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/User.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/entity/User.java
@@ -40,6 +40,23 @@ public class User {
*/
private long lastActiveTime;
+ public User() {
+ // empty constructor
+ }
+
+ /**
+ * construct function for User.
+ *
+ * @param name -user name
+ * @param password -user password
+ */
+ public User(String name, String password) {
+ this.name = name;
+ this.password = password;
+ this.privilegeList = new ArrayList<>();
+ this.roleList = new ArrayList<>();
+ }
+
public String getName() {
return name;
}
@@ -80,32 +97,16 @@ public class User {
this.lastActiveTime = lastActiveTime;
}
- public User() {
- }
-
- /**
- * construct function for User.
- *
- * @param name -user name
- * @param password -user password
- */
- public User(String name, String password) {
- this.name = name;
- this.password = password;
- this.privilegeList = new ArrayList<>();
- this.roleList = new ArrayList<>();
- }
-
public boolean hasPrivilege(String path, int privilegeId) {
return AuthUtils.hasPrivilege(path, privilegeId, privilegeList);
}
- public void addPrivilege(String path, int privilgeId) {
- AuthUtils.addPrivilege(path, privilgeId, privilegeList);
+ public void addPrivilege(String path, int privilegeId) {
+ AuthUtils.addPrivilege(path, privilegeId, privilegeList);
}
- public void removePrivilege(String path, int privilgeId) {
- AuthUtils.removePrivilege(path, privilgeId, privilegeList);
+ public void removePrivilege(String path, int privilegeId) {
+ AuthUtils.removePrivilege(path, privilegeId, privilegeList);
}
/**
@@ -143,15 +144,20 @@ public class User {
return false;
}
User user = (User) o;
- return lastActiveTime == user.lastActiveTime && Objects.equals(name,
user.name)
- && Objects.equals(password, user.password) && Objects
- .equals(privilegeList, user.privilegeList)
- && Objects.equals(roleList, user.roleList);
+
+ return lastActiveTime == user.lastActiveTime && contentEquals(user);
}
+ private boolean contentEquals(User user) {
+ return Objects.equals(name, user.name)
+ && Objects.equals(password, user.password)
+ && Objects.equals(privilegeList, user.privilegeList)
+ && Objects.equals(roleList, user.roleList);
+ }
+
+
@Override
public int hashCode() {
-
return Objects.hash(name, password, privilegeList, roleList,
lastActiveTime);
}
}
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
index 8f46f56..0cac736 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/auth/role/LocalFileRoleAccessor.java
@@ -104,7 +104,7 @@ public class LocalFileRoleAccessor implements IRoleAccessor
{
try {
IOUtils.writeString(outputStream, role.getName(), STRING_ENCODING,
encodingBufferLocal);
- role.getPrivilegeList().sort(PathPrivilege.referenceDescentSorter);
+ role.getPrivilegeList().sort(PathPrivilege.REFERENCE_DESCENT_SORTER);
int privilegeNum = role.getPrivilegeList().size();
IOUtils.writeInt(outputStream, privilegeNum, encodingBufferLocal);
for (int i = 0; i < privilegeNum; i++) {
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
index 1e5283c..8be5ee4 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/BasicUserManager.java
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
public abstract class BasicUserManager implements IUserManager {
private static final Logger logger =
LoggerFactory.getLogger(BasicUserManager.class);
+ private static final String NO_SUCH_USER_ERROR = "No such user %s";
private Map<String, User> userMap;
private IUserAccessor accessor;
@@ -145,7 +146,7 @@ public abstract class BasicUserManager implements
IUserManager {
try {
User user = getUser(username);
if (user == null) {
- throw new AuthException(String.format("No such user %s", username));
+ throw new AuthException(String.format(NO_SUCH_USER_ERROR, username));
}
if (user.hasPrivilege(path, privilegeId)) {
return false;
@@ -172,7 +173,7 @@ public abstract class BasicUserManager implements
IUserManager {
try {
User user = getUser(username);
if (user == null) {
- throw new AuthException(String.format("No such user %s", username));
+ throw new AuthException(String.format(NO_SUCH_USER_ERROR, username));
}
if (!user.hasPrivilege(path, privilegeId)) {
return false;
@@ -202,7 +203,7 @@ public abstract class BasicUserManager implements
IUserManager {
try {
User user = getUser(username);
if (user == null) {
- throw new AuthException(String.format("No such user %s", username));
+ throw new AuthException(String.format(NO_SUCH_USER_ERROR, username));
}
String oldPassword = user.getPassword();
user.setPassword(AuthUtils.encryptPassword(newPassword));
@@ -224,7 +225,7 @@ public abstract class BasicUserManager implements
IUserManager {
try {
User user = getUser(username);
if (user == null) {
- throw new AuthException(String.format("No such user %s", username));
+ throw new AuthException(String.format(NO_SUCH_USER_ERROR, username));
}
if (user.hasRole(roleName)) {
return false;
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
index 48e77d1..495577e 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/auth/user/LocalFileUserAccessor.java
@@ -73,6 +73,7 @@ public class LocalFileUserAccessor implements IUserAccessor {
* @param username The name of the user to be deserialized.
* @return The user object or null if no such user.
*/
+ @Override
public User loadUser(String username) throws IOException {
File userProfile = new File(
userDirPath + File.separator + username +
IoTDBConstant.PROFILE_SUFFIX);
@@ -120,6 +121,7 @@ public class LocalFileUserAccessor implements IUserAccessor
{
*
* @param user The user object that is to be saved.
*/
+ @Override
public void saveUser(User user) throws IOException {
File userProfile = new File(
userDirPath + File.separator + user.getName() +
IoTDBConstant.PROFILE_SUFFIX + TEMP_SUFFIX);
@@ -128,7 +130,7 @@ public class LocalFileUserAccessor implements IUserAccessor
{
IOUtils.writeString(outputStream, user.getName(), STRING_ENCODING,
encodingBufferLocal);
IOUtils.writeString(outputStream, user.getPassword(), STRING_ENCODING,
encodingBufferLocal);
- user.getPrivilegeList().sort(PathPrivilege.referenceDescentSorter);
+ user.getPrivilegeList().sort(PathPrivilege.REFERENCE_DESCENT_SORTER);
int privilegeNum = user.getPrivilegeList().size();
IOUtils.writeInt(outputStream, privilegeNum, encodingBufferLocal);
for (int i = 0; i < privilegeNum; i++) {
@@ -164,6 +166,7 @@ public class LocalFileUserAccessor implements IUserAccessor
{
* @return True if the file is successfully deleted, false if the file does
not exists.
* @throws IOException when the file cannot be deleted.
*/
+ @Override
public boolean deleteUser(String username) throws IOException {
File userProfile = new File(
userDirPath + File.separator + username +
IoTDBConstant.PROFILE_SUFFIX);
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
index 7e8c783..970bfc5 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/HashLock.java
@@ -18,6 +18,9 @@
*/
package org.apache.iotdb.db.concurrent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
@@ -27,6 +30,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
*/
public class HashLock {
+ private static final Logger LOGGER = LoggerFactory.getLogger(HashLock.class);
+
private static final int DEFAULT_LOCK_NUM = 100;
private ReentrantReadWriteLock[] locks;
@@ -37,14 +42,6 @@ public class HashLock {
init();
}
- public HashLock(int lockSize) {
- if (lockSize <= 0) {
- lockSize = DEFAULT_LOCK_NUM;
- }
- this.lockSize = lockSize;
- init();
- }
-
private void init() {
locks = new ReentrantReadWriteLock[lockSize];
for (int i = 0; i < lockSize; i++) {
@@ -76,12 +73,12 @@ public class HashLock {
try {
locks[i].readLock().unlock();
} catch (Exception ignored) {
- // ignored
+ // do nothing
}
try {
locks[i].writeLock().unlock();
} catch (Exception ignored) {
- // ignored
+ // do nothing
}
}
}
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandler.java
b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandler.java
index 628f75a..0623d16 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandler.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBDefaultThreadExceptionHandler.java
@@ -26,9 +26,6 @@ public class IoTDBDefaultThreadExceptionHandler implements
Thread.UncaughtExcept
private static final Logger LOGGER = LoggerFactory
.getLogger(IoTDBDefaultThreadExceptionHandler.class);
- public IoTDBDefaultThreadExceptionHandler() {
- }
-
@Override
public void uncaughtException(Thread t, Throwable e) {
LOGGER.error("Exception in thread {}-{}", t.getName(), t.getId(), e);
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactory.java
b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactory.java
index d138410..f191607 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactory.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/concurrent/IoTDBThreadPoolFactory.java
@@ -31,6 +31,7 @@ import org.apache.thrift.server.TThreadPoolServer.Args;
* @author liukun
*/
public class IoTDBThreadPoolFactory {
+ private IoTDBThreadPoolFactory() {}
/**
* see {@link Executors#newFixedThreadPool(int,
java.util.concurrent.ThreadFactory)}.
@@ -112,7 +113,7 @@ public class IoTDBThreadPoolFactory {
* function for creating JDBC client thread pool.
*/
public static ExecutorService createJDBCClientThreadPool(Args args, String
poolName) {
- SynchronousQueue<Runnable> executorQueue = new
SynchronousQueue<Runnable>();
+ SynchronousQueue<Runnable> executorQueue = new SynchronousQueue<>();
return new ThreadPoolExecutor(args.minWorkerThreads,
args.maxWorkerThreads, args.stopTimeoutVal,
args.stopTimeoutUnit, executorQueue, new IoTThreadFactory(poolName));
}
@@ -122,7 +123,7 @@ public class IoTDBThreadPoolFactory {
*/
public static ExecutorService createJDBCClientThreadPool(Args args, String
poolName,
Thread.UncaughtExceptionHandler handler) {
- SynchronousQueue<Runnable> executorQueue = new
SynchronousQueue<Runnable>();
+ SynchronousQueue<Runnable> executorQueue = new SynchronousQueue<>();
return new ThreadPoolExecutor(args.minWorkerThreads,
args.maxWorkerThreads, args.stopTimeoutVal,
args.stopTimeoutUnit, executorQueue, new IoTThreadFactory(poolName,
handler));
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index a94ac4d..a480ab7 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -89,8 +89,8 @@ public class IoTDBConfig {
/**
* Data directory of bufferWrite data.
+ * It can be setted as bufferWriteDirs = {"settled1", "settled2",
"settled3"};
*/
- // public String[] bufferWriteDirs = {"settled1", "settled2", "settled3"};
public String[] bufferWriteDirs = {"settled"};
/**
@@ -273,6 +273,7 @@ public class IoTDBConfig {
public long cacheFileReaderClearPeriod = 100000;
public IoTDBConfig() {
+ // empty constructor
}
public ZoneId getZoneID() {
@@ -284,7 +285,7 @@ public class IoTDBConfig {
}
public void updatePath() {
- confirmMultDirStrategy();
+ confirmMultiDirStrategy();
preUpdatePath();
@@ -358,7 +359,7 @@ public class IoTDBConfig {
*
*/
- public void preUpdatePath() {
+ private void preUpdatePath() {
if (dataDir == null) {
dataDir = default_data_dir + File.separatorChar + default_data_dir;
}
@@ -373,23 +374,16 @@ public class IoTDBConfig {
dirs.add(dataDir);
dirs.add(sysDir);
dirs.add(walDir);
- // List<String> newdirs = new ArrayList<>();
String homeDir = System.getProperty(IoTDBConstant.IOTDB_HOME, null);
for (int i = 0; i < 3; i++) {
String dir = dirs.get(i);
- if (new File(dir).isAbsolute()) {
- continue;
- } else {
- if (homeDir != null) {
- if (homeDir.length() > 0) {
- if (!homeDir.endsWith(File.separator)) {
- dir = homeDir + File.separatorChar + dir;
- } else {
- dir = homeDir + dir;
- }
- dirs.set(i, dir);
- }
+ if (!new File(dir).isAbsolute() && homeDir != null && homeDir.length() >
0) {
+ if (!homeDir.endsWith(File.separator)) {
+ dir = homeDir + File.separatorChar + dir;
+ } else {
+ dir = homeDir + dir;
}
+ dirs.set(i, dir);
}
}
dataDir = dirs.get(0);
@@ -397,7 +391,7 @@ public class IoTDBConfig {
walDir = dirs.get(2);
}
- public void confirmMultDirStrategy() {
+ private void confirmMultiDirStrategy() {
if (multDirStrategyClassName == null) {
multDirStrategyClassName = default_mult_dir_strategy;
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
index b25b7c1..5135e79 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConstant.java
@@ -20,13 +20,15 @@ package org.apache.iotdb.db.conf;
public class IoTDBConstant {
+ private IoTDBConstant() {}
+
public static final String ENV_FILE_NAME = "iotdb-env";
public static final String IOTDB_CONF = "IOTDB_CONF";
public static final String GLOBAL_DB_NAME = "IoTDB";
public static final String VERSION = "0.7.0";
public static final String REMOTE_JMX_PORT_NAME =
"com.sun.management.jmxremote.port";
- public static final String TSFILEDB_LOCAL_JMX_PORT_NAME =
"iotdb.jmx.local.port";
- public static final String TSFILEDB_REMOTE_JMX_PORT_NAME =
"iotdb.jmx.remote.port";
+ public static final String IOTDB_LOCAL_JMX_PORT_NAME =
"iotdb.jmx.local.port";
+ public static final String IOTDB_REMOTE_JMX_PORT_NAME =
"iotdb.jmx.remote.port";
public static final String SERVER_RMI_ID = "java.rmi.server.randomIDs";
public static final String RMI_SERVER_HOST_NAME = "java.rmi.server.hostname";
public static final String JMX_REMOTE_RMI_PORT =
"com.sun.management.jmxremote.rmi.port";
@@ -46,12 +48,11 @@ public class IoTDBConstant {
public static final String OVERFLOW_LOG_NODE_SUFFIX = "-overflow";
public static final String PATH_ROOT = "root";
- public static final char PATH_SEPARATER = '.';
+ public static final char PATH_SEPARATOR = '.';
public static final String ADMIN_NAME = "root";
public static final String ADMIN_PW = "root";
public static final String PROFILE_SUFFIX = ".profile";
- public static final String BACKUP_SUFFIX = ".backup";
public static final String MAX_TIME = "max_time";
public static final String MIN_TIME = "min_time";
- public static final int minSupportedJDKVerion = 8;
+ public static final int MIN_SUPPORTED_JDK_VERSION = 8;
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index e919cdb..5faf717 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -84,16 +84,16 @@ public class IoTDBDescriptor {
properties.load(inputStream);
conf.enableStatMonitor = Boolean
.parseBoolean(properties.getProperty("enable_stat_monitor",
- conf.enableStatMonitor + ""));
+ Boolean.toString(conf.enableStatMonitor)));
conf.backLoopPeriodSec = Integer
.parseInt(properties.getProperty("back_loop_period_sec",
- conf.backLoopPeriodSec + ""));
+ Integer.toString(conf.backLoopPeriodSec)));
int statMonitorDetectFreqSec = Integer.parseInt(
properties.getProperty("stat_monitor_detect_freq_sec",
- conf.statMonitorDetectFreqSec + ""));
+ Integer.toString(conf.statMonitorDetectFreqSec)));
int statMonitorRetainIntervalSec = Integer.parseInt(
properties.getProperty("stat_monitor_retain_interval_sec",
- conf.statMonitorRetainIntervalSec + ""));
+ Integer.toString(conf.statMonitorRetainIntervalSec)));
// the conf value must > default value, or may cause system unstable
if (conf.statMonitorDetectFreqSec < statMonitorDetectFreqSec) {
conf.statMonitorDetectFreqSec = statMonitorDetectFreqSec;
@@ -110,20 +110,20 @@ public class IoTDBDescriptor {
}
conf.rpcPort = Integer.parseInt(properties.getProperty("rpc_port",
- conf.rpcPort + ""));
+ Integer.toString(conf.rpcPort)));
conf.enableWal =
Boolean.parseBoolean(properties.getProperty("enable_wal",
- conf.enableWal + ""));
+ Boolean.toString(conf.enableWal)));
conf.flushWalThreshold = Integer
.parseInt(properties.getProperty("flush_wal_threshold",
- conf.flushWalThreshold + ""));
- conf.flushWalPeriodInMs = Integer
- .parseInt(properties.getProperty("flush_wal_period_in_ms",
- conf.flushWalPeriodInMs + ""));
- conf.forceWalPeriodInMs = Integer
- .parseInt(properties.getProperty("force_wal_period_in_ms",
- conf.forceWalPeriodInMs + ""));
+ Integer.toString(conf.flushWalThreshold)));
+ conf.flushWalPeriodInMs = Long
+ .parseLong(properties.getProperty("flush_wal_period_in_ms",
+ Long.toString(conf.flushWalPeriodInMs)));
+ conf.forceWalPeriodInMs = Long
+ .parseLong(properties.getProperty("force_wal_period_in_ms",
+ Long.toString(conf.forceWalPeriodInMs)));
conf.dataDir = properties.getProperty("data_dir", conf.dataDir);
conf.bufferWriteDirs = properties.getProperty("tsfile_dir",
conf.default_tsfile_dir)
@@ -135,68 +135,68 @@ public class IoTDBDescriptor {
conf.multDirStrategyClassName);
conf.maxOpenFolder =
Integer.parseInt(properties.getProperty("max_opened_folder",
- conf.maxOpenFolder + ""));
+ Integer.toString(conf.maxOpenFolder)));
conf.mergeConcurrentThreads = Integer
.parseInt(properties.getProperty("merge_concurrent_threads",
- conf.mergeConcurrentThreads + ""));
+ Integer.toString(conf.mergeConcurrentThreads)));
if (conf.mergeConcurrentThreads <= 0
|| conf.mergeConcurrentThreads >
Runtime.getRuntime().availableProcessors()) {
conf.mergeConcurrentThreads =
Runtime.getRuntime().availableProcessors();
}
conf.fetchSize = Integer.parseInt(properties.getProperty("fetch_size",
- conf.fetchSize + ""));
+ Integer.toString(conf.fetchSize)));
conf.periodTimeForFlush = Long.parseLong(
properties.getProperty("period_time_for_flush_in_second",
- conf.periodTimeForFlush + "").trim());
+ Long.toString(conf.periodTimeForFlush)).trim());
conf.periodTimeForMerge = Long.parseLong(
properties.getProperty("period_time_for_merge_in_second",
- conf.periodTimeForMerge + "").trim());
+ Long.toString(conf.periodTimeForMerge)).trim());
conf.enableTimingCloseAndMerge = Boolean.parseBoolean(properties
.getProperty("enable_timing_close_and_Merge",
- conf.enableTimingCloseAndMerge + "").trim());
+ Boolean.toString(conf.enableTimingCloseAndMerge)).trim());
conf.memThresholdWarning = (long) (Runtime.getRuntime().maxMemory() *
Double.parseDouble(
properties.getProperty("mem_threshold_warning",
- conf.memThresholdWarning + "").trim()));
+ Long.toString(conf.memThresholdWarning)).trim()));
conf.memThresholdDangerous = (long) (Runtime.getRuntime().maxMemory() *
Double.parseDouble(
properties.getProperty("mem_threshold_dangerous",
- conf.memThresholdDangerous + "").trim()));
+ Long.toString(conf.memThresholdDangerous)).trim()));
conf.memMonitorInterval = Long
.parseLong(properties.getProperty("mem_monitor_interval",
- conf.memMonitorInterval + "").trim());
+ Long.toString(conf.memMonitorInterval)).trim());
conf.memControllerType = Integer
.parseInt(properties.getProperty("mem_controller_type",
- conf.memControllerType + "").trim());
+ Integer.toString(conf.memControllerType)).trim());
conf.memControllerType = conf.memControllerType >=
ControllerType.values().length ? 0
: conf.memControllerType;
conf.bufferwriteMetaSizeThreshold = Long.parseLong(properties
.getProperty("bufferwrite_meta_size_threshold",
- conf.bufferwriteMetaSizeThreshold + "").trim());
+ Long.toString(conf.bufferwriteMetaSizeThreshold)).trim());
conf.bufferwriteFileSizeThreshold = Long.parseLong(properties
.getProperty("bufferwrite_file_size_threshold",
- conf.bufferwriteFileSizeThreshold + "").trim());
+ Long.toString(conf.bufferwriteFileSizeThreshold)).trim());
conf.overflowMetaSizeThreshold = Long.parseLong(
properties.getProperty("overflow_meta_size_threshold",
- conf.overflowMetaSizeThreshold + "").trim());
+ Long.toString(conf.overflowMetaSizeThreshold)).trim());
conf.overflowFileSizeThreshold = Long.parseLong(
properties.getProperty("overflow_file_size_threshold",
- conf.overflowFileSizeThreshold + "").trim());
+ Long.toString(conf.overflowFileSizeThreshold)).trim());
conf.isPostbackEnable = Boolean
.parseBoolean(properties.getProperty("is_postback_enable",
- conf.isPostbackEnable + ""));
+ Boolean.toString(conf.isPostbackEnable)));
conf.postbackServerPort = Integer
.parseInt(properties.getProperty("postback_server_port",
- conf.postbackServerPort + "").trim());
+ Integer.toString(conf.postbackServerPort)).trim());
conf.update_historical_data_possibility = Boolean.parseBoolean(
properties.getProperty("update_historical_data_possibility",
- conf.isPostbackEnable + ""));
+ Boolean.toString(conf.isPostbackEnable)));
conf.ipWhiteList = properties.getProperty("IP_white_list",
conf.ipWhiteList);
if (conf.memThresholdWarning <= 0) {
@@ -209,30 +209,30 @@ public class IoTDBDescriptor {
conf.concurrentFlushThread = Integer
.parseInt(properties.getProperty("concurrent_flush_thread",
- conf.concurrentFlushThread + ""));
+ Integer.toString(conf.concurrentFlushThread)));
if (conf.concurrentFlushThread <= 0) {
conf.concurrentFlushThread =
Runtime.getRuntime().availableProcessors();
}
conf.enableMemMonitor = Boolean
.parseBoolean(properties.getProperty("enable_mem_monitor",
- conf.enableMemMonitor + "").trim());
+ Boolean.toString(conf.enableMemMonitor)).trim());
conf.enableSmallFlush = Boolean
.parseBoolean(properties.getProperty("enable_small_flush",
- conf.enableSmallFlush + "").trim());
+ Boolean.toString(conf.enableSmallFlush)).trim());
conf.smallFlushInterval = Long
.parseLong(properties.getProperty("small_flush_interval",
- conf.smallFlushInterval + "").trim());
+ Long.toString(conf.smallFlushInterval)).trim());
conf.externalSortThreshold = Integer.parseInt(
properties.getProperty("external_sort_threshold",
- conf.externalSortThreshold + "").trim());
+ Integer.toString(conf.externalSortThreshold)).trim());
conf.mManagerCacheSize = Integer
.parseInt(properties.getProperty("schema_manager_cache_size",
- conf.mManagerCacheSize + "").trim());
+ Integer.toString(conf.mManagerCacheSize)).trim());
int maxLogEntrySize = Integer
.parseInt(properties.getProperty("max_log_entry_size",
- conf.maxLogEntrySize + "").trim());
+ Integer.toString(conf.maxLogEntrySize)).trim());
conf.maxLogEntrySize = maxLogEntrySize > 0 ? maxLogEntrySize :
conf.maxLogEntrySize;
@@ -267,7 +267,6 @@ public class IoTDBDescriptor {
}
private static class IoTDBDescriptorHolder {
-
private static final IoTDBDescriptor INSTANCE = new IoTDBDescriptor();
}
}
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java
b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java
index 668b9ec..789a81e 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/Directories.java
@@ -40,7 +40,7 @@ public class Directories {
private DirectoryStrategy strategy;
private Directories() {
- tsfileFolders = new ArrayList<String>(
+ tsfileFolders = new ArrayList<>(
Arrays.asList(IoTDBDescriptor.getInstance().getConfig().getBufferWriteDirs()));
initFolders();
@@ -88,9 +88,7 @@ public class Directories {
* @return next folder index
*/
public int getNextFolderIndexForTsFile() {
- int index = 0;
- index = strategy.nextFolderIndex();
- return index;
+ return strategy.nextFolderIndex();
}
public String getTsFileFolder(int index) {
@@ -106,7 +104,6 @@ public class Directories {
}
private static class DirectoriesHolder {
-
private static final Directories INSTANCE = new Directories();
}
}
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
index 7666fda..d6bb2dd 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinDirOccupiedSpaceFirstStrategy.java
@@ -39,10 +39,8 @@ public class MinDirOccupiedSpaceFirstStrategy extends
DirectoryStrategy {
private int getMinOccupiedSpaceFolder() {
List<Integer> candidates = new ArrayList<>();
- long min = 0;
-
candidates.add(0);
- min = getOccupiedSpace(folders.get(0));
+ long min = getOccupiedSpace(folders.get(0));
for (int i = 1; i < folders.size(); i++) {
long current = getOccupiedSpace(folders.get(i));
if (min > current) {
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
index 1eb9438..224aee9 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/conf/directories/strategy/MinFolderOccupiedSpaceFirstStrategy.java
@@ -39,10 +39,8 @@ public class MinFolderOccupiedSpaceFirstStrategy extends
DirectoryStrategy {
private int getMinOccupiedSpaceFolder() {
List<Integer> candidates = new ArrayList<>();
- long min = 0;
-
candidates.add(0);
- min = getOccupiedSpace(folders.get(0));
+ long min = getOccupiedSpace(folders.get(0));
for (int i = 1; i < folders.size(); i++) {
long current = getOccupiedSpace(folders.get(i));
if (min > current) {
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/FileNodeConstants.java
b/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/FileNodeConstants.java
index 9b7af01..483f7f1 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/FileNodeConstants.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/engine/bufferwrite/FileNodeConstants.java
@@ -25,7 +25,6 @@ package org.apache.iotdb.db.engine.bufferwrite;
public class FileNodeConstants {
private FileNodeConstants(){
-
}
public static final String FILE_NODE_OPERATOR_TYPE = "OPERATOR_TYPE";
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
b/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
index a4c7969..482715a 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/engine/cache/RowGroupBlockMetaDataCache.java
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
*/
public class RowGroupBlockMetaDataCache {
- private static Logger LOGGER =
LoggerFactory.getLogger(RowGroupBlockMetaDataCache.class);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(RowGroupBlockMetaDataCache.class);
private static final int CACHE_SIZE = 100;
/**
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/TimeIntervalTsFile.java
b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/TimeIntervalTsFile.java
new file mode 100644
index 0000000..8dea600
--- /dev/null
+++
b/iotdb/src/main/java/org/apache/iotdb/db/engine/filenode/TimeIntervalTsFile.java
@@ -0,0 +1,287 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.engine.filenode;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.conf.directories.Directories;
+
+/**
+ * This class is used to store the TsFile status.<br>
+ */
+public class TimeIntervalTsFile implements Serializable {
+
+ private static final long serialVersionUID = -4309683416067212549L;
+ public OverflowChangeType overflowChangeType;
+ private int baseDirIndex;
+ private String relativePath;
+ private Map<String, Long> startTimeMap;
+ private Map<String, Long> endTimeMap;
+ private Set<String> mergeChanged = new HashSet<>();
+
+ /**
+ * construct function for TimeIntervalTsFile.
+ */
+ public TimeIntervalTsFile(Map<String, Long> startTimeMap, Map<String, Long>
endTimeMap,
+ OverflowChangeType type,
+ int baseDirIndex, String relativePath) {
+
+ this.overflowChangeType = type;
+ this.baseDirIndex = baseDirIndex;
+ this.relativePath = relativePath;
+
+ this.startTimeMap = startTimeMap;
+ this.endTimeMap = endTimeMap;
+
+ }
+
+ /**
+ * This is just used to construct a new TsFile.
+ */
+ public TimeIntervalTsFile(OverflowChangeType type, String relativePath) {
+
+ this.overflowChangeType = type;
+ this.relativePath = relativePath;
+
+ startTimeMap = new HashMap<>();
+ endTimeMap = new HashMap<>();
+ }
+
+ public void setStartTime(String deviceId, long startTime) {
+
+ startTimeMap.put(deviceId, startTime);
+ }
+
+ /**
+ * get start time.
+ *
+ * @param deviceId -Map key
+ * @return -start time
+ */
+ public long getStartTime(String deviceId) {
+
+ if (startTimeMap.containsKey(deviceId)) {
+ return startTimeMap.get(deviceId);
+ } else {
+ return -1;
+ }
+ }
+
+ public Map<String, Long> getStartTimeMap() {
+
+ return startTimeMap;
+ }
+
+ public void setStartTimeMap(Map<String, Long> startTimeMap) {
+
+ this.startTimeMap = startTimeMap;
+ }
+
+ public void setEndTime(String deviceId, long timestamp) {
+
+ this.endTimeMap.put(deviceId, timestamp);
+ }
+
+ /**
+ * get end time for given device.
+ *
+ * @param deviceId -id of device
+ * @return -end time of the device
+ */
+ public long getEndTime(String deviceId) {
+
+ if (endTimeMap.get(deviceId) == null) {
+ return -1;
+ }
+ return endTimeMap.get(deviceId);
+ }
+
+ public Map<String, Long> getEndTimeMap() {
+
+ return endTimeMap;
+ }
+
+ public void setEndTimeMap(Map<String, Long> endTimeMap) {
+
+ this.endTimeMap = endTimeMap;
+ }
+
+ /**
+ * remove given device'startTime start time and end time.
+ *
+ * @param deviceId -id of the device
+ */
+ public void removeTime(String deviceId) {
+
+ startTimeMap.remove(deviceId);
+ endTimeMap.remove(deviceId);
+ }
+
+ /**
+ * get file path.
+ */
+ public String getFilePath() {
+
+ if (relativePath == null) {
+ return relativePath;
+ }
+ return new File(Directories.getInstance().getTsFileFolder(baseDirIndex),
relativePath)
+ .getPath();
+ }
+
+ public String getRelativePath() {
+
+ return relativePath;
+ }
+
+ public void setRelativePath(String relativePath) {
+
+ this.relativePath = relativePath;
+ }
+
+ public boolean checkEmpty() {
+
+ return startTimeMap.isEmpty() && endTimeMap.isEmpty();
+ }
+
+ /**
+ * clear the member variable of the given object.
+ */
+ public void clear() {
+
+ startTimeMap.clear();
+ endTimeMap.clear();
+ mergeChanged.clear();
+ overflowChangeType = OverflowChangeType.NO_CHANGE;
+ relativePath = null;
+ }
+
+ /**
+ * change file type corresponding to the given param.
+ */
+ public void changeTypeToChanged(FileNodeProcessorStatus
fileNodeProcessorState) {
+
+ if (fileNodeProcessorState == FileNodeProcessorStatus.MERGING_WRITE) {
+ overflowChangeType = OverflowChangeType.MERGING_CHANGE;
+ } else {
+ overflowChangeType = OverflowChangeType.CHANGED;
+ }
+ }
+
+ public void addMergeChanged(String deviceId) {
+
+ mergeChanged.add(deviceId);
+ }
+
+ public Set<String> getMergeChanged() {
+
+ return mergeChanged;
+ }
+
+ public void clearMergeChanged() {
+
+ mergeChanged.clear();
+ }
+
+ /**
+ * judge whether the time interval is closed.
+ */
+ public boolean isClosed() {
+
+ return !endTimeMap.isEmpty();
+
+ }
+
+ /**
+ * back up the time interval of tsfile.
+ */
+ public TimeIntervalTsFile backUp() {
+
+ Map<String, Long> startTimeMap = new HashMap<>(this.startTimeMap);
+ Map<String, Long> endTimeMap = new HashMap<>(this.endTimeMap);
+ return new TimeIntervalTsFile(startTimeMap, endTimeMap,
overflowChangeType, baseDirIndex,
+ relativePath);
+ }
+
+ @Override
+ public int hashCode() {
+
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((endTimeMap == null) ? 0 :
endTimeMap.hashCode());
+ result = prime * result + ((relativePath == null) ? 0 :
relativePath.hashCode());
+ result = prime * result + ((overflowChangeType == null) ? 0 :
overflowChangeType.hashCode());
+ result = prime * result + ((startTimeMap == null) ? 0 :
startTimeMap.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TimeIntervalTsFile other = (TimeIntervalTsFile) obj;
+ if (endTimeMap == null) {
+ if (other.endTimeMap != null) {
+ return false;
+ }
+ } else if (!endTimeMap.equals(other.endTimeMap)) {
+ return false;
+ }
+ if (relativePath == null) {
+ if (other.relativePath != null) {
+ return false;
+ }
+ } else if (!relativePath.equals(other.relativePath)) {
+ return false;
+ }
+ if (overflowChangeType != other.overflowChangeType) {
+ return false;
+ }
+ if (startTimeMap == null) {
+ if (other.startTimeMap != null) {
+ return false;
+ }
+ } else if (!startTimeMap.equals(other.startTimeMap)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "TimeIntervalTsFile [relativePath=" + relativePath + ",
overflowChangeType="
+ + overflowChangeType
+ + ", startTimeMap=" + startTimeMap + ", endTimeMap=" + endTimeMap + ",
mergeChanged="
+ + mergeChanged
+ + "]";
+ }
+
+}
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/RecordMemController.java
b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/RecordMemController.java
index ec92af0..2ffcc97 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/RecordMemController.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/engine/memcontrol/RecordMemController.java
@@ -60,6 +60,11 @@ public class RecordMemController extends BasicMemController {
totalMemUsed.set(0);
}
+ @Override
+ public void close() {
+ super.close();
+ }
+
/**
* get the current memory usage level.
*/
diff --git
a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
index 96d336b..abbf372 100644
---
a/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
+++
b/iotdb/src/main/java/org/apache/iotdb/db/engine/overflow/io/OverflowProcessor.java
@@ -524,6 +524,7 @@ public class OverflowProcessor extends Processor {
flushOperation("synchronously");
} else {
FlushManager.getInstance().submit(new Runnable() {
+ @Override
public void run() {
flushOperation("asynchronously");
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
b/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
index f6ae80a..74e5691 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/JMXService.java
@@ -115,11 +115,11 @@ public class JMXService implements IService {
}
System.setProperty(IoTDBConstant.SERVER_RMI_ID, "true");
boolean localOnly = false;
- String jmxPort =
System.getProperty(IoTDBConstant.TSFILEDB_REMOTE_JMX_PORT_NAME);
+ String jmxPort =
System.getProperty(IoTDBConstant.IOTDB_REMOTE_JMX_PORT_NAME);
if (jmxPort == null) {
localOnly = true;
- jmxPort = System.getProperty(IoTDBConstant.TSFILEDB_LOCAL_JMX_PORT_NAME);
+ jmxPort = System.getProperty(IoTDBConstant.IOTDB_LOCAL_JMX_PORT_NAME);
}
if (jmxPort == null) {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/service/StartupChecks.java
b/iotdb/src/main/java/org/apache/iotdb/db/service/StartupChecks.java
index f4bdb79..ce64f0f 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/service/StartupChecks.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/service/StartupChecks.java
@@ -39,11 +39,11 @@ public class StartupChecks {
+ "Please check conf/{}.sh(Unix or OS X, if you use Windows, "
+ "check conf/{}.bat) for more info",
IoTDBConstant.ENV_FILE_NAME, IoTDBConstant.ENV_FILE_NAME);
- jmxPort =
System.getProperty(IoTDBConstant.TSFILEDB_LOCAL_JMX_PORT_NAME);
+ jmxPort = System.getProperty(IoTDBConstant.IOTDB_LOCAL_JMX_PORT_NAME);
if (jmxPort == null) {
LOGGER.warn("{} missing from {}.sh(Unix or OS X, if you use Windows,"
+ " check conf/{}.bat)",
- IoTDBConstant.TSFILEDB_LOCAL_JMX_PORT_NAME,
IoTDBConstant.ENV_FILE_NAME,
+ IoTDBConstant.IOTDB_LOCAL_JMX_PORT_NAME,
IoTDBConstant.ENV_FILE_NAME,
IoTDBConstant.ENV_FILE_NAME);
}
} else {
@@ -56,10 +56,10 @@ public class StartupChecks {
@Override
public void execute() throws StartupException {
int version = CommonUtils.getJdkVersion();
- if (version < IoTDBConstant.minSupportedJDKVerion) {
+ if (version < IoTDBConstant.MIN_SUPPORTED_JDK_VERSION) {
throw new StartupException(
String.format("Requires JDK version >= %d, current version is %d",
- IoTDBConstant.minSupportedJDKVerion, version));
+ IoTDBConstant.MIN_SUPPORTED_JDK_VERSION, version));
} else {
LOGGER.info("JDK veriosn is {}.", version);
}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/utils/AuthUtils.java
b/iotdb/src/main/java/org/apache/iotdb/db/utils/AuthUtils.java
index fd9bac9..6d7710e 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/utils/AuthUtils.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/utils/AuthUtils.java
@@ -177,7 +177,7 @@ public class AuthUtils {
public static boolean pathBelongsTo(String pathA, String pathB) {
return pathA.equals(pathB)
|| (pathA.startsWith(pathB)
- && pathA.charAt(pathB.length()) == IoTDBConstant.PATH_SEPARATER);
+ && pathA.charAt(pathB.length()) == IoTDBConstant.PATH_SEPARATOR);
}
/**
diff --git a/iotdb/src/test/java/PerformanceTest.java
b/iotdb/src/test/java/PerformanceTest.java
deleted file mode 100644
index c7a9213..0000000
--- a/iotdb/src/test/java/PerformanceTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.iotdb.db.exception.FileNodeManagerException;
-import org.apache.iotdb.db.query.executor.EngineQueryRouter;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.read.common.RowRecord;
-import org.apache.iotdb.tsfile.read.expression.IExpression;
-import org.apache.iotdb.tsfile.read.expression.QueryExpression;
-import org.apache.iotdb.tsfile.read.expression.impl.SingleSeriesExpression;
-import org.apache.iotdb.tsfile.read.filter.TimeFilter;
-import org.apache.iotdb.tsfile.read.filter.ValueFilter;
-import org.apache.iotdb.tsfile.read.filter.basic.Filter;
-import org.apache.iotdb.tsfile.read.filter.factory.FilterFactory;
-import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
-
-/**
- * Delete this class when submitting pr.
- */
-public class PerformanceTest {
-
- private static int deviceStart = 9, deviceEnd = 9;
- private static int sensorStart = 9, sensorEnd = 9;
-
- public static void main(String[] args) throws IOException,
FileNodeManagerException {
-
- // singleWithoutFilterTest();
-
- // queryMultiSeriesWithoutFilterTest();
-
- queryMultiSeriesWithFilterTest();
- }
-
- private static void singleWithoutFilterTest() throws IOException,
FileNodeManagerException {
-
- List<Path> selectedPathList = new ArrayList<>();
- selectedPathList.add(getPath(1, 1));
-
- QueryExpression queryExpression = QueryExpression.create(selectedPathList,
null);
-
- EngineQueryRouter queryRouter = new EngineQueryRouter();
-
- long startTime = System.currentTimeMillis();
-
- QueryDataSet queryDataSet = queryRouter.query(queryExpression);
-
- int count = 0;
- while (queryDataSet.hasNext()) {
- RowRecord rowRecord = queryDataSet.next();
- count++;
- // output(count, rowRecord, true);
- }
-
- long endTime = System.currentTimeMillis();
- System.out
- .println(String.format("Time consume : %s, count number : %s", endTime
- startTime, count));
-
- }
-
- public static void queryMultiSeriesWithoutFilterTest()
- throws IOException, FileNodeManagerException {
-
- List<Path> selectedPathList = new ArrayList<>();
- for (int i = deviceStart; i <= deviceEnd; i++) {
- for (int j = sensorStart; j <= sensorEnd; j++) {
- selectedPathList.add(getPath(i, j));
- }
- }
-
- QueryExpression queryExpression = QueryExpression.create(selectedPathList,
null);
-
- EngineQueryRouter queryRouter = new EngineQueryRouter();
-
- long startTime = System.currentTimeMillis();
-
- QueryDataSet queryDataSet = queryRouter.query(queryExpression);
-
- int count = 0;
- while (queryDataSet.hasNext()) {
- RowRecord rowRecord = queryDataSet.next();
- count++;
- }
-
- long endTime = System.currentTimeMillis();
- System.out
- .println(String.format("Time consume : %s, count number : %s", endTime
- startTime, count));
-
- }
-
- public static void queryMultiSeriesWithFilterTest() throws IOException,
FileNodeManagerException {
-
- List<Path> selectedPathList = new ArrayList<>();
- for (int i = deviceStart; i <= deviceEnd; i++) {
- for (int j = sensorStart; j <= sensorEnd; j++) {
- selectedPathList.add(getPath(i, j));
- }
- }
-
- Filter valueFilter = ValueFilter.gtEq(34300.0);
- Filter timeFilter = FilterFactory
- .and(TimeFilter.gtEq(1536396840000L), TimeFilter.ltEq(1537736665000L));
-
- IExpression expression = new SingleSeriesExpression(getPath(9, 9),
timeFilter);
- EngineQueryRouter queryRouter = new EngineQueryRouter();
-
- QueryExpression queryExpression = QueryExpression.create(selectedPathList,
expression);
- long startTime = System.currentTimeMillis();
-
- QueryDataSet queryDataSet = queryRouter.query(queryExpression);
-
- int count = 0;
- while (queryDataSet.hasNext()) {
- RowRecord rowRecord = queryDataSet.next();
- count++;
- // if (count % 10000 == 0)
- // System.out.println(rowRecord);
- }
-
- long endTime = System.currentTimeMillis();
- System.out
- .println(String.format("Time consume : %s, count number : %s", endTime
- startTime, count));
-
- }
-
- public static void output(int cnt, RowRecord rowRecord, boolean flag) {
- if (!flag) {
- return;
- }
-
- if (cnt % 10000 == 0) {
- System.out.println(cnt + " : " + rowRecord);
- }
-
- if (cnt > 97600) {
- System.out.println("----" + cnt + " : " + rowRecord);
- }
- }
-
- public static Path getPath(int d, int s) {
- return new Path(String.format("root.perform.group_0.d_%s.s_%s", d, s));
- }
-
-}
diff --git a/mvnw.sh b/mvnw.sh
index f448a40..46cba08 100755
--- a/mvnw.sh
+++ b/mvnw.sh
@@ -1,5 +1,6 @@
#!/bin/sh
#
+#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information