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
-
Table(String)
- Create a table with the give name (opens a dbm file).
-
clear()
- Clear all the tuples from a table.
-
deleteTuple(byte[])
- Delete a tuple with the given key from the table.
-
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.
-
enumerateKeys()
- Return an enumeration of the key values.
-
IdAsStringKeysImage()
- Return a string of the key values (assumed to be Ids) as Strings.
-
IdIdImage()
- Return a string of the key, value pairs (assumed to be Ids).
-
IdIdListImage()
- Return a string of the key, value pairs (assumed to be Id Lists).
-
IdKeysImage()
- Return a string of the key values (assumed to be Ids).
-
insertTuple(Tuple)
- Insert a tuple
-
retrieveTuple(Id)
- Retrieve a tuple with an Id Key from the table.
-
retrieveTuple(IdList)
- Retrieve a tuple with an IdList Key from the table.
-
retrieveTuple(Tuple)
- Retrieve a tuple with the given key from the table.
-
save()
- Clear all the tuples from a table.
-
size()
- Size of table, number of tuples.
Table
public Table(String name)
- Create a table with the give name (opens a dbm file).
- Parameters:
- name - Name of the table.
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.
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?
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.
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.
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.
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.
IdIdImage
public String IdIdImage()
- Return a string of the key, value pairs (assumed to be Ids).
IdIdListImage
public String IdIdListImage()
- Return a string of the key, value pairs (assumed to be Id Lists).
enumerateKeys
public Enumeration enumerateKeys()
- Return an enumeration of the key values.
IdAsStringKeysImage
public String IdAsStringKeysImage()
- Return a string of the key values (assumed to be Ids) as Strings.
IdKeysImage
public String IdKeysImage()
- Return a string of the key values (assumed to be Ids).
size
public int size()
- Size of table, number of tuples.
clear
public void clear()
- Clear all the tuples from a table. Not yet implemented.
save
public void save()
- Clear all the tuples from a table. Not yet implemented.
All Packages Class Hierarchy This Package Previous Next Index