Package com.rapidminer.belt.buffer
Class UInt4NominalBuffer
- java.lang.Object
-
- com.rapidminer.belt.buffer.NominalBuffer
-
- com.rapidminer.belt.buffer.UInt4NominalBuffer
-
public class UInt4NominalBuffer extends NominalBuffer
Implementation of aNominalBufferwith category index formatIntegerFormats.Format.UNSIGNED_INT4that can hold15different categories. Two category indices are stored in a singlebyte.- 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 intdifferentValues()Returns the number of different values that were fed into this buffer.java.lang.Stringget(int index)Retrieves the value at the given index.IntegerFormats.FormatindexFormat()voidset(int index, java.lang.String value)Sets the data at the given index to the given value.booleansetSave(int index, java.lang.String value)Tries to set the data at the given index to the given value.intsize()CategoricalColumntoBooleanColumn(java.lang.String positiveValue)Creates a boolean column with the given positive value if the dictionary has at most two values.CategoricalColumntoColumn()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:NominalBufferRetrieves 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:
getin 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.Due to the compressed integer format, this method is only thread-safe for indices with different results when divided by 2. Values can be lost when writing at indices
index1andindex2withindex1/2 == index2/2from different threads. So when writing in batches of indices[m,n)you must ensure that m and n are even.- Specified by:
setin 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. Returnstrueif it worked andfalseif the buffer format cannot hold any more different values.Due to the compressed integer format, this method is only thread-safe for indices with different results when divided by 2. Values can be lost when writing at indices
index1andindex2withindex1/2 == index2/2from different threads. So when writing in batches of indices[m,n)you must ensure that m and n are even.- Specified by:
setSavein classNominalBuffer- Parameters:
index- the index where the value should be setvalue- the value to set- Returns:
falseif the buffer contained already to many different values to take this value,trueotherwise
-
size
public int size()
- Specified by:
sizein classNominalBuffer- Returns:
- the size of the buffer
-
indexFormat
public IntegerFormats.Format indexFormat()
- Specified by:
indexFormatin classNominalBuffer- Returns:
- the category index format of the buffer determining the maximal number of categories
-
differentValues
public int differentValues()
Description copied from class:NominalBufferReturns the number of different values that were fed into this buffer.nullvalues are not counted.- Specified by:
differentValuesin classNominalBuffer- Returns:
- the number of different values
-
toColumn
public CategoricalColumn toColumn()
Description copied from class:NominalBufferReturns 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:
toColumnin classNominalBuffer- Returns:
- the categorical column
-
toBooleanColumn
public CategoricalColumn toBooleanColumn(java.lang.String positiveValue)
Description copied from class:NominalBufferCreates 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 benullmaking the only value negative.- Specified by:
toBooleanColumnin classNominalBuffer- Parameters:
positiveValue- the positive value ornull- Returns:
- a categorical column with a boolean
Dictionary
-
-