Exemplo n.º 1
0
def make_aggregate_nullmask(df, columns=None, op="and"):
    out_mask = None
    for k in columns or df.columns:
        if not df[k].has_null_mask:
            continue

        nullmask = df[k].nullmask
        if out_mask is None:
            out_mask = columnops.as_column(nullmask.copy(),
                                           dtype=utils.mask_dtype)
            continue

        cpp_binops.apply_op(columnops.as_column(nullmask), out_mask, out_mask,
                            op)

    return out_mask
Exemplo n.º 2
0
def numeric_column_binop(lhs, rhs, op, out_dtype, reflect=False):
    if reflect:
        lhs, rhs = rhs, lhs
    nvtx_range_push("CUDF_BINARY_OP", "orange")
    # Allocate output
    masked = False
    name = None
    if np.isscalar(lhs):
        masked = rhs.has_null_mask
        row_count = len(rhs)
        name = rhs.name
    elif np.isscalar(rhs):
        masked = lhs.has_null_mask
        row_count = len(lhs)
        name = lhs.name
    else:
        masked = lhs.has_null_mask or rhs.has_null_mask
        row_count = len(lhs)

    is_op_comparison = op in ["lt", "gt", "le", "ge", "eq", "ne"]

    out = columnops.column_empty(row_count, dtype=out_dtype, masked=masked)
    # Call and fix null_count
    null_count = cpp_binops.apply_op(lhs, rhs, out, op)

    if is_op_comparison:
        out.fillna(op == "ne", inplace=True)
    else:
        out = out.replace(null_count=null_count)

    result = out.view(NumericalColumn, dtype=out_dtype, name=name)
    nvtx_range_pop()
    return result
Exemplo n.º 3
0
def binop(lhs, rhs, op, out_dtype):
    nvtx_range_push("CUDF_BINARY_OP", "orange")
    masked = lhs.has_null_mask or rhs.has_null_mask
    out = columnops.column_empty_like(lhs, dtype=out_dtype, masked=masked)
    null_count = cpp_binops.apply_op(lhs, rhs, out, op)
    out = out.replace(null_count=null_count)
    nvtx_range_pop()
    return out
Exemplo n.º 4
0
def string_column_binop(lhs, rhs, op):
    nvtx_range_push("CUDF_BINARY_OP", "orange")
    # Allocate output
    masked = lhs.has_null_mask or rhs.has_null_mask
    out = columnops.column_empty_like(lhs, dtype='bool', masked=masked)
    # Call and fix null_count
    null_count = cpp_binops.apply_op(lhs=lhs, rhs=rhs, out=out, op=op)

    result = out.replace(null_count=null_count)
    nvtx_range_pop()
    return result
Exemplo n.º 5
0
def numeric_column_binop(lhs, rhs, op, out_dtype):
    nvtx_range_push("CUDF_BINARY_OP", "orange")
    # Allocate output
    masked = lhs.has_null_mask or rhs.has_null_mask
    out = columnops.column_empty_like(lhs, dtype=out_dtype, masked=masked)
    # Call and fix null_count
    null_count = cpp_binops.apply_op(lhs, rhs, out, op)

    out = out.replace(null_count=null_count)
    result = out.view(NumericalColumn, dtype=out_dtype)
    nvtx_range_pop()
    return result
Exemplo n.º 6
0
def numeric_column_binop(lhs, rhs, op, out_dtype):
    nvtx_range_push("CUDF_BINARY_OP", "orange")
    # Allocate output
    masked = lhs.has_null_mask or rhs.has_null_mask
    out = columnops.column_empty_like(lhs, dtype=out_dtype, masked=masked)
    # Call and fix null_count
    if lhs.dtype != rhs.dtype or op not in _binary_impl:
        # Use JIT implementation
        null_count = cpp_binops.apply_op(lhs=lhs, rhs=rhs, out=out, op=op)
    else:
        # Use compiled implementation
        null_count = _gdf.apply_binaryop(_binary_impl[op], lhs, rhs, out)

    out = out.replace(null_count=null_count)
    result = out.view(NumericalColumn, dtype=out_dtype)
    nvtx_range_pop()
    return result
Exemplo n.º 7
0
def numeric_column_binop(lhs, rhs, op, out_dtype, reflect=False):
    if reflect:
        lhs, rhs = rhs, lhs
    nvtx_range_push("CUDF_BINARY_OP", "orange")
    # Allocate output
    masked = False
    if np.isscalar(lhs):
        masked = rhs.has_null_mask
        row_count = len(rhs)
    elif np.isscalar(rhs):
        masked = lhs.has_null_mask
        row_count = len(lhs)
    else:
        masked = lhs.has_null_mask or rhs.has_null_mask
        row_count = len(lhs)

    out = columnops.column_empty(row_count, dtype=out_dtype, masked=masked)
    # Call and fix null_count
    null_count = cpp_binops.apply_op(lhs, rhs, out, op)

    out = out.replace(null_count=null_count)
    result = out.view(NumericalColumn, dtype=out_dtype)
    nvtx_range_pop()
    return result