Scalar#
- public final class Scalar implements AutoCloseable, BinaryOperable#
A single scalar value.
Constructor Summary
Constructor to create a scalar from a native handle and a type.
Method Summary
Multiple different binary operations.
Free the memory associated with a scalar.
Returns a DURATION_DAYS scalar.
Returns a DURATION_DAYS scalar.
Returns a duration scalar based on the type parameter.
Returns a duration scalar based on the type parameter.
Creates a String scalar from an array of UTF8 bytes.
Returns the scalar value as a BigDecimal.
Returns the BigDecimal unscaled scalar value as a byte array.
Returns the scalar value as a boolean.
Returns the scalar value as a byte.
Fetches views of children columns from struct scalar.
Returns the scalar value as a double.
Returns the scalar value as a float.
Returns the scalar value as an int.
Returns the scalar value as a Java string.
Returns the scalar value as a ColumnView.
Returns the scalar value as a long.
Get the native handle (native pointer address) for the scalar.
Returns the scalar value as a short.
Get the type of this data.
Returns the scalar value as UTF-8 data.
Increment the reference count for this scalar.
Creates a scalar of list from a ColumnView.
Creates a null scalar of list type.
Repeat the given string scalar a number of times specified by the repeatTimes parameter.
Creates a scalar of struct from a ColumnView.
Creates a null scalar of struct type.
Methods inherited from interface
ai.rapids.cudf.BinaryOperable:add,and,arctan2,bitAnd,bitOr,bitXor,div,equalTo,equalToNullAware,floorDiv,greaterOrEqualTo,greaterThan,lessOrEqualTo,lessThan,log,maxNullAware,minNullAware,mod,mul,notEqualTo,notEqualToNullAware,or,pmod,pow,shiftLeft,shiftRight,shiftRightUnsigned,sub,trueDivConstructors
- public Scalar(DType type, long scalarHandle)#
Constructor to create a scalar from a native handle and a type.
- Parameters:
type – The type of the scalar
scalarHandle – The native handle (pointer address) to the scalar data
Methods
- public long getScalarHandle()#
Get the native handle (native pointer address) for the scalar.
- Returns:
The native handle
- public Scalar incRefCount()#
Increment the reference count for this scalar.
You need to call close on this to decrement the reference count again.
- public void close()#
Free the memory associated with a scalar.
- public boolean isValid()#
- public boolean getBoolean()#
Returns the scalar value as a boolean.
- public byte getByte()#
Returns the scalar value as a byte.
- public short getShort()#
Returns the scalar value as a short.
- public int getInt()#
Returns the scalar value as an int.
- public long getLong()#
Returns the scalar value as a long.
- public byte[] getBigInteger()#
Returns the BigDecimal unscaled scalar value as a byte array.
- public float getFloat()#
Returns the scalar value as a float.
- public double getDouble()#
Returns the scalar value as a double.
- public BigDecimal getBigDecimal()#
Returns the scalar value as a BigDecimal.
- public byte[] getUTF8()#
Returns the scalar value as UTF-8 data.
- public ColumnView 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.
- public ColumnView[] 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
- public ColumnVector binaryOp(
- BinaryOp op,
- BinaryOperable rhs,
- DType outType
Multiple different binary operations.
- Parameters:
op – the operation to perform
rhs – the rhs of the operation
outType – the type of output you want.
- Returns:
the result
- public int hashCode()#
- public Scalar repeatString(int repeatTimes)#
Repeat the given string scalar a number of times specified by the
repeatTimesparameter.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 of
repeatTimes.- 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.
Static Methods
- public static Scalar durationDaysFromInt(int value)#
Returns a DURATION_DAYS scalar.
- Parameters:
value – - days
- Returns:
- Scalar value
- public static Scalar durationDaysFromInt(Integer value)#
Returns a DURATION_DAYS scalar.
- Parameters:
value – - days
- Returns:
- Scalar value
- public static Scalar fromDecimal(int scale, BigInteger unscaledValue)#
- public static Scalar fromDecimal(BigDecimal value)#
- public static Scalar fromDecimal(BigInteger unscaledValue, DType dt)#
- public static Scalar durationFromLong(DType type, long value)#
Returns a duration scalar based on the type parameter.
- Parameters:
type – - dtype of scalar to be returned
value – - corresponding value for the scalar
- Returns:
- Scalar of the respective type
- public static Scalar durationFromLong(DType type, Long value)#
Returns a duration scalar based on the type parameter.
- Parameters:
type – - dtype of scalar to be returned
value – - corresponding value for the scalar
- Returns:
- Scalar of the respective type
- public static Scalar fromUTF8String(byte[] value)#
Creates a String scalar from an array of UTF8 bytes.
- Parameters:
value – the array of UTF8 bytes
- Returns:
a String scalar
- public static Scalar listFromNull(
- HostColumnVector.DataType elementType
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
- public static Scalar listFromColumnView(ColumnView list)#
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.
- public static Scalar structFromNull(
- HostColumnVector.DataType... elementTypes
Creates a null scalar of struct type.
- Parameters:
elementTypes – data types of children in the struct
- Returns:
a null scalar of struct type
- public static Scalar structFromColumnViews(ColumnView... columns)#
Creates a scalar of struct from a ColumnView.
- Parameters:
columns – children columns of struct
- Returns:
a Struct scalar