0

我需要在 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.

有人可以帮我吗?

更新:-

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

下面是 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
4

1 回答 1

1

它应该是BytesType,而不是ByteType

CompositeType(BytesType,UTF8Type,DateType)

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

于 2013-09-19T19:32:59.230 回答