【问题标题】:RuntimeException: Unknown comparator 'CompositeType'RuntimeException:未知比较器'CompositeType'
【发布时间】:2013-09-20 03:45:21
【问题描述】:

我需要在 Cassandra ColumnFamily 中创建 CompositeColumns。

每个列的值都会存储这样的东西-

user-id   column1
123      (Column1-Value  Column1-SchemaName  LastModifiedDate)

column2 和其他列也是如此。所以我决定用这样的东西-

以下是列的描述-

ByteType for Column-Value
UTF8Type for Column-SchemaName
DateType for LastModifiedDate

我像这样创建了下面的列族-

create column family USER_DATA
with key_validation_class = 'UTF8Type'
and comparator = 'CompositeType(ByteType,UTF8Type,DateType)'
and default_validation_class = 'UTF8Type'
and gc_grace = 86400
and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

让我知道这是否是创建上述列族的正确方法?

但是一旦我尝试执行上面的列,我总是得到下面的错误。

[default@userks]     create column family USER_DATA
...         with key_validation_class = 'UTF8Type'
...         and comparator = 'CompositeType(ByteType,UTF8Type,DateType)'
...         and default_validation_class = 'UTF8Type'
...         and gc_grace = 86400
...         and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

java.lang.RuntimeException: Unknown comparator 'CompositeType(ByteType,UTF8Type,DateType)'. Available functions: bytes, integer, long, int, lexicaluui
d, timeuuid, utf8, ascii, double, countercolumn.

谁能帮我解决这个问题?

更新:-

我刚刚发现了那个错误,我忘记在 ByteType 中添加额外的s

下面是ColumnFamily-

create column family USER_DATA
with key_validation_class = 'UTF8Type'
and comparator = 'CompositeType(BytesType,UTF8Type,DateType)'
and default_validation_class = 'UTF8Type'
and gc_grace = 86400
and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

以下是我得到的错误..

[default@beprofileks]     create column family USER_DATA
...         with key_validation_class = 'UTF8Type'
...         and comparator = 'CompositeType(BytesType,UTF8Type,DateType)'
...         and default_validation_class = 'UTF8Type'
...         and gc_grace = 86400
...         and column_metadata = [ {column_name : 'lmd', validation_class : DateType}];

java.lang.RuntimeException: org.apache.cassandra.db.marshal.MarshalException: cannot parse 'lmd' as hex bytes

【问题讨论】:

    标签: java cassandra astyanax column-family


    【解决方案1】:

    应该是BytesType,而不是ByteType

    CompositeType(BytesType,UTF8Type,DateType)
    

    另一个问题是lmd 不是比较器CompositeType(BytesType,UTF8Type,DateType) 的有效列名。例如,一个有效的名称是aa00:string:2013-09-19

    【讨论】:

    • 我的错误。我只是抓住了那个错误。但是在做出改变之后,我又遇到了另一个异常。我也编辑了我的问题。
    猜你喜欢
    • 2013-12-05
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-29
    • 2016-06-06
    • 1970-01-01
    相关资源
    最近更新 更多