Mercurial > hg > audiodb
comparison 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 |
comparison
equal
deleted
inserted
replaced
727:4d9e4ff0a9cd | 728:d3407d1e2f57 |
---|---|
141 | 141 |
142 (*env)->SetLongField(env, obj, fid, 0); | 142 (*env)->SetLongField(env, obj, fid, 0); |
143 (*env)->DeleteLocalRef(env, adbClass); | 143 (*env)->DeleteLocalRef(env, adbClass); |
144 } | 144 } |
145 | 145 |
146 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) | |
147 { | |
148 adb_t *handle = get_handle(env, obj); | |
149 if(!handle) | |
150 return JNI_FALSE; | |
151 | |
152 adb_datum_t* ins = (adb_datum_t *)malloc(sizeof(adb_datum_t)); | |
153 if(!features || !key) | |
154 return JNI_FALSE; | |
155 | |
156 ins->data = (*env)->GetDoubleArrayElements(env, features, NULL); | |
157 ins->power = NULL; | |
158 ins->times = NULL; | |
159 | |
160 if(power) | |
161 ins->power = (*env)->GetDoubleArrayElements(env, power, NULL); | |
162 if(times) | |
163 ins->times = (*env)->GetDoubleArrayElements(env, times, NULL); | |
164 | |
165 ins->key = (*env)->GetStringUTFChars(env, key, 0); | |
166 ins->nvectors = nvectors; | |
167 ins->dim = dim; | |
168 | |
169 int result = audiodb_insert_datum(handle, ins); | |
170 if(result) | |
171 return JNI_FALSE; | |
172 | |
173 return JNI_TRUE; | |
174 } | |
175 | |
146 JNIEXPORT jboolean JNICALL Java_org_omras2_AudioDB_audiodb_1insert_1path(JNIEnv *env, jobject obj, jstring key, jstring features, jstring power, jstring times) | 176 JNIEXPORT jboolean JNICALL Java_org_omras2_AudioDB_audiodb_1insert_1path(JNIEnv *env, jobject obj, jstring key, jstring features, jstring power, jstring times) |
147 { | 177 { |
148 adb_t *handle = get_handle(env, obj); | 178 adb_t *handle = get_handle(env, obj); |
149 if(!handle) | 179 if(!handle) |
150 return JNI_FALSE; | 180 return JNI_FALSE; |