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

[#6638]Optimize method listColumnPOsByTableIdAndVersion to make it more efficient #6640

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
implementation(libs.commons.dbcp2)
implementation(libs.commons.io)
implementation(libs.commons.lang3)
implementation(libs.commons.collections4)
implementation(libs.guava)
implementation(libs.h2db)
implementation(libs.mybatis)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import lombok.ToString;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.gravitino.Auditable;
import org.apache.gravitino.Entity;
import org.apache.gravitino.Field;
Expand Down Expand Up @@ -131,11 +132,14 @@ public boolean equals(Object o) {
}

TableEntity baseTable = (TableEntity) o;
// Objects.equal() will judge the sequence of elements in the list. For example, if the
// sequence of columns is different, it will return false. So we need to use
// CollectionUtils.isEqualCollection() to compare the two lists.
return Objects.equal(id, baseTable.id)
&& Objects.equal(name, baseTable.name)
&& Objects.equal(namespace, baseTable.namespace)
&& Objects.equal(auditInfo, baseTable.auditInfo)
&& Objects.equal(columns, baseTable.columns);
&& CollectionUtils.isEqualCollection(columns, baseTable.columns);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public String listColumnPOsByTableIdAndVersion(
+ TableColumnMapper.COLUMN_TABLE_NAME
+ " WHERE table_id = #{tableId} AND table_version <= #{tableVersion} AND deleted_at = 0"
+ " GROUP BY column_id) t2"
+ " ON t1.column_id = t2.column_id AND t1.table_version = t2.max_table_version";
+ " ON t1.column_id = t2.column_id AND t1.table_version = t2.max_table_version"
+ " AND t1.table_id = #{tableId}";
}

public String insertColumnPOs(@Param("columnPOs") List<ColumnPO> columnPOs) {
Expand Down
Loading