0

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?

ikevin8me
  • 4,253
  • 5
  • 44
  • 84

1 Answers1

1

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

cruppstahl
  • 2,447
  • 1
  • 19
  • 25
  • Thanks for your answer. The question is what am I going to use as a key. In traditional SQL, it would be a generated unique ID. (I'm making the transition from a traditional SQL to HyperTable, so it would help if you could explain how to structure the new schema.) – ikevin8me Sep 10 '12 at 10:35
  • You can use a GUID. Everything else can stay as is, but as i wrote above, you might want to create indices on some of the column families. Here's the documentation on how to use unique keys in hypertable: http://hypertable.com/documentation/developer_guide/#unique-cells – cruppstahl Sep 10 '12 at 16:19