Skip to content

Schema changes to get entities count for labels #122

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

Merged
merged 1 commit into from
Dec 22, 2021

Conversation

saxenakshitiz
Copy link
Contributor

No description provided.

@saxenakshitiz saxenakshitiz requested a review from a team as a code owner December 21, 2021 12:56
@codecov
Copy link

codecov bot commented Dec 21, 2021

Codecov Report

Merging #122 (b79269a) into main (4a365d6) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #122   +/-   ##
=========================================
  Coverage     23.03%   23.03%           
  Complexity       75       75           
=========================================
  Files            65       65           
  Lines          1680     1680           
  Branches         52       52           
=========================================
  Hits            387      387           
  Misses         1284     1284           
  Partials          9        9           
Flag Coverage Δ
unit 23.03% <ø> (ø)

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


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a365d6...b79269a. Read the comment docs.

@github-actions

This comment has been minimized.

@Accessors(fluent = true)
private static class DefaultLabeledEntity implements LabeledEntity {
String id;
Map<String, Object> attributeValues;
Copy link
Contributor

Choose a reason for hiding this comment

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

ah crap, I have an enormous change (oops) locally that changes how attributes work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let me know what changes are coming, and I will update accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

The relevant part here is that AttributeQueryable changes.

Object attribute(@GraphQLName(AttributeExpression.ARGUMENT_NAME) AttributeExpression expression);

and most of the impls are now holding a

    Map<AttributeExpression, Object> attributeValues;

Unless I'm able to get stuff merged (and it won't be today), not much you can do to prepare for it, since don't have the new types.

List<LabeledEntity> labeledEntities =
Optional.ofNullable(labeledEntitiesMap.get(entityType)).orElse(Collections.emptyList());
List<LabeledEntity> labeledEntitiesWithLimit =
labeledEntities.size() > limit ? labeledEntities.subList(0, limit) : labeledEntities;
Copy link
Contributor

Choose a reason for hiding this comment

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

limits should be enforced on the request side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

An entity may hold multiple labels. I was planning to fetch entities along with labels, and reverse map from labels to entities here. Let me know if there is a better approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking we'd just create a query for entities filtered by label. Using the label results, you have a list of label IDs which can become an IN filter on a single entity query (per requested type). You're likely right about the limit being enforced on the response side though, now that I think about it. We can either

  • Make a request per [label, type] pair and enforce it per request
  • Make a request per type, and enforce it in memory when demuxing the result
    The second option seems to me like it will be significantly more performant, even if I don't love the idea that we're limiting in memory.

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 was going for second option as well

@@ -60,5 +66,36 @@ private Label convertLabel(org.hypertrace.label.config.service.v1.Label label) {
String key;
String color;
String description;
Map<String, List<LabeledEntity>> labeledEntitiesMap;
Copy link
Contributor

Choose a reason for hiding this comment

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

would make sense to hold a Map<String, LabeledEntityResultSet> I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

@Override
public LabeledEntityResultSet labeledEntities(String entityType, int limit) {
List<LabeledEntity> labeledEntities =
Optional.ofNullable(labeledEntitiesMap.get(entityType)).orElse(Collections.emptyList());
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're doing the work on the request side, this should be unreachable - can assume the map contains any requested entity types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to return empty values till implementation is done

@saxenakshitiz saxenakshitiz merged commit b41bda0 into main Dec 22, 2021
@saxenakshitiz saxenakshitiz deleted the labels_associated_entities_count_part1 branch December 22, 2021 04:33
@github-actions
Copy link

Unit Test Results

11 files  ±0  11 suites  ±0   9s ⏱️ ±0s
24 tests ±0  24 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit b41bda0. ± Comparison against base commit 4a365d6.

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.

2 participants