org.apache.derbyTesting.perf.clients
Class BankAccountFiller

java.lang.Object
  extended by org.apache.derbyTesting.perf.clients.BankAccountFiller
All Implemented Interfaces:
DBFiller

public class BankAccountFiller
extends java.lang.Object
implements DBFiller

This class creates and populates tables that can be used by the bank transactions test clients. It attempts to create tables that follow the rules defined by the TPC-B benchmark specification.


Field Summary
private static int ACCOUNT_EXTRA
          Number of extra bytes needed to make the rows in the account table at least 100 bytes, as required by the TPC-B spec.
(package private) static java.lang.String ACCOUNT_TABLE
          Name of the account table.
private  int accountsPerBranch
          Number of accounts per branch.
private static int BRANCH_EXTRA
          Number of extra bytes needed to make the rows in the branch table at least 100 bytes, as required by the TPC-B spec.
(package private) static java.lang.String BRANCH_TABLE
          Name of the branch table.
private  int branches
          Number of records in the branch table.
(package private) static int DEFAULT_ACCOUNTS_PER_BRANCH
          The number of accounts per branch, if not specified.
(package private) static int DEFAULT_TELLERS_PER_BRANCH
          The number of tellers per branch, if not specified.
(package private) static int HISTORY_EXTRA
          Number of extra bytes needed to make the rows in the history table at least 50 bytes, as required by the TPC-B spec.
(package private) static java.lang.String HISTORY_TABLE
          Name of the history table.
private static int TELLER_EXTRA
          Number of extra bytes needed to make the rows in the teller table at least 100 bytes, as required by the TPC-B spec.
(package private) static java.lang.String TELLER_TABLE
          Name of the teller table.
private  int tellersPerBranch
          Number of tellers per branch.
 
Constructor Summary
BankAccountFiller(int scale)
          Create a filler that generate tables which have correct sizes relative to each other.
BankAccountFiller(int branches, int tellersPerBranch, int accountsPerBranch)
          Create a filler that generates tables with the given sizes.
 
Method Summary
(package private) static java.lang.String createJunk(int length)
          Return a string of the specified length that can be used to increase the size of the rows.
private static void createTables(java.sql.Connection c)
          Create the tables.
private static void dropTables(java.sql.Connection c)
          Drop the tables if they exits.
 void fill(java.sql.Connection c)
          Populate the database.
private  void fillTables(java.sql.Connection c)
          Fill the tables with rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACCOUNT_TABLE

static final java.lang.String ACCOUNT_TABLE
Name of the account table.

See Also:
Constant Field Values

BRANCH_TABLE

static final java.lang.String BRANCH_TABLE
Name of the branch table.

See Also:
Constant Field Values

TELLER_TABLE

static final java.lang.String TELLER_TABLE
Name of the teller table.

See Also:
Constant Field Values

HISTORY_TABLE

static final java.lang.String HISTORY_TABLE
Name of the history table.

See Also:
Constant Field Values

DEFAULT_TELLERS_PER_BRANCH

static final int DEFAULT_TELLERS_PER_BRANCH
The number of tellers per branch, if not specified.

See Also:
Constant Field Values

DEFAULT_ACCOUNTS_PER_BRANCH

static final int DEFAULT_ACCOUNTS_PER_BRANCH
The number of accounts per branch, if not specified.

See Also:
Constant Field Values

ACCOUNT_EXTRA

private static final int ACCOUNT_EXTRA
Number of extra bytes needed to make the rows in the account table at least 100 bytes, as required by the TPC-B spec. The table has two INT columns (4 bytes each) and one BIGINT column (8 bytes).

See Also:
Constant Field Values

BRANCH_EXTRA

private static final int BRANCH_EXTRA
Number of extra bytes needed to make the rows in the branch table at least 100 bytes, as required by the TPC-B spec. The table has one INT column (4 bytes) and one BIGINT column (8 bytes).

See Also:
Constant Field Values

TELLER_EXTRA

private static final int TELLER_EXTRA
Number of extra bytes needed to make the rows in the teller table at least 100 bytes, as required by the TPC-B spec. The table has two INT columns (4 bytes each) and one BIGINT column (8 bytes).

See Also:
Constant Field Values

HISTORY_EXTRA

static final int HISTORY_EXTRA
Number of extra bytes needed to make the rows in the history table at least 50 bytes, as required by the TPC-B spec. The table has three INT columns (4 bytes each), one BIGINT column (8 bytes) and one TIMESTAMP column (12 bytes).

See Also:
Constant Field Values

branches

private final int branches
Number of records in the branch table.


tellersPerBranch

private final int tellersPerBranch
Number of tellers per branch.


accountsPerBranch

private final int accountsPerBranch
Number of accounts per branch.

Constructor Detail

BankAccountFiller

public BankAccountFiller(int branches,
                         int tellersPerBranch,
                         int accountsPerBranch)
Create a filler that generates tables with the given sizes.

Parameters:
branches - number of branches
tellersPerBranch - number of tellers per branch
accountsPerBranch - number of accounts per branch

BankAccountFiller

public BankAccountFiller(int scale)
Create a filler that generate tables which have correct sizes relative to each other. With scale factor 1, the account table has 100000 rows, the teller table has 10 rows and the branch table has 1 row. If the scale factor is different from 1, the number of rows is multiplied with the scale factor.

Parameters:
scale - the scale factor for this database
Method Detail

fill

public void fill(java.sql.Connection c)
          throws java.sql.SQLException
Populate the database.

Specified by:
fill in interface DBFiller
Parameters:
c - the connection to use
Throws:
java.sql.SQLException - if a database error occurs

dropTables

private static void dropTables(java.sql.Connection c)
                        throws java.sql.SQLException
Drop the tables if they exits.

Throws:
java.sql.SQLException

createTables

private static void createTables(java.sql.Connection c)
                          throws java.sql.SQLException
Create the tables.

Throws:
java.sql.SQLException

fillTables

private void fillTables(java.sql.Connection c)
                 throws java.sql.SQLException
Fill the tables with rows.

Throws:
java.sql.SQLException

createJunk

static java.lang.String createJunk(int length)
Return a string of the specified length that can be used to increase the size of the rows. The string only contains x's. The rows have a defined minimum size in bytes, whereas the string length is in characters. For now, we assume that one character maps to one byte on the disk as long as the string only contains ASCII characters.

Parameters:
length - the length of the string
Returns:
a string of the specified length

Built on Thu 2009-11-26 18:42:53-0800, from revision 884739

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.