Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOTDB-527] Refactor series reader #864

Merged
merged 32 commits into from Mar 3, 2020
Merged

Conversation

qiaojialin
Copy link
Member

remove hasOverlappedPage & isPageOverlapped methods in IAggregateReader

optimize logic in series reader

@qiaojialin qiaojialin changed the title [IOTDB-527] Optimize series reader [IOTDB-527] Refactor series reader Mar 2, 2020
Copy link
Contributor

@JackieTien97 JackieTien97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the Group by parallel, it seems that it will create new future task and invoke future.get() each time nextWithoutConstraint() is called. This way is like the first version's raw data query parallel that I implements. It will slower the query instead of speeding up.

Comment on lines 67 to 69
if (!satisfyTimeFilter(seriesReader.currentChunkStatistics())) {
seriesReader.skipCurrentChunk();
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here delete this, if we can know from the chunk statistics that the chunk is not satisfied, we can just skip that chunk

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made up for it

Comment on lines 132 to 108
public boolean hasNextChunk() throws IOException {
if (hasCachedFirstChunkMetadata) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that if I keep calling hasNextChunk(), the firstChunkMetaData will move to next all the time.
you can add an if statement.
if (firstChunkMetaData != null)
return true;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if (remainingToCalculate == 0) {
return aggregateResultList;

private class GroupByExecutor {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better name it GroupByTask

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no , i like executor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executor or task are all fine to me

Comment on lines 85 to 88
QueryDataSource queryDataSource = QueryResourceManager.getInstance()
.getQueryDataSource(path, context, timeFilter);
// update filter by TTL
timeFilter = queryDataSource.updateFilterUsingTTL(timeFilter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to construct these two, if pathExecutors already has the path

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@liutaohua
Copy link
Contributor

About the Group by parallel, it seems that it will create new future task and invoke future.get() each time nextWithoutConstraint() is called. This way is like the first version's raw data query parallel that I implements. It will slower the query instead of speeding up.

Thank you very much for your reminding. I will continue to study why is it slow

Copy link
Contributor

@JackieTien97 JackieTien97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some places still needs to be fixed

}
} catch (QueryProcessException e) {
logger.error("GroupByWithoutValueFilterDataSet execute has error,{}", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use {},just
logger.error("GroupByWithoutValueFilterDataSet execute has error ", e);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -85,7 +86,7 @@ private static void insertData()
.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
Statement statement = connection.createStatement()) {

for (String sql : Constant.create_sql) {
for (String sql : org.apache.iotdb.db.constant.TestConstant.create_sql) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (String sql : org.apache.iotdb.db.constant.TestConstant.create_sql) {
for (String sql : TestConstant.create_sql) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -138,7 +139,7 @@ public void selectAllTest() throws ClassNotFoundException {
int cnt1 = 0;
while (resultSet1.next() && cnt1 < 5) {
StringBuilder builder = new StringBuilder();
builder.append(resultSet1.getString(Constant.TIMESTAMP_STR))
builder.append(resultSet1.getString(org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
builder.append(resultSet1.getString(org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR))
builder.append(resultSet1.getString(TestConstant.TIMESTAMP_STR))

@@ -154,7 +155,7 @@ public void selectAllTest() throws ClassNotFoundException {
int cnt2 = 0;
while (resultSet2.next()) {
StringBuilder builder = new StringBuilder();
builder.append(resultSet2.getString(Constant.TIMESTAMP_STR))
builder.append(resultSet2.getString(org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
builder.append(resultSet2.getString(org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR))
builder.append(resultSet2.getString(TestConstant.TIMESTAMP_STR))

Comment on lines 48 to 49
private static String filePath1 = org.apache.iotdb.db.constant.TestConstant.BASE_OUTPUT_PATH.concat("watermarked_query_result.csv");
private static String filePath2 = org.apache.iotdb.db.constant.TestConstant.BASE_OUTPUT_PATH.concat("notWatermarked_query_result.csv");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static String filePath1 = org.apache.iotdb.db.constant.TestConstant.BASE_OUTPUT_PATH.concat("watermarked_query_result.csv");
private static String filePath2 = org.apache.iotdb.db.constant.TestConstant.BASE_OUTPUT_PATH.concat("notWatermarked_query_result.csv");
private static String filePath1 = TestConstant.BASE_OUTPUT_PATH.concat("watermarked_query_result.csv");
private static String filePath2 = TestConstant.BASE_OUTPUT_PATH.concat("notWatermarked_query_result.csv");

@sonarcloud
Copy link

sonarcloud bot commented Mar 2, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 9 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@JackieTien97 JackieTien97 self-requested a review March 2, 2020 15:26
Copy link
Contributor

@JackieTien97 JackieTien97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qiaojialin qiaojialin merged commit c00b63f into master Mar 3, 2020
@qiaojialin qiaojialin deleted the optimize_series_reader branch March 3, 2020 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants