Using Human-Readable Data
Applications on Cassandra may require values in bytes type or other formats that are not naturally human-readable. The CLI allows you to temporarily translate machine-readable data to human readable formats in order to work with data more easily.
To retrieve a more human-readable value for a particular value such as the UTF8Type password value used above, add as ascii to the get command:
[default@twissandra] get users['jsmith']['password'] as ascii;
=> (column=password, value=ch@ngem3, timestamp=1295635612024000)
Or, for more comprehensive translation of values, you can use the assume command. This command lets you select any one of the following attributes to view as a specified type:
keys (row key) validator comparator sub_comparator (for sub-columns in a column family of type super)
For example, we could issue a command that assumes integer type for the row keys in the users column family. This would render human-readable values like ‘jmith’ and ‘jbellis’ as numbers; then, if we further assumed the comparator for users as integer, we could take advantage of that sort order to perform range queries (given the appropriate partitioner, and other conditions). The following example displays the users rows keys as integers:
[default@twissandra] assume users keys as integer;
Assumption for column family 'users' added successfully.
[default@twissandra] list users limit 2;
=> (column=8097880544751088228, value=6368406e67656d33, timestamp=129710078100)
=> (column=8097880544751088228, value=6368406e67656d33, timestamp=129624362200)
2 Rows Returned.
You can use both assume and as <type> with any one of these valid type values:
bytes integer long lexicaluuid timeuuid utf8 ascii