edu.ksu.cis.kdd.data
Class DatabaseTally

java.lang.Object
  extended byedu.ksu.cis.kdd.data.DatabaseTally
All Implemented Interfaces:
Tally
Direct Known Subclasses:
JDBCTally, LocalDatabaseTally

public abstract class DatabaseTally
extends java.lang.Object
implements Tally

Tallying for database. This is incorrect yet

Author:
Roby Joehanes

Field Summary
protected  int[] allAttributeIndices
           
protected  edu.ksu.cis.kdd.data.DatabaseTally.Cache[] attributeCache
           
protected  int[] attributeIndices
           
protected  Attribute[] attributes
           
protected  Database db
           
protected  int numTables
           
protected  int[] tableBaseIndex
           
protected  Table[] tables
           
protected  TableTally[] tallies
           
 
Method Summary
 void dumpTallyStatus()
           
 int[] getAllAttributeIndices()
           
 Attribute getAtttribute(int idx)
           
 int[] getRelevantAttributeIndices()
           
 Table[] getTables()
           
 TableTally[] getTallies()
          Returns the tally for each table.
 Data getUnderlyingData()
           
 java.util.List groupedTally(int[] indices)
           
protected  java.util.List groupedTally(int[] indices, int[] values, int depth, java.util.List valueList)
           
protected  void preprocess()
          This big chunk of code is for preprocessing the database.
 void setUnderlyingData(Data d)
           
abstract  int tally(int attr, int value)
           
 java.lang.String toString()
          Dump tallyer status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.ksu.cis.kdd.data.Tally
createSubTally, createSubTally, size, tally
 

Field Detail

db

protected Database db

tallies

protected TableTally[] tallies

tables

protected Table[] tables

attributeCache

protected edu.ksu.cis.kdd.data.DatabaseTally.Cache[] attributeCache

attributeIndices

protected int[] attributeIndices

allAttributeIndices

protected int[] allAttributeIndices

tableBaseIndex

protected int[] tableBaseIndex

numTables

protected int numTables

attributes

protected Attribute[] attributes
Method Detail

preprocess

protected void preprocess()

This big chunk of code is for preprocessing the database. The process is roughly as follows:

  1. Sort the table according to the dependency (see Database.getSortedTables)
  2. After sorting, assign each attribute of each table a number in ascending order.
  3. Find the linking reference index (on either forward or backward reference).

Note to self: Do NOT call this method in the constructor as it would slow down the createSubTally.


getAllAttributeIndices

public int[] getAllAttributeIndices()
Returns:
The array of attribute indices that includes primary and reference keys

getRelevantAttributeIndices

public int[] getRelevantAttributeIndices()
Specified by:
getRelevantAttributeIndices in interface Tally
Returns:
The array of attribute indices that does not include primary or reference keys

getAtttribute

public Attribute getAtttribute(int idx)

getTables

public Table[] getTables()

getTallies

public TableTally[] getTallies()
Returns the tally for each table. That is, if the learner algo doesn't want the single table abstraction. Note: Do not modify this if you later want to use database tally. Rather, create a subtally instead

Returns:
Tally[]

tally

public abstract int tally(int attr,
                          int value)
Specified by:
tally in interface Tally

toString

public java.lang.String toString()
Dump tallyer status. For debugging purposes only


dumpTallyStatus

public void dumpTallyStatus()

getUnderlyingData

public Data getUnderlyingData()
Specified by:
getUnderlyingData in interface Tally

setUnderlyingData

public void setUnderlyingData(Data d)
Specified by:
setUnderlyingData in interface Tally

groupedTally

public java.util.List groupedTally(int[] indices)
Specified by:
groupedTally in interface Tally
See Also:
edu.ksu.cis.kdd.data.TallyInterface#groupedTally(int[])

groupedTally

protected java.util.List groupedTally(int[] indices,
                                      int[] values,
                                      int depth,
                                      java.util.List valueList)