Sto provando il driver del nodo cassandra e ho bloccato il problema mentre inserivo un record, sembra che il driver cassandra non sia in grado di inserire valori float.ResponseError: Previsto 4 o 0 byte int
Problem: When passing int value for insertion in db, api gives following error:
Debug: hapi, internal, implementation, error
ResponseError: Expected 4 or 0 byte int (8)
at FrameReader.readError (/home/gaurav/Gaurav-Drive/code/nodejsWorkspace/cassandraTest/node_modules/cassandra-driver/lib/readers.js:291:13)
at Parser.parseError (/home/gaurav/Gaurav-Drive/code/nodejsWorkspace/cassandraTest/node_modules/cassandra-driver/lib/streams.js:185:45)
at Parser.parseBody (/home/gaurav/Gaurav-Drive/code/nodejsWorkspace/cassandraTest/node_modules/cassandra-driver/lib/streams.js:167:19)
at Parser._transform (/home/gaurav/Gaurav-Drive/code/nodejsWorkspace/cassandraTest/node_modules/cassandra-driver/lib/streams.js:101:10)
at Parser.Transform._read (_stream_transform.js:179:10)
at Parser.Transform._write (_stream_transform.js:167:12)
at doWrite (_stream_writable.js:225:10)
at writeOrBuffer (_stream_writable.js:215:5)
at Parser.Writable.write (_stream_writable.js:182:11)
at write (_stream_readable.js:601:24)
sto provando ad eseguire query riportata di seguito dal codice:
INSERT INTO ragchews.user
(uid ,iid ,jid ,jpass ,rateCount ,numOfratedUser ,hndl ,interests ,locX ,locY ,city)
VALUES
('uid_1',{'iid1'},'jid_1','pass_1',25, 10, {'NEX1231'}, {'MUSIC'}, 21.321, 43.235, 'delhi');
parametro passato a execute()
è
var params = [uid, iid, jid, jpass, rateCount, numOfratedUser, hndl, interest, locx, locy, city];
dove
var locx = 32.09;
var locy = 54.90;
e chiamare per eseguire lo OKS come:
var addUserQuery = 'INSERT INTO ragchews.user (uid ,iid ,jid ,jpass ,rateCount ,numOfratedUser ,hndl ,interests ,locX ,locY ,city) VALUES (?,?,?,?,?,?,?,?,?,?,?);';
var addUser = function(user, cb){
console.log(user);
client.execute(addUserQuery, user, function(err, result){
if(err){
throw err;
}
cb(result);
});
};
CREATE TABLE ragchews.user(
uid varchar,
iid set<varchar>,
jid varchar,
jpass varchar,
rateCount int,
numOfratedUser int,
hndl set<varchar>,
interests set<varchar>,
locX float,
locY float,
city varchar,
favorite map<varchar, varchar>,
PRIMARY KEY(uid)
);
PS Alcune osservazioni cercando di comprendere il problema:
- Poiché sembra, problema con galleggiante così ho cambiato tipo galleggiante (di LocX, Locy) a int e rieseguire il codice. Lo stesso errore persiste. Quindi, non è un problema associato in modo specifico al tipo CQL.
- Successivamente, ho tentato di rimuovere tutti int dalla query INSERT e ho tentato di inserire solo valori non numerici. Questo tentativo ha inserito correttamente il valore in db. Quindi sembra che ora,
this problem may be associated with numeric types
.
Grande dettaglio nella risposta, bello che hai indicato anche il problema del lotto. – jorgebg
Il primo approccio funziona per me, grazie –