Skip to content

fix: Moving from List datastructure to Set to reduce the number of array list creations.#37963

Closed
trishaanand wants to merge 1 commit intoreleasefrom
fix/page-upload-ds
Closed

fix: Moving from List datastructure to Set to reduce the number of array list creations.#37963
trishaanand wants to merge 1 commit intoreleasefrom
fix/page-upload-ds

Conversation

@trishaanand
Copy link
Contributor

@trishaanand trishaanand commented Dec 5, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/test all

🔍 Cypress test results

Caution

🔴 🔴 🔴 Some tests have failed.
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12174449514
Commit: 76a3273
Cypress dashboard.
Tags: @tag.All
Spec:
The following are new failures, please fix them before merging the PR:

  1. cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.js
  2. cypress/e2e/Regression/ClientSide/Linting/BasicLint_spec.ts
List of identified flaky tests.
Thu, 05 Dec 2024 07:32:08 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling for cyclical dependencies during page load execution.
  • New Features

    • Improved management of executable dependencies and bindings, optimizing the loading process.
  • Documentation

    • Updated internal comments and documentation for clarity on method functionalities.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

The changes in this pull request focus on the OnLoadExecutablesUtilCEImpl class, specifically updating method signatures and internal logic to improve the handling of executable dependencies during page load execution. Key modifications include changing parameters from List<String> to Set<String> for better efficiency in managing bindings, refining graph construction logic, enhancing error handling for cyclical dependencies, and updating documentation for clarity.

Changes

File Change Summary
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java - Updated method signatures to use Set<String> instead of List<String> for bindings in multiple methods.
- Refined logic for managing executable dependencies and graph construction.
- Enhanced error handling for cyclical dependencies.
- Updated documentation for clarity.

Possibly related PRs

  • chore: removed unwanted metrics #37052: This PR modifies the OnLoadExecutablesUtilCEImpl class, which is directly related to the changes made in the main PR, specifically regarding the handling of executable references and the management of dynamic bindings.

Suggested labels

Task, Bug, ok-to-test, Query & JS Pod, Integrations Product, Integrations Pod General

Suggested reviewers

  • NilanshBansal
  • rishabhrathod01

🎉 In the realm of code where logic flows,
We tweak the methods, watch the efficiency grow.
From lists to sets, we refine the way,
Binding dependencies, clearer each day!
With graphs now robust, and errors in check,
Our executable dance is a perfect tech trek! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@trishaanand trishaanand added the ok-to-test Required label for CI label Dec 5, 2024
@github-actions github-actions bot added the Bug Something isn't working label Dec 5, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (1)

Line range hint 704-712: Simplify Addition to 'allBindings'

Since allBindings is a Set<String>, adding bindings inside the inner loop is acceptable but can be simplified. Consider adding all bindings from bindingsInWidget directly to allBindings to enhance readability.

You can replace the inner loop with:

allBindings.addAll(bindingsInWidget);
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4de9c51 and 76a3273.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (5 hunks)
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/onload/internal/OnLoadExecutablesUtilCEImpl.java (2)

669-671: Verify the Impact of Changing 'bindings' from List to Set

Converting the bindings parameter from List<String> to Set<String> and then to a List with new ArrayList<>(bindings) may affect the order of elements and remove duplicates. Ensure that astService.getPossibleReferencesFromDynamicBinding does not rely on element order or duplicates in the bindings list.

To confirm, please review the implementation of astService.getPossibleReferencesFromDynamicBinding and ensure that it functions correctly with a list derived from a Set<String>.


528-528: Ensure Consistency with 'bindings' Type Change

After changing the type of bindings to Set<String>, verify that all method calls and internal logic that use bindings are updated accordingly. This includes ensuring that any methods that expect a List<String> receive the correct type.

Please audit the methods that interact with bindings to ensure type consistency and prevent potential runtime issues.

widgetBindingEntries.getValue(), entityTypes, evalVersion)
.map(possibleParentsMap -> {
possibleParentsMap.entrySet().stream().forEach(entry -> {
if (entry.getValue() == null || entry.getValue().isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Prevent Potential NullPointerException

At line 1226, calling trim() on widgetBindingEntries.getKey() may result in a NullPointerException if the key is null. Ensure that the key is not null before trimming.

Consider adding a null check:

String widgetPath = widgetBindingEntries.getKey();
if (widgetPath != null) {
    widgetPath = widgetPath.trim();
}

@github-actions
Copy link

github-actions bot commented Dec 5, 2024

Failed server tests

  • com.appsmith.server.services.LayoutServiceTest#getActionsExecuteOnLoadWithAstLogic

1 similar comment
@github-actions
Copy link

github-actions bot commented Dec 5, 2024

Failed server tests

  • com.appsmith.server.services.LayoutServiceTest#getActionsExecuteOnLoadWithAstLogic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants