Was this page helpful?
Caution
You're viewing documentation for an unstable version of ScyllaDB Manual. Switch to the latest stable version.
ScyllaDB Types¶
Introduction¶
This tool allows you to examine raw values obtained from SStables, logs, coredumps, etc., by performing operations on them,
such as deserialize, compare, or validate. See Supported Operations for details.
Run scylla types --help for additional information about the tool and the operations.
Usage¶
The command syntax is as follows:
scylla types <operation> [options] <hex_value1> [hex_value2]
By default, provide the values in the hex form without a leading 0x prefix. The exception is the
serializeoperation, which expects values in human-readable form. Some operations accept values in other formats too, see Input Formats.You must specify the type of the provided values. See Specifying the Value Type.
The number of provided values depends on the operation. See Supported Operations for details.
The
scylla typesoperations come with additional options. See Additional Options for the list of options.
Specifying the Value Type¶
You must specify the type of the value(s) you want to examine by adding the -t [type name] option to the operation.
Specify the type by providing either its CQL name (for example, int or map<int, text>) or its Cassandra class name (the prefix can be omitted,
for example, you can provide Int32Type instead of org.apache.cassandra.db.marshal.Int32Type). See CQL3 Type Mapping
for a mapping of CQL types to Cassandra type class names. CQL names are case-insensitive and can be mixed with Cassandra class names, for example,
ReversedType(timeuuid).
Type names and values containing spaces, for example MapType(Int32Type, UTF8Type), have to be quoted on the command line.
If you provide more than one value, all of the values must share the same type. For example:
scylla types deserialize -t Int32Type b34b62d4 00783562
Compounds
A compound is a single value that is composed of multiple values of possibly different types. An example of a compound value is a clustering key or a partition key.
You can use the --prefix-compound, --full-compound or --legacy-composite options to indicate that the provided value is a compound
(see Additional Options) for details. These options have more human-friendly aliases, which can be used
interchangeably with them: --clustering-key (alias of --prefix-compound), --partition-key (alias of --full-compound) and
--legacy-partition-key (alias of --legacy-composite).
Full compounds (partition keys) can be serialized in two formats: ScyllaDB’s in-memory format (--full-compound), which is the format
partition keys are printed in, in ScyllaDB’s logs, and the legacy composite format (--legacy-composite), which is the format partition
keys are stored in, in SStables. Note that in the legacy composite format, single-component keys are serialized as the value of the component.
When a value is a compound, you can specify a different type for each value making up the compound, respectively (i.e., the order of the types on the command line must be the same as the order in the compound). For example:
scylla types deserialize --prefix-compound -t TimeUUIDType -t Int32Type 0010d00819896f6b11ea00000000001c571b000400000010
Schema file
Instead of specifying the type(s) with -t, you can load the schema of the table the values belong to, from a schema file, with --schema-file.
The schema file is expected to contain the CREATE TABLE statement of exactly one table, possibly preceded by CREATE KEYSPACE and CREATE TYPE
statements (for the UDTs the table uses). This is the same schema file format accepted by scylla sstable.
When loading the type from the schema file, you also have to specify which type of the table the values belong to:
--column <name>- The type of the named column. For clustering columns, this is the type the clustering order of the column applies to (ReversedTypefor descending order).--prefix-compound(--clustering-key) - The clustering key.--full-compound(--partition-key) or--legacy-composite(--legacy-partition-key) - The partition key. When working with partition keys of a table loaded from a schema file, its partitioner is used too (e.g., the CDC partitioner for CDC log tables), sotokenof,shardofandring-order-comparework correctly even for tables with non-default partitioners.
For example:
scylla types deserialize --schema-file schema.cql --partition-key 0004000000010003616263
Input Formats¶
The format of the provided values can be selected with the -f (or --input-format) option. The supported input formats are:
hex- The values are serialized, hex encoded, without a leading 0x prefix. This is the default for all operations, exceptserialize.text- The values are unserialized, in their human-readable string representation. This is the default for theserializeoperation. This saves the need to serialize the values with theserializeoperation first, before passing them to another operation.json- The values are unserialized, in their JSON representation, the same format accepted byINSERT JSON. Values of collection and vector types have no string representation, they can only be provided in this format.
Not all operations support all input formats, see Supported Operations. For operations which operate on more than one value, unserialized values are interpreted as follows:
compareandring-order-compare- The first half of the values make up the first compared value, the second half the second one. This allows comparing compounds, which are made up of multiple values.tokenofandshardof- All values make up a single partition key.
Note that boost program options, used to parse the command line, doesn’t support -f=<format>, use -f <format> or --input-format=<format>.
Supported Operations¶
serialize- Serializes the value and prints it in a hex encoded form. Input formats:text(default),json. Required arguments: 1 value in human-readable form, or in the case of compounds, 1 value for each component (--full-compound), or for some of the components (--prefix-compound). To avoid problems around special symbols, separate values with--from the rest of the arguments. Values of collection and vector types (including tuples and UDTs, which have fields of such types) have no string representation, they can only be serialized from their JSON representation (-f json).deserialize- Deserializes and prints the provided value in a human-readable form. Input formats:hex. Required arguments: 1 or more serialized values.compare- Compares two values and prints the result. Input formats:hex(default),text,json. Required arguments: 2 values.ring-order-compare- Compares two partition keys in ring order, the order ScyllaDB orders partitions in, and prints the result, along with the tokens of the keys: partition keys are ordered by their token first and only by the keys themselves on token collision. Input formats:hex(default),text,json. Required arguments: 2 values. Only accepts partition keys (--full-compound/--partition-keyor--legacy-composite/--legacy-partition-key).validate- Verifies if the value is valid for the type, according to the requirements of the type. Input formats:hex. Required arguments: 1 or more serialized values.tokenof- Calculates the token of the partition key (i.e. decorates it). Input formats:hex(default),text,json. Required arguments: 1 or more values. Only accepts partition keys (--full-compound/--partition-keyor--legacy-composite/--legacy-partition-key).shardof- Calculates the token of the partition key and the shard it belongs to, given the provided shard configuration (--shardsand--ignore-msb-bits). In most cases, only--shardshas to be provided unless you have a non-standard configuration. Input formats:hex(default),text,json. Required arguments: 1 or more values. Only accepts partition keys (--full-compound/--partition-keyor--legacy-composite/--legacy-partition-key).
You can learn more about each operation by invoking its help:
scylla types $OPERATION --help
Additional Options¶
You can run scylla types [operation] --help for additional information on a given operation.
-h( or--help) - Prints the help message.--help-seastar- Prints the help message about the Seastar options.--help-loggers- Prints a list of logger names.-t( or--type) - Specifies the type of the provided value. See Specifying the Value Type.--schema-file- Path to a schema file, to load the type of the values from, instead of specifying it with-t. See Schema file.--column- The name of the column, which the values belong to. Only usable with--schema-file.--prefix-compound(or--clustering-key) - Indicates that the value is a prefixable compound (e.g., clustering key) composed of multiple values of possibly different types.--full-compound(or--partition-key) - Indicates that the value is a full compound (e.g., partition key) composed of multiple values of possibly different types.--legacy-composite(or--legacy-partition-key) - Indicates that the value is a full compound (e.g., partition key), serialized in the legacy composite format, used in SStables, instead of ScyllaDB’s in-memory format.-f(or--input-format) - The format the values are provided in:hex,textorjson. See Input Formats.--shards- The number of shards (only relevant for theshardofoperation).--ignore-msb-bits- The number of the most significant bits of the token to ignore, when calculating the shard. Defaults to 12, the default value of themurmur3_partitioner_ignore_msb_bitsconfiguration option (only relevant for theshardofoperation).--value arg- Specifies the value to process (if not provided as a positional argument).
Examples¶
Serializing a value of type Int32Type:
scylla types serialize -t Int32Type -- -1286905132Output:
Serializing a clustering-key (
--prefix-compound):scylla types serialize --prefix-compound -t TimeUUIDType -t Int32Type -- d0081989-6f6b-11ea-0000-0000001c571b 16Output:
Serializing a clustering-key prefix (
--prefix-compound), with only some of the components present:scylla types serialize --prefix-compound -t TimeUUIDType -t Int32Type -- d0081989-6f6b-11ea-0000-0000001c571bOutput:
Serializing a partition-key (
--full-compound):scylla types serialize --full-compound -t Int32Type -t UTF8Type -- 1 abcOutput:
Serializing a partition-key in the legacy composite format, used in SStables (
--legacy-composite):scylla types serialize --legacy-composite -t Int32Type -t UTF8Type -- 1 abcOutput:
Serializing a value of a collection type, from its JSON representation (
-f json):scylla types serialize -f json -t 'map<int, text>' -- '{"1": "a"}'Output:
Deserializing and printing a value of type Int32Type:
scylla types deserialize -t Int32Type b34b62d4Output:
Validating a value of type Int32Type:
scylla types validate -t Int32Type b34b62d4Output:
Deserializing a value of a collection type, specified with its CQL name:
scylla types deserialize -t 'map<int, text>' 0000000100000004000000010000000161Output:
Comparing two values of ReversedType(TimeUUIDType):
scylla types compare -t 'ReversedType(TimeUUIDType)' b34b62d46a8d11ea0000005000237906 d00819896f6b11ea00000000001c571bOutput:
Comparing two partition keys in ring order. Note that
comparewould return the opposite result, as it compares the components of the keys, not their tokens:scylla types ring-order-compare --partition-key -t Int32Type -t UTF8Type 0004000000010003616263 0004000000020003616263Output:
Deserializing and printing a compound value:
scylla types deserialize --prefix-compound -t TimeUUIDType -t Int32Type 0010d00819896f6b11ea00000000001c571b000400000010Output:
Calculating the token of a partition key:
scylla types tokenof --full-compound -t UTF8Type -t SimpleDateType -t UUIDType 000d66696c655f696e7374616e63650004800049190010c61a3321045941c38e5675255feb0196Output:
Calculating the token of a partition key, provided in human-readable form (
-f text):scylla types tokenof --partition-key -t text -t date -t uuid -f text -- file_instance 2021-03-27 c61a3321-0459-41c3-8e56-75255feb0196Output:
Calculating the owner shard of a partition key:
scylla types shardof --full-compound -t UTF8Type -t SimpleDateType -t UUIDType --shards=7 000d66696c655f696e7374616e63650004800049190010c61a3321045941c38e5675255feb0196Output: