Package com.rapidminer.belt.buffer
Class UInt16NominalBuffer
- java.lang.Object
-
- com.rapidminer.belt.buffer.NominalBuffer
-
- com.rapidminer.belt.buffer.UInt16NominalBuffer
-
public class UInt16NominalBuffer extends NominalBuffer
Implementation of aNominalBuffer
with category index formatIntegerFormats.Format.UNSIGNED_INT16
that can hold65535
different categories. The category indices are stored asshort
.- Author:
- Gisa Meier
-
-
Field Summary
-
Fields inherited from class com.rapidminer.belt.buffer.NominalBuffer
type
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
differentValues()
Returns the number of different values that were fed into this buffer.java.lang.String
get(int index)
Retrieves the value at the given index.IntegerFormats.Format
indexFormat()
void
set(int index, java.lang.String value)
Sets the data at the given index to the given value.boolean
setSave(int index, java.lang.String value)
Tries to set the data at the given index to the given value.int
size()
CategoricalColumn
toBooleanColumn(java.lang.String positiveValue)
Creates a boolean column with the given positive value if the dictionary has at most two values.CategoricalColumn
toColumn()
Returns a column of the given type using the buffer's data.-
Methods inherited from class com.rapidminer.belt.buffer.NominalBuffer
toString
-
-
-
-
Method Detail
-
get
public java.lang.String get(int index)
Description copied from class:NominalBuffer
Retrieves the value at the given index. This method is thread-safe and can be used alongside invocations ofNominalBuffer.set(int, java.lang.String)
andNominalBuffer.setSave(int, java.lang.String)
. However, this method might not return the latest value set on another thread.- Specified by:
get
in classNominalBuffer
- Parameters:
index
- the index to look up- Returns:
- the value at the index
-
set
public void set(int index, java.lang.String value)
Sets the data at the given index to the given value. This method is thread-safe.- Specified by:
set
in classNominalBuffer
- Parameters:
index
- the index where the value should be setvalue
- the value to set
-
setSave
public boolean setSave(int index, java.lang.String value)
Tries to set the data at the given index to the given value. Returnstrue
if it worked andfalse
if the buffer format cannot hold any more different values. This method is thread-safe.- Specified by:
setSave
in classNominalBuffer
- Parameters:
index
- the index where the value should be setvalue
- the value to set- Returns:
false
if the buffer contained already to many different values to take this value,true
otherwise
-
size
public int size()
- Specified by:
size
in classNominalBuffer
- Returns:
- the size of the buffer
-
indexFormat
public IntegerFormats.Format indexFormat()
- Specified by:
indexFormat
in classNominalBuffer
- Returns:
- the category index format of the buffer determining the maximal number of categories
-
differentValues
public int differentValues()
Description copied from class:NominalBuffer
Returns the number of different values that were fed into this buffer.null
values are not counted.- Specified by:
differentValues
in classNominalBuffer
- Returns:
- the number of different values
-
toColumn
public CategoricalColumn toColumn()
Description copied from class:NominalBuffer
Returns a column of the given type using the buffer's data. The buffer becomes read-only. In contrast to constructing a new buffer from a column this method does not copy the data.- Specified by:
toColumn
in classNominalBuffer
- Returns:
- the categorical column
-
toBooleanColumn
public CategoricalColumn toBooleanColumn(java.lang.String positiveValue)
Description copied from class:NominalBuffer
Creates a boolean column with the given positive value if the dictionary has at most two values. The positive value must be either one of the dictionary values, making the other value, if it exists, negative. Or in case of a dictionary with only one value the positive value can benull
making the only value negative.- Specified by:
toBooleanColumn
in classNominalBuffer
- Parameters:
positiveValue
- the positive value ornull
- Returns:
- a categorical column with a boolean
Dictionary
-
-