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

[AMORO-2215] Optimize the speed of searching for tables in the tables navigation bar #2452

Merged
merged 13 commits into from
Mar 29, 2024
Merged

[AMORO-2215] Optimize the speed of searching for tables in the tables navigation bar #2452

merged 13 commits into from
Mar 29, 2024

Conversation

tcodehuber
Copy link
Contributor

@tcodehuber tcodehuber commented Dec 19, 2023

Why are the changes needed?

Close #2215.

Brief change log

  • If all the databases have been loaded, searching db action will not trigger querying backend;
  • If all the tables have been loaded, searching tb action will not trigger querying backend Similarly.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@github-actions github-actions bot added the module:ams-dashboard Ams dashboard module label Dec 19, 2023
@tcodehuber
Copy link
Contributor Author

tcodehuber commented Dec 19, 2023

@zhoujinsong @hameizi Can you take some time to review the PR? I have tested in my own env, in which it works ok.

@wangtaohz
Copy link
Contributor

wangtaohz commented Dec 25, 2023

Sorry for the late reply. @tcodehuber

We have recently done some refactoring on the front-end, so there are some conflicts that need to be resolved. Afterward, we can proceed with merging this PR.

BTW, there are some changes when building the front-end, you can refer to ams/dashboard/README.md.

Copy link

codecov bot commented Dec 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.71%. Comparing base (82691aa) to head (06b3fdf).

❗ Current head 06b3fdf differs from pull request most recent head ec5d4a3. Consider uploading reports for the commit ec5d4a3 to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2452      +/-   ##
============================================
+ Coverage     33.96%   34.71%   +0.74%     
- Complexity     4357     4521     +164     
============================================
  Files           604      608       +4     
  Lines         50754    50980     +226     
  Branches       6673     6686      +13     
============================================
+ Hits          17241    17698     +457     
+ Misses        32124    31829     -295     
- Partials       1389     1453      +64     
Flag Coverage Δ
core 33.06% <ø> (+0.77%) ⬆️
trino 50.89% <ø> (+0.53%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tcodehuber
Copy link
Contributor Author

@wangtaohz I have resolved conflicts, please review it again.

@wangtaohz wangtaohz changed the title [AMORO-2215] Optimize the speed of searching for tables in the tables… [AMORO-2215] Optimize the speed of searching for tables in the tables navigation bar Dec 27, 2023
Comment on lines 255 to 261
if (state.allDatabaseListLoaded.length) {
state.databaseList = state.allDatabaseListLoaded.filter((ele) => {
return ele.label.includes(state.DBSearchInput)
})
return
}

Copy link
Member

Choose a reason for hiding this comment

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

Maybe can use computed to implement this filtering instead of creating a new state

Copy link
Contributor Author

@tcodehuber tcodehuber Dec 27, 2023

Choose a reason for hiding this comment

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

But I have to store all databases/tables in the frontend, then filtering by keyword can be acted at them. the databaseList and tableLIst in the state just are just used as values displaying in virtual-recycle-scroller. Or can i move the allDatabaseListLoaded/allTableListLoaded out of const state = reactive({

Copy link
Member

Choose a reason for hiding this comment

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

There is no conflict between the two. You just need to remove database and table and filter with computed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zhangmo8 Can you review it again?

@@ -283,10 +305,14 @@ export default defineComponent({
label: ele.name,
type: ele.type
}))
if (state.tableSearchInput === '') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest moving the filtering of databases and tables from the backend to the frontend and the HTTP API always returns all databases and all tables. Then there will be no need for additional checks on whether allTableListLoaded should be set.

BTW, removing the filtering from the HTTP API won't incur additional overhead on the backend, because the filtering takes effect at the final step of returning results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, filtering of databases and tables is acted in the frontend now. We only need load all databases or tables for the first time. Afterwards, keyword filtering will not request HTTP API.

@@ -271,6 +286,13 @@ export default defineComponent({
if (!state.curCatalog || !state.database) {
return
}
if (state.allTableListLoaded.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if the tableList here is still old after switching database, if yes, maybe you need to save a mapping from database to tableList?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, in the const handleClickDb = (item: IDatabaseItem) function, i have set state.allTableListLoaded.length = 0.

Copy link
Member

@zhangmo8 zhangmo8 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your contribution! @tcodehuber
Thanks a lot for your reviewing! @zhangmo8

@tcodehuber tcodehuber merged commit 45db986 into apache:master Mar 29, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:ams-dashboard Ams dashboard module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Optimize the speed of searching for tables in the tables navigation bar
5 participants