You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/07/10 10:20:32 UTC

[incubator-iotdb] branch fix_file_name_compare created (now 09d30d0)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a change to branch fix_file_name_compare
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at 09d30d0  fix file name compare bug

This branch includes the following new commits:

     new 09d30d0  fix file name compare bug

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: fix file name compare bug

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch fix_file_name_compare
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 09d30d05095cd47ebb47c9971f40be07be1fffb4
Author: qiaojialin <64...@qq.com>
AuthorDate: Wed Jul 10 18:20:19 2019 +0800

    fix file name compare bug
---
 .../engine/storagegroup/StorageGroupProcessor.java |  7 ++---
 .../iotdb/db/qp/strategy/LogicalGenerator.java     |  6 ++---
 .../iotdb/db/qp/plan/LogicalPlanSmallTest.java     | 10 ++++----
 .../apache/iotdb/db/qp/plan/PhysicalPlanTest.java  | 10 ++++----
 .../iotdb/tsfile/common/conf/TSFileDescriptor.java |  6 ++---
 .../{SystemConstant.java => TsFileConstant.java}   |  4 +--
 .../org/apache/iotdb/tsfile/read/common/Path.java  | 30 ++++++++++------------
 7 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/iotdb/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/iotdb/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 2cf59c9..a3d0e9d 100755
--- a/iotdb/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.db.engine.storagegroup;
 
-import static org.apache.iotdb.tsfile.common.constant.SystemConstant.TSFILE_SUFFIX;
+import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX;
 
 import java.io.File;
 import java.io.IOException;
@@ -33,6 +33,7 @@ import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.commons.io.FileUtils;
+import org.apache.iotdb.db.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.directories.DirectoryManager;
 import org.apache.iotdb.db.engine.StorageEngine;
