edu.ksu.cis.kdd.data
Class TableTally

java.lang.Object
  extended byedu.ksu.cis.kdd.data.TableTally
All Implemented Interfaces:
Tally, WeightedTally

public class TableTally
extends java.lang.Object
implements WeightedTally

Tallying tuples. Contains cache. So, if you modify the tuples, it won't reflect the changes. You will have to reset the cache manually. OR you can always create a new Tally object.

Author:
Roby Joehanes

Field Summary
protected  Attribute[] attrs
           
protected  java.util.HashSet continuousValues
           
protected  java.util.Set indexableAttr
           
protected  java.util.Hashtable indexCache
           
protected  java.util.Set[] indexedValues
           
protected  int[] local2globalIndex
           
protected  boolean needIndexing
           
protected  DatabaseTally owner
           
protected  Table table
           
protected  int tallyID
           
protected  int tupleCount
           
protected  java.util.Hashtable valueCache
           
 
Method Summary
 Tally createSubTally(int[] indices, int[] values)
          Create a new tally that basically filtered according to the spec mentioned in the q table (i.e. the query table).
 Tally createSubTally(int idx, int value)
          Create subtally that has val[nodeindex] = value.
 void filter(int idx, java.util.Set values)
          Pretty much like createSubTally, except that it doesn't create a new Tally object and apply the filter to this object.
 int getArity(int i)
          Get the values of a particular atribute name
 int getArity(java.lang.String attr)
          Get the values of a particular atribute name
 DatabaseTally getOwner()
           
 int[] getRelevantAttributeIndices()
           
 int getTallyID()
           
 Data getUnderlyingData()
           
 int getValueIndex(java.lang.String attr, java.lang.String value)
           
 java.util.List groupedTally(int[] indices)
           
protected  java.util.List groupedTally(int[] indices, int[] values, int depth, java.util.List valueList)
           
 void resetCache()
           
 void setOwner(DatabaseTally tally)
           
 void setUnderlyingData(Data tuples)
          Sets the tuples.
 int size()
           
 int tally(int[] indices, int[] values)
          Count the number of tuples that is compliant to the spec mentioned in the q table (i.e. the query table).
 int tally(int idx, int value)
          Count the number of tuples that has val[nodeindex] = value.
 double weightedTally()
          Count total weights of the tuples
 double weightedTally(int idx, int value)
          Count the weights of tuples that has val[nodeindex] = value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected Table table

valueCache

protected java.util.Hashtable valueCache

indexCache

protected java.util.Hashtable indexCache

continuousValues

protected java.util.HashSet continuousValues

tupleCount

protected int tupleCount

attrs

protected Attribute[] attrs

tallyID

protected int tallyID

owner

protected DatabaseTally owner

local2globalIndex

protected int[] local2globalIndex

indexableAttr

protected java.util.Set indexableAttr

indexedValues

protected java.util.Set[] indexedValues

needIndexing

protected boolean needIndexing
Method Detail

getTallyID

public int getTallyID()

resetCache

public void resetCache()

tally

public int tally(int[] indices,
                 int[] values)

Count the number of tuples that is compliant to the spec mentioned in the q table (i.e. the query table).

If you only have one entry in q table, better use tally(int, int).

Specified by:
tally in interface Tally
Parameters:
indices - is the array of index
values - is the array of values of that index
Returns:
int the count.

tally

public int tally(int idx,
                 int value)
Count the number of tuples that has val[nodeindex] = value.

Specified by:
tally in interface Tally
Parameters:
idx - Node index
value - Node value
Returns:
int The count

weightedTally

public double weightedTally(int idx,
                            int value)
Count the weights of tuples that has val[nodeindex] = value.

Specified by:
weightedTally in interface WeightedTally
Parameters:
idx - Node index
value - Node value
Returns:
double The count

weightedTally

public double weightedTally()
Count total weights of the tuples

Specified by:
weightedTally in interface WeightedTally

createSubTally

public Tally createSubTally(int[] indices,
                            int[] values)

Create a new tally that basically filtered according to the spec mentioned in the q table (i.e. the query table).

If you only have one entry in q table, better use createSubTally(int, int).

Specified by:
createSubTally in interface Tally
Parameters:
indices - is the array of index
values - is the array of values of that index
Returns:
Tally the sub tally

createSubTally

public Tally createSubTally(int idx,
                            int value)

Create subtally that has val[nodeindex] = value.

Specified by:
createSubTally in interface Tally
Parameters:
idx - Node index
value - Node value
Returns:
Tally the sub tally.

filter

public void filter(int idx,
                   java.util.Set values)
Pretty much like createSubTally, except that it doesn't create a new Tally object and apply the filter to this object.

Parameters:
idx -
values -

getValueIndex

public int getValueIndex(java.lang.String attr,
                         java.lang.String value)

getArity

public int getArity(java.lang.String attr)
Get the values of a particular atribute name

Parameters:
attr -
Returns:
Set

getArity

public int getArity(int i)
Get the values of a particular atribute name


getUnderlyingData

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

setUnderlyingData

public void setUnderlyingData(Data tuples)
Sets the tuples.

Specified by:
setUnderlyingData in interface Tally
Parameters:
tuples - The tuples to set

size

public int size()
Specified by:
size in interface Tally
Returns:
int

getOwner

public DatabaseTally getOwner()
Returns:

setOwner

public void setOwner(DatabaseTally tally)
Parameters:
tally -

getRelevantAttributeIndices

public int[] getRelevantAttributeIndices()
Specified by:
getRelevantAttributeIndices 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)