Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize date/time truncation for scalar format #2687

Merged
merged 10 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/main/cpp/src/DateTimeUtilsJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,34 @@ JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_DateTimeUtils_rebaseJul
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_DateTimeUtils_truncate(JNIEnv* env,
jclass,
jlong datetime,
jlong format)
JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_DateTimeUtils_truncateWithColumnFormat(
JNIEnv* env, jclass, jlong datetime, jlong format)
{
JNI_NULL_CHECK(env, datetime, "datetime column is null", 0);
JNI_NULL_CHECK(env, format, "format column is null", 0);
JNI_NULL_CHECK(env, datetime, "input datetime is null", 0);
JNI_NULL_CHECK(env, format, "input format is null", 0);

try {
cudf::jni::auto_set_device(env);

auto const datetime_cv = reinterpret_cast<cudf::column_view const*>(datetime);
auto const format_cv = reinterpret_cast<cudf::column_view const*>(format);
auto output = spark_rapids_jni::truncate(*datetime_cv, *format_cv);
return reinterpret_cast<jlong>(output.release());
return reinterpret_cast<jlong>(spark_rapids_jni::truncate(*datetime_cv, *format_cv).release());
}
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_com_nvidia_spark_rapids_jni_DateTimeUtils_truncateWithScalarFormat(
JNIEnv* env, jclass, jlong datetime, jstring format)
{
JNI_NULL_CHECK(env, datetime, "input datetime is null", 0);

try {
cudf::jni::auto_set_device(env);

auto const datetime_cv = reinterpret_cast<cudf::column_view const*>(datetime);
auto const format_jstr = cudf::jni::native_jstring(env, format);
auto const format = std::string(format_jstr.get(), format_jstr.size_bytes());
return reinterpret_cast<jlong>(spark_rapids_jni::truncate(*datetime_cv, format).release());
}
CATCH_STD(env, 0);
}
Expand Down
Loading
Loading