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

Expose Scalar's constructor and Scalar#getScalarHandle() to public #17580

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all 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
21 changes: 16 additions & 5 deletions java/src/main/java/ai/rapids/cudf/Scalar.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,28 @@ private static ColumnVector buildNullColumnVector(HostColumnVector.DataType host
private static native long makeStructScalar(long[] viewHandles, boolean isValid);
private static native long repeatString(long scalarHandle, int repeatTimes);

Scalar(DType type, long scalarHandle) {
/**
* Constructor to create a scalar from a native handle and a type.
*
* @param type The type of the scalar
* @param scalarHandle The native handle (pointer address) to the scalar data
*/
public Scalar(DType type, long scalarHandle) {
this.type = type;
this.offHeap = new OffHeapState(scalarHandle);
MemoryCleaner.register(this, offHeap);
incRefCount();
}

/**
* Get the native handle (native pointer address) for the scalar.
*
* @return The native handle
*/
public long getScalarHandle() {
return offHeap.scalarHandle;
}

/**
* Increment the reference count for this scalar. You need to call close on this
* to decrement the reference count again.
Expand All @@ -542,10 +557,6 @@ public synchronized Scalar incRefCount() {
return this;
}

long getScalarHandle() {
return offHeap.scalarHandle;
}

/**
* Free the memory associated with a scalar.
*/
Expand Down
Loading