diff bindings/java/ext/libAudioDB_JNI.c @ 728:d3407d1e2f57

* Initial insertion from data code * Added some tests for insertion * Added a simple example
author mas01mj
date Mon, 26 Jul 2010 16:19:56 +0000
parents 4d9e4ff0a9cd
children a9978a6d0bb3
line wrap: on
line diff
--- a/bindings/java/ext/libAudioDB_JNI.c	Mon Jul 26 14:58:13 2010 +0000
+++ b/bindings/java/ext/libAudioDB_JNI.c	Mon Jul 26 16:19:56 2010 +0000
@@ -143,6 +143,36 @@
 	(*env)->DeleteLocalRef(env, adbClass);
 }
 
+JNIEXPORT jboolean JNICALL Java_org_omras2_AudioDB_audiodb_1insert_1data(JNIEnv *env, jobject obj, jstring key, int nvectors, int dim, jdoubleArray features, jdoubleArray power, jdoubleArray times)
+{
+	adb_t *handle = get_handle(env, obj);
+	if(!handle)
+		return JNI_FALSE;
+	
+	adb_datum_t* ins = (adb_datum_t *)malloc(sizeof(adb_datum_t));
+	if(!features || !key)
+		return JNI_FALSE;
+
+	ins->data = (*env)->GetDoubleArrayElements(env, features, NULL); 
+	ins->power = NULL;
+	ins->times = NULL;
+
+	if(power)
+		ins->power = (*env)->GetDoubleArrayElements(env, power, NULL); 
+	if(times)
+		ins->times = (*env)->GetDoubleArrayElements(env, times, NULL); 
+
+	ins->key = (*env)->GetStringUTFChars(env, key, 0); 
+	ins->nvectors = nvectors;
+	ins->dim = dim;
+
+	int result =  audiodb_insert_datum(handle, ins);
+	if(result)
+		return JNI_FALSE;
+
+	return JNI_TRUE;
+}
+
 JNIEXPORT jboolean JNICALL Java_org_omras2_AudioDB_audiodb_1insert_1path(JNIEnv *env, jobject obj, jstring key, jstring features, jstring power, jstring times)
 {
 	adb_t *handle = get_handle(env, obj);