Cassandra cli: Convert hex values into a human-readable format

谁说我不能喝 提交于 2019-12-03 00:03:30
Tyler Hobbs

By default, column names and column values have no type in Cassandra, they are only byte arrays. If you set a comparator class (column name type) or validation class (column value type), the CLI will pick up on this and show you the data types in a sensible format instead of a hex version of the byte array.

If you don't want this actual data typing, you can tell the CLI to assume that column names or values are a certain data type by using the assume command. Keys never have a data type, so assume has to be used there if you want to work with some data types.

Here's the help info on assume for reference:

[default@Keyspace1] help assume;    
assume <column_family> comparator as <type>;
assume <column_family> sub_comparator as <type>;
assume <column_family> validator as <type>;
assume <column_family> keys as <type>;

Assume one of the attributes (comparator, sub_comparator, validator or keys)
of the given column family to match specified type. Available types: bytes, integer,
long, lexicaluuid, timeuuid, utf8, ascii.
example:
assume Users comparator as lexicaluuid;

EDIT: As of Cassandra 0.8, you can specify a validation class for keys, and the CLI automatically makes use of this info.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!