@@ -226,8 +227,8 @@ public class StorageGroupProcessor {
   // TsFileNameComparator compares TsFiles by the version number in its name
   // ({systemTime}-{versionNum}.tsfile)
   public int compareFileName(File o1, File o2) {
-    String[] items1 = o1.getName().split("-");
-    String[] items2 = o2.getName().split("-");
+    String[] items1 = o1.getName().replace(TSFILE_SUFFIX, "").split("-");
+    String[] items2 = o2.getName().replace(TSFILE_SUFFIX, "").split("-");
     if (Long.valueOf(items1[0]) - Long.valueOf(items2[0]) == 0) {
       return Long.compare(Long.valueOf(items1[1]), Long.valueOf(items2[1]));
     } else {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
index 38df832..91dc42e 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
@@ -57,7 +57,7 @@ import org.apache.iotdb.db.sql.parse.AstNode;
 import org.apache.iotdb.db.sql.parse.Node;
 import org.apache.iotdb.db.sql.parse.TSParser;
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
-import org.apache.iotdb.tsfile.common.constant.SystemConstant;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
@@ -892,7 +892,7 @@ public class LogicalGenerator {
         path[i] = node.getChild(i).getText();
       }
     }
-    return new Path(new StringContainer(path, SystemConstant.PATH_SEPARATOR));
+    return new Path(new StringContainer(path, TsFileConstant.PATH_SEPARATOR));
   }
 
   private String parseStringWithQuoto(String src) throws IllegalASTFormatException {
@@ -916,7 +916,7 @@ public class LogicalGenerator {
         || csvPath.charAt(csvPath.length() - 1) != '\'') {
       throw new IllegalASTFormatException("data load: error format csvPath:" + csvPath);
     }
-    StringContainer sc = new StringContainer(SystemConstant.PATH_SEPARATOR);
+    StringContainer sc = new StringContainer(TsFileConstant.PATH_SEPARATOR);
     sc.addTail(SQLConstant.ROOT);
     for (int i = 2; i < childCount; i++) {
       // String pathNode = astNode.getChild(i).getText().toLowerCase();
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java b/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
index f08e668..e738b30 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/LogicalPlanSmallTest.java
@@ -37,7 +37,7 @@ import org.apache.iotdb.db.sql.ParseGenerator;
 import org.apache.iotdb.db.sql.parse.AstNode;
 import org.apache.iotdb.db.sql.parse.ParseException;
 import org.apache.iotdb.db.sql.parse.ParseUtils;
-import org.apache.iotdb.tsfile.common.constant.SystemConstant;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.read.common.Path;
 import org.apache.iotdb.tsfile.utils.StringContainer;
 import org.junit.Assert;
@@ -143,16 +143,16 @@ public class LogicalPlanSmallTest {
     MemIntQpExecutor executor = new MemIntQpExecutor();
     Path path1 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d1", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     Path path2 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d2", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     Path path3 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d3", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     Path path4 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d4", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     executor.insert(new InsertPlan(path1.getDevice(), 10, path1.getMeasurement(), "10"));
     executor.insert(new InsertPlan(path2.getDevice(), 10, path2.getMeasurement(), "10"));
     executor.insert(new InsertPlan(path3.getDevice(), 10, path3.getMeasurement(), "10"));
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java b/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
index f17f229..b447319 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/qp/plan/PhysicalPlanTest.java
@@ -39,7 +39,7 @@ import org.apache.iotdb.db.qp.physical.sys.PropertyPlan;
 import org.apache.iotdb.db.qp.utils.MemIntQpExecutor;
 import org.apache.iotdb.db.query.fill.LinearFill;
 import org.apache.iotdb.db.query.fill.PreviousFill;
-import org.apache.iotdb.tsfile.common.constant.SystemConstant;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 import org.apache.iotdb.tsfile.read.common.Path;
 import org.apache.iotdb.tsfile.read.expression.IExpression;
@@ -61,16 +61,16 @@ public class PhysicalPlanTest {
   public void before() throws ProcessorException {
     Path path1 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d1", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     Path path2 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d2", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     Path path3 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d3", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     Path path4 = new Path(
         new StringContainer(new String[]{"root", "vehicle", "d4", "s1"},
-            SystemConstant.PATH_SEPARATOR));
+            TsFileConstant.PATH_SEPARATOR));
     processor.getExecutor().insert(new InsertPlan(path1.getDevice(), 10, path1.getMeasurement(), "10"));
     processor.getExecutor().insert(new InsertPlan(path2.getDevice(), 10, path2.getMeasurement(), "10"));
     processor.getExecutor().insert(new InsertPlan(path3.getDevice(), 10, path3.getMeasurement(), "10"));
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java
index 39faece..e783068 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/conf/TSFileDescriptor.java
@@ -27,7 +27,7 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.Properties;
 import java.util.Set;
-import org.apache.iotdb.tsfile.common.constant.SystemConstant;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.utils.Loader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -77,9 +77,9 @@ public class TSFileDescriptor {
    */
   private void loadProps() {
     InputStream inputStream;
-    String url = System.getProperty(SystemConstant.TSFILE_CONF, null);
+    String url = System.getProperty(TsFileConstant.TSFILE_CONF, null);
     if (url == null) {
-      url = System.getProperty(SystemConstant.TSFILE_HOME, null);
+      url = System.getProperty(TsFileConstant.TSFILE_HOME, null);
       if (url != null) {
         url = url + File.separator + "conf" + File.separator + TSFileConfig.CONFIG_FILE_NAME;
       } else {
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/constant/SystemConstant.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/constant/TsFileConstant.java
similarity index 93%
rename from tsfile/src/main/java/org/apache/iotdb/tsfile/common/constant/SystemConstant.java
rename to tsfile/src/main/java/org/apache/iotdb/tsfile/common/constant/TsFileConstant.java
index fe3063b..01c7fed 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/common/constant/SystemConstant.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/common/constant/TsFileConstant.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.tsfile.common.constant;
 
-public class SystemConstant {
+public class TsFileConstant {
 
   public static final String TSFILE_SUFFIX = ".tsfile";
   public static final String TSFILE_HOME = "TSFILE_HOME";
@@ -27,5 +27,5 @@ public class SystemConstant {
   public static final String PATH_SEPARATER_NO_REGEX = "\\.";
   public static final String DEFAULT_DELTA_TYPE = "default_delta_type";
 
-  private SystemConstant(){}
+  private TsFileConstant(){}
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Path.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Path.java
index 3d448d7..9f6c528 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Path.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/common/Path.java
@@ -19,12 +19,8 @@
 package org.apache.iotdb.tsfile.read.common;
 
 import java.io.Serializable;
-import org.apache.iotdb.tsfile.common.constant.SystemConstant;
+import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
 import org.apache.iotdb.tsfile.utils.StringContainer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
 
 /**
  * This class define an Object named Path to represent a series in IoTDB. AndExpression in batch read, this definition
@@ -44,7 +40,7 @@ public class Path implements Serializable {
     if (pathSc == null) {
       throw new IllegalArgumentException("input pathSc is null!");
     }
-    String[] splits = pathSc.toString().split(SystemConstant.PATH_SEPARATER_NO_REGEX);
+    String[] splits = pathSc.toString().split(TsFileConstant.PATH_SEPARATER_NO_REGEX);
     init(splits);
   }
 
@@ -52,7 +48,7 @@ public class Path implements Serializable {
     if (pathSc == null) {
       throw new IllegalArgumentException(illegalPathArgument);
     }
-    String[] splits = pathSc.split(SystemConstant.PATH_SEPARATER_NO_REGEX);
+    String[] splits = pathSc.split(TsFileConstant.PATH_SEPARATER_NO_REGEX);
     init(splits);
   }
 
@@ -60,15 +56,15 @@ public class Path implements Serializable {
     if (pathSc == null) {
       throw new IllegalArgumentException(illegalPathArgument);
     }
-    String[] splits = new StringContainer(pathSc, SystemConstant.PATH_SEPARATOR).toString()
-        .split(SystemConstant.PATH_SEPARATER_NO_REGEX);
+    String[] splits = new StringContainer(pathSc, TsFileConstant.PATH_SEPARATOR).toString()
+        .split(TsFileConstant.PATH_SEPARATER_NO_REGEX);
     init(splits);
   }
 
   /**
    * construct a Path directly using device and measurement, no need to reformat the path
    * @param device root.deviceType.d1
-   * @param measurement s1 , does not contain SystemConstant.PATH_SEPARATOR
+   * @param measurement s1 , does not contain TsFileConstant.PATH_SEPARATOR
    */
   public Path(String device, String measurement) {
     if (device == null || measurement == null) {
@@ -76,11 +72,11 @@ public class Path implements Serializable {
     }
     this.device = device;
     this.measurement = measurement;
-    this.fullPath = device + SystemConstant.PATH_SEPARATOR + measurement;
+    this.fullPath = device + TsFileConstant.PATH_SEPARATOR + measurement;
   }
 
   public static Path mergePath(Path prefix, Path suffix) {
-    StringContainer sc = new StringContainer(SystemConstant.PATH_SEPARATOR);
+    StringContainer sc = new StringContainer(TsFileConstant.PATH_SEPARATOR);
     sc.addTail(prefix);
     sc.addTail(suffix);
     return new Path(sc);
@@ -96,7 +92,7 @@ public class Path implements Serializable {
    * @return if this path start with prefix
    */
   public static Path addPrefixPath(Path src, String prefix) {
-    StringContainer sc = new StringContainer(SystemConstant.PATH_SEPARATOR);
+    StringContainer sc = new StringContainer(TsFileConstant.PATH_SEPARATOR);
     sc.addTail(prefix);
     sc.addTail(src);
     return new Path(sc);
@@ -131,12 +127,12 @@ public class Path implements Serializable {
     if ("".equals(srcPrefix) || descPrefix.startWith(srcPrefix)) {
       return descPrefix;
     }
-    int prefixSize = srcPrefix.split(SystemConstant.PATH_SEPARATER_NO_REGEX).length;
-    String[] descArray = descPrefix.fullPath.split(SystemConstant.PATH_SEPARATER_NO_REGEX);
+    int prefixSize = srcPrefix.split(TsFileConstant.PATH_SEPARATER_NO_REGEX).length;
+    String[] descArray = descPrefix.fullPath.split(TsFileConstant.PATH_SEPARATER_NO_REGEX);
     if (descArray.length <= prefixSize) {
       return new Path(srcPrefix);
     }
-    StringContainer sc = new StringContainer(SystemConstant.PATH_SEPARATOR);
+    StringContainer sc = new StringContainer(TsFileConstant.PATH_SEPARATOR);
     sc.addTail(srcPrefix);
     for (int i = prefixSize; i < descArray.length; i++) {
       sc.addTail(descArray[i]);
@@ -159,7 +155,7 @@ public class Path implements Serializable {
   }
 
   private void init(String[] splitedPathArray) {
-    StringContainer sc = new StringContainer(splitedPathArray, SystemConstant.PATH_SEPARATOR);
+    StringContainer sc = new StringContainer(splitedPathArray, TsFileConstant.PATH_SEPARATOR);
     if (sc.size() <= 1) {
       device = "";
       fullPath = measurement = sc.toString();