Memoirs of a QWERTY Keyboard

Writing a simple Kudu Java API Program

Kudu ships with a Java client library that is ready to use, and also publishes the Java library jars on Cloudera’s Maven repositories. To use within your Maven project pom.xml, add the below to the appropriate areas:

To create a table, a schema needs to be built first, and then created via the client. If say we have a simple schema for table “users“, with columns “username” (string, key) and “age” (8-bit signed int, value), then we can create it as shown below, utilising ColumnSchema and Schema objects over the previously created kuduClient object:

Data work (such as inserts, updates or deletes) in Kudu are done within Sessions. The below continuance shows how to insert a row, after creating a Session and a KuduTable for the table “users” and applying the insert object over it: