Forum: Building VoltDB Applications

Post: Node.js and Bigint

Node.js and Bigint
francis
Oct 11, 2013
I've been struggling for a while on trying to get VoltDB to accept BigInts

If I do this:

	var query = objectGet.getQuery();
	
	var appID = 1291439048920924160;
	var objectID = 1476268322696724481;

	query.setParameters([appID,objectID]);
	
	console.log(query);


My results are:

{ 
  procName: 'objects_getObject',
  types: [ 'bigint', 'bigint' ],
  parameters: [ 1291439048920924200, 1476268322696724500 ], //They are losing precision
  uid: null 
}


However if I try to do:

	var query = objectGet.getQuery();
	
	var appID = new BigInteger('1291439048920924160');
	var objectID = new BigInteger('1476268322696724481').toString();

	query.setParameters([appID,objectID]);
	
	console.log(query);


I get:

Error: Cannot provide custom objects as procedure parameters


So my question is. How can I even pass BigInts or even generate some through my app?
francis
Oct 11, 2013
I've also attempted to make an AdHoc query without sending any parameters, seems the data I get back from VoltDB is mostly wrong or is throwing me a lot of errors.

If I do:

	objectGet = new VoltProcedure('@AdHoc', ['string']);
	var query = objectGet.getQuery();
	query.setParameters(["SELECT * FROM objects LIMIT 3;"]);

	console.log(query);

	client.callProcedure(query, function initVoter(code, event, results) {
		console.log(results.table[0]);
	});


I get:

{ 
  OBJECTID: 50331648, //This is way off
  APPID: 67125247, //This is way off also
  ...
}


If I remove the limit...

	objectGet = new VoltProcedure('@AdHoc', ['string']);
	var query = objectGet.getQuery();
	query.setParameters(["SELECT * FROM objects;"]);

	console.log(query);

	client.callProcedure(query, function initVoter(code, event, results) {
		console.log(results.table[0]);
	});


I get:

buffer.js:416
      return this.parent.utf8Slice(start, end);
                         ^
Error: Must have start <= end

mbetter95
Nov 25, 2013
i might be able to go with the workaround and modify the WHERE criteria for subsequent queries, but the logic will be quite complex.
i'll give it a try anyway :