-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the interface for streaming the vectors from java to jni layer wi…
…th initial capacity Signed-off-by: Navneet Verma <[email protected]>
- Loading branch information
Showing
21 changed files
with
404 additions
and
1,666 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
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,37 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
#include "jni_util.h" | ||
#include <jni.h> | ||
namespace knn_jni { | ||
namespace commons { | ||
/** | ||
* This is utility function that can be used to store data in native memory. This function will allocate memory for | ||
* the data(rows*columns) with initialCapacity and return the memory address where the data is stored. | ||
* If you are using this function for first time use memoryAddress = 0 to ensure that a new memory location is created. | ||
* For subsequent calls you can pass the same memoryAddress. If the data cannot be stored in the memory location | ||
* will throw Exception. | ||
* | ||
* @param memoryAddress The address of the memory location where data will be stored. | ||
* @param data 2D float array containing data to be stored in native memory. | ||
* @param initialCapacity The initial capacity of the memory location. | ||
* @return memory address where the data is stored. | ||
*/ | ||
jlong storeVectorData(knn_jni::JNIUtilInterface *, JNIEnv *, jlong , jobjectArray, jlong); | ||
|
||
/** | ||
* Free up the memory allocated for the data stored in memory address. This function should be used with the memory | ||
* address returned by {@link JNICommons#storeVectorData(long, float[][], long, long)} | ||
* | ||
* @param memoryAddress address to be freed. | ||
*/ | ||
void freeVectorData(jlong); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
/* DO NOT EDIT THIS FILE - it is machine generated */ | ||
#include <jni.h> | ||
/* Header for class org_opensearch_knn_jni_JNICommons */ | ||
|
||
#ifndef _Included_org_opensearch_knn_jni_JNICommons | ||
#define _Included_org_opensearch_knn_jni_JNICommons | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/* | ||
* Class: org_opensearch_knn_jni_JNICommons | ||
* Method: storeVectorData | ||
* Signature: (J[[FJJ) | ||
*/ | ||
JNIEXPORT jlong JNICALL Java_org_opensearch_knn_jni_JNICommons_storeVectorData | ||
(JNIEnv *, jclass, jlong, jobjectArray, jlong); | ||
|
||
/* | ||
* Class: org_opensearch_knn_jni_JNICommons | ||
* Method: freeVectorData | ||
* Signature: (J)V | ||
*/ | ||
JNIEXPORT void JNICALL Java_org_opensearch_knn_jni_JNICommons_freeVectorData | ||
(JNIEnv *, jclass, jlong); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
Oops, something went wrong.