Package ai.rapids.cudf
Class Scalar
java.lang.Object
ai.rapids.cudf.Scalar
- All Implemented Interfaces:
BinaryOperable,AutoCloseable
A single scalar value.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbinaryOp(BinaryOp op, BinaryOperable rhs, DType outType) Multiple different binary operations.voidclose()Free the memory associated with a scalar.static ScalardurationDaysFromInt(int value) Returns a DURATION_DAYS scalarstatic ScalardurationDaysFromInt(Integer value) Returns a DURATION_DAYS scalarstatic ScalardurationFromLong(DType type, long value) Returns a duration scalar based on the type parameter.static ScalardurationFromLong(DType type, Long value) Returns a duration scalar based on the type parameter.booleanstatic ScalarfromBool(boolean value) static Scalarstatic ScalarfromByte(byte value) static Scalarstatic ScalarfromDecimal(int scale, int unscaledValue) static ScalarfromDecimal(int scale, long unscaledValue) static ScalarfromDecimal(int scale, BigInteger unscaledValue) static ScalarfromDecimal(BigDecimal value) static ScalarfromDecimal(BigInteger unscaledValue, DType dt) static ScalarfromDouble(double value) static ScalarfromDouble(Double value) static ScalarfromFloat(float value) static Scalarstatic ScalarfromInt(int value) static Scalarstatic ScalarfromLong(long value) static Scalarstatic Scalarstatic ScalarfromShort(short value) static Scalarstatic ScalarfromString(String value) static ScalarfromUnsignedByte(byte value) static ScalarfromUnsignedByte(Byte value) static ScalarfromUnsignedInt(int value) static ScalarfromUnsignedInt(Integer value) static ScalarfromUnsignedLong(long value) static ScalarfromUnsignedLong(Long value) static ScalarfromUnsignedShort(short value) static ScalarfromUnsignedShort(Short value) static ScalarfromUTF8String(byte[] value) Creates a String scalar from an array of UTF8 bytes.Returns the scalar value as a BigDecimal.byte[]Returns the BigDecimal unscaled scalar value as a byte array.booleanReturns the scalar value as a boolean.bytegetByte()Returns the scalar value as a byte.Fetches views of children columns from struct scalar.doubleReturns the scalar value as a double.floatgetFloat()Returns the scalar value as a float.intgetInt()Returns the scalar value as an int.Returns the scalar value as a Java string.Returns the scalar value as a ColumnView.longgetLong()Returns the scalar value as a long.longGet the native handle (native pointer address) for the scalar.shortgetShort()Returns the scalar value as a short.getType()Get the type of this data.byte[]getUTF8()Returns the scalar value as UTF-8 data.inthashCode()Increment the reference count for this scalar.booleanisValid()static ScalarlistFromColumnView(ColumnView list) Creates a scalar of list from a ColumnView.static ScalarlistFromNull(HostColumnVector.DataType elementType) Creates a null scalar of list type.repeatString(int repeatTimes) Repeat the given string scalar a number of times specified by therepeatTimesparameter.static ScalarstructFromColumnViews(ColumnView... columns) Creates a scalar of struct from a ColumnView.static ScalarstructFromNull(HostColumnVector.DataType... elementTypes) Creates a null scalar of struct type.static ScalartimestampDaysFromInt(int value) static ScalartimestampDaysFromInt(Integer value) static ScalartimestampFromLong(DType type, long value) static ScalartimestampFromLong(DType type, Long value) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.rapids.cudf.BinaryOperable
add, add, and, and, arctan2, arctan2, bitAnd, bitAnd, bitOr, bitOr, bitXor, bitXor, div, div, equalTo, equalTo, equalToNullAware, equalToNullAware, floorDiv, floorDiv, greaterOrEqualTo, greaterOrEqualTo, greaterThan, greaterThan, lessOrEqualTo, lessOrEqualTo, lessThan, lessThan, log, log, maxNullAware, maxNullAware, minNullAware, minNullAware, mod, mod, mul, mul, notEqualTo, notEqualTo, notEqualToNullAware, notEqualToNullAware, or, or, pmod, pmod, pow, pow, shiftLeft, shiftLeft, shiftRight, shiftRight, shiftRightUnsigned, shiftRightUnsigned, sub, sub, trueDiv, trueDiv
-
Constructor Details
-
Scalar
Constructor to create a scalar from a native handle and a type.- Parameters:
type- The type of the scalarscalarHandle- The native handle (pointer address) to the scalar data
-
-
Method Details
-
fromNull
-
fromBool
-
fromBool
-
fromByte
-
fromByte
-
fromUnsignedByte
-
fromUnsignedByte
-
fromShort
-
fromShort
-
fromUnsignedShort
-
fromUnsignedShort
-
durationDaysFromInt
Returns a DURATION_DAYS scalar- Parameters:
value- - days- Returns:
- - Scalar value
-
durationDaysFromInt
Returns a DURATION_DAYS scalar- Parameters:
value- - days- Returns:
- - Scalar value
-
fromInt
-
fromInt
-
fromUnsignedInt
-
fromUnsignedInt
-
fromLong
-
fromLong
-
fromUnsignedLong
-
fromUnsignedLong
-
fromFloat
-
fromDecimal
-
fromDecimal
-
fromDecimal
-
fromFloat
-
fromDouble
-
fromDouble
-
fromDecimal
-
fromDecimal
-
timestampDaysFromInt
-
timestampDaysFromInt
-
durationFromLong
Returns a duration scalar based on the type parameter.- Parameters:
type- - dtype of scalar to be returnedvalue- - corresponding value for the scalar- Returns:
- - Scalar of the respective type
-
durationFromLong
Returns a duration scalar based on the type parameter.- Parameters:
type- - dtype of scalar to be returnedvalue- - corresponding value for the scalar- Returns:
- - Scalar of the respective type
-
timestampFromLong
-
timestampFromLong
-
fromString
-
fromUTF8String
Creates a String scalar from an array of UTF8 bytes.- Parameters:
value- the array of UTF8 bytes- Returns:
- a String scalar
-
listFromNull
Creates a null scalar of list type. Having this special API because the element type is required to build an empty nested column as the underlying column of the list scalar.- Parameters:
elementType- the data type of the element in the list.- Returns:
- a null scalar of list type
-
listFromColumnView
Creates a scalar of list from a ColumnView. All the rows in the ColumnView will be copied into the Scalar. So the ColumnView can be closed after this call completes. -
structFromNull
Creates a null scalar of struct type.- Parameters:
elementTypes- data types of children in the struct- Returns:
- a null scalar of struct type
-
structFromColumnViews
Creates a scalar of struct from a ColumnView.- Parameters:
columns- children columns of struct- Returns:
- a Struct scalar
-
getScalarHandle
public long getScalarHandle()Get the native handle (native pointer address) for the scalar.- Returns:
- The native handle
-
incRefCount
Increment the reference count for this scalar. You need to call close on this to decrement the reference count again. -
close
public void close()Free the memory associated with a scalar.- Specified by:
closein interfaceAutoCloseable
-
getType
Description copied from interface:BinaryOperableGet the type of this data.- Specified by:
getTypein interfaceBinaryOperable
-
isValid
public boolean isValid() -
getBoolean
public boolean getBoolean()Returns the scalar value as a boolean. -
getByte
public byte getByte()Returns the scalar value as a byte. -
getShort
public short getShort()Returns the scalar value as a short. -
getInt
public int getInt()Returns the scalar value as an int. -
getLong
public long getLong()Returns the scalar value as a long. -
getBigInteger
public byte[] getBigInteger()Returns the BigDecimal unscaled scalar value as a byte array. -
getFloat
public float getFloat()Returns the scalar value as a float. -
getDouble
public double getDouble()Returns the scalar value as a double. -
getBigDecimal
Returns the scalar value as a BigDecimal. -
getJavaString
Returns the scalar value as a Java string. -
getUTF8
public byte[] getUTF8()Returns the scalar value as UTF-8 data. -
getListAsColumnView
Returns the scalar value as a ColumnView. Callers should close the returned ColumnView to avoid memory leak. The returned ColumnView is only valid as long as the Scalar remains valid. If the Scalar is closed before this ColumnView is closed, using this ColumnView will result in undefined behavior. -
getChildrenFromStructScalar
Fetches views of children columns from struct scalar. The returned ColumnViews should be closed appropriately. Otherwise, a native memory leak will occur.- Returns:
- array of column views refer to children of struct scalar
-
binaryOp
Description copied from interface:BinaryOperableMultiple different binary operations.- Specified by:
binaryOpin interfaceBinaryOperable- Parameters:
op- the operation to performrhs- the rhs of the operationoutType- the type of output you want.- Returns:
- the result
-
equals
-
hashCode
public int hashCode() -
toString
-
repeatString
Repeat the given string scalar a number of times specified by therepeatTimesparameter. If that parameter has a non-positive value, an empty (valid) string scalar will be returned. An invalid input scalar will always result in an invalid output scalar regardless of the value ofrepeatTimes.- Parameters:
repeatTimes- The number of times the input string is copied to the output.- Returns:
- The resulting scalar containing repeated result of the current string.
-