description:
setting integer column values with cqlsh does not return the same values when read back with Hector;
cassandra version 1.0.7
hector version 1.0-2
mycf: 1-row, multi-column CF with integer values:
ColumnFamily: mycf
Key Validation Class: org.apache.cassandra.db.marshal.AsciiType
Default column value validator: org.apache.cassandra.db.marshal.IntegerType
Columns sorted by: org.apache.cassandra.db.marshal.UTF8Type
Row cache size / save period in seconds / keys to save : 0.0/0/all
Row Cache Provider: org.apache.cassandra.cache.SerializingCacheProvider
Key cache size / save period in seconds: 200000.0/14400
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 1.0
Replicate on write: true
Bloom Filter FP chance: default
Built indexes: []
cqlsh:
update mycf set alt = 81001 where KEY = 'alt';
java:
public void write(final String alt, final int hash) {
final Mutator<String> mut = HFactory.createMutator(
HFactory.createKeyspace("test", cluster),
StringSerializer.get());
mut.addInsertion("alt", "mycf", HFactory.createColumn(alt, hash,
StringSerializer.get(), IntegerSerializer.get()));
mut.execute();
}
public int read(final String alt) {
final RangeSlicesQuery<String, String, Integer> query = HFactory
.createRangeSlicesQuery(
HFactory.createKeyspace("test", cluster),
StringSerializer.get(), StringSerializer.get(),
IntegerSerializer.get()).setColumnFamily("mycf")
.setRange(null, null, false, 13).setColumnNames(alt);
final ArrayList<Byte> arrayList = new ArrayList<Byte>();
Integer result = null;
for (final Row<String, String, Integer> item : query.setRowCount(10)
.execute().get().getList()) {
final HColumn<String, Integer> i = item.getColumnSlice()
.getColumnByName(alt);
log.debug(Arrays.toString(i.getValueBytes().array()));
result = i.getValue();
}
return result;
}
writing an integer with hector, and reading with hector:
[-128, 1, 0, 2, 0, 0, 0, 16, 103, 101, 116, 95, 114, 97, 110, 103, 101, 95, 115, 108, 105, 99, 101, 115, 0, 0, 0, 5, 15, 0, 0, 12, 0, 0, 0, 1, 11, 0, 1, 0, 0, 0, 3, 97, 108,
116, 15, 0, 2, 12, 0, 0, 0, 1, 12, 0, 1, 11, 0, 1, 0, 0, 0, 6, 68, 69, 78, 73, 83, 50, 11, 0, 2, 0, 0, 0, 4, 0, 1, 60, 105, 10, 0, 3, 0, 4, -73, -24, -127, -39, 107, -128, 0, 0, 0, 0]
writing an integer with cqlsh, reading with hector:
[-128, 1, 0, 2, 0, 0, 0, 16, 103, 101, 116, 95, 114, 97, 110, 103, 101, 95, 115, 108, 105, 99, 101, 115, 0, 0, 0, 3, 15, 0, 0, 12, 0, 0, 0, 1, 11, 0, 1, 0, 0, 0, 3, 97, 108,
116, 15, 0, 2, 12, 0, 0, 0, 1, 12, 0, 1, 11, 0, 1, 0, 0, 0, 6, 68, 69, 78, 73, 83, 50, 11, 0, 2, 0, 0, 0, 3, 1, 60, 105, 10, 0, 3, 0, 4, -73, -24, -111, 104, 96, 56, 0, 0, 0, 0]
