Skip to content

Commit

Permalink
Use HostMemoryAllocator in ParquetFooter
Browse files Browse the repository at this point in the history
depends on rapidsai/cudf#13975

Signed-off-by: Gera Shegalov <[email protected]>
  • Loading branch information
gerashegalov committed Aug 26, 2023
1 parent 88c0a9f commit 66d43d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/cpp/src/NativeParquetJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_ParquetFooter_getNumCol
}

JNIEXPORT jobject JNICALL Java_com_nvidia_spark_rapids_jni_ParquetFooter_serializeThriftFile(
JNIEnv* env, jclass, jlong handle)
JNIEnv* env, jclass, jlong handle, jobject host_memory_allocator)
{
CUDF_FUNC_RANGE();
try {
Expand All @@ -798,7 +798,7 @@ JNIEXPORT jobject JNICALL Java_com_nvidia_spark_rapids_jni_ParquetFooter_seriali
transportOut->getBuffer(&buf_ptr, &buf_size);

// 12 extra is for the MAGIC thrift_footer length MAGIC
jobject ret = cudf::jni::allocate_host_buffer(env, buf_size + 12, false);
jobject ret = cudf::jni::allocate_host_buffer(env, buf_size + 12, false, host_memory_allocator);
uint8_t* ret_addr = reinterpret_cast<uint8_t*>(cudf::jni::get_host_buffer_address(env, ret));
ret_addr[0] = 'P';
ret_addr[1] = 'A';
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/nvidia/spark/rapids/jni/ParquetFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ private ParquetFooter(long handle) {
* footer file. This will include the MAGIC PAR1 at the beginning and end and also the
* length of the footer just before the PAR1 at the end.
*/
public HostMemoryBuffer serializeThriftFile(HostMemoryAllocator hostMemoryAllocator) {
return serializeThriftFile(nativeHandle, hostMemoryAllocator);
}

public HostMemoryBuffer serializeThriftFile() {
return serializeThriftFile(nativeHandle);
return serializeThriftFile(DefaultHostMemoryAllocator.get());
}

/**
Expand Down Expand Up @@ -232,5 +236,6 @@ private static native long readAndFilter(long address, long length,

private static native int getNumColumns(long nativeHandle);

private static native HostMemoryBuffer serializeThriftFile(long nativeHandle);
private static native HostMemoryBuffer serializeThriftFile(long nativeHandle,
HostMemoryAllocator hostMemoryAllocator);
}

0 comments on commit 66d43d7

Please sign in to comment.