如果我具有以下表架构来记录异常(在标准SQL架构中):

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


我将如何在HyperTable中设计相同的东西(具体来说,提高效率的最佳方法是什么)?而且,我将如何使用HyperTable Java客户端对其进行编码?

最佳答案

什么是ID-它是自动递增的唯一ID? Hypertable没有自动递增功能,但是如果您不想提供自己的ID,则对唯一ID使用随机GUID。这是更多信息的链接:
http://hypertable.com/documentation/developer_guide/#unique-cells

我可能将Host和Port合并到一个列中(“ hypertable.com:8080”),但这是我个人的喜好。

其他一切看起来都很好。您可以简单地将其转换为HQL中的CREATE TABLE语句:

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


如果您经常遇到类似这样的查询,则可能还需要二级索引,即在ExceptionClass上

SELECT ExceptionClass FROM ExceptionLog WHERE ExceptionClass = "Segfault";


次要索引记录在这里:http://hypertable.com/documentation/developer_guide/#secondary-indices

这是显示如何使用Java客户端的示例。这很简单:https://github.com/cruppstahl/hypertable/blob/v0.9.6/src/java/ThriftClient/org/hypertable/thrift/BasicClientTest.java

09-10 08:30