|
What is Aruna DB? |
Last Updated: 9/25/2001
A_Table_Data
All iterators for A_Table, A_Index, and A_View classes all yield an object of this class. This class is used for holding and communicating data as it is put into and read from A_Table, A_Index, and A_View classes. This class stores data such that it can be quickly put into na A_BTree. This class also stores data such that you can reference column data by using the column's name. You will use this class every time you iterator over tables, indexes, and/or views. You should never have to create an object of this class because the A_Table, A_Index, and A_View classes do this automatically.
This class requires an array of A_Column object and uses two arrays. The first array stores the key and the second array stores the data in the table that is not part of the key. The key is one or more columns in a table. The data for the key is stored separately from the rest of the data in the table so that this information can be quickly stored into a btree and the key information is not duplicated as it is stored in the btree. Singleton methods are added to a_table_data objects when they are created to allow you to reference the data by column name. For example: let’s create a table called membership with columns for member_id, last_name, and first_name where the member_id is the primary key for this table. Accessing and updating the data for the member_id is as simple as a_table_data.member_id or a_table_data.member_id = value. Internally, a_table_data.member_id will get and put the data in the @__keys__ array and a_table_data.last_name will get and put the data in the @__data__ array. FYI, all method names for this class are prefixed and suffixed with '__' to make sure instance method names don't conflict with potential column names. This class is co-located with the A_Column class in the a_column.rb module.
cols = []
cols.push(A_Column.new('member_id', nil, nil, nil, nil, nil, '%3d'))
cols.push(A_Column.new('first_name', 'v', nil, nil, nil, nil, '%-20.20s'))
cols.push(A_Column.new('last_name', 'v', nil, nil, nil, nil, '%-20.20s'))
view = A_Table_Data.new('view_data_array', cols)
view.member_id = 10
view.last_name = 'Davis'
view.first_name = 'Michael'
view.__show__
A_Table_Data.new(name, columns, key_names=nil, assignment_is_okay=true)
__check_all_values__(transaction=nil)
This checks the A_Column.constraint for each column in this A_Table_Data object. A_Table.insert() and A_Table.update() calls this just before inserting the data into the btree. If any column violates a column constraint, then a ColumnConstraintError error is raised.
__close__()
Close this instance of A_Table_Data and clear any variables (memory) used by this object.
__column_info__(col_name)
Returns the A_Column object associated with col_name.
__set_defaults__()
Copy A_Column.default into this A_Table_Data object for each column. This is called at the beginning of A_Table.insert() to populate the A_Table_Data object for the table with default values.
__show__(prefix='', separator=',')
Prints the data in this variable. If formatting is provided via the format_array parameter, then the format_array information is used to format the data as it is printed.
__show_types__(prefix='', separator=',')
Prints the Ruby type:size of each element in this A_Table_Data object.
to_s()
Calls __show__() as long as you don't have a column named to_s. If there is a column named to_s then it’s value is returned.
There are other methods but they are only used interally by the A_Table and A_Index classes.
See A_Table, A_Index, and A_View.
N/A