proper.database
Class Sparser

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.database.ConnectorObject
          extended by proper.database.ExecutorObject
              extended by proper.database.Sparser
All Implemented Interfaces:
ProperInterface

public class Sparser
extends ExecutorObject

This class retrieves a certain percentage of data from a table. Sometimes it is necessary to retrieve only a small sample of a huge table. If a a uniformly distributed sample is preferred the classfield has to be set, too. The Reader class uses this.
Via the iterator you can access the IDs that were chosen for retrieval.

Version:
$Revision: 1.2 $
Author:
FracPete
See Also:
Reader.setPercentage(double)

Field Summary
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
Sparser(Connector conn)
          initializes the object
 
Method Summary
 void clear()
          resets the sparser (percentage back to 0%, i.e.
 java.lang.String getClassField()
          returns the currently set column used as class
 int getClassFieldType()
          returns the sql type of the classfield
 java.lang.String getIndex()
          returns the index the keys are taken from
 int getIndexType()
          returns the sql type of the index
 double getKeyRatio()
          returns the ratio between all rows and all distinct rows, important for tables that do not contain a unique key (then the ratio is >1.0)
 boolean getOnlyClassified()
          returns whether we only want classified instances
 boolean getOnlyUnclassified()
          returns whether we only want unclassified instances
 double getPercentage()
          returns the currently set percentage
 java.lang.String getTable()
          returns the currently set table
 java.util.Iterator iterator()
          returns an iterator over the stored keys
 void setClassField(java.lang.String classField)
          sets the column to use as class
 void setIndex(java.lang.String index)
          sets the index to get the keys from (can be determined automatically!)
 void setOnlyClassified(boolean onlyClassified)
          sets whether we only want to retrieve keys for classified instances, i.e.
 void setOnlyUnclassified(boolean onlyUnclassified)
          sets whether we only want to retrieve keys for unclassified instances, i.e.
 void setPercentage(double percentage)
          sets the percentage of rows to retrieve (0-100), where 0 and 100 mean both "all rows"
 void setTable(java.lang.String table)
          sets the table to work on
 int size()
          returns the number of stored keys
 java.lang.String toString()
          returns some information about the current state
 
Methods inherited from class proper.database.ExecutorObject
getExecutor, getLastException, getLastStatement
 
Methods inherited from class proper.database.ConnectorObject
getConnector
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sparser

public Sparser(Connector conn)
initializes the object

Method Detail

clear

public void clear()
resets the sparser (percentage back to 0%, i.e. all)


setTable

public void setTable(java.lang.String table)
sets the table to work on


getTable

public java.lang.String getTable()
returns the currently set table


setIndex

public void setIndex(java.lang.String index)
sets the index to get the keys from (can be determined automatically!)


getIndex

public java.lang.String getIndex()
returns the index the keys are taken from


getIndexType

public int getIndexType()
returns the sql type of the index

See Also:
Types

setClassField

public void setClassField(java.lang.String classField)
sets the column to use as class


getClassField

public java.lang.String getClassField()
returns the currently set column used as class


getClassFieldType

public int getClassFieldType()
returns the sql type of the classfield

See Also:
Types

setOnlyClassified

public void setOnlyClassified(boolean onlyClassified)
sets whether we only want to retrieve keys for classified instances, i.e. the classfield has to be set to determine the classified state


getOnlyClassified

public boolean getOnlyClassified()
returns whether we only want classified instances


setOnlyUnclassified

public void setOnlyUnclassified(boolean onlyUnclassified)
sets whether we only want to retrieve keys for unclassified instances, i.e. the classfield has to be set to determine the unclassified state


getOnlyUnclassified

public boolean getOnlyUnclassified()
returns whether we only want unclassified instances


setPercentage

public void setPercentage(double percentage)
sets the percentage of rows to retrieve (0-100), where 0 and 100 mean both "all rows"


getPercentage

public double getPercentage()
returns the currently set percentage


getKeyRatio

public double getKeyRatio()
returns the ratio between all rows and all distinct rows, important for tables that do not contain a unique key (then the ratio is >1.0)


iterator

public java.util.Iterator iterator()
returns an iterator over the stored keys


size

public int size()
returns the number of stored keys


toString

public java.lang.String toString()
returns some information about the current state

Overrides:
toString in class ProperObject