00001
00002
00003
00004 #include "Postlist.java.h"
00005 #include "JNIGateway.hpp"
00006
00014
00015 using namespace aitools::invertedindex;
00016
00017
00018
00019
00020
00021
00022 JNIEXPORT jint JNICALL Java_de_aitools_aq_invertedindex_core_Postlist_natGetLength
00023 (JNIEnv* env, jobject jpostlist, jint oid)
00024 {
00025 try
00026 {
00027 return JNIGateway::get_iterator(oid)->header().value_count;
00028 }
00029 catch (const std::exception& error)
00030 {
00031 env->ThrowNew(env->FindClass(JNIGateway::java_exception), error.what());
00032 }
00033 return 0;
00034 }
00035
00036
00037
00038
00039
00040
00041 JNIEXPORT void JNICALL Java_de_aitools_aq_invertedindex_core_Postlist_natDelete
00042 (JNIEnv* env, jobject jpostlist, jint oid)
00043 {
00044 JNIGateway::delete_iterator(oid);
00045 }
00046
00047
00048
00049
00050
00051
00052 JNIEXPORT void JNICALL Java_de_aitools_aq_invertedindex_core_Postlist_natRewind
00053 (JNIEnv* env, jobject jpostlist, jint oid)
00054 {
00055 try
00056 {
00057 JNIGateway::get_iterator(oid)->rewind();
00058 }
00059 catch (const std::exception& error)
00060 {
00061 env->ThrowNew(env->FindClass(JNIGateway::java_exception), error.what());
00062 }
00063 }
00064
00065
00066
00067
00068
00069
00070 JNIEXPORT jbyteArray JNICALL Java_de_aitools_aq_invertedindex_core_Postlist_natNext
00071 (JNIEnv* env, jobject jpostlist, jint oid)
00072 {
00073 try
00074 {
00075 const Iterator::SharedPointer& it(JNIGateway::get_iterator(oid));
00076 if (it->is_valid())
00077 {
00078 jbyteArray jentry(env->NewByteArray(it->size()));
00079 env->SetByteArrayRegion(jentry, 0, it->size(), (jbyte*)it->value());
00080 it->advance();
00081 return jentry;
00082 }
00083 }
00084 catch (const std::exception& error)
00085 {
00086 env->ThrowNew(env->FindClass(JNIGateway::java_exception), error.what());
00087 }
00088 return NULL;
00089 }