未验证 提交 5a752b0d 编写于 作者: W wangchao316 提交者: GitHub

[IOTDB-1267] optimize ServerTimeGenerator IExpression parameter (#2955)

上级 453d95dc
...@@ -38,7 +38,6 @@ import org.apache.iotdb.db.query.executor.RawDataQueryExecutor; ...@@ -38,7 +38,6 @@ import org.apache.iotdb.db.query.executor.RawDataQueryExecutor;
import org.apache.iotdb.db.query.reader.series.IReaderByTimestamp; import org.apache.iotdb.db.query.reader.series.IReaderByTimestamp;
import org.apache.iotdb.db.query.reader.series.ManagedSeriesReader; import org.apache.iotdb.db.query.reader.series.ManagedSeriesReader;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.expression.IExpression;
import org.apache.iotdb.tsfile.read.expression.impl.GlobalTimeExpression; import org.apache.iotdb.tsfile.read.expression.impl.GlobalTimeExpression;
import org.apache.iotdb.tsfile.read.filter.basic.Filter; import org.apache.iotdb.tsfile.read.filter.basic.Filter;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet; import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
...@@ -200,11 +199,9 @@ public class ClusterDataQueryExecutor extends RawDataQueryExecutor { ...@@ -200,11 +199,9 @@ public class ClusterDataQueryExecutor extends RawDataQueryExecutor {
} }
@Override @Override
protected TimeGenerator getTimeGenerator( protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan rawDataQueryPlan)
IExpression queryExpression, QueryContext context, RawDataQueryPlan rawDataQueryPlan)
throws StorageEngineException { throws StorageEngineException {
return new ClusterTimeGenerator( return new ClusterTimeGenerator(context, metaGroupMember, rawDataQueryPlan, false);
queryExpression, context, metaGroupMember, rawDataQueryPlan, false);
} }
@Override @Override
...@@ -214,8 +211,7 @@ public class ClusterDataQueryExecutor extends RawDataQueryExecutor { ...@@ -214,8 +211,7 @@ public class ClusterDataQueryExecutor extends RawDataQueryExecutor {
if (hasValueFilter) { if (hasValueFilter) {
// 1. check time Generator has local data // 1. check time Generator has local data
ClusterTimeGenerator clusterTimeGenerator = ClusterTimeGenerator clusterTimeGenerator =
new ClusterTimeGenerator( new ClusterTimeGenerator(context, metaGroupMember, queryPlan, true);
queryPlan.getExpression(), context, metaGroupMember, queryPlan, true);
if (clusterTimeGenerator.isHasLocalReader()) { if (clusterTimeGenerator.isHasLocalReader()) {
this.hasLocalReader = true; this.hasLocalReader = true;
this.endPoint = null; this.endPoint = null;
......
...@@ -85,7 +85,7 @@ public class ClusterAggregateExecutor extends AggregationExecutor { ...@@ -85,7 +85,7 @@ public class ClusterAggregateExecutor extends AggregationExecutor {
@Override @Override
protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan rawDataQueryPlan) protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan rawDataQueryPlan)
throws StorageEngineException { throws StorageEngineException {
return new ClusterTimeGenerator(expression, context, metaMember, rawDataQueryPlan, false); return new ClusterTimeGenerator(context, metaMember, rawDataQueryPlan, false);
} }
@Override @Override
......
...@@ -33,7 +33,6 @@ import org.apache.iotdb.db.query.dataset.groupby.GroupByWithValueFilterDataSet; ...@@ -33,7 +33,6 @@ import org.apache.iotdb.db.query.dataset.groupby.GroupByWithValueFilterDataSet;
import org.apache.iotdb.db.query.filter.TsFileFilter; import org.apache.iotdb.db.query.filter.TsFileFilter;
import org.apache.iotdb.db.query.reader.series.IReaderByTimestamp; import org.apache.iotdb.db.query.reader.series.IReaderByTimestamp;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.expression.IExpression;
import org.apache.iotdb.tsfile.read.query.timegenerator.TimeGenerator; import org.apache.iotdb.tsfile.read.query.timegenerator.TimeGenerator;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -60,10 +59,9 @@ public class ClusterGroupByVFilterDataSet extends GroupByWithValueFilterDataSet ...@@ -60,10 +59,9 @@ public class ClusterGroupByVFilterDataSet extends GroupByWithValueFilterDataSet
} }
@Override @Override
protected TimeGenerator getTimeGenerator( protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan rawDataQueryPlan)
IExpression expression, QueryContext context, RawDataQueryPlan rawDataQueryPlan)
throws StorageEngineException { throws StorageEngineException {
return new ClusterTimeGenerator(expression, context, metaGroupMember, rawDataQueryPlan, false); return new ClusterTimeGenerator(context, metaGroupMember, rawDataQueryPlan, false);
} }
@Override @Override
......
...@@ -58,7 +58,6 @@ public class ClusterTimeGenerator extends ServerTimeGenerator { ...@@ -58,7 +58,6 @@ public class ClusterTimeGenerator extends ServerTimeGenerator {
/** Constructor of EngineTimeGenerator. */ /** Constructor of EngineTimeGenerator. */
public ClusterTimeGenerator( public ClusterTimeGenerator(
IExpression expression,
QueryContext context, QueryContext context,
MetaGroupMember metaGroupMember, MetaGroupMember metaGroupMember,
RawDataQueryPlan rawDataQueryPlan, RawDataQueryPlan rawDataQueryPlan,
...@@ -70,9 +69,10 @@ public class ClusterTimeGenerator extends ServerTimeGenerator { ...@@ -70,9 +69,10 @@ public class ClusterTimeGenerator extends ServerTimeGenerator {
try { try {
readerFactory.syncMetaGroup(); readerFactory.syncMetaGroup();
if (onlyCheckLocalData) { if (onlyCheckLocalData) {
whetherHasLocalDataGroup(expression, metaGroupMember, queryPlan.isAscending()); whetherHasLocalDataGroup(
queryPlan.getExpression(), metaGroupMember, queryPlan.isAscending());
} else { } else {
constructNode(expression); constructNode(queryPlan.getExpression());
} }
} catch (IOException | CheckConsistencyException e) { } catch (IOException | CheckConsistencyException e) {
throw new StorageEngineException(e); throw new StorageEngineException(e);
......
...@@ -62,7 +62,7 @@ public class ClusterTimeGeneratorTest extends BaseQueryTest { ...@@ -62,7 +62,7 @@ public class ClusterTimeGeneratorTest extends BaseQueryTest {
dataQueryPlan.addDeduplicatedPaths(new PartialPath(TestUtils.getTestSeries(1, 1))); dataQueryPlan.addDeduplicatedPaths(new PartialPath(TestUtils.getTestSeries(1, 1)));
ClusterTimeGenerator timeGenerator = ClusterTimeGenerator timeGenerator =
new ClusterTimeGenerator(expression, context, testMetaMember, dataQueryPlan, false); new ClusterTimeGenerator(context, testMetaMember, dataQueryPlan, false);
for (int i = 3; i <= 8; i++) { for (int i = 3; i <= 8; i++) {
assertTrue(timeGenerator.hasNext()); assertTrue(timeGenerator.hasNext());
assertEquals(i, timeGenerator.next()); assertEquals(i, timeGenerator.next());
......
...@@ -39,7 +39,6 @@ import org.apache.iotdb.db.utils.TestOnly; ...@@ -39,7 +39,6 @@ import org.apache.iotdb.db.utils.TestOnly;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.common.Path; import org.apache.iotdb.tsfile.read.common.Path;
import org.apache.iotdb.tsfile.read.common.RowRecord; import org.apache.iotdb.tsfile.read.common.RowRecord;
import org.apache.iotdb.tsfile.read.expression.IExpression;
import org.apache.iotdb.tsfile.read.query.timegenerator.TimeGenerator; import org.apache.iotdb.tsfile.read.query.timegenerator.TimeGenerator;
import org.apache.iotdb.tsfile.utils.Pair; import org.apache.iotdb.tsfile.utils.Pair;
...@@ -81,8 +80,7 @@ public class GroupByWithValueFilterDataSet extends GroupByEngineDataSet { ...@@ -81,8 +80,7 @@ public class GroupByWithValueFilterDataSet extends GroupByEngineDataSet {
/** init reader and aggregate function. */ /** init reader and aggregate function. */
protected void initGroupBy(QueryContext context, GroupByTimePlan groupByTimePlan) protected void initGroupBy(QueryContext context, GroupByTimePlan groupByTimePlan)
throws StorageEngineException, QueryProcessException { throws StorageEngineException, QueryProcessException {
this.timestampGenerator = this.timestampGenerator = getTimeGenerator(context, groupByTimePlan);
getTimeGenerator(groupByTimePlan.getExpression(), context, groupByTimePlan);
this.allDataReaderList = new ArrayList<>(); this.allDataReaderList = new ArrayList<>();
this.groupByTimePlan = groupByTimePlan; this.groupByTimePlan = groupByTimePlan;
...@@ -100,10 +98,9 @@ public class GroupByWithValueFilterDataSet extends GroupByEngineDataSet { ...@@ -100,10 +98,9 @@ public class GroupByWithValueFilterDataSet extends GroupByEngineDataSet {
} }
} }
protected TimeGenerator getTimeGenerator( protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan queryPlan)
IExpression expression, QueryContext context, RawDataQueryPlan queryPlan)
throws StorageEngineException { throws StorageEngineException {
return new ServerTimeGenerator(expression, context, queryPlan); return new ServerTimeGenerator(context, queryPlan);
} }
protected IReaderByTimestamp getReaderByTime( protected IReaderByTimestamp getReaderByTime(
......
...@@ -390,7 +390,7 @@ public class AggregationExecutor { ...@@ -390,7 +390,7 @@ public class AggregationExecutor {
protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan queryPlan) protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan queryPlan)
throws StorageEngineException { throws StorageEngineException {
return new ServerTimeGenerator(expression, context, queryPlan); return new ServerTimeGenerator(context, queryPlan);
} }
protected IReaderByTimestamp getReaderByTime( protected IReaderByTimestamp getReaderByTime(
......
...@@ -36,7 +36,6 @@ import org.apache.iotdb.db.query.reader.series.SeriesRawDataBatchReader; ...@@ -36,7 +36,6 @@ import org.apache.iotdb.db.query.reader.series.SeriesRawDataBatchReader;
import org.apache.iotdb.db.query.reader.series.SeriesReaderByTimestamp; import org.apache.iotdb.db.query.reader.series.SeriesReaderByTimestamp;
import org.apache.iotdb.db.query.timegenerator.ServerTimeGenerator; import org.apache.iotdb.db.query.timegenerator.ServerTimeGenerator;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.iotdb.tsfile.read.expression.IExpression;
import org.apache.iotdb.tsfile.read.expression.impl.GlobalTimeExpression; import org.apache.iotdb.tsfile.read.expression.impl.GlobalTimeExpression;
import org.apache.iotdb.tsfile.read.filter.basic.Filter; import org.apache.iotdb.tsfile.read.filter.basic.Filter;
import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet; import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
...@@ -146,8 +145,7 @@ public class RawDataQueryExecutor { ...@@ -146,8 +145,7 @@ public class RawDataQueryExecutor {
return dataSet; return dataSet;
} }
TimeGenerator timestampGenerator = TimeGenerator timestampGenerator = getTimeGenerator(context, queryPlan);
getTimeGenerator(queryPlan.getExpression(), context, queryPlan);
List<Boolean> cached = List<Boolean> cached =
markFilterdPaths( markFilterdPaths(
queryPlan.getExpression(), queryPlan.getExpression(),
...@@ -204,10 +202,9 @@ public class RawDataQueryExecutor { ...@@ -204,10 +202,9 @@ public class RawDataQueryExecutor {
queryPlan.isAscending()); queryPlan.isAscending());
} }
protected TimeGenerator getTimeGenerator( protected TimeGenerator getTimeGenerator(QueryContext context, RawDataQueryPlan queryPlan)
IExpression expression, QueryContext context, RawDataQueryPlan queryPlan)
throws StorageEngineException { throws StorageEngineException {
return new ServerTimeGenerator(expression, context, queryPlan); return new ServerTimeGenerator(context, queryPlan);
} }
/** /**
......
...@@ -58,8 +58,7 @@ public class UDTFQueryExecutor extends RawDataQueryExecutor { ...@@ -58,8 +58,7 @@ public class UDTFQueryExecutor extends RawDataQueryExecutor {
public QueryDataSet executeWithValueFilterAlignByTime(QueryContext context) public QueryDataSet executeWithValueFilterAlignByTime(QueryContext context)
throws StorageEngineException, QueryProcessException, IOException { throws StorageEngineException, QueryProcessException, IOException {
TimeGenerator timestampGenerator = TimeGenerator timestampGenerator = getTimeGenerator(context, udtfPlan);
getTimeGenerator(udtfPlan.getExpression(), context, udtfPlan);
List<Boolean> cached = List<Boolean> cached =
markFilterdPaths( markFilterdPaths(
udtfPlan.getExpression(), udtfPlan.getExpression(),
...@@ -90,8 +89,7 @@ public class UDTFQueryExecutor extends RawDataQueryExecutor { ...@@ -90,8 +89,7 @@ public class UDTFQueryExecutor extends RawDataQueryExecutor {
public QueryDataSet executeWithValueFilterNonAlign(QueryContext context) public QueryDataSet executeWithValueFilterNonAlign(QueryContext context)
throws QueryProcessException, StorageEngineException, IOException { throws QueryProcessException, StorageEngineException, IOException {
TimeGenerator timestampGenerator = TimeGenerator timestampGenerator = getTimeGenerator(context, udtfPlan);
getTimeGenerator(udtfPlan.getExpression(), context, udtfPlan);
List<Boolean> cached = List<Boolean> cached =
markFilterdPaths( markFilterdPaths(
udtfPlan.getExpression(), udtfPlan.getExpression(),
......
...@@ -58,13 +58,12 @@ public class ServerTimeGenerator extends TimeGenerator { ...@@ -58,13 +58,12 @@ public class ServerTimeGenerator extends TimeGenerator {
} }
/** Constructor of EngineTimeGenerator. */ /** Constructor of EngineTimeGenerator. */
public ServerTimeGenerator( public ServerTimeGenerator(QueryContext context, RawDataQueryPlan queryPlan)
IExpression expression, QueryContext context, RawDataQueryPlan queryPlan)
throws StorageEngineException { throws StorageEngineException {
this.context = context; this.context = context;
this.queryPlan = queryPlan; this.queryPlan = queryPlan;
try { try {
serverConstructNode(expression); serverConstructNode(queryPlan.getExpression());
} catch (IOException e) { } catch (IOException e) {
throw new StorageEngineException(e); throw new StorageEngineException(e);
} }
......
...@@ -22,6 +22,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor; ...@@ -22,6 +22,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.constant.TestConstant; import org.apache.iotdb.db.constant.TestConstant;
import org.apache.iotdb.db.exception.StorageEngineException; import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.exception.metadata.IllegalPathException; import org.apache.iotdb.db.exception.metadata.IllegalPathException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.db.metadata.PartialPath; import org.apache.iotdb.db.metadata.PartialPath;
import org.apache.iotdb.db.qp.physical.crud.RawDataQueryPlan; import org.apache.iotdb.db.qp.physical.crud.RawDataQueryPlan;
import org.apache.iotdb.db.query.timegenerator.ServerTimeGenerator; import org.apache.iotdb.db.query.timegenerator.ServerTimeGenerator;
...@@ -188,7 +189,7 @@ public class IoTDBEngineTimeGeneratorIT { ...@@ -188,7 +189,7 @@ public class IoTDBEngineTimeGeneratorIT {
/** value >= 14 && time > 500 */ /** value >= 14 && time > 500 */
@Test @Test
public void testOneSeriesWithValueAndTimeFilter() public void testOneSeriesWithValueAndTimeFilter()
throws IOException, StorageEngineException, IllegalPathException { throws IOException, StorageEngineException, IllegalPathException, QueryProcessException {
// System.out.println("Test >>> root.vehicle.d0.s0 >= 14 && time > 500"); // System.out.println("Test >>> root.vehicle.d0.s0 >= 14 && time > 500");
PartialPath pd0s0 = PartialPath pd0s0 =
...@@ -202,8 +203,8 @@ public class IoTDBEngineTimeGeneratorIT { ...@@ -202,8 +203,8 @@ public class IoTDBEngineTimeGeneratorIT {
List<PartialPath> paths = new ArrayList<>(); List<PartialPath> paths = new ArrayList<>();
paths.add(pd0s0); paths.add(pd0s0);
queryPlan.setDeduplicatedPaths(paths); queryPlan.setDeduplicatedPaths(paths);
ServerTimeGenerator timeGenerator = queryPlan.setExpression(singleSeriesExpression);
new ServerTimeGenerator(singleSeriesExpression, TEST_QUERY_CONTEXT, queryPlan); ServerTimeGenerator timeGenerator = new ServerTimeGenerator(TEST_QUERY_CONTEXT, queryPlan);
int cnt = 0; int cnt = 0;
while (timeGenerator.hasNext()) { while (timeGenerator.hasNext()) {
...@@ -218,7 +219,7 @@ public class IoTDBEngineTimeGeneratorIT { ...@@ -218,7 +219,7 @@ public class IoTDBEngineTimeGeneratorIT {
/** root.vehicle.d1.s0 >= 5, and d1.s0 has no data */ /** root.vehicle.d1.s0 >= 5, and d1.s0 has no data */
@Test @Test
public void testEmptySeriesWithValueFilter() public void testEmptySeriesWithValueFilter()
throws IOException, StorageEngineException, IllegalPathException { throws IOException, StorageEngineException, IllegalPathException, QueryProcessException {
// System.out.println("Test >>> root.vehicle.d1.s0 >= 5"); // System.out.println("Test >>> root.vehicle.d1.s0 >= 5");
PartialPath pd1s0 = PartialPath pd1s0 =
...@@ -230,9 +231,8 @@ public class IoTDBEngineTimeGeneratorIT { ...@@ -230,9 +231,8 @@ public class IoTDBEngineTimeGeneratorIT {
List<PartialPath> paths = new ArrayList<>(); List<PartialPath> paths = new ArrayList<>();
paths.add(pd1s0); paths.add(pd1s0);
queryPlan.setDeduplicatedPaths(paths); queryPlan.setDeduplicatedPaths(paths);
queryPlan.setExpression(singleSeriesExpression);
ServerTimeGenerator timeGenerator = ServerTimeGenerator timeGenerator = new ServerTimeGenerator(TEST_QUERY_CONTEXT, queryPlan);
new ServerTimeGenerator(singleSeriesExpression, TEST_QUERY_CONTEXT, queryPlan);
int cnt = 0; int cnt = 0;
while (timeGenerator.hasNext()) { while (timeGenerator.hasNext()) {
...@@ -244,7 +244,7 @@ public class IoTDBEngineTimeGeneratorIT { ...@@ -244,7 +244,7 @@ public class IoTDBEngineTimeGeneratorIT {
/** root.vehicle.d0.s0 >= 5 && root.vehicle.d0.s2 >= 11.5 || time > 900 */ /** root.vehicle.d0.s0 >= 5 && root.vehicle.d0.s2 >= 11.5 || time > 900 */
@Test @Test
public void testMultiSeriesWithValueFilterAndTimeFilter() public void testMultiSeriesWithValueFilterAndTimeFilter()
throws IOException, StorageEngineException, IllegalPathException { throws IOException, StorageEngineException, IllegalPathException, QueryProcessException {
System.out.println( System.out.println(
"Test >>> root.vehicle.d0.s0 >= 5 && root.vehicle.d0.s2 >= 11.5 || time > 900"); "Test >>> root.vehicle.d0.s0 >= 5 && root.vehicle.d0.s2 >= 11.5 || time > 900");
...@@ -269,8 +269,8 @@ public class IoTDBEngineTimeGeneratorIT { ...@@ -269,8 +269,8 @@ public class IoTDBEngineTimeGeneratorIT {
paths.add(pd0s0); paths.add(pd0s0);
paths.add(pd0s2); paths.add(pd0s2);
queryPlan.setDeduplicatedPaths(paths); queryPlan.setDeduplicatedPaths(paths);
ServerTimeGenerator timeGenerator = queryPlan.setExpression(andExpression);
new ServerTimeGenerator(andExpression, TEST_QUERY_CONTEXT, queryPlan); ServerTimeGenerator timeGenerator = new ServerTimeGenerator(TEST_QUERY_CONTEXT, queryPlan);
int cnt = 0; int cnt = 0;
while (timeGenerator.hasNext()) { while (timeGenerator.hasNext()) {
long time = timeGenerator.next(); long time = timeGenerator.next();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册