[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378330797
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
+  private Map dataTypeConsistencyChecker; // for group by 
device sql, e.g. root.ln.d1.temperature -> Float
+  private Map deviceToFilterMap; // for group by device 
sql
+
+  private GroupByPlan groupByPlan;
+  private FillQueryPlan fillQueryPlan;
+  private AggregationPlan aggregationPlan;
 
 Review comment:
   I have added a RawDataQueryPlan in AlignByDeviceDataSet.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378329768
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
 ##
 @@ -45,8 +45,8 @@
   private int seriesLimit = 0;
   private int seriesOffset = 0;
 
-  private boolean isGroupByDevice = false;
-  private boolean isAlign = true;
+  private boolean isAlignByDevice = false;
+  private boolean isAlignByTime = true;
 
 Review comment:
   Just keep it please.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378329640
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/logical/crud/QueryOperator.java
 ##
 @@ -45,8 +45,8 @@
   private int seriesLimit = 0;
   private int seriesOffset = 0;
 
-  private boolean isGroupByDevice = false;
-  private boolean isAlign = true;
+  private boolean isAlignByDevice = false;
 
 Review comment:
   Just keep it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378328712
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,45 +77,41 @@
   private int[] currentColumnMapRelation;
 
 Review comment:
   It's nice. I will rename it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378325886
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -36,9 +42,6 @@
 import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
 import org.apache.iotdb.tsfile.utils.Binary;
 
-import java.io.IOException;
-import java.util.*;
-
 
 /**
  * This QueryDataSet is used for GROUP_BY_DEVICE query result.
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378325049
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/GroupByPlan.java
 ##
 @@ -20,7 +20,8 @@
 
 import org.apache.iotdb.db.qp.logical.Operator;
 
-public class GroupByPlan extends AggregationPlan {
+public class
+GroupByPlan extends AggregationPlan {
 
 Review comment:
   Just keep it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378324259
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,180 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // e.g. temperature, status, speed
+  private Map> deviceToMeasurementsMap; // e.g. root.ln.d1 
-> temperature
+  // to check data type consistency for the same name sensor of different 
devices
+  private Map dataTypeConsistencyChecker;
+  private Map deviceToFilterMap;
+
+  private GroupByPlan groupByPlan;
+  private FillQueryPlan fillQueryPlan;
+  private AggregationPlan aggregationPlan;
+
+  // the measurements that do not exist in any device,
+  // data type is considered as Boolean. The value is considered as null
+  private List notExistMeasurements = new ArrayList<>();
+  private List positionOfNotExistMeasurements = new ArrayList<>();
+  // the measurements that have quotation mark. e.g. "abc",
+  // '11', the data type is considered as String and the value is considered 
is the same with measurement name
+  private List constMeasurements = new ArrayList<>();
+  private List positionOfConstMeasurements = new ArrayList<>();
+
+  public AlignByDevicePlan() {
+super();
+  }
+
+  public AlignByDevicePlan(boolean isQuery, Operator.OperatorType 
operatorType) {
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378324334
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/GroupByPlan.java
 ##
 @@ -20,7 +20,8 @@
 
 import org.apache.iotdb.db.qp.logical.Operator;
 
-public class GroupByPlan extends AggregationPlan {
+public class
+GroupByPlan extends AggregationPlan {
 
 Review comment:
   ...Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378167061
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,39 +84,39 @@
   private int[] currentColumnMapRelation;
   private Map tsDataTypeMap;
 
-  public DeviceIterateDataSet(QueryPlan queryPlan, QueryContext context,
+  public DeviceIterateDataSet(AlignByDevicePlan alignByDevicePlan, 
QueryContext context,
   IQueryRouter queryRouter) {
-super(null, queryPlan.getDataTypes());
+super(null, alignByDevicePlan.getDataTypes());
 
 // get deduplicated measurement columns (already deduplicated in 
TSServiceImpl.executeDataQuery)
-this.deduplicatedMeasurementColumns = queryPlan.getMeasurements();
-this.tsDataTypeMap = queryPlan.getDataTypeMapping();
+this.deduplicatedMeasurementColumns = alignByDevicePlan.getMeasurements();
+this.tsDataTypeMap = alignByDevicePlan.getDataTypeMapping();
 this.queryRouter = queryRouter;
 this.context = context;
-this.measurementColumnsGroupByDevice = 
queryPlan.getMeasurementsGroupByDevice();
-this.deviceToFilterMap = queryPlan.getDeviceToFilterMap();
-this.notExistMeasurements = queryPlan.getNotExistMeasurements();
-this.constMeasurements = queryPlan.getConstMeasurements();
-this.positionOfNotExistMeasurements = 
queryPlan.getPositionOfNotExistMeasurements();
-this.positionOfConstMeasurements = 
queryPlan.getPositionOfConstMeasurements();
+this.measurementColumnsGroupByDevice = 
alignByDevicePlan.getDeviceToMeasurementsMap();
+this.deviceToFilterMap = alignByDevicePlan.getDeviceToFilterMap();
+this.notExistMeasurements = alignByDevicePlan.getNotExistMeasurements();
+this.constMeasurements = alignByDevicePlan.getConstMeasurements();
+this.positionOfNotExistMeasurements = 
alignByDevicePlan.getPositionOfNotExistMeasurements();
+this.positionOfConstMeasurements = 
alignByDevicePlan.getPositionOfConstMeasurements();
 //BuildOutDataTypes();
 
-if (queryPlan instanceof GroupByPlan) {
+if (alignByDevicePlan.getGroupByPlan() != null) {
   this.dataSetType = DataSetType.GROUPBY;
   // assign parameters
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378167041
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,39 +84,39 @@
   private int[] currentColumnMapRelation;
   private Map tsDataTypeMap;
 
-  public DeviceIterateDataSet(QueryPlan queryPlan, QueryContext context,
+  public DeviceIterateDataSet(AlignByDevicePlan alignByDevicePlan, 
QueryContext context,
   IQueryRouter queryRouter) {
-super(null, queryPlan.getDataTypes());
+super(null, alignByDevicePlan.getDataTypes());
 
 // get deduplicated measurement columns (already deduplicated in 
TSServiceImpl.executeDataQuery)
-this.deduplicatedMeasurementColumns = queryPlan.getMeasurements();
-this.tsDataTypeMap = queryPlan.getDataTypeMapping();
+this.deduplicatedMeasurementColumns = alignByDevicePlan.getMeasurements();
+this.tsDataTypeMap = alignByDevicePlan.getDataTypeMapping();
 this.queryRouter = queryRouter;
 this.context = context;
-this.measurementColumnsGroupByDevice = 
queryPlan.getMeasurementsGroupByDevice();
-this.deviceToFilterMap = queryPlan.getDeviceToFilterMap();
-this.notExistMeasurements = queryPlan.getNotExistMeasurements();
-this.constMeasurements = queryPlan.getConstMeasurements();
-this.positionOfNotExistMeasurements = 
queryPlan.getPositionOfNotExistMeasurements();
-this.positionOfConstMeasurements = 
queryPlan.getPositionOfConstMeasurements();
+this.measurementColumnsGroupByDevice = 
alignByDevicePlan.getDeviceToMeasurementsMap();
+this.deviceToFilterMap = alignByDevicePlan.getDeviceToFilterMap();
+this.notExistMeasurements = alignByDevicePlan.getNotExistMeasurements();
+this.constMeasurements = alignByDevicePlan.getConstMeasurements();
+this.positionOfNotExistMeasurements = 
alignByDevicePlan.getPositionOfNotExistMeasurements();
+this.positionOfConstMeasurements = 
alignByDevicePlan.getPositionOfConstMeasurements();
 //BuildOutDataTypes();
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378166916
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,39 +84,39 @@
   private int[] currentColumnMapRelation;
   private Map tsDataTypeMap;
 
-  public DeviceIterateDataSet(QueryPlan queryPlan, QueryContext context,
+  public DeviceIterateDataSet(AlignByDevicePlan alignByDevicePlan, 
QueryContext context,
   IQueryRouter queryRouter) {
-super(null, queryPlan.getDataTypes());
+super(null, alignByDevicePlan.getDataTypes());
 
 // get deduplicated measurement columns (already deduplicated in 
TSServiceImpl.executeDataQuery)
-this.deduplicatedMeasurementColumns = queryPlan.getMeasurements();
-this.tsDataTypeMap = queryPlan.getDataTypeMapping();
+this.deduplicatedMeasurementColumns = alignByDevicePlan.getMeasurements();
+this.tsDataTypeMap = alignByDevicePlan.getDataTypeMapping();
 this.queryRouter = queryRouter;
 this.context = context;
-this.measurementColumnsGroupByDevice = 
queryPlan.getMeasurementsGroupByDevice();
-this.deviceToFilterMap = queryPlan.getDeviceToFilterMap();
-this.notExistMeasurements = queryPlan.getNotExistMeasurements();
-this.constMeasurements = queryPlan.getConstMeasurements();
-this.positionOfNotExistMeasurements = 
queryPlan.getPositionOfNotExistMeasurements();
-this.positionOfConstMeasurements = 
queryPlan.getPositionOfConstMeasurements();
+this.measurementColumnsGroupByDevice = 
alignByDevicePlan.getDeviceToMeasurementsMap();
+this.deviceToFilterMap = alignByDevicePlan.getDeviceToFilterMap();
+this.notExistMeasurements = alignByDevicePlan.getNotExistMeasurements();
+this.constMeasurements = alignByDevicePlan.getConstMeasurements();
+this.positionOfNotExistMeasurements = 
alignByDevicePlan.getPositionOfNotExistMeasurements();
+this.positionOfConstMeasurements = 
alignByDevicePlan.getPositionOfConstMeasurements();
 //BuildOutDataTypes();
 
-if (queryPlan instanceof GroupByPlan) {
+if (alignByDevicePlan.getGroupByPlan() != null) {
   this.dataSetType = DataSetType.GROUPBY;
   // assign parameters
-  this.unit = ((GroupByPlan) queryPlan).getInterval();
-  this.slidingStep = ((GroupByPlan) queryPlan).getSlidingStep();
-  this.startTime = ((GroupByPlan) queryPlan).getStartTime();
-  this.endTime = ((GroupByPlan) queryPlan).getEndTime();
+  this.unit = alignByDevicePlan.getGroupByPlan().getInterval();
 
 Review comment:
   Good Idea. Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378166987
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -207,7 +211,7 @@ protected boolean hasNextWithoutConstraint() throws 
IOException {
 currentDataSet = queryRouter.fill(fillQueryPlan, context);
 break;
   case QUERY:
-QueryPlan queryPlan = new QueryPlan();
+RawDataQueryPlan queryPlan = new RawDataQueryPlan();
 
 Review comment:
   Good Idea. Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378162915
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,39 +84,39 @@
   private int[] currentColumnMapRelation;
   private Map tsDataTypeMap;
 
-  public DeviceIterateDataSet(QueryPlan queryPlan, QueryContext context,
+  public DeviceIterateDataSet(AlignByDevicePlan alignByDevicePlan, 
QueryContext context,
   IQueryRouter queryRouter) {
-super(null, queryPlan.getDataTypes());
+super(null, alignByDevicePlan.getDataTypes());
 
 // get deduplicated measurement columns (already deduplicated in 
TSServiceImpl.executeDataQuery)
-this.deduplicatedMeasurementColumns = queryPlan.getMeasurements();
-this.tsDataTypeMap = queryPlan.getDataTypeMapping();
+this.deduplicatedMeasurementColumns = alignByDevicePlan.getMeasurements();
+this.tsDataTypeMap = alignByDevicePlan.getDataTypeMapping();
 this.queryRouter = queryRouter;
 this.context = context;
-this.measurementColumnsGroupByDevice = 
queryPlan.getMeasurementsGroupByDevice();
-this.deviceToFilterMap = queryPlan.getDeviceToFilterMap();
-this.notExistMeasurements = queryPlan.getNotExistMeasurements();
-this.constMeasurements = queryPlan.getConstMeasurements();
-this.positionOfNotExistMeasurements = 
queryPlan.getPositionOfNotExistMeasurements();
-this.positionOfConstMeasurements = 
queryPlan.getPositionOfConstMeasurements();
+this.measurementColumnsGroupByDevice = 
alignByDevicePlan.getDeviceToMeasurementsMap();
+this.deviceToFilterMap = alignByDevicePlan.getDeviceToFilterMap();
+this.notExistMeasurements = alignByDevicePlan.getNotExistMeasurements();
+this.constMeasurements = alignByDevicePlan.getConstMeasurements();
+this.positionOfNotExistMeasurements = 
alignByDevicePlan.getPositionOfNotExistMeasurements();
+this.positionOfConstMeasurements = 
alignByDevicePlan.getPositionOfConstMeasurements();
 //BuildOutDataTypes();
 
-if (queryPlan instanceof GroupByPlan) {
+if (alignByDevicePlan.getGroupByPlan() != null) {
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378159045
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,39 +84,39 @@
   private int[] currentColumnMapRelation;
   private Map tsDataTypeMap;
 
-  public DeviceIterateDataSet(QueryPlan queryPlan, QueryContext context,
+  public DeviceIterateDataSet(AlignByDevicePlan alignByDevicePlan, 
QueryContext context,
   IQueryRouter queryRouter) {
-super(null, queryPlan.getDataTypes());
+super(null, alignByDevicePlan.getDataTypes());
 
 // get deduplicated measurement columns (already deduplicated in 
TSServiceImpl.executeDataQuery)
-this.deduplicatedMeasurementColumns = queryPlan.getMeasurements();
-this.tsDataTypeMap = queryPlan.getDataTypeMapping();
+this.deduplicatedMeasurementColumns = alignByDevicePlan.getMeasurements();
+this.tsDataTypeMap = alignByDevicePlan.getDataTypeMapping();
 this.queryRouter = queryRouter;
 this.context = context;
-this.measurementColumnsGroupByDevice = 
queryPlan.getMeasurementsGroupByDevice();
-this.deviceToFilterMap = queryPlan.getDeviceToFilterMap();
-this.notExistMeasurements = queryPlan.getNotExistMeasurements();
-this.constMeasurements = queryPlan.getConstMeasurements();
-this.positionOfNotExistMeasurements = 
queryPlan.getPositionOfNotExistMeasurements();
-this.positionOfConstMeasurements = 
queryPlan.getPositionOfConstMeasurements();
+this.measurementColumnsGroupByDevice = 
alignByDevicePlan.getDeviceToMeasurementsMap();
+this.deviceToFilterMap = alignByDevicePlan.getDeviceToFilterMap();
+this.notExistMeasurements = alignByDevicePlan.getNotExistMeasurements();
+this.constMeasurements = alignByDevicePlan.getConstMeasurements();
+this.positionOfNotExistMeasurements = 
alignByDevicePlan.getPositionOfNotExistMeasurements();
+this.positionOfConstMeasurements = 
alignByDevicePlan.getPositionOfConstMeasurements();
 //BuildOutDataTypes();
 
-if (queryPlan instanceof GroupByPlan) {
+if (alignByDevicePlan.getGroupByPlan() != null) {
   this.dataSetType = DataSetType.GROUPBY;
   // assign parameters
-  this.unit = ((GroupByPlan) queryPlan).getInterval();
-  this.slidingStep = ((GroupByPlan) queryPlan).getSlidingStep();
-  this.startTime = ((GroupByPlan) queryPlan).getStartTime();
-  this.endTime = ((GroupByPlan) queryPlan).getEndTime();
+  this.unit = alignByDevicePlan.getGroupByPlan().getInterval();
+  this.slidingStep = alignByDevicePlan.getGroupByPlan().getSlidingStep();
+  this.startTime = alignByDevicePlan.getGroupByPlan().getStartTime();
+  this.endTime = alignByDevicePlan.getGroupByPlan().getEndTime();
 
-} else if (queryPlan instanceof AggregationPlan) {
+} else if (alignByDevicePlan.getAggregationPlan() != null) {
   this.dataSetType = DataSetType.AGGREGATE;
 
-} else if (queryPlan instanceof FillQueryPlan) {
+} else if (alignByDevicePlan.getFillQueryPlan() != null) {
   this.dataSetType = DataSetType.FILL;
   // assign parameters
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378157900
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/query/dataset/DeviceIterateDataSet.java
 ##
 @@ -80,39 +84,39 @@
   private int[] currentColumnMapRelation;
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378157494
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
 ##
 @@ -395,7 +408,7 @@ private PhysicalPlan transformQuery(QueryOperator 
queryOperator)
 
   if (filterOperator != null) {
 IExpression expression = filterOperator.transformToExpression();
-queryPlan.setExpression(expression);
+((RawDataQueryPlan) queryPlan).setExpression(expression);
   }
 }
 generateDataTypes(queryPlan);
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378157032
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
 ##
 @@ -242,16 +244,26 @@ private PhysicalPlan transformQuery(QueryOperator 
queryOperator)
   ((AggregationPlan) queryPlan)
   
.setAggregations(queryOperator.getSelectOperator().getAggregations());
 } else {
-  queryPlan = new QueryPlan();
+  queryPlan = new RawDataQueryPlan();
 }
 if (queryOperator.isGroupByDevice()) {
-  // below is the core realization of GROUP_BY_DEVICE sql logic
+  // below is the core realization of ALIGN_BY_DEVICE sql logic
+  AlignByDevicePlan alignByDevicePlan = new AlignByDevicePlan();
+  if (queryPlan instanceof GroupByPlan) {
+alignByDevicePlan.setGroupByPlan((GroupByPlan) queryPlan);
+  } else if (queryPlan instanceof FillQueryPlan) {
+alignByDevicePlan.setFillQueryPlan((FillQueryPlan) queryPlan);
+  } else if (queryPlan instanceof AggregationPlan) {
+alignByDevicePlan.setAggregationPlan((AggregationPlan) queryPlan);
+  }
+
+  queryPlan = alignByDevicePlan;
 
 Review comment:
   Thank you for advice! Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378143314
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
 
 Review comment:
   Actually, the paths in QueryPlan are paths of all devices. It's for 
verification and complete DataTypeMap to execute the datatypes for the 
execution paths this time in DataSet.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378148729
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
 ##
 @@ -242,16 +244,26 @@ private PhysicalPlan transformQuery(QueryOperator 
queryOperator)
   ((AggregationPlan) queryPlan)
   
.setAggregations(queryOperator.getSelectOperator().getAggregations());
 } else {
-  queryPlan = new QueryPlan();
+  queryPlan = new RawDataQueryPlan();
 }
 if (queryOperator.isGroupByDevice()) {
 
 Review comment:
   I think it's nice now.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378148847
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
 ##
 @@ -373,17 +386,17 @@ private PhysicalPlan transformQuery(QueryOperator 
queryOperator)
   }
 
   // assigns to queryPlan
-  queryPlan.setGroupByDevice(true);
-  queryPlan.setMeasurements(measurements);
-  queryPlan.setMeasurementsGroupByDevice(measurementsGroupByDevice);
-  queryPlan.setDataTypeConsistencyChecker(dataTypeConsistencyChecker);
+  ((AlignByDevicePlan) queryPlan).setMeasurements(measurements);
+  ((AlignByDevicePlan) 
queryPlan).setMeasurementsGroupByDevice(deviceToMeasurementsMap);
+  ((AlignByDevicePlan) 
queryPlan).setDataTypeConsistencyChecker(dataTypeConsistencyChecker);
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378148282
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
+  private Map dataTypeConsistencyChecker; // for group by 
device sql, e.g. root.ln.d1.temperature -> Float
+  private Map deviceToFilterMap; // for group by device 
sql
+
+  private GroupByPlan groupByPlan;
+  private FillQueryPlan fillQueryPlan;
+  private AggregationPlan aggregationPlan;
+
+  public AlignByDevicePlan() {
+super();
+  }
+
+  public AlignByDevicePlan(boolean isQuery, Operator.OperatorType 
operatorType) {
+super(isQuery, operatorType);
+  }
+
+  public void setMeasurements(List measurements) {
+this.measurements = measurements;
+  }
+
+  public List getMeasurements() {
+return measurements;
+  }
+
+  public void setMeasurementsGroupByDevice(
+  Map> deviceToMeasurementsMap) {
+this.deviceToMeasurementsMap = deviceToMeasurementsMap;
+  }
+
+  public Map> getDeviceToMeasurementsMap() {
+return deviceToMeasurementsMap;
+  }
+
+  public void setDataTypeConsistencyChecker(
+  Map dataTypeConsistencyChecker) {
+this.dataTypeConsistencyChecker = dataTypeConsistencyChecker;
+  }
+
+  public Map getDataTypeConsistencyChecker() {
+return dataTypeConsistencyChecker;
+  }
+
+  public Map getDeviceToFilterMap() {
+return deviceToFilterMap;
+  }
+
+  public void setDeviceToFilterMap(Map deviceToFilterMap) 
{
+this.deviceToFilterMap = deviceToFilterMap;
+  }
+
+  public GroupByPlan getGroupByPlan() {
+return groupByPlan;
+  }
+
+  public void setGroupByPlan(GroupByPlan groupByPlan) {
+this.groupByPlan = groupByPlan;
+this.setOperatorType(OperatorType.GROUPBY);
+  }
+
+  public FillQueryPlan getFillQueryPlan() {
+return fillQueryPlan;
+  }
+
+  public void setFillQueryPlan(FillQueryPlan fillQueryPlan) {
+this.fillQueryPlan = fillQueryPlan;
+this.setOperatorType(OperatorType.FILL);
+  }
+
+  public AggregationPlan getAggregationPlan() {
+return aggregationPlan;
+  }
+
+  public void setAggregationPlan(AggregationPlan aggregationPlan) {
+this.aggregationPlan = aggregationPlan;
+this.setOperatorType(Operator.OperatorType.AGGREGATION);
+  }
+
+  //the measurements that do not exist in any device,
+  // data type is considered as Boolean. The value is considered as null
+  private List notExistMeasurements = new ArrayList<>();
+  ; // for group by device sql
+  private List positionOfNotExistMeasurements = new ArrayList<>(); // 
for group by device sql
+  //the measurements that have quotation mark. e.g., "abc",
+  // '11', the data type is considered as String and the value  is considered 
is the same with measurement name
+  private List constMeasurements = new ArrayList<>(); // for group by 
device sql
+  private List positionOfConstMeasurements = new ArrayList<>(); // 
for group by device sql
+
+  //we use the following algorithm to reproduce the order of measurements that 
user writes.
+  //suppose user writes SELECT 'c1',a1,b1,b2,'c2',a2,a3,'c3',b3,a4,a5 FROM ... 
where for each a_i
+  // column there is at least one device having it, and for each b_i column 
there is no device
+  // having it, and 'c_i' is a const column.
+  // Then, measurements = {a1, a2, a3, a4, a5};
+  // notExistMeasurements = {b1, b2, b3}, and positionOfNotExistMeasurements = 
{2, 3, 8};
+  // constMeasurements = {'c1', 'c2', 

[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378146486
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
+  private Map dataTypeConsistencyChecker; // for group by 
device sql, e.g. root.ln.d1.temperature -> Float
+  private Map deviceToFilterMap; // for group by device 
sql
+
+  private GroupByPlan groupByPlan;
+  private FillQueryPlan fillQueryPlan;
+  private AggregationPlan aggregationPlan;
+
+  public AlignByDevicePlan() {
+super();
+  }
+
+  public AlignByDevicePlan(boolean isQuery, Operator.OperatorType 
operatorType) {
+super(isQuery, operatorType);
+  }
+
+  public void setMeasurements(List measurements) {
+this.measurements = measurements;
+  }
+
+  public List getMeasurements() {
+return measurements;
+  }
+
+  public void setMeasurementsGroupByDevice(
+  Map> deviceToMeasurementsMap) {
+this.deviceToMeasurementsMap = deviceToMeasurementsMap;
+  }
+
+  public Map> getDeviceToMeasurementsMap() {
+return deviceToMeasurementsMap;
+  }
+
+  public void setDataTypeConsistencyChecker(
+  Map dataTypeConsistencyChecker) {
+this.dataTypeConsistencyChecker = dataTypeConsistencyChecker;
+  }
+
+  public Map getDataTypeConsistencyChecker() {
+return dataTypeConsistencyChecker;
+  }
+
+  public Map getDeviceToFilterMap() {
+return deviceToFilterMap;
+  }
+
+  public void setDeviceToFilterMap(Map deviceToFilterMap) 
{
+this.deviceToFilterMap = deviceToFilterMap;
+  }
+
+  public GroupByPlan getGroupByPlan() {
+return groupByPlan;
+  }
+
+  public void setGroupByPlan(GroupByPlan groupByPlan) {
+this.groupByPlan = groupByPlan;
+this.setOperatorType(OperatorType.GROUPBY);
+  }
+
+  public FillQueryPlan getFillQueryPlan() {
+return fillQueryPlan;
+  }
+
+  public void setFillQueryPlan(FillQueryPlan fillQueryPlan) {
+this.fillQueryPlan = fillQueryPlan;
+this.setOperatorType(OperatorType.FILL);
+  }
+
+  public AggregationPlan getAggregationPlan() {
+return aggregationPlan;
+  }
+
+  public void setAggregationPlan(AggregationPlan aggregationPlan) {
+this.aggregationPlan = aggregationPlan;
+this.setOperatorType(Operator.OperatorType.AGGREGATION);
+  }
+
+  //the measurements that do not exist in any device,
+  // data type is considered as Boolean. The value is considered as null
+  private List notExistMeasurements = new ArrayList<>();
+  ; // for group by device sql
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378145663
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
+  private Map dataTypeConsistencyChecker; // for group by 
device sql, e.g. root.ln.d1.temperature -> Float
+  private Map deviceToFilterMap; // for group by device 
sql
+
+  private GroupByPlan groupByPlan;
+  private FillQueryPlan fillQueryPlan;
+  private AggregationPlan aggregationPlan;
+
+  public AlignByDevicePlan() {
+super();
+  }
+
+  public AlignByDevicePlan(boolean isQuery, Operator.OperatorType 
operatorType) {
+super(isQuery, operatorType);
+  }
+
+  public void setMeasurements(List measurements) {
+this.measurements = measurements;
+  }
+
+  public List getMeasurements() {
+return measurements;
+  }
+
+  public void setMeasurementsGroupByDevice(
+  Map> deviceToMeasurementsMap) {
+this.deviceToMeasurementsMap = deviceToMeasurementsMap;
+  }
+
+  public Map> getDeviceToMeasurementsMap() {
+return deviceToMeasurementsMap;
+  }
+
+  public void setDataTypeConsistencyChecker(
+  Map dataTypeConsistencyChecker) {
+this.dataTypeConsistencyChecker = dataTypeConsistencyChecker;
+  }
+
+  public Map getDataTypeConsistencyChecker() {
+return dataTypeConsistencyChecker;
+  }
+
+  public Map getDeviceToFilterMap() {
+return deviceToFilterMap;
+  }
+
+  public void setDeviceToFilterMap(Map deviceToFilterMap) 
{
+this.deviceToFilterMap = deviceToFilterMap;
+  }
+
+  public GroupByPlan getGroupByPlan() {
+return groupByPlan;
+  }
+
+  public void setGroupByPlan(GroupByPlan groupByPlan) {
+this.groupByPlan = groupByPlan;
+this.setOperatorType(OperatorType.GROUPBY);
+  }
+
+  public FillQueryPlan getFillQueryPlan() {
+return fillQueryPlan;
+  }
+
+  public void setFillQueryPlan(FillQueryPlan fillQueryPlan) {
+this.fillQueryPlan = fillQueryPlan;
+this.setOperatorType(OperatorType.FILL);
+  }
+
+  public AggregationPlan getAggregationPlan() {
+return aggregationPlan;
+  }
+
+  public void setAggregationPlan(AggregationPlan aggregationPlan) {
+this.aggregationPlan = aggregationPlan;
+this.setOperatorType(Operator.OperatorType.AGGREGATION);
+  }
+
+  //the measurements that do not exist in any device,
+  // data type is considered as Boolean. The value is considered as null
+  private List notExistMeasurements = new ArrayList<>();
+  ; // for group by device sql
+  private List positionOfNotExistMeasurements = new ArrayList<>(); // 
for group by device sql
+  //the measurements that have quotation mark. e.g., "abc",
+  // '11', the data type is considered as String and the value  is considered 
is the same with measurement name
+  private List constMeasurements = new ArrayList<>(); // for group by 
device sql
+  private List positionOfConstMeasurements = new ArrayList<>(); // 
for group by device sql
 
 Review comment:
   OK.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378145507
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
+  private Map dataTypeConsistencyChecker; // for group by 
device sql, e.g. root.ln.d1.temperature -> Float
+  private Map deviceToFilterMap; // for group by device 
sql
+
+  private GroupByPlan groupByPlan;
+  private FillQueryPlan fillQueryPlan;
+  private AggregationPlan aggregationPlan;
 
 Review comment:
   Of course there isn't a RawDataQueryPan. We don't need parameters in it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378145132
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
+  private Map dataTypeConsistencyChecker; // for group by 
device sql, e.g. root.ln.d1.temperature -> Float
 
 Review comment:
   Add a comment to explain it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378143497
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
+  private Map> deviceToMeasurementsMap; // for group by 
device sql, e.g. root.ln.d1 -> temperature
 
 Review comment:
   Fixed.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-iotdb] Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure QueryPlan

2020-02-12 Thread GitBox
Alima777 commented on a change in pull request #796: [IoTDB-468] Restructure 
QueryPlan
URL: https://github.com/apache/incubator-iotdb/pull/796#discussion_r378143314
 
 

 ##
 File path: 
server/src/main/java/org/apache/iotdb/db/qp/physical/crud/AlignByDevicePlan.java
 ##
 @@ -0,0 +1,181 @@
+/*
+ * 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.qp.physical.crud;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.iotdb.db.qp.logical.Operator;
+import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.read.expression.IExpression;
+
+public class AlignByDevicePlan extends QueryPlan {
+
+  private List measurements; // for group by device sql, e.g. 
temperature
 
 Review comment:
   Actually, the paths in QueryPlan are just for verification now and the 
acutal paths and datatypes are calculated for every device in DataSet. I will 
try reorganize the structure.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services