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

Support replication_num setting for table level #2737

Merged
merged 11 commits into from
Jan 18, 2020

Conversation

caiconghui
Copy link
Contributor

Support replication_num setting for table level, so There is no need for user to set replication_num for every alter table add partition statement.

@caiconghui
Copy link
Contributor Author

#2738

@@ -87,15 +87,13 @@ public short getReplicationNum() {
return this.properties;
}

public void analyze(int partColNum, Map<String, String> otherProperties) throws AnalysisException {
public void analyze(int partColNum, Map<String, String> otherProperties, Short replicationNum) throws AnalysisException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it is a good way to analyze this class with a input replicationNum. It is up to the caller to decide how to use this object.
If we do this through input arguments, there will be too many arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will fix it

@@ -148,6 +150,8 @@ public OlapTable() {
this.indexes = null;

this.tableProperty = null;

this.replicationNum = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can add this this.replicationNum to the tableProperty so that we do not need to update the FeMetaVersion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current analyzer will remove all the table property after analyzed, include replication_num, so is it a better way to change this design?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. I will fix it

@@ -3908,6 +3907,12 @@ public static void getDdlStmt(Table table, List<String> createTableStmt, List<St
sb.append(olapTable.getTableProperty().getDynamicPartitionProperty().toString());
}

// 7. replicationNum
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not add replication num in create table stmt, cause it does not reflect the real replication num of each partition of a table.

Copy link
Contributor Author

@caiconghui caiconghui Jan 12, 2020

Choose a reason for hiding this comment

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

I think just like the DISTRIBUTED BY HASH(id) BUCKETS 5, which also does not reflect the real hash info of each partition of a table. so in the create table it just show the baisc config for the table and user can still set different distribution info for the special partition
the real table status like partition real information should be got by show partitions statement, and create table statement show only show the basic config for the table and the initial status

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I agree with u.

@@ -242,6 +242,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;

import static org.apache.doris.common.util.PropertyAnalyzer.PROPERTIES_REPLICATION_NUM;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use static import

tableProperty.getProperties().put(PropertyAnalyzer.PROPERTIES_REPLICATION_NUM, replicationNum.toString());
}

public Short getReplicationNum() {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about just return FeConstants.default_replication_num is there is no default replica num?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that may confused user. Because the user doesn't set the replication_num in table level,
however, FeConstants.default_replication_num can be changed by admin, and when user don't modify config for table, he may find the replication_num config in table level changed, return null indicate that we don't set any replication_num config in table level, and then we use FeConstants.default_replication_num

@@ -1203,4 +1203,19 @@ public boolean convertRandomDistributionToHashDistribution() {
}
return hasChanged;
}

public void setReplicationNum(Short replicationNum) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment of TableProperty about how to modify and use this class.
You should add a new field defaultReplicaNum in TableProperty, and this field is built from properties.
Also, a method buildDefaultReplicaNum() should be implemented.

tableProperty.modifyTableProperties(properties);
}
tableProperty.buildReplicationNum();
ModifyTablePropertyOperationLog info = new ModifyTablePropertyOperationLog(db.getId(), table.getId(), table.getTableProperty().getProperties());
Copy link
Contributor

Choose a reason for hiding this comment

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

You do not need to log all properties in TableProperty, only properties is enough

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman merged commit ae01804 into apache:master Jan 18, 2020
@chaoyli chaoyli mentioned this pull request Feb 10, 2020
@caiconghui caiconghui deleted the replication_num branch May 25, 2020 03:08
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.

3 participants