Class UInt4NominalBuffer

    • 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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • 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 index1 and index2 with index1/2 == index2/2 from different threads. So when writing in batches of indices [m,n) you must ensure that m and n are even.

        Specified by:
        set in class NominalBuffer
        Parameters:
        index - the index where the value should be set
        value - 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. Returns true if it worked and false if 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 index1 and index2 with index1/2 == index2/2 from different threads. So when writing in batches of indices [m,n) you must ensure that m and n are even.

        Specified by:
        setSave in class NominalBuffer
        Parameters:
        index - the index where the value should be set
        value - 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 class NominalBuffer
        Returns:
        the size of the buffer
      • 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 class NominalBuffer
        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 class NominalBuffer
        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 be null making the only value negative.
        Specified by:
        toBooleanColumn in class NominalBuffer
        Parameters:
        positiveValue - the positive value or null
        Returns:
        a categorical column with a boolean Dictionary