-
Notifications
You must be signed in to change notification settings - Fork 4
KdbTable
Jas edited this page Mar 9, 2017
·
1 revision
This object is a replacement for c.Flip. The main features provided by this class are:
-
Conversion to and from
c.Flip- new KdbTable(String, Flip) to create a new object from
c.Flip -
KdbTable.convertToFlipfor conversion to aFlipready for serialisation byc.java
- new KdbTable(String, Flip) to create a new object from
-
Column-wise and row-wise addition of data
-
addColumnadds a new column, with existing column and column length checks -
addRowadds a new row (asKdbDictorMap), ensuring the row has all required columns
-
-
Rows access as
KdbDict-
getRowreturns the specific row - Custom iterator and stream functions to allow iterator via
forloop and Java 8 streams
-
Iterating over each row with a for loop:
public void printRowsWithIterator(KdbTable table) {
for(KdbDict row : table) {
System.out.println(row.get("col1");
}
}Using Java 8 streams to count the occurrence of a particular sym:
public long getSymCount(KdbTable table, String sym) {
return table.stream()
.filter((row) -> sym.equals(row.getAs("sym", String.class)))
.count();
}Copyright (C) Sport Trades Ltd 2017 - 2020, John Keys and Jaskirat Rajasansir 2020 - 2021