com.rapidminer.example.table
Class MemoryExampleTable

java.lang.Object
  extended by com.rapidminer.example.table.AbstractExampleTable
      extended by com.rapidminer.example.table.MemoryExampleTable
All Implemented Interfaces:
ExampleTable, java.io.Serializable

public class MemoryExampleTable
extends AbstractExampleTable

This class is the core data supplier for example sets. Several example sets can use the same data and access the attribute values by reference. In this case the data is hold in the main memory during the process.

Author:
Ingo Mierswa
See Also:
Serialized Form

Constructor Summary
MemoryExampleTable(java.util.List<Attribute> attributes)
          Creates a new instance of MemoryExampleTable.
MemoryExampleTable(java.util.List<Attribute> attributes, DataRowFactory factory, int size)
          Creates a new instance of MemoryExampleTable.
MemoryExampleTable(java.util.List<Attribute> attributes, DataRowReader i)
          Creates an empty memory example table and fills it with the data rows read from i.
MemoryExampleTable(java.util.List<Attribute> attributes, DataRowReader i, boolean permutate)
          Creates an empty memory example table and fills it with the data rows read from i.
 
Method Summary
 int addAttribute(Attribute attribute)
          Adds a new attribute to this example table by invoking the super method.
 void addAttributes(java.util.Collection<Attribute> newAttributes)
          Adds all Attributes in newAttributes to the end of the list of attributes, creating new data columns if necessary.
 void addDataRow(DataRow dataRow)
          Convenience method allowing the adding of data rows without a data row reader.
 void clear()
          Clears the table.
static MemoryExampleTable createCompleteCopy(ExampleTable oldTable)
           
 DataRow getDataRow(int index)
          Returns the data row with the given index.
 DataRowReader getDataRowReader()
          Returns a new data row reader.
 void readExamples(DataRowReader i)
          Reads the examples into memory in the order they are delivered by the given reader.
 void readExamples(DataRowReader i, boolean permutate)
          Reads the examples into memory and permutates the order.
 void readExamples(DataRowReader i, boolean permutate, java.util.Random random)
          Reads the examples into memory and permutates the order.
 boolean removeDataRow(DataRow dataRow)
          Convenience method for removing data rows.
 DataRow removeDataRow(int index)
          Convenience method for removing data rows.
 int size()
          Returns the size of this example table, i.e. the number of data rows.
 
Methods inherited from class com.rapidminer.example.table.AbstractExampleTable
createExampleSet, createExampleSet, createExampleSet, createExampleSet, createExampleSet, createExampleSet, findAttribute, getAttribute, getAttributeCount, getAttributes, getNumberOfAttributes, removeAttribute, removeAttribute, toDataString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MemoryExampleTable

public MemoryExampleTable(java.util.List<Attribute> attributes)
Creates a new instance of MemoryExampleTable.

Parameters:
attributes - List of Attribute containing the attributes of the columns. None of these must be null.

MemoryExampleTable

public MemoryExampleTable(java.util.List<Attribute> attributes,
                          DataRowFactory factory,
                          int size)
Creates a new instance of MemoryExampleTable.

Parameters:
attributes - List of Attribute containing the attributes of the columns. None of these must be null.
size - initial size of this example table. All values will be Double.NaN.

MemoryExampleTable

public MemoryExampleTable(java.util.List<Attribute> attributes,
                          DataRowReader i)
Creates an empty memory example table and fills it with the data rows read from i.


MemoryExampleTable

public MemoryExampleTable(java.util.List<Attribute> attributes,
                          DataRowReader i,
                          boolean permutate)
Creates an empty memory example table and fills it with the data rows read from i.

Method Detail

readExamples

public void readExamples(DataRowReader i)
Reads the examples into memory in the order they are delivered by the given reader. Removes all old data rows first.


readExamples

public void readExamples(DataRowReader i,
                         boolean permutate)
Reads the examples into memory and permutates the order. Removes all old data rows first.


readExamples

public void readExamples(DataRowReader i,
                         boolean permutate,
                         java.util.Random random)
Reads the examples into memory and permutates the order. Removes all old data rows first.


getDataRowReader

public DataRowReader getDataRowReader()
Returns a new data row reader.


getDataRow

public DataRow getDataRow(int index)
Returns the data row with the given index.


size

public int size()
Returns the size of this example table, i.e. the number of data rows.


addDataRow

public void addDataRow(DataRow dataRow)
Convenience method allowing the adding of data rows without a data row reader.


removeDataRow

public boolean removeDataRow(DataRow dataRow)
Convenience method for removing data rows.


removeDataRow

public DataRow removeDataRow(int index)
Convenience method for removing data rows.


clear

public void clear()
Clears the table.


addAttributes

public void addAttributes(java.util.Collection<Attribute> newAttributes)
Adds all Attributes in newAttributes to the end of the list of attributes, creating new data columns if necessary. This method is much faster than calling repeatedly addAttribute, because this would cause the data rows to be enlarged and hence copied many times.

Specified by:
addAttributes in interface ExampleTable
Overrides:
addAttributes in class AbstractExampleTable

addAttribute

public int addAttribute(Attribute attribute)
Adds a new attribute to this example table by invoking the super method. If the number of attributes reaches a threshold, the number of attributes is increased by INCREMENT attributes. This avoids a large number of array copies in cases like automatic feature construction etc.

Specified by:
addAttribute in interface ExampleTable
Overrides:
addAttribute in class AbstractExampleTable

createCompleteCopy

public static MemoryExampleTable createCompleteCopy(ExampleTable oldTable)


Copyright © 2001-2009 by Rapid-I