Skip to content

Commit

Permalink
Fix cudf java build error. (#9958)
Browse files Browse the repository at this point in the history
cudf Java build is broken by #9942. So update the `hash` JNI accordingly.

Signed-off-by: Firestarman <[email protected]>

Authors:
  - Liangcai Li (https://github.com/firestarman)

Approvers:
  - Gary Shen (https://github.com/GaryShen2008)

URL: #9958
  • Loading branch information
firestarman authored Dec 29, 2021
1 parent bf7f7be commit 67c925c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
12 changes: 4 additions & 8 deletions java/src/main/java/ai/rapids/cudf/ColumnVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ public static ColumnVector md5Hash(ColumnView... columns) {
"Unsupported nested type column";
columnViews[i] = columns[i].getNativeView();
}
return new ColumnVector(hash(columnViews, HashType.HASH_MD5.getNativeId(), new int[0], 0));
return new ColumnVector(hash(columnViews, HashType.HASH_MD5.getNativeId(), 0));
}

/**
Expand All @@ -704,7 +704,7 @@ public static ColumnVector serial32BitMurmurHash3(int seed, ColumnView columns[]
assert !columns[i].getType().equals(DType.LIST) : "List columns are not supported";
columnViews[i] = columns[i].getNativeView();
}
return new ColumnVector(hash(columnViews, HashType.HASH_SERIAL_MURMUR3.getNativeId(), new int[0], seed));
return new ColumnVector(hash(columnViews, HashType.HASH_SERIAL_MURMUR3.getNativeId(), seed));
}

/**
Expand Down Expand Up @@ -739,7 +739,7 @@ public static ColumnVector spark32BitMurmurHash3(int seed, ColumnView columns[])
assert !columns[i].getType().equals(DType.LIST) : "List columns are not supported";
columnViews[i] = columns[i].getNativeView();
}
return new ColumnVector(hash(columnViews, HashType.HASH_SPARK_MURMUR3.getNativeId(), new int[0], seed));
return new ColumnVector(hash(columnViews, HashType.HASH_SPARK_MURMUR3.getNativeId(), seed));
}

/**
Expand Down Expand Up @@ -859,14 +859,10 @@ private static native long stringConcatenationSepCol(long[] columnViews,
*
* @param viewHandles array of native handles to the cudf::column_view columns being operated on.
* @param hashId integer native ID of the hashing function identifier HashType.
* @param initialValues array of integer values, one per column, only used by non-serial murmur3
* hash. Each element's hash value is merged with its column's initial value
* before the row is merged into a single value.
* @param seed integer seed for the hash. Only used by serial murmur3 hash.
* @return native handle of the resulting cudf column containing the hex-string hashing results.
*/
private static native long hash(long[] viewHandles, int hashId, int[] initialValues,
int seed) throws CudfException;
private static native long hash(long[] viewHandles, int hashId, int seed) throws CudfException;

/////////////////////////////////////////////////////////////////////////////
// INTERNAL/NATIVE ACCESS
Expand Down
11 changes: 2 additions & 9 deletions java/src/main/native/src/ColumnVectorJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_concatenate(JNIEnv *env

JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, jobject j_object,
jlongArray column_handles,
jint hash_function_id,
jintArray initial_values, jint seed) {
jint hash_function_id, jint seed) {
JNI_NULL_CHECK(env, column_handles, "array of column handles is null", 0);
JNI_NULL_CHECK(env, initial_values, "array of initial values is null", 0);

try {
cudf::jni::native_jpointerArray<cudf::column_view> n_cudf_columns(env, column_handles);
Expand All @@ -340,13 +338,8 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnVector_hash(JNIEnv *env, jobje
[](auto const &p_column) { return *p_column; });
cudf::table_view *input_table = new cudf::table_view(column_views);

cudf::jni::native_jintArray native_iv(env, initial_values);
std::vector<uint32_t> vector_iv;
std::transform(native_iv.data(), native_iv.data() + native_iv.size(),
std::back_inserter(vector_iv), [](auto const &iv) { return iv; });

std::unique_ptr<cudf::column> result =
cudf::hash(*input_table, static_cast<cudf::hash_id>(hash_function_id), vector_iv, seed);
cudf::hash(*input_table, static_cast<cudf::hash_id>(hash_function_id), seed);
return reinterpret_cast<jlong>(result.release());
}
CATCH_STD(env, 0);
Expand Down

0 comments on commit 67c925c

Please sign in to comment.