com.rapidminer.example.table
Class AbstractSparseArrayDataRow

java.lang.Object
  extended by com.rapidminer.example.table.DataRow
      extended by com.rapidminer.example.table.AbstractSparseArrayDataRow
All Implemented Interfaces:
SparseDataRow, java.io.Serializable
Direct Known Subclasses:
BooleanSparseArrayDataRow, ByteSparseArrayDataRow, DoubleSparseArrayDataRow, FloatSparseArrayDataRow, IntSparseArrayDataRow, LongSparseArrayDataRow, ShortSparseArrayDataRow

public abstract class AbstractSparseArrayDataRow
extends DataRow
implements SparseDataRow

Implementation of DataRow that is backed by primitive arrays. Should always be used if more than 50% of the data is sparse. As fast (or even faster than map implementation) but needs considerably less memory.

Author:
Niraj Aswani, Julien Nioche, Ingo Mierswa, Shevek Exp $
See Also:
Serialized Form

Constructor Summary
AbstractSparseArrayDataRow()
          Creates an empty sparse array data row with size 0.
AbstractSparseArrayDataRow(int size)
          Creates a sparse array data row of the given size.
 
Method Summary
 void ensureNumberOfColumns(int numberOfColumns)
          Does nothing.
protected  double get(int val, double defaultValue)
          Returns the desired data for the given attribute.
protected abstract  double[] getAllValues()
           
 int[] getNonDefaultIndices()
          Returns an array of all attribute indices with corresponding non-default values.
 double[] getNonDefaultValues()
          Returns an array of all non-default attribute values.
protected abstract  double getValue(int index)
           
protected abstract  void removeValue(int index)
           
protected abstract  void resizeValues(int length)
           
protected  void set(int index, double value, double defaultValue)
          Sets the given data for the given attribute.
protected abstract  void setValue(int index, double value)
           
protected  void swap(int a, int b)
          Swaps x[a] with x[b].
protected abstract  void swapValues(int a, int b)
           
 java.lang.String toString()
          Returns a string representation of the data row.
 void trim()
          Trims the data row to the number of actually used elements.
 
Methods inherited from class com.rapidminer.example.table.DataRow
get, set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractSparseArrayDataRow

public AbstractSparseArrayDataRow()
Creates an empty sparse array data row with size 0.


AbstractSparseArrayDataRow

public AbstractSparseArrayDataRow(int size)
Creates a sparse array data row of the given size.

Method Detail

removeValue

protected abstract void removeValue(int index)

resizeValues

protected abstract void resizeValues(int length)

setValue

protected abstract void setValue(int index,
                                 double value)

getValue

protected abstract double getValue(int index)

swapValues

protected abstract void swapValues(int a,
                                   int b)

getAllValues

protected abstract double[] getAllValues()

swap

protected void swap(int a,
                    int b)
Swaps x[a] with x[b].


get

protected double get(int val,
                     double defaultValue)
Returns the desired data for the given attribute.

Specified by:
get in class DataRow

set

protected void set(int index,
                   double value,
                   double defaultValue)
Sets the given data for the given attribute.

Specified by:
set in class DataRow

getNonDefaultIndices

public int[] getNonDefaultIndices()
Description copied from interface: SparseDataRow
Returns an array of all attribute indices with corresponding non-default values.

Specified by:
getNonDefaultIndices in interface SparseDataRow

getNonDefaultValues

public double[] getNonDefaultValues()
Description copied from interface: SparseDataRow
Returns an array of all non-default attribute values.

Specified by:
getNonDefaultValues in interface SparseDataRow

ensureNumberOfColumns

public void ensureNumberOfColumns(int numberOfColumns)
Does nothing.

Specified by:
ensureNumberOfColumns in class DataRow

trim

public void trim()
Trims the data row to the number of actually used elements.

Specified by:
trim in class DataRow

toString

public java.lang.String toString()
Returns a string representation of the data row.

Specified by:
toString in class DataRow


Copyright © 2001-2009 by Rapid-I