|
6 | 6 | #include "LibVCFNative.h"
|
7 | 7 | #include "tiledbvcf/tiledbvcf.h"
|
8 | 8 |
|
| 9 | +static int set_out_params_size_t(JNIEnv* env, size_t value1, size_t value2, jlongArray valuesOut) { |
| 10 | + jlong* c_values = (*env)->GetLongArrayElements(env, valuesOut, NULL); |
| 11 | + if (c_values == NULL) { |
| 12 | + return -1; |
| 13 | + } |
| 14 | + |
| 15 | + // Check that an array of length 2 was passed. |
| 16 | + if ((*env)->GetArrayLength(env, valuesOut) != 2) { |
| 17 | + (*env)->ReleaseLongArrayElements(env, valuesOut, c_values, 0); |
| 18 | + return -1; |
| 19 | + } |
| 20 | + |
| 21 | + // Set the values in the result array. |
| 22 | + c_values[0] = (jlong)value1; |
| 23 | + c_values[1] = (jlong)value2; |
| 24 | + |
| 25 | + // Set the modified array back to the Java array. |
| 26 | + (*env)->SetLongArrayRegion(env, valuesOut, 0, 2, c_values); |
| 27 | + |
| 28 | + // Release the array elements. |
| 29 | + (*env)->ReleaseLongArrayElements(env, valuesOut, c_values, 0); |
| 30 | + |
| 31 | + return TILEDB_VCF_OK; |
| 32 | +} |
| 33 | + |
9 | 34 | static int set_out_param_int32(JNIEnv* env, int32_t value, jintArray valueOut) {
|
10 | 35 | jint* c_value = (*env)->GetIntArrayElements(env, valueOut, NULL);
|
11 | 36 | if (c_value == NULL) {
|
@@ -1083,3 +1108,53 @@ Java_io_tiledb_libvcfnative_LibVCFNative_tiledb_1vcf_1bed_1file_1get_1contig_1re
|
1083 | 1108 |
|
1084 | 1109 | return rc;
|
1085 | 1110 | }
|
| 1111 | + |
| 1112 | +JNIEXPORT jint JNICALL |
| 1113 | +Java_io_tiledb_libvcfnative_LibVCFNative_tiledb_1vcf_1reader_1get_1variant_1stats_1buffer_1sizes( |
| 1114 | + JNIEnv* env, jclass self, jlong readerPtr, jlongArray resultsOut) { |
| 1115 | + (void)self; |
| 1116 | + tiledb_vcf_reader_t* reader = (tiledb_vcf_reader_t*)readerPtr; |
| 1117 | + if (reader == 0) { |
| 1118 | + return TILEDB_VCF_ERR; |
| 1119 | + } |
| 1120 | + |
| 1121 | + size_t num_rows; |
| 1122 | + size_t allele_size; |
| 1123 | + int32_t rc = tiledb_vcf_reader_get_variant_stats_buffer_sizes(reader, &num_rows, &allele_size); |
| 1124 | + if (rc == TILEDB_VCF_OK) { |
| 1125 | + return set_out_params_size_t(env, (size_t)num_rows, (size_t)allele_size, resultsOut); |
| 1126 | + } |
| 1127 | + |
| 1128 | + return rc; |
| 1129 | +} |
| 1130 | + |
| 1131 | +JNIEXPORT jint JNICALL |
| 1132 | +Java_io_tiledb_libvcfnative_LibVCFNative_tiledb_1vcf_1reader_1prepare_1variant_1stats( |
| 1133 | + JNIEnv* env, jclass self, jlong readerPtr){ |
| 1134 | + (void)self; |
| 1135 | + |
| 1136 | + tiledb_vcf_reader_t* reader = (tiledb_vcf_reader_t*)readerPtr; |
| 1137 | + |
| 1138 | + if (reader == 0) { |
| 1139 | + return TILEDB_VCF_ERR; |
| 1140 | + } |
| 1141 | + |
| 1142 | + int32_t rc = tiledb_vcf_reader_prepare_variant_stats(reader); |
| 1143 | + |
| 1144 | + return rc; |
| 1145 | +} |
| 1146 | + |
| 1147 | +JNIEXPORT jint JNICALL |
| 1148 | +Java_io_tiledb_libvcfnative_LibVCFNative_tiledb_1vcf_1reader_1read_1from_1variant_1stats( |
| 1149 | + JNIEnv* env, |
| 1150 | + jclass self, |
| 1151 | + jlong readerPtr, |
| 1152 | + jlongArray , |
| 1153 | + jstring, |
| 1154 | + jlongArray, |
| 1155 | + jintArray, |
| 1156 | + jintArray, |
| 1157 | + jfloatArray){ |
| 1158 | + |
| 1159 | +//todo |
| 1160 | + } |
0 commit comments