dbStat
Class StatDriver

java.lang.Object
  extended bydbStat.StatDriver

public class StatDriver
extends java.lang.Object

Responsible for the logic to compute the aggregate statistics for each stock and to send updates to the database to load those statistics into the table.


Field Summary
private  java.util.HashMap statHash
          a hash to hold the statistics being computed with keys as 'statKeys'
private static java.lang.String[] statKeys
          the list of keys to a hashmap to hold statistics as they are computed
private  java.util.ArrayList tickerData
          Collection to hold the data returned by a query.
private  java.util.ArrayList tickerList
          collection to hold all the tickers for which data is to be queried from the database (to use to compute statistics on)
private  java.util.ArrayList updateQueries
          collection of array lists where each array list will contain a set number of batch update statemetns that can be fired off to the database to perform in batch mode.
 
Constructor Summary
StatDriver()
           
 
Method Summary
private  void computeStatistics()
          Computes the statistics for each stock, which has its data from the database stored in the class variable tickerData.
private  void initializeStorage()
          Initialize the hashmap containing the statistics to be computed.
private  boolean loadTickerList()
          Gets the list of tickers and load them in the class variable tickerList for which can be iterated through to compute statistics
private  void loadTickerQueryResults(java.lang.String stockTicker)
          Runs a query for the stock passed and loads the rows into the class variable tickerData with each object encapsulating a single row from the results set.
private  void printHash(java.util.HashMap h)
          Debug feature to print out the hash in an orderly manner
 void runStatDriver(WaitMessage wm)
          main function to run the statistics driver functions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statKeys

private static java.lang.String[] statKeys
the list of keys to a hashmap to hold statistics as they are computed


statHash

private java.util.HashMap statHash
a hash to hold the statistics being computed with keys as 'statKeys'


tickerList

private java.util.ArrayList tickerList
collection to hold all the tickers for which data is to be queried from the database (to use to compute statistics on)


tickerData

private java.util.ArrayList tickerData
Collection to hold the data returned by a query.

Used so that the result set handle can be returned to the database.


updateQueries

private java.util.ArrayList updateQueries
collection of array lists where each array list will contain a set number of batch update statemetns that can be fired off to the database to perform in batch mode.

Constructor Detail

StatDriver

public StatDriver()
Method Detail

runStatDriver

public void runStatDriver(WaitMessage wm)
main function to run the statistics driver functions.

Gets a list of tickers, iteratively queries for the relevant data pertaining to each stock, computes statistics on each ticker, and loads these values back in to the database.


loadTickerList

private boolean loadTickerList()
Gets the list of tickers and load them in the class variable tickerList for which can be iterated through to compute statistics


loadTickerQueryResults

private void loadTickerQueryResults(java.lang.String stockTicker)
Runs a query for the stock passed and loads the rows into the class variable tickerData with each object encapsulating a single row from the results set.

Parameters:
stockTicker - the name of the ticker for which to compute statistics on

computeStatistics

private void computeStatistics()
Computes the statistics for each stock, which has its data from the database stored in the class variable tickerData.

The computed statistics are stored the hash map class variable statHash for later insert into the database.


initializeStorage

private void initializeStorage()
Initialize the hashmap containing the statistics to be computed.

Call to clear the hash map each time a new stock is about to be analyzed.


printHash

private void printHash(java.util.HashMap h)
Debug feature to print out the hash in an orderly manner

Parameters:
h - the hashmap which to print