5. 5
KDB database overview
KDB:
• an in-memory column-based database
• can be used to handle large volumes of real-time or historical data
• provides OLTP and OLAP capabilities
6. 6
KDB database overview
KDB:
• provides much of the same functionality of an RDBMS
• supports SQL and KSql (for column-based queries)
7. 7
KDB database overview
Used by almost any large financial institution …
• Goldman Sachs
• Morgan Stanley
• J.P. Morgan
• Deutsche Bank
• Commerzbank AG
8. 8
KDB database overview
KDB+:
• 64bit release of KDB
• OLTP: 100 000 – 1 000 000 records per second per CPU
• OLAP: 1 000 000 – 10 000 000 records per second per CPU
• Backed by the Q general purpose programming language
9. 9
KDB database overview
KDB+:
• multi-threaded and multi-process (scales vertically)
• can be deployed in a distributed environment (scales horizontally)
• provides multiple APIs for C++, Java, Perl, Python …
• and provides support for JDBC …
11. 11
Q Lang Basics
Q language:
• vector processing language
• allows for complex calculations across a large volume of data
• merges the K and ksql languages
12. 12
Q Lang Basics
Q language:
• Interpreted (a mixture of APL and Scheme)
• simple rules of precedence (right -> left evaluation of all expressions)
• functions are first-class citizens (can be assigned to variables)
13. 13
Q Lang Basics
Q language data types:
• Integer
• floating point
• char
• symbol
• lists
• dictionaries
• time
• datetime
• date
• others …
22. 22
KDB Java API
c.ks() – for executing an operation without waiting for a
response
c.k() – for execution an operation and waiting for a response
c.k() – for waiting for a message from the KDB+ server
(naming is somewhat dummy … )
23. 23
KDB Java API
// getting the 'tbl' table
c connection = new c("localhost", 5000);
Flip tbl = (Flip) connection.k("tbl");
for(String key : tbl.x) {
System.out.println(key + " " +
tbl.at(key).getClass().getSimpleName());
}
24. 24
KDB Java API
// inserting a record in the 'tbl‘ table
connection.ks("`tbl insert (`x;10)");