Reputation: 1325
I'm having a problem understanding the code system cassandra provides for each column type.
I'm using Node.js driver ('cassandra-driver') and I'm using the client.metadata.getTable
to retrieve metadata information:
client.metadata.getTable( 'dev', 'artists', function ( err, table ) {
if ( !err ) {
table.columns.forEach( function ( column ) {
console.log( column );
});
}
});
Example column result:
{ name: 'genre',
type:
{ code: 13,
info: null,
options: { reversed: false, frozen: false } } }
When I created the table, I set 'genre' as varchar (so I'm guessing 13 = varchar). What I'm trying to understand is the connection between all the code numbers and their type, without guessing. I haven't found anything regarding this subject in the docs nor online. Any thoughts?
Upvotes: 2
Views: 361
Reputation: 1661
Have a look at nodejs-driver/lib/types/index.js ( Node.js sources on gitHub. )
var dataTypes = {
custom: 0x0000,
ascii: 0x0001,
bigint: 0x0002,
blob: 0x0003,
boolean: 0x0004,
counter: 0x0005,
decimal: 0x0006,
double: 0x0007,
float: 0x0008,
int: 0x0009,
text: 0x000a,
timestamp: 0x000b,
uuid: 0x000c,
varchar: 0x000d,
varint: 0x000e,
timeuuid: 0x000f,
inet: 0x0010,
date: 0x0011,
time: 0x0012,
smallint: 0x0013,
tinyint: 0x0014,
list: 0x0020,
map: 0x0021,
set: 0x0022,
udt: 0x0030,
tuple: 0x0031,
So you guessed right, 13 equals varchar.
edit Those values are hexadezimal representations. For example varchar 0x000d (hex) equals 13 (dec). But actually I don't really know why they are using hex here instead of dec. Basically they are using values from custom:0 (dec) to tuple:25 (dec) for defining those types.
The google calculator can help you with the convertion between hex and dec. Example: https://www.google.de/#q=0x000d+to+decimal
Upvotes: 2