-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New feature](statistics) Step1: Statistics collection framework
Framework code for statistics collection, containing only the main data structures, no implementation details. This pr will not affect any existing code and users will not be able to create statistics job.
- Loading branch information
1 parent
ee0037e
commit a9da0d2
Showing
17 changed files
with
726 additions
and
21 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyzeStmt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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.doris.analysis; | ||
|
||
/** | ||
* Collect statistics about a database | ||
* | ||
* syntax: | ||
* ANALYZE [[ db_name.tb_name ] [( column_name [, ...] )], ...] [ PROPERTIES(...) ] | ||
* | ||
* db_name.tb_name: collect table and column statistics from tb_name | ||
* | ||
* column_name: collect column statistics from column_name | ||
* | ||
* properties: properties of statistics jobs | ||
* | ||
*/ | ||
public class AnalyzeStmt extends DdlStmt { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
fe/fe-core/src/main/java/org/apache/doris/statistics/MetaStatisticsTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// 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.doris.statistics; | ||
|
||
import java.util.List; | ||
|
||
/* | ||
A statistics task that directly collects statistics by reading FE meta. | ||
*/ | ||
public class MetaStatisticsTask extends StatisticsTask { | ||
|
||
public MetaStatisticsTask(long jobId, StatsGranularityDesc granularityDesc, | ||
StatsCategoryDesc categoryDesc, List<StatsType> statsTypeList) { | ||
super(jobId, granularityDesc, categoryDesc, statsTypeList); | ||
} | ||
|
||
@Override | ||
public StatisticsTaskResult call() throws Exception { | ||
// TODO | ||
return null; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
fe/fe-core/src/main/java/org/apache/doris/statistics/SQLStatisticsTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// 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.doris.statistics; | ||
|
||
import org.apache.doris.analysis.SelectStmt; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.Maps; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/* | ||
A statistics task that collects statistics by executing query. | ||
The results of the query will be returned as @StatisticsTaskResult. | ||
*/ | ||
public class SQLStatisticsTask extends StatisticsTask { | ||
private SelectStmt query; | ||
|
||
public SQLStatisticsTask(long jobId, StatsGranularityDesc granularityDesc, | ||
StatsCategoryDesc categoryDesc, List<StatsType> statsTypeList) { | ||
super(jobId, granularityDesc, categoryDesc, statsTypeList); | ||
} | ||
|
||
@Override | ||
public StatisticsTaskResult call() throws Exception { | ||
// TODO | ||
// step1: construct query by statsDescList | ||
constructQuery(); | ||
// step2: execute query | ||
// the result should be sequence by @statsTypeList | ||
List<String> queryResultList = executeQuery(query); | ||
// step3: construct StatisticsTaskResult by query result | ||
constructTaskResult(queryResultList); | ||
return null; | ||
} | ||
|
||
protected void constructQuery() { | ||
// TODO | ||
// step1: construct FROM by @granularityDesc | ||
// step2: construct SELECT LIST by @statsTypeList | ||
} | ||
|
||
protected List<String> executeQuery(SelectStmt query) { | ||
// TODO (ML) | ||
return null; | ||
} | ||
|
||
protected StatisticsTaskResult constructTaskResult(List<String> queryResultList) { | ||
Preconditions.checkState(statsTypeList.size() == queryResultList.size()); | ||
Map<StatsType, String> statsTypeToValue = Maps.newHashMap(); | ||
for (int i = 0; i < statsTypeList.size(); i++) { | ||
statsTypeToValue.put(statsTypeList.get(i), queryResultList.get(i)); | ||
} | ||
StatisticsTaskResult result = new StatisticsTaskResult(granularityDesc, categoryDesc, statsTypeToValue); | ||
return result; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
fe/fe-core/src/main/java/org/apache/doris/statistics/SampleSQLStatisticsTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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.doris.statistics; | ||
|
||
import org.apache.doris.common.Config; | ||
|
||
import java.util.List; | ||
|
||
/* | ||
The @SampleSQLStatisticsTask is also a statistical task that executes a query | ||
and uses the query result as a statistical value (same as @SQLStatisticsTask). | ||
The only difference from the SQLStatisticsTask is that the query is a sampling table query. | ||
*/ | ||
public class SampleSQLStatisticsTask extends SQLStatisticsTask { | ||
private float samplePercentage = Config.default_sample_percentage; | ||
|
||
public SampleSQLStatisticsTask(long jobId, StatsGranularityDesc granularityDesc, | ||
StatsCategoryDesc categoryDesc, List<StatsType> statsTypeList) { | ||
super(jobId, granularityDesc, categoryDesc, statsTypeList); | ||
} | ||
|
||
@Override | ||
protected void constructQuery() { | ||
// TODO | ||
super.constructQuery(); | ||
// step1: construct table sample | ||
} | ||
} |
Oops, something went wrong.