Skip to content

Commit

Permalink
fix qp DNF bug and remove hasReserved
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaojialin committed May 24, 2017
1 parent f48dc55 commit d8a6cd6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cn/edu/thu/tsfile/spark/QueryProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public List<TSQueryPlan> generatePlans(FilterOperator filter, List<String> paths

DNFFilterOptimizer dnf = new DNFFilterOptimizer();
filter = dnf.optimize(filter);

MergeSingleFilterOptimizer merge = new MergeSingleFilterOptimizer();
filter = merge.optimize(filter);

Expand All @@ -53,7 +54,6 @@ public List<TSQueryPlan> generatePlans(FilterOperator filter, List<String> paths
} else {
queryPlans.addAll(new PhysicalOptimizer().optimize(null, paths, in, start, end));
}

return queryPlans;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public BasicOperator(int tokenIntType, String path, String value) {
this.seriesValue = value;
this.isLeaf = true;
this.isSingle = true;
if(path.equals(SQLConstant.RESERVED_DELTA_OBJECT) || path.equals(SQLConstant.RESERVED_TIME)) {
hasReserve = true;
}
}

public void setReversedTokenIntType() throws BasicOperatorException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public class FilterOperator extends Operator implements Comparable<FilterOperato
protected boolean isSingle = false;
// if isSingle = false, singlePath must be null
protected String singlePath = null;
// if paths contain "delta_object" or "time", hasReserve = true
public boolean hasReserve = false;

public FilterOperator(int tokenType) {
super(tokenType);
Expand Down Expand Up @@ -73,9 +71,6 @@ public List<String> getAllPaths() {

public void setChildrenList(List<FilterOperator> children) {
this.childOperators = children;
for(FilterOperator child: children) {
hasReserve |= child.hasReserve;
}
}

public void setIsSingle(boolean b) {
Expand All @@ -92,7 +87,6 @@ public String getSinglePath() {

public void addChildOPerator(FilterOperator op) {
childOperators.add(op);
hasReserve |= op.hasReserve;
}


Expand Down Expand Up @@ -140,7 +134,6 @@ public FilterOperator clone() {
ret.tokenSymbol=tokenSymbol;
ret.isLeaf = isLeaf;
ret.isSingle = isSingle;
ret.hasReserve = hasReserve;
if(singlePath != null)
ret.singlePath = singlePath;
for (FilterOperator filterOperator : this.childOperators) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public FilterOperator optimize(FilterOperator filter) throws DNFOptimizeExceptio
}

private FilterOperator getDNF(FilterOperator filter) throws DNFOptimizeException {
if(!filter.hasReserve) {
return filter;
}
if (filter.isLeaf())
return filter;
List<FilterOperator> children = filter.getChildren();
Expand Down
7 changes: 7 additions & 0 deletions src/test/scala/cn/edu/thu/tsfile/spark/TSFileSuit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class TSFileSuit extends FunSuite with BeforeAndAfterAll {
}
}

test("qp") {
val df = spark.read.format("cn.edu.thu.tsfile.spark").load(tsfileFolder)
df.createOrReplaceTempView("tsfile_table")
val newDf = spark.sql("select s1,s2 from tsfile_table where delta_object = 'root.car.d1' and time <= 10 and (time > 5 or s1 > 10)")
Assert.assertEquals(0, newDf.count())
}

test("testMultiFilesNoneExistDelta_object") {
val df = spark.read.format("cn.edu.thu.tsfile.spark").load(tsfileFolder)
df.createOrReplaceTempView("tsfile_table")
Expand Down

0 comments on commit d8a6cd6

Please sign in to comment.