All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cube.database.Table

java.lang.Object
   |
   +----cube.database.Table

public class Table
extends Object
This class encapsulates a database table. We have implemented tables as persistent associative array. More specifically, they are GDBM files. The good things about GDBM files are that they can be copied, compressed, fields can be of any size, and they are cheap to build. The bad things are that they do not have concurrency control and are not as fast as other kinds of DBM files.

For more information on the cube see the cube Overview.
Copyright © 1997 Curtis E. Dyreson. All rights reserved. Please be aware of the Licence and Version.

See Also:
Database, Tuple

Constructor Index

 o Table(String)
Create a table with the give name (opens a dbm file).

Method Index

 o clear()
Clear all the tuples from a table.
 o deleteTuple(byte[])
Delete a tuple with the given key from the table.
 o emitCannedInitializationCode(int)
Emit code to initialize a dbm file (hashtable) with the info in this table This is strictly for the canned version of the interface.
 o enumerateKeys()
Return an enumeration of the key values.
 o IdAsStringKeysImage()
Return a string of the key values (assumed to be Ids) as Strings.
 o IdIdImage()
Return a string of the key, value pairs (assumed to be Ids).
 o IdIdListImage()
Return a string of the key, value pairs (assumed to be Id Lists).
 o IdKeysImage()
Return a string of the key values (assumed to be Ids).
 o insertTuple(Tuple)
Insert a tuple
 o retrieveTuple(Id)
Retrieve a tuple with an Id Key from the table.
 o retrieveTuple(IdList)
Retrieve a tuple with an IdList Key from the table.
 o retrieveTuple(Tuple)
Retrieve a tuple with the given key from the table.
 o save()
Clear all the tuples from a table.
 o size()
Size of table, number of tuples.

Constructors

 o Table
  public Table(String name)
Create a table with the give name (opens a dbm file).

Parameters:
name - Name of the table.

Methods

 o insertTuple
  public void insertTuple(Tuple tuple)
Insert a tuple @see cube.database.Tuple into the table. Will replace an existing tuple so be careful.

Parameters:
tuple - Tuple to insert.
 o deleteTuple
  public boolean deleteTuple(byte key[])
Delete a tuple with the given key from the table.

Parameters:
key - Key to delete.
Returns:
Was the tuple found and deleted?
 o retrieveTuple
  public Tuple retrieveTuple(IdList key)
Retrieve a tuple with an IdList Key from the table.

Parameters:
key - IdList to retrieve,
Returns:
The tuple retrieved or null if no matching tuple was found.
 o retrieveTuple
  public Tuple retrieveTuple(Id key)
Retrieve a tuple with an Id Key from the table.

Parameters:
key - Id to retrieve,
Returns:
The tuple retrieved or null if no matching tuple was found.
 o retrieveTuple
  public Tuple retrieveTuple(Tuple tuple)
Retrieve a tuple with the given key from the table. This routine will fill in the value of the passed tuple, or it will return null for the tuple. To use this you must fill in the type of the return value in the tuple, and the key for the tuple, e.g.,
   Tuple r = new Tuple("hi", 0);  // we want an integer value for key "hi"
   r = table.retrieveTuple(r);    // try to retrieve it 
   if (r == null) ...             // key was not found in the table 
   else {                         // tuple was retrieved, the table 
                                  // fetch the integer value 
     int i = ((IntColumn)(r.getValue())).getValue();
     ...
 

Parameters:
tuple - Tuple to retrieve,
Returns:
The tuple retrieved or null if no matching tuple was found.
 o emitCannedInitializationCode
  public void emitCannedInitializationCode(int which)
Emit code to initialize a dbm file (hashtable) with the info in this table This is strictly for the canned version of the interface.

 o IdIdImage
  public String IdIdImage()
Return a string of the key, value pairs (assumed to be Ids).

 o IdIdListImage
  public String IdIdListImage()
Return a string of the key, value pairs (assumed to be Id Lists).

 o enumerateKeys
  public Enumeration enumerateKeys()
Return an enumeration of the key values.

 o IdAsStringKeysImage
  public String IdAsStringKeysImage()
Return a string of the key values (assumed to be Ids) as Strings.

 o IdKeysImage
  public String IdKeysImage()
Return a string of the key values (assumed to be Ids).

 o size
  public int size()
Size of table, number of tuples.

 o clear
  public void clear()
Clear all the tuples from a table. Not yet implemented.

 o save
  public void save()
Clear all the tuples from a table. Not yet implemented.


All Packages  Class Hierarchy  This Package  Previous  Next  Index