Skip to content

MLE-19601 : Update annTopK in Node API #937

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
Jul 10, 2025
Merged

Conversation

anu3990
Copy link
Contributor

@anu3990 anu3990 commented Jul 9, 2025

No description provided.

@anu3990 anu3990 requested review from Copilot, rjrudin and BillFarber and removed request for Copilot July 9, 2025 21:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR extends the annTopK Node API to accept new PlanAnnTopKOptions in string, array, or map form and adds corresponding tests and builder logic.

  • Added multiple tests in test-basic/annTopK.js covering absence of options, string, array, map, and invalid options.
  • Updated plan-builder-generated.js to mark the options parameter as a named (optional) argument.
  • Enhanced plan-builder-base.js to validate Map inputs for PlanAnnTopKOptions and extend string type handling.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
test-basic/annTopK.js New tests for various annTopK option formats; shared map usage
lib/plan-builder-generated.js Changed annTopK paramdefs to allow named options argument
lib/plan-builder-base.js Added cast logic for PlanAnnTopKOptions; extended string types
Comments suppressed due to low confidence (1)

@@ -11,8 +11,10 @@ const assert = require('assert');
const testlib = require('../etc/test-lib');
let serverConfiguration = {};
const execPlan = pbb.execPlan;
const planAnnTopKOptionsMap = new Map();
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

Declaring a shared Map at file scope can lead to state leakage across tests. Consider initializing a fresh Map within each it(...) or using beforeEach to reset it.

Suggested change
const planAnnTopKOptionsMap = new Map();
// Removed global declaration of planAnnTopKOptionsMap.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like a good change to make, it's better to declare it in each test as needed.

assert(rows[1].distance.type === 'xs:float', 'Verifying that the distance column was populated.');
done();
} catch (error){
throw error;
Copy link
Preview

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

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

Throwing inside the verifyResults catch won’t invoke the Mocha done callback on failure. Replace throw error with done(error) to correctly signal test failures.

Suggested change
throw error;
done(error);

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like a good change too?

Comment on lines +405 to +413
const planAnnTopKOptionsSet = new Set(['maxDistance', 'max-distance', 'searchFactor','search-factor']);
if(Object.getPrototypeOf(arg) === Map.prototype){
arg.forEach((value, key) => {
if(!planAnnTopKOptionsSet.has(key)) {
throw new Error(
`${argLabel(funcName, paramName, argPos)} has invalid key- ${key}`
);
}
});

This comment was marked as off-topic.

Copy link
Contributor

@rjrudin rjrudin left a comment

Choose a reason for hiding this comment

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

Looks good, I just agreed with a couple Copilot suggestions for small changes to the test.

@@ -11,8 +11,10 @@ const assert = require('assert');
const testlib = require('../etc/test-lib');
let serverConfiguration = {};
const execPlan = pbb.execPlan;
const planAnnTopKOptionsMap = new Map();
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like a good change to make, it's better to declare it in each test as needed.

assert(rows[1].distance.type === 'xs:float', 'Verifying that the distance column was populated.');
done();
} catch (error){
throw error;
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like a good change too?

@anu3990 anu3990 merged commit e67bcb4 into marklogic:develop Jul 10, 2025
1 of 2 checks passed
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