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