Tuesday, 15 May 2012

java - cassandra field string vs. long -



java - cassandra field string vs. long -

ok, turning crazy here. there number of behaviors cannot explain cassandra , not sure whether related or not.

i created table follows (not showing columns sake of brevity):

create column family cachekey comparator = utf8type , column_metadata = [ { column_name : accountnumber, validation_class : utf8type }, { column_name : homeid, validation_class : longtype } ... ];

some records added table (not me). now, when display schema, not sure why not see columns created

[default@cachekeydata] show schema; ... utilize cachekeydata; create column family cachekey column_type = 'standard' , comparator = 'utf8type' , default_validation_class = 'bytestype' , key_validation_class = 'bytestype' , read_repair_chance = 0.1 , dclocal_read_repair_chance = 0.0 , gc_grace = 864000 , min_compaction_threshold = 4 , max_compaction_threshold = 32 , replicate_on_write = true , compaction_strategy = 'org.apache.cassandra.db.compaction.sizetieredcompactionstrategy' , caching = 'keys_only' , compression_options = {'sstable_compression' : 'org.apache.cassandra.io.compress.snappycompressor'};

now, puzzling me: when pull info java code, null pointer exception when attempting retrieve long not when retrieving string of records:

system.out.println("mac=" + mac); system.out.println(" cidx=<" + result.getstringvalue("homeid",null) + ">"); system.out.println(" cidx=<" + result.getlongvalue("homeid",null) + ">"); system.out.println(" cidx=<" + result.getcolumnbyname("homeid").getlongvalue() + ">");

leads to:

mac=001dd67cff46 cidx=<50190074> cidx=<3832617404583655220> cidx=<3832617404583655220> mac=001dcfe2122c cidx=<3663580>

followed nullpointerexception. in other words, result.getstringvalue("homeid",null) returns 3663580 result.getlongvalue("homeid",null) causes nullpointerexception when running next line within cassandra library code:

longserializer.get().frombytes(column.getvalue());

last, displaying these same 2 records above cli console not show suspicious me:

[default@cachekeydata] cachekey[utf8('001dd67cff46')]; => (column=accountnumber, value=30373833373132303730323036, timestamp=1361305382124) => (column=corp, value=3037383337, timestamp=1361305382124) => (column=homeid, value=3530313930303734, timestamp=1361305382124) => (column=zip, value=3130343732, timestamp=1361305382124) returned 4 results. elapsed time: 70 msec(s). [default@cachekeydata] cachekey[utf8('001dcfe2122c')]; => (column=accountnumber, value=30373830383132333437323032, timestamp=1361305376659) => (column=corp, value=3037383038, timestamp=1361305376659) => (column=homeid, value=33363633353830, timestamp=1361305376659) => (column=zip, value=3036393033, timestamp=1361305376659) returned 4 results. elapsed time: 45 msec(s).

my questions:

q1. big question. why null pointer in illustration above? q2. smaller ones: q2a. observe in 3 normal given how set table in 1? q2b. why string , long values not match?

not sure reply useful anyone, info expected long inserted string. apparently caused @ to the lowest degree 2 issues explained above:

displaying different result whether info read string or long (something wasn't used coming oracle world) causing these occasional null pointer exceptions

java schema cassandra astyanax

No comments:

Post a Comment