public class KdbTable extends Object implements Iterable<KdbDict>
Data container representing a table that can be serialised and sent to a kdb process (via c)
Also provides the ability to accept a c.Flip object received from a kdb process and access it
within Java, including iterating over it with the KdbDict object.
Implementation is not thread-safe.
(c) 2014 - 2017 Sport Trades LtdKdbTableIterator,
KdbDict| Modifier and Type | Field and Description |
|---|---|
private Map<String,List<Object>> |
data
The container of the kdb data stored column-wise
|
private static org.slf4j.Logger |
log |
private Integer |
rowCount |
private String |
tableName
The table name for the current instance
|
| Constructor and Description |
|---|
KdbTable(String tableName)
Instantiate an empty table structure
|
KdbTable(String tableName,
c.Flip initialData)
Instantiates a new kdb table object with a set of initial data in kdb format
|
| Modifier and Type | Method and Description |
|---|---|
void |
addColumn(String columnName,
List<Object> columnData)
Adds a new column to the current table stored within the object.
|
void |
addRow(KdbDict row) |
void |
addRow(Map<String,Object> row)
Adds a row to a table based on an
HashMap representation of the row (i.e. |
void |
append(KdbTable that)
Appends the specified table onto the current table (similar to the kdb+
uj function) |
static KdbTable |
buildFromRowList(String name,
List<KdbDict> rows)
|
void |
changeTableName(String newTableName)
Allows the name of the table stored within this object to be changed.
|
c.Flip |
convertToFlip()
Converts the nice Java representation of a kdb table into the actual format ready for sending across
the wire to a kdb process.
|
void |
deleteColumn(String columnName) |
private void |
doSetOfInitialDataSet(c.Flip initialData,
boolean overwrite) |
void |
forceSetInitialDataSet(c.Flip initialData)
Performs the initial (or subsequent) set of data from a kdb
c.Flip object |
static KdbTable |
fromObject(Object object)
Generates a new
KdbTable object from an object. |
KdbDict |
getRow(int rowNumber)
Provides the ability to return a specified row of the table.
|
Integer |
getRowCount() |
Map<String,List<Object>> |
getTableData() |
String |
getTableName() |
Boolean |
isEmpty() |
Iterator<KdbDict> |
iterator() |
void |
setInitialDataSet(c.Flip initialData)
Performs the initial set of data from a kdb
c.Flip object |
Stream<KdbDict> |
stream()
TODO: Implement
Collection interface so this is an override |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorprivate static final org.slf4j.Logger log
private String tableName
private Integer rowCount
public KdbTable(String tableName) throws IllegalArgumentException
tableName - The name of the table to createIllegalArgumentException - If the table name is empty or nullpublic KdbTable(String tableName, c.Flip initialData) throws DataOverwriteNotPermittedException
tableName - The name of the table to createinitialData - The initial data set to populate the new object withIllegalArgumentException - If the table name is empty or nullDataOverwriteNotPermittedException#setInitialDataSet(Flip)public void setInitialDataSet(c.Flip initialData) throws DataOverwriteNotPermittedException
c.Flip objectinitialData - The dataset to use to set the objectDataOverwriteNotPermittedException - If there is already data in the current data structure#doSetOfInitialDataSet(Flip, boolean)public void forceSetInitialDataSet(c.Flip initialData)
c.Flip objectinitialData - The dataset to use to set the object#doSetOfInitialDataSet(Flip, boolean)private void doSetOfInitialDataSet(c.Flip initialData, boolean overwrite) throws DataOverwriteNotPermittedException
public void addColumn(String columnName, List<Object> columnData) throws TableColumnAlreadyExistsException, TableSchemaMismatchException
columnName - The name of the new columncolumnData - The list of new elements of the columnTableColumnAlreadyExistsException - If there is a column with the same name as the one to be addedTableSchemaMismatchException - If the length of the new column does not match the current number of rows in the tablepublic void deleteColumn(String columnName)
public void addRow(KdbDict row) throws TableSchemaMismatchException
TableSchemaMismatchExceptionaddRow(Map)public void addRow(Map<String,Object> row) throws TableSchemaMismatchException
HashMap representation of the row (i.e. a kdb dictionary)row - The new row to addTableSchemaMismatchException - If there are any missing columns from the new rowpublic void append(KdbTable that) throws TableSchemaMismatchException
uj function)TableSchemaMismatchException - If the two table names or table schemas do not matchpublic String getTableName()
public c.Flip convertToFlip()
public Integer getRowCount()
public Boolean isEmpty()
public void changeTableName(String newTableName) throws UnsupportedOperationException
newTableName - The new table nameUnsupportedOperationException - If the new table name is null or an empty stringpublic KdbDict getRow(int rowNumber) throws ArrayIndexOutOfBoundsException
KdbDict.rowNumber - The row to retrieveArrayIndexOutOfBoundsException - If the row requested is less than 0 or greater than or
equal to the number of rows in the tablepublic static KdbTable buildFromRowList(String name, List<KdbDict> rows) throws TableSchemaMismatchException
name - The name of the new tablerows - The list of rows to generate the table fromTableSchemaMismatchExceptionaddRow(KdbDict)public static KdbTable fromObject(Object object) throws ClassCastException
Generates a new KdbTable object from an object. This method will
only succeed if the object provided can be cast into a c.Flip.
Use this method along with KdbQuery to convert a query result
into a table when one is expected.
object - The object to generate a new KdbTable fromnull if the provided object is nullClassCastException - If the specified object cannot be cast into a c.Flippublic Stream<KdbDict> stream()
Collection interface so this is an overrideCopyright © 2017. All rights reserved.