Class NominalBuffer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected ColumnType<java.lang.String> type  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected NominalBuffer​(ColumnType<java.lang.String> type)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract int differentValues()
      Returns the number of different values that were fed into this buffer.
      abstract java.lang.String get​(int index)
      Retrieves the value at the given index.
      abstract IntegerFormats.Format indexFormat()  
      abstract void set​(int index, java.lang.String value)
      Sets the data at the given index to the given value.
      abstract boolean setSave​(int index, java.lang.String value)
      Tries to set the data at the given index to the given value.
      abstract int size()  
      abstract CategoricalColumn toBooleanColumn​(java.lang.String positiveValue)
      Creates a boolean column with the given positive value if the dictionary has at most two values.
      abstract CategoricalColumn toColumn()
      Returns a column of the given type using the buffer's data.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • type

        protected final ColumnType<java.lang.String> type
    • Constructor Detail

      • NominalBuffer

        protected NominalBuffer​(ColumnType<java.lang.String> type)
    • Method Detail

      • get

        public abstract java.lang.String get​(int index)
        Retrieves the value at the given index. This method is thread-safe and can be used alongside invocations of set(int, java.lang.String) and setSave(int, java.lang.String). However, this method might not return the latest value set on another thread.
        Parameters:
        index - the index to look up
        Returns:
        the value at the index
      • set

        public abstract void set​(int index,
                                 java.lang.String value)
        Sets the data at the given index to the given value.
        Parameters:
        index - the index where the value should be set
        value - the value to set
        Throws:
        java.lang.IllegalStateException - if called after the buffer was used to create a Column
      • setSave

        public abstract 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.
        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
        Throws:
        java.lang.IllegalStateException - if called after the buffer was used to create a Column
      • differentValues

        public abstract int differentValues()
        Returns the number of different values that were fed into this buffer. null values are not counted.
        Returns:
        the number of different values
      • indexFormat

        public abstract IntegerFormats.Format indexFormat()
        Returns:
        the category index format of the buffer determining the maximal number of categories
      • size

        public abstract int size()
        Returns:
        the size of the buffer
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • toColumn

        public abstract CategoricalColumn toColumn()
        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.
        Returns:
        the categorical column
      • toBooleanColumn

        public abstract CategoricalColumn toBooleanColumn​(java.lang.String positiveValue)
        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.
        Parameters:
        positiveValue - the positive value or null
        Returns:
        a categorical column with a boolean Dictionary
        Throws:
        java.lang.IllegalArgumentException - if the given positive value is not one of the values, if there are more than two values in the dictionary or if positive value is null in case there are two values in the dictionary