javanosqlhypertable

How to design an exception logging table using HyperTable and access it via the Java client?


If I have the following table schema to log an exception (in standard SQL schema):

Table: ExceptionLog
Columns: ID (Long), 
         ExceptionClass (String),      
         ExceptionMessage (String), 
         Host (String), 
         Port (Integer), 
         HttpHeader (String), 
         HttpPostBody (String), 
         HttpMethod (String)

How would I design the same thing in HyperTable (specifically, what is the best approach for efficiency)? And, how would I code it using the HyperTable Java client?


Solution

  • What is ID - is it an auto-incremented unique ID? Hypertable does not have auto-increments, but uses random GUIDs for unique IDs if you don't want to provide your own ID. Here's a link with more information: http://hypertable.com/documentation/developer_guide/#unique-cells

    I would maybe combine Host and Port into a single column ("hypertable.com:8080"), but that's my personal preference.

    Everything else looks fine. You can simply translate this to a CREATE TABLE statement in HQL:

    CREATE TABLE ExceptionLog (ID, ExceptionClass, ExceptionMessage, Host, Port, HttpHeader, HttpPostBody, HttpMethod);
    

    You might also want to have secondary indices, i.e. on ExceptionClass, if you have frequent queries like

    SELECT ExceptionClass FROM ExceptionLog WHERE ExceptionClass = "Segfault";
    

    Secondary indices are documented here: http://hypertable.com/documentation/developer_guide/#secondary-indices

    Here's a sample which shows how to use the Java client. It's fairly simple: https://github.com/cruppstahl/hypertable/blob/v0.9.6/src/java/ThriftClient/org/hypertable/thrift/BasicClientTest.java