-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved remote index build client to a separate module
Signed-off-by: Navneet Verma <navneev@amazon.com>
- Loading branch information
Showing
33 changed files
with
722 additions
and
651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OpenSearch k-NN | ||
Copyright OpenSearch Contributors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
id 'jacoco' | ||
id "io.freefair.lombok" | ||
id 'com.diffplug.spotless' version '6.25.0' | ||
id 'opensearch.build' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } | ||
mavenCentral() | ||
maven { url "https://plugins.gradle.org/m2/" } | ||
} | ||
|
||
compileJava { | ||
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor']) | ||
} | ||
compileTestJava { | ||
options.compilerArgs.addAll(["-processor", 'lombok.launch.AnnotationProcessorHider$AnnotationProcessor']) | ||
} | ||
|
||
dependencies { | ||
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}" | ||
api group: 'commons-lang', name: 'commons-lang', version: '2.6' | ||
api "org.apache.httpcomponents.client5:httpclient5:${versions.httpclient5}" | ||
api "org.apache.httpcomponents.core5:httpcore5:${versions.httpcore5}" | ||
api "org.apache.httpcomponents.core5:httpcore5-h2:${versions.httpcore5}" | ||
testImplementation "org.opensearch.test:framework:${opensearch_version}" | ||
} | ||
|
||
check.dependsOn spotlessCheck | ||
|
||
publishing { | ||
publications { | ||
pluginZip(MavenPublication) { publication -> | ||
pom { | ||
name = "opensearch-knn-remote-index-build-client" | ||
description = 'Client for connecting to remote index build endpoint' | ||
licenses { | ||
license { | ||
name = "The Apache License, Version 2.0" | ||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
} | ||
} | ||
developers { | ||
developer { | ||
name = "OpenSearch" | ||
url = "https://github.com/opensearch-project/k-NN/remote-index-build-client" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...client/src/main/java/org/opensearch/remoteindexbuild/client/RemoteIndexClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.remoteindexbuild.client; | ||
|
||
public class RemoteIndexClientFactory { | ||
|
||
// Default to HTTP client | ||
public static RemoteIndexClient getRemoteIndexClient(final String endpoint) { | ||
return new RemoteIndexHTTPClient(endpoint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ld-client/src/main/java/org/opensearch/remoteindexbuild/constants/KNNRemoteConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.remoteindexbuild.constants; | ||
|
||
// Public class to define the constants used by Remote Index Build in 2 or more classes. | ||
public class KNNRemoteConstants { | ||
// Build request keys | ||
public static final String ALGORITHM = "algorithm"; | ||
public static final String ALGORITHM_PARAMETERS = "algorithm_parameters"; | ||
public static final String METHOD_PARAMETER_SPACE_TYPE = "space_type"; | ||
public static final String METHOD_PARAMETER_EF_SEARCH = "ef_search"; | ||
public static final String METHOD_PARAMETER_EF_CONSTRUCTION = "ef_construction"; | ||
public static final String METHOD_PARAMETER_M = "m"; | ||
} |
61 changes: 61 additions & 0 deletions
61
...-build-client/src/main/java/org/opensearch/remoteindexbuild/model/RemoteBuildRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.remoteindexbuild.model; | ||
|
||
import lombok.Builder; | ||
import lombok.Value; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Request object for sending build requests to the remote build service, encapsulating all the required parameters | ||
* in a generic XContent format. | ||
*/ | ||
@Value | ||
@Builder | ||
public class RemoteBuildRequest implements ToXContentObject { | ||
private static final String DOC_COUNT = "doc_count"; | ||
private static final String TENANT_ID = "tenant_id"; | ||
private static final String DOC_ID_PATH = "doc_id_path"; | ||
private static final String DIMENSION = "dimension"; | ||
private static final String VECTOR_DATA_TYPE_FIELD = "data_type"; | ||
private static final String KNN_ENGINE = "engine"; | ||
|
||
private static final String VECTOR_PATH = "vector_path"; | ||
private static final String CONTAINER_NAME = "container_name"; | ||
private static final String REPOSITORY_TYPE = "repository_type"; | ||
private static final String INDEX_PARAMETERS = "index_parameters"; | ||
|
||
String repositoryType; | ||
String containerName; | ||
String vectorPath; | ||
String docIdPath; | ||
String tenantId; | ||
int dimension; | ||
int docCount; | ||
String vectorDataType; | ||
String engine; | ||
RemoteIndexParameters indexParameters; | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(REPOSITORY_TYPE, repositoryType); | ||
builder.field(CONTAINER_NAME, containerName); | ||
builder.field(VECTOR_PATH, vectorPath); | ||
builder.field(DOC_ID_PATH, docIdPath); | ||
builder.field(TENANT_ID, tenantId); | ||
builder.field(DIMENSION, dimension); | ||
builder.field(DOC_COUNT, docCount); | ||
builder.field(VECTOR_DATA_TYPE_FIELD, vectorDataType); | ||
builder.field(KNN_ENGINE, engine); | ||
builder.field(INDEX_PARAMETERS, indexParameters); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
remote-index-build-client/src/test/java/org/opensearch/remoteindexbuild/TestConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.remoteindexbuild; | ||
|
||
public class TestConstants { | ||
public static final String TEST_BUCKET = "test-bucket"; | ||
public static final String TEST_CLUSTER = "test-cluster"; | ||
public static final String MOCK_JOB_ID_RESPONSE = "{\"job_id\": \"job-1739930402\"}"; | ||
public static final String MOCK_JOB_ID = "job-1739930402"; | ||
public static final String MOCK_BLOB_NAME = "blob"; | ||
public static final String MOCK_ENDPOINT = "https://mock-build-service.com"; | ||
public static final String USERNAME = "username"; | ||
public static final String PASSWORD = "password"; | ||
public static final String L2_SPACE_TYPE = "l2"; | ||
public static final String HNSW_ALGORITHM = "hnsw"; | ||
} |
Oops, something went wrong.