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

[rule based autotagging] add attribute value store #17342

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kaushalmahi12
Copy link
Contributor

@kaushalmahi12 kaushalmahi12 commented Feb 12, 2025

Description

This change will allow us to store prefix based string values in-memory structures. This will be fundamental to process Rules or any prefix based structure in memory.

Changes in this PR

  • It introduces an interface for allowing prefix based string manipulation
  • It adds a Patricia Trie based implementation of the above interface and includes UTs

Related Issues

#16797 (comment)

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Kaushal Kumar <[email protected]>
@kaushalmahi12 kaushalmahi12 added the backport 2.x Backport to 2.x branch label Feb 12, 2025
Copy link
Contributor

❌ Gradle check result for f575fbd: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Kaushal Kumar <[email protected]>
Copy link
Contributor

❌ Gradle check result for 24c4ea6: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Kaushal Kumar <[email protected]>
Copy link
Contributor

❌ Gradle check result for acdb27c: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

❌ Gradle check result for acdb27c: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Comment on lines +17 to +22
/**
* Adds the value to the data structure
* @param key to be added
* @param value to be added
*/
void add(K key, V value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did we not agree to make this put?

* It is important to find the largest matching prefix key in the trie efficiently
* Hence we can do binary search
*/
String longestMatchingPrefix = findLongestMatchingPrefix(key);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can be final?

int high = key.length() - 1;

while (low < high) {
int mid = low + (high - low + 1) / 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this just be be (low + high) / 2 + 1? or (low+high+1)/2?


while (low < high) {
int mid = low + (high - low + 1) / 2;
String possibleMatchingPrefix = key.substring(0, mid);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can be done inline


/**
* Returns the value associated with the key
* @param key in the data structure
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: key in the attribute value store

Optional<V> get(K key);

/**
* Clears all the keys and their associated values from the structure
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: values from the attribute value store


/**
* It returns the number of values stored
* @return count of key,val pairs in the store
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: attribute value store is more appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants