-
Notifications
You must be signed in to change notification settings - Fork 68
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
Hyper log log plus plus(HLL++) #2522
Open
res-life
wants to merge
19
commits into
NVIDIA:branch-25.02
Choose a base branch
from
res-life:hll
base: branch-25.02
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,428
−2
Open
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
03c0f5a
Add HLL++ evaluation function
df8b223
Update function comments
2daca3f
Fix
3afdfde
Use exec_policy_nosync instead of exec_policy
956af39
Format code; Remove a useless file
8aaf0f6
Merge branch 'branch-25.02' into hll
5bfb544
Use UDF
f8c6a02
Use UDF
208d67e
Use UDF
e29d5a1
Address comments
9f7ec44
Merge branch 'branch-25.02' into hll
3c70a30
Merge branch 'branch-25.02' into hll
3e22512
Fix compile error
aa7ca68
Handle null inputs: must ignore the null input values
f0970c0
Rename refactor: Correct spelling errors
2e74412
Update copyright for new year 2025
7fe4a39
Use get_current_device_resource_ref
b7058a7
Fix comments
78cc207
Fix comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2024, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "cudf_jni_apis.hpp" | ||
#include "hyper_log_log_plus_plus.hpp" | ||
#include "hyper_log_log_plus_plus_host_udf.hpp" | ||
|
||
extern "C" { | ||
|
||
JNIEXPORT jlong JNICALL | ||
Java_com_nvidia_spark_rapids_jni_HyperLogLogPlusPlusHostUDF_createHLLPPHostUDF(JNIEnv* env, | ||
jclass, | ||
jint agg_type, | ||
int precision) | ||
{ | ||
try { | ||
cudf::jni::auto_set_device(env); | ||
auto udf_ptr = [&] { | ||
// The value of agg_type must be sync with | ||
// `HyperLogLogPlusPlusHostUDF.java#AggregationType`. | ||
switch (agg_type) { | ||
case 0: return spark_rapids_jni::create_hllpp_reduction_host_udf(precision); | ||
case 1: return spark_rapids_jni::create_hllpp_reduction_merge_host_udf(precision); | ||
case 2: return spark_rapids_jni::create_hllpp_groupby_host_udf(precision); | ||
default: return spark_rapids_jni::create_hllpp_groupby_merge_host_udf(precision); | ||
} | ||
}(); | ||
CUDF_EXPECTS(udf_ptr != nullptr, "Invalid HyperLogLogPlusPlus(HLLPP) UDF instance."); | ||
|
||
return reinterpret_cast<jlong>(udf_ptr.release()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is this pointer released? It looks like this is a memory leak after this. |
||
} | ||
CATCH_STD(env, 0); | ||
} | ||
|
||
JNIEXPORT jlong JNICALL | ||
Java_com_nvidia_spark_rapids_jni_HyperLogLogPlusPlusHostUDF_estimateDistinctValueFromSketches( | ||
JNIEnv* env, jclass, jlong sketches, jint precision) | ||
{ | ||
JNI_NULL_CHECK(env, sketches, "Sketch column is null", 0); | ||
try { | ||
cudf::jni::auto_set_device(env); | ||
auto const sketch_view = reinterpret_cast<cudf::column_view const*>(sketches); | ||
return cudf::jni::ptr_as_jlong( | ||
spark_rapids_jni::estimate_from_hll_sketches(*sketch_view, precision).release()); | ||
} | ||
CATCH_STD(env, 0); | ||
} | ||
|
||
} // extern "C" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done