Package smile.data.vector
Interface ValueVector
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractVector
,BooleanVector
,ByteVector
,CharVector
,DoubleVector
,FloatVector
,IntVector
,LongVector
,NullableBooleanVector
,NullableByteVector
,NullableCharVector
,NullableDoubleVector
,NullableFloatVector
,NullableIntVector
,NullableLongVector
,NullablePrimitiveVector
,NullableShortVector
,NumberVector
,ObjectVector
,PrimitiveVector
,ShortVector
,StringVector
ValueVector interface is an abstraction that is used to store a sequence
of values having the same type in an individual column of data frame.
The implementation should support random access and sequential stream
operations.
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
anyNull()
Returns true if there are any null/missing values in this vector.default Object
apply
(int i) Returns the value at position i, which may be null.default ValueVector
apply
(int... indices) Returns a new vector with selected entries.default DoubleStream
Returns a DoubleStream consisting of the elements of this vector, converted to double.default DataType
dtype()
Returns the data type of elements.default boolean[]
Returns the result of equality comparison.field()
Returns the struct field of the vector.default <T extends Comparable<T>>
boolean[]ge
(T other) Returns the result of greater-than or equal comparison.get
(int i) Returns the value at position i, which may be null.default ValueVector
get
(int... indices) Returns a new vector with selected entries.Returns a new vector with selected entries.boolean
getBoolean
(int i) Returns the boolean value at position i.byte
getByte
(int i) Returns the byte value at position i.char
getChar
(int i) Returns the character value at position i.double
getDouble
(int i) Returns the double value at position i.float
getFloat
(int i) Returns the float value at position i.int
getInt
(int i) Returns the integer value at position i.long
getLong
(int i) Returns the long value at position i.int
Returns the number of null/missing values in this vector.default String
getScale
(int i) Returns the value at position i of NominalScale or OrdinalScale.short
getShort
(int i) Returns the short value at position i.default String
getString
(int i) Returns the string representation of the value at position i.default <T extends Comparable<T>>
boolean[]gt
(T other) Returns the result of greater-than comparison.default IntStream
Returns an IntStream consisting of the elements of this vector, converted to integer.default boolean[]
Returns whether each element is contained in values.default boolean[]
isNull()
Returns whether each element is null/missing.boolean
Returns true if the values of vector may be null.boolean
isNullAt
(int i) Returns true if the value at the given index is null/missing.default <T extends Comparable<T>>
boolean[]le
(T other) Returns the result of less-than or equal comparison.default LongStream
Returns a LongStream consisting of the elements of this vector, converted to long.default <T extends Comparable<T>>
boolean[]lt
(T other) Returns the result of less-than comparison.default Measure
measure()
Returns the (optional) level of measurements.default String
name()
Returns the name of vector.default boolean[]
Returns the result of non-equality comparison.static ValueVector
Creates a nominal value vector.static ValueVector
Creates a nominal value vector.static BooleanVector
Creates a boolean vector.static ByteVector
Creates a byte vector.static CharVector
Creates a char vector.static DoubleVector
Creates a named double vector.static FloatVector
Creates a float vector.static IntVector
Creates an integer vector.static LongVector
Creates a long vector.static ShortVector
Creates a short integer vector.static StringVector
Creates a string vector.static NumberVector
<BigDecimal> of
(String name, BigDecimal... vector) Creates a decimal vector.static ObjectVector
<Timestamp> Creates a timestamp vector.static ObjectVector
<Instant> Creates an instant vector.static ObjectVector
<LocalDate> Creates a date vector.static ObjectVector
<LocalDateTime> of
(String name, LocalDateTime... vector) Creates a datetime vector.static ObjectVector
<LocalTime> Creates a time vector.static ObjectVector
<OffsetTime> of
(String name, OffsetTime... vector) Creates a time vector.static ObjectVector
<ZonedDateTime> of
(String name, ZonedDateTime... vector) Creates a datetime vector.static NullableBooleanVector
ofNullable
(String name, Boolean... vector) Creates a nullable boolean vector.static NullableByteVector
ofNullable
(String name, Byte... vector) Creates a nullable byte vector.static NullableCharVector
ofNullable
(String name, Character... vector) Creates a nullable char vector.static NullableDoubleVector
ofNullable
(String name, Double... vector) Creates a nullable double vector.static NullableFloatVector
ofNullable
(String name, Float... vector) Creates a nullable float vector.static NullableIntVector
ofNullable
(String name, Integer... vector) Creates a nullable integer vector.static NullableLongVector
ofNullable
(String name, Long... vector) Creates a nullable long integer vector.static NullableShortVector
ofNullable
(String name, Short... vector) Creates a nullable short integer vector.static ValueVector
Creates a nominal value vector.static ValueVector
Creates a nominal value vector.void
Sets the value at position i.int
size()
Returns the number of elements in the vector.default ValueVector
slice
(int start, int end) Returns the slice index for [start, end) with step 1.default ValueVector
slice
(int start, int end, int step) Returns the slice index for [start, end) with step 1.default Stream
<?> stream()
Returns a stream consisting of the elements of this vector.default double[]
Returns a double array of this vector.default int[]
Returns an int array of this vector.default long[]
Returns a long array of this vector.default String[]
Returns a string array of this vector.default String[]
toStringArray
(String[] a) Copies the vector value as string to the given array.default void
Updates the value at position i.Returns the vector with the new name.
-
Method Details
-
field
StructField field()Returns the struct field of the vector.- Returns:
- the struct field.
-
size
int size()Returns the number of elements in the vector.- Returns:
- the number of elements in the vector.
-
withName
Returns the vector with the new name.- Parameters:
name
- the new name.- Returns:
- the vector with the new name.
-
name
Returns the name of vector.- Returns:
- the name of vector.
-
dtype
Returns the data type of elements.- Returns:
- the data type of elements.
-
measure
Returns the (optional) level of measurements. Only valid for number types.- Returns:
- the (optional) level of measurements.
-
isNullable
boolean isNullable()Returns true if the values of vector may be null.- Returns:
- true if the values of vector may be null.
-
isNullAt
boolean isNullAt(int i) Returns true if the value at the given index is null/missing.- Parameters:
i
- the index.- Returns:
- true if the value at the given index is null/missing.
-
getNullCount
int getNullCount()Returns the number of null/missing values in this vector.- Returns:
- the number of null/missing values in this vector.
-
eq
Returns the result of equality comparison.- Parameters:
other
- the reference object with which to compare.- Returns:
- the result of equality comparison.
-
ne
Returns the result of non-equality comparison.- Parameters:
other
- the reference object with which to compare.- Returns:
- the result of non-equality comparison.
-
lt
Returns the result of less-than comparison.- Parameters:
other
- the reference object with which to compare.- Returns:
- the result of less-than comparison.
-
le
Returns the result of less-than or equal comparison.- Parameters:
other
- the reference object with which to compare.- Returns:
- the result of less-than or equal comparison.
-
gt
Returns the result of greater-than comparison.- Parameters:
other
- the reference object with which to compare.- Returns:
- the result of greater-than comparison.
-
ge
Returns the result of greater-than or equal comparison.- Parameters:
other
- the reference object with which to compare.- Returns:
- the result of greater-than or equal comparison.
-
anyNull
default boolean anyNull()Returns true if there are any null/missing values in this vector.- Returns:
- true if there are any null/missing values in this vector.
-
isNull
default boolean[] isNull()Returns whether each element is null/missing.- Returns:
- whether each element is null/missing.
-
isin
Returns whether each element is contained in values.- Parameters:
values
- the set of values.- Returns:
- whether each element is contained in values.
-
stream
Returns a stream consisting of the elements of this vector.- Returns:
- a stream consisting of the elements of this vector.
-
intStream
Returns an IntStream consisting of the elements of this vector, converted to integer.- Returns:
- an IntStream consisting of the elements of this vector.
-
longStream
Returns a LongStream consisting of the elements of this vector, converted to long.- Returns:
- a LongStream consisting of the elements of this vector.
-
doubleStream
Returns a DoubleStream consisting of the elements of this vector, converted to double.- Returns:
- a DoubleStream consisting of the elements of this vector.
-
toIntArray
default int[] toIntArray()Returns an int array of this vector.- Returns:
- an int array.
-
toLongArray
default long[] toLongArray()Returns a long array of this vector.- Returns:
- a long array.
-
toDoubleArray
default double[] toDoubleArray()Returns a double array of this vector.- Returns:
- a double array.
-
toStringArray
Returns a string array of this vector.- Returns:
- the string array.
-
toStringArray
Copies the vector value as string to the given array.- Parameters:
a
- the array to copy into.- Returns:
- the input array
a
.
-
get
Returns the value at position i, which may be null.- Parameters:
i
- the index.- Returns:
- the value.
-
apply
Returns the value at position i, which may be null. This is an alias toget
for Scala's convenience.- Parameters:
i
- the index.- Returns:
- the value.
-
set
Sets the value at position i.- Parameters:
i
- the index.value
- the new value.
-
update
Updates the value at position i. This is an alias toset
for Scala's convenience.- Parameters:
i
- the index.value
- the new value.
-
get
Returns a new vector with selected entries.- Parameters:
index
- the index of selected entries.- Returns:
- the new vector of selected entries.
-
get
Returns a new vector with selected entries.- Parameters:
indices
- the index of selected entries.- Returns:
- the new vector of selected entries.
-
apply
Returns a new vector with selected entries. This is an alias toget
for Scala's convenience.- Parameters:
indices
- the index of selected entries.- Returns:
- the new vector of selected entries.
-
slice
Returns the slice index for [start, end) with step 1.- Parameters:
start
- the start index.end
- the end index.- Returns:
- the slice.
-
slice
Returns the slice index for [start, end) with step 1.- Parameters:
start
- the start index.end
- the end index.step
- the incremental step.- Returns:
- the slice.
-
getString
Returns the string representation of the value at position i.- Parameters:
i
- the index.- Returns:
- string representation.
-
getScale
Returns the value at position i of NominalScale or OrdinalScale.- Parameters:
i
- the index.- Returns:
- the value scale.
- Throws:
ClassCastException
- when the data is not nominal or ordinal.
-
getBoolean
boolean getBoolean(int i) Returns the boolean value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getChar
char getChar(int i) Returns the character value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getByte
byte getByte(int i) Returns the byte value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getShort
short getShort(int i) Returns the short value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getInt
int getInt(int i) Returns the integer value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getLong
long getLong(int i) Returns the long value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getFloat
float getFloat(int i) Returns the float value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
getDouble
double getDouble(int i) Returns the double value at position i.- Parameters:
i
- the index.- Returns:
- the value.
-
of
Creates a boolean vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable boolean vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a char vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable char vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a byte vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable byte vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a short integer vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable short integer vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates an integer vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable integer vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a long vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable long integer vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a float vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable float vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a named double vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ofNullable
Creates a nullable double vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a string vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a decimal vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a timestamp vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates an instant vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a datetime vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a datetime vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a date vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a time vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
of
Creates a time vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
nominal
Creates a nominal value vector.- Parameters:
name
- the name of vector.vector
- the enum data of vector.- Returns:
- the vector.
-
nominal
Creates a nominal value vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-
ordinal
Creates a nominal value vector.- Parameters:
name
- the name of vector.vector
- the enum data of vector.- Returns:
- the vector.
-
ordinal
Creates a nominal value vector.- Parameters:
name
- the name of vector.vector
- the data of vector.- Returns:
- the vector.
-