Skip to content

Added values only to discovery count.#3530

Open
hoper-38709 wants to merge 8 commits intointegrationfrom
task/add-sum-count-to-discovery
Open

Added values only to discovery count.#3530
hoper-38709 wants to merge 8 commits intointegrationfrom
task/add-sum-count-to-discovery

Conversation

@hoper-38709
Copy link
Copy Markdown
Collaborator

Add values only option to return from a DiscoveryLogic/ DiscoveryIterator.

@hoper-38709 hoper-38709 force-pushed the task/add-sum-count-to-discovery branch from 0707bd6 to 076cbf5 Compare May 1, 2026 13:14
fields.add(this.makeField("VALUE", markings, "", 0L, thing.getTerm()));
/**
* Added query model to alias FIELD
* Added query model to alias FIELD, if DiscoveredThing::field both not NULL and not empty.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

apply similar logic to DATE and DATATYPE. We only want to show the term value and the combined vis.

TermEntry termEntry = new TermEntry(key, iterator.getTopValue()) {
// Only use term and visibility for equality.
@Override
public boolean equals(Object o) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Move these to a TermOnlyEntry?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Keep as TermEntry so that, downstream, we can re-use aggregate function for both "term only" path and "summation path" . DiscoveredThing aggregate(Collection termEntries)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I assumed we would make inheritance appropriate between them such that we could still use the aggregate

Comment on lines +16 to +25
// @formatter:off
return (valuesOnly) ? new DiscoveredThing(dt.getTerm(),
"",
"",
"",
dt.getColumnVisibility(),
0L,
new MapWritable())
: dt;
// @formatter:on
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Few comments here. Do not use a ternary operator and do not disable the formatter to put constructor args on different lines like this.

Use a simple guard statement with a simpler constructor like this:

if (valuesOnly ) {
  return new DiscoveredThing(dt.getTerm, dt.getColumnVisibility())
}
return dt;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good idea.

// Find all matching entries and parse term entries from them.
while (iterator.hasTop() && start.equals((key = iterator.getTopKey()), PartialKey.ROW_COLFAM) && dateMatchingFunction.apply(start, key)) {
//@formatter:off
while (Optional.ofNullable(iterator).isPresent() &&
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In the event that the iterator is not set, or is later set to null a NPE is appropriate. This code change will suppress a failure state that we want to know about. Please reset this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll re-set. Another commenter recommended a NULL check.

@hlgp
Copy link
Copy Markdown
Collaborator

hlgp commented May 8, 2026

New direction: Turns out we don't need to aggregate the vis. We only need to return the first instance of each unique rowid.

So, if valuesOnly, break when you get the first valid TermEntry. Each next iteration will have just a single DiscoveredThing. Do the logic to only set the term and vis.

In setTop, precedent is already set to modify the column family to advance to the next column family. In the values only case we will want to skip to the next row. Note: appending a null byte to the end of the current row won't work, so recommend the start key be the row and last possible column family (something like \uffff)

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.

5 participants