Skip to content

Commit

Permalink
Merge branch 'branch-0.19' into fix-string-replace
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowe committed Mar 4, 2021
2 parents b508d67 + 4d0c160 commit dd94e10
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
23 changes: 19 additions & 4 deletions java/src/main/java/ai/rapids/cudf/ColumnView.java
Original file line number Diff line number Diff line change
Expand Up @@ -1106,9 +1106,7 @@ public Scalar any(DType outType) {
* Returns a boolean scalar that is true if all of the elements in
* the column are true or non-zero otherwise false.
* Null values are skipped.
* @deprecated the only output type supported is BOOL8.
*/
@Deprecated
public Scalar all() {
return all(DType.BOOL8);
}
Expand All @@ -1118,7 +1116,9 @@ public Scalar all() {
* if all of the elements in the column are true or non-zero
* otherwise false or 0.
* Null values are skipped.
* @deprecated the only output type supported is BOOL8.
*/
@Deprecated
public Scalar all(DType outType) {
return reduce(Aggregation.all(), outType);
}
Expand Down Expand Up @@ -1304,9 +1304,24 @@ public ColumnVector castTo(DType type) {
* types must match.
* @param type the type you want to go to.
* @return a ColumnView that cannot outlive the Column that owns the actual data it points to.
* @deprecated this has changed to bit_cast in C++ so use that name instead
*/
@Deprecated
public ColumnView logicalCastTo(DType type) {
return new ColumnView(logicalCastTo(getNativeView(),
return bitCastTo(type);
}

/**
* Zero-copy cast between types with the same underlying length.
*
* Similar to bit_cast in C++. This will take the underlying data and create new metadata
* so it is interpreted as a new type. Not all types are supported the width of the
* types must match.
* @param type the type you want to go to.
* @return a ColumnView that cannot outlive the Column that owns the actual data it points to.
*/
public ColumnView bitCastTo(DType type) {
return new ColumnView(bitCastTo(getNativeView(),
type.typeId.getNativeId(), type.getScale()));
}

Expand Down Expand Up @@ -2607,7 +2622,7 @@ private static native long stringReplaceWithBackrefs(long columnView, String pat

private static native long castTo(long nativeHandle, int type, int scale);

private static native long logicalCastTo(long nativeHandle, int type, int scale);
private static native long bitCastTo(long nativeHandle, int type, int scale);

private static native long byteListCast(long nativeHandle, boolean config);

Expand Down
8 changes: 4 additions & 4 deletions java/src/main/native/src/ColumnViewJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,16 +760,16 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_castTo(JNIEnv *env, jclas
CATCH_STD(env, 0);
}

JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_logicalCastTo(JNIEnv *env, jclass,
jlong handle, jint type,
jint scale) {
JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_ColumnView_bitCastTo(JNIEnv *env, jclass,
jlong handle, jint type,
jint scale) {
JNI_NULL_CHECK(env, handle, "native handle is null", 0);
try {
cudf::jni::auto_set_device(env);
cudf::column_view *column = reinterpret_cast<cudf::column_view *>(handle);
cudf::data_type n_data_type = cudf::jni::make_data_type(type, scale);
std::unique_ptr<cudf::column_view> result = std::make_unique<cudf::column_view>();
*result = cudf::logical_cast(*column, n_data_type);
*result = cudf::bit_cast(*column, n_data_type);
return reinterpret_cast<jlong>(result.release());
}
CATCH_STD(env, 0);
Expand Down
4 changes: 2 additions & 2 deletions java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2061,10 +2061,10 @@ void emptyStringColumnFindReplaceAll() {
}

@Test
void testLogicalCast() {
void testBitCast() {
try (ColumnVector cv = ColumnVector.decimalFromLongs(-2, 1L, 2L, 100L, 552L);
ColumnVector expected = ColumnVector.fromLongs(1L, 2L, 100L, 552L);
ColumnView casted = cv.logicalCastTo(DType.INT64)) {
ColumnView casted = cv.bitCastTo(DType.INT64)) {
assertColumnsAreEqual(expected, casted);
}
}
Expand Down
1 change: 1 addition & 0 deletions python/cudf/cudf/core/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
PANDAS_GE_100 = PANDAS_VERSION >= version.parse("1.0")
PANDAS_GE_110 = PANDAS_VERSION >= version.parse("1.1")
PANDAS_GE_120 = PANDAS_VERSION >= version.parse("1.2")
PANDAS_EQ_123 = PANDAS_VERSION == version.parse("1.2.3")
7 changes: 3 additions & 4 deletions python/cudf/cudf/tests/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

import cudf
from cudf.core._compat import PANDAS_GE_120
from cudf.core._compat import PANDAS_EQ_123, PANDAS_GE_120
from cudf.tests.utils import assert_eq, assert_exceptions_equal


Expand All @@ -21,9 +21,8 @@ def test_dataframe_setitem_bool_mask_scaler(df, arg, value):


@pytest.mark.xfail(
condition=not PANDAS_GE_120,
reason="pandas incorrectly adds nulls with dataframes "
"but works fine with scalars",
condition=PANDAS_EQ_123 or not PANDAS_GE_120,
reason="https://github.com/pandas-dev/pandas/issues/40204",
)
def test_dataframe_setitem_scaler_bool():
df = pd.DataFrame({"a": [1, 2, 3]})
Expand Down

0 comments on commit dd94e10

Please sign in to comment.