I know that Stargate expects the values to be inserted into a HBase table to be base64 encoded.
How do we base64 encode numerical values like integer and floats before forming the JSON payload for HTTP PUT?
I could solve this myself, below is the snippet how I could encode integer and double values:
long t = 11;
String e1 = Base64.encodeBase64String(BigInteger.valueOf(t).toByteArray());
t = 78;
String e2 = Base64.encodeBase64String(BigInteger.valueOf(t).toByteArray());
System.out.println("e1: "+e1+", e2: "+e2);
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(byteOut);
double d = -1.966723;
out.writeDouble(d);
out.flush();
byte[] buf = byteOut.toByteArray();
String e3 = Base64.encodeBase64String(buf);
System.out.println("e3: "+e3);
}
catch(Exception e) {
System.out.println("Exception: "+e);
}