RegisterSign In

API Documentation: Class SDBTable

Package: com.mckoi.sdb
implements java.lang.Iterable<com.mckoi.sdb.SDBRow>, com.mckoi.sdb.SDBTrustedObject

SDBTable is a table structure with a single cell value type (strings), and supports ordered column indexes and a single row index ordered by insert order.

The table structure is primarily supported by a single dimension row index that is an append only list of row keys. Each row key entry references a DataFile that contains formatted row data information. Column indexes are each supported by a sorted (by column value) list of row keys.

Row updates require creating a duplicate of the row and deleting the original. All inserts, updates and deletes are recorded in a transaction log, and will fail during commit only when the change is incompatible (for example, two transactions delete the same row). New row inserts will not fail for any reason at commit. Concurrent structural changes to a single table will fail at commit.

This is a simple implementation of a table structure that may not be optimal for all uses, such as intensive column index queries. Information is grouped by row which offers good performance for many types of online applications.

Methods Summary

long getRowCount()
long getColumnCount()
String[] getColumnList()
String[] getIndexedColumnList()
boolean isColumnIndexed(String column_name)
void addColumn(String column_name)
void removeColumn(String column_name)
void addIndex(String column_name, String collator_locale)
void addIndex(String column_name)
void removeIndex(String column_name)
RowCursor iterator()
RowCursor reverseIterator()
SDBIndex getIndex(String column_name)
void delete(SDBRow row)
void insert()
void update(SDBRow row)
void setValue(String column, String value)
void complete()
void infoDump(PrintWriter out)

Method Details

long getRowCount()

Returns the number of rows currently stored in this table.

long getColumnCount()

Returns the number of columns currently defined on this table.

String[] getColumnList()

Return the columns defined on this table in the order they were added.

String[] getIndexedColumnList()

Returns the list of columns that have an index defined on them.

boolean isColumnIndexed(String column_name)

Returns true if the column is indexed.

void addColumn(String column_name)

Adds an index on the column with the given name. This builds the index on the column so may take a long time to perform if there is a lot of information stored in the table.

void removeColumn(String column_name)

Removes a column with the given name from the table.

void addIndex(String column_name, String collator_locale)

Adds an index of the given column in the table with the given locale used as the source of collation for the index. The 'collator_locale' encoded string is formatted as 2 char ISO language/2 char ISO Country. For example, "enUK" (English UK), "frFR" (French France), "frCA" (French Canada), etc. If 'collator_locale' is null then the index is ordered lexicographically.

void addIndex(String column_name)

Adds an index of the given column in the table with a lexicographical ordering.

void removeIndex(String column_name)

Removes a column index from the table.

RowCursor iterator()

Returns an iterator of all rows in the table. The last row added/updated in the table is the last item in the iterator. The iterator is immutable.

Note that if a change happens to the table while an iterator is being used, the behavior of the iterator is not defined.

RowCursor reverseIterator()

Returns a reverse iterator of all rows in the table. The last row added/updated in the table is the first item in the iterator. The iterator is immutable.

Note that if a change happens to the table while an iterator is being used, the behavior of the iterator is not defined.

SDBIndex getIndex(String column_name)

Returns an SDBIndex of the index on the given column.

Note that if a change happens to the table while the SDBIndex is being used, the behavior of the index is not defined.

void delete(SDBRow row)

Deletes the given row in the table, updating all indexes as is appropriate.

void insert()

Creates an empty row in the row buffer ready to be populated and inserted into the table. To insert a new row in a table, a call is made to this method, then 'setValue' is used to modify the row buffer content, and then 'complete' is called to finish the insert procedure.

void update(SDBRow row)

Copies the given row object to the row update buffer ready to be updated. To update a row in a table, a call is made to this method, then 'setValue' is used to modify the row buffer content, and then 'complete' is called to finish the update procedure.

void setValue(String column, String value)

Changes the value of a column of the insert/update row buffer.

void complete()

Called after an insert or update operation, to complete the modification to the table. All table indexes will be changed appropriately by this method.

void infoDump(PrintWriter out)

Outputs some information about the table to System.out, used for debugging.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2018 Diehl and Associates, Inc. All rights reserved.