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

Java: VSS commands init #2385

Closed
wants to merge 18 commits into from
Closed

Conversation

Yury-Fridlyand
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand commented Oct 3, 2024

@Yury-Fridlyand Yury-Fridlyand added the java issues and fixes related to the java client label Oct 3, 2024
@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner October 3, 2024 00:25
.github/workflows/java.yml Outdated Show resolved Hide resolved
glide-core/src/protobuf/command_request.proto Show resolved Hide resolved
@@ -165,8 +165,8 @@ jar.dependsOn('copyNativeLib')
javadoc.dependsOn('copyNativeLib')
copyNativeLib.dependsOn('buildRustRelease')
compileTestJava.dependsOn('copyNativeLib')
test.dependsOn('buildRust')
testFfi.dependsOn('buildRust')
test.dependsOn('buildRustRelease')
Copy link
Contributor

Choose a reason for hiding this comment

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

why? I thought we were okay with running tests vs the debug version?

Copy link
Collaborator Author

@Yury-Fridlyand Yury-Fridlyand Oct 3, 2024

Choose a reason for hiding this comment

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

gradle still runs UT on release due to copyNativeLib. At least it doesn't build debug version which is never used.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know when we decided to switch to the release version. Better to run against debug, but we can fix this in a separate PR

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@acarbonetto acarbonetto changed the title Java: VSS commans init Java: VSS commands init Oct 8, 2024
@@ -685,6 +691,9 @@ impl RequestType {
RequestType::ScriptExists => Some(get_two_word_command("SCRIPT", "EXISTS")),
RequestType::ScriptFlush => Some(get_two_word_command("SCRIPT", "FLUSH")),
RequestType::ScriptKill => Some(get_two_word_command("SCRIPT", "KILL")),
RequestType::FtCreate => Some(cmd("FT.CREATE")),
RequestType::FtSearch => Some(cmd("FT.SEARCH")),
RequestType::FtDrop => Some(cmd("FT.DROPINDEX")),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RequestType::FtDrop => Some(cmd("FT.DROPINDEX")),
RequestType::FtDropIndex => Some(cmd("FT.DROPINDEX")),

@@ -457,6 +460,9 @@ impl From<::protobuf::EnumOrUnknown<ProtobufRequestType>> for RequestType {
ProtobufRequestType::ScriptFlush => RequestType::ScriptFlush,
ProtobufRequestType::ScriptKill => RequestType::ScriptKill,
ProtobufRequestType::ScriptShow => RequestType::ScriptShow,
ProtobufRequestType::FtCreate => RequestType::FtCreate,
ProtobufRequestType::FtSearch => RequestType::FtSearch,
ProtobufRequestType::FtDrop => RequestType::FtDrop,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ProtobufRequestType::FtDrop => RequestType::FtDrop,
ProtobufRequestType::FtDropIndex => RequestType::FtDropIndex,

@@ -227,6 +227,9 @@ pub enum RequestType {
ScriptFlush = 216,
ScriptKill = 217,
ScriptShow = 218,
FtCreate = 2000,
FtSearch = 2001,
FtDrop = 2002,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FtDrop = 2002,
FtDropIndex = 2002,


FtCreate = 2000;
FtSearch = 2001;
FtDrop = 2002;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FtDrop = 2002;
FtDropIndex = 2002;

@@ -165,8 +165,8 @@ jar.dependsOn('copyNativeLib')
javadoc.dependsOn('copyNativeLib')
copyNativeLib.dependsOn('buildRustRelease')
compileTestJava.dependsOn('copyNativeLib')
test.dependsOn('buildRust')
testFfi.dependsOn('buildRust')
test.dependsOn('buildRustRelease')
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know when we decided to switch to the release version. Better to run against debug, but we can fix this in a separate PR

import glide.api.models.commands.vss.FTSearchOptions.FTSearchOptionsBuilder;
import java.util.concurrent.CompletableFuture;

public interface VectorSearchBaseCommands {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change this to a Static Public Class and put it under package glide.api.commands.servermodules.
Move the commands function from BaseClient to here (add the argument BaseClient to each command).
We don't need to separate Interface and commands, and we can put the documentation in one place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Following the JSON and FT commands, we should rename this class to FT, and commands should only reference the action. Example:

import static glide.api.models.commands. servermodules.FT;

FT.create(client, "hash_idx1", FTCreateOptions.empty(), new FieldInfo[] {
    new FieldInfo("vec", VectorFieldFlat.builder(DistanceMetric.L2, 2).build())
}).get();

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do after merging #2414

* client.ftdrop("hash_idx1").get();
* }</pre>
*/
CompletableFuture<String> ftdrop(String indexName);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
CompletableFuture<String> ftdrop(String indexName);
CompletableFuture<String> ftdropindex(String indexName);

var args = new ArrayList<String>();
args.add("TAG");
if (separator.isPresent()) {
args.add("SEPARATOR");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these keywords be constants?

@Override
public String[] toArgs() {
var args = new ArrayList<String>();
args.add("VECTOR");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: Types TEXT, VECTOR, TAG, etc. could be Enums.

var args = new ArrayList<String>();
args.add("VECTOR");
args.add(Algorithm);
args.add(Integer.toString(params.size() * 2));
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no null check for params? This is a potential null pointer exception.

*/
public static class VectorFieldHnsw extends VectorField {
protected VectorFieldHnsw(Map<String, String> params) {
super(params, "HNSW");
Copy link
Collaborator

Choose a reason for hiding this comment

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

"HNSW" value can be taken from Algorithm Enum.

concatenateArrays(
new GlideString[] {gs(indexName), gs(query)},
options.toArgs(),
new GlideString[] {gs("DIALECT"), gs("2")});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see this option in the inputs.

@Yury-Fridlyand
Copy link
Collaborator Author

Superseded by #2414, #2439 and #2440

@Yury-Fridlyand Yury-Fridlyand deleted the java/yuryf-ft-create-search-drop branch October 11, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants