put.addColumn(FAMILY, QUALIFIER, VALUE); json = put.toJSON(); parsedJSON = mapper.readValue(json, HashMap.class);
public static void main(String[] args) throws Exception { // vv FingerprintExample Put put = new Put(Bytes.toBytes("testrow")); put.addColumn(Bytes.toBytes("fam-1"), Bytes.toBytes("qual-1"), Bytes.toBytes("val-1")); put.addColumn(Bytes.toBytes("fam-1"), Bytes.toBytes("qual-2"), Bytes.toBytes("val-2")); put.addColumn(Bytes.toBytes("fam-2"), Bytes.toBytes("qual-3"), Bytes.toBytes("val-3")); String id = String.format("Hostname: %s, App: %s", InetAddress.getLocalHost().getHostName(), System.getProperty("sun.java.command")); put.setId(id); System.out.println("Put.size: " + put.size()); System.out.println("Put.id: " + put.getId()); System.out.println("Put.fingerprint: " + put.getFingerprint()); System.out.println("Put.toMap: " + put.toMap()); System.out.println("Put.toJSON: " + put.toJSON()); System.out.println("Put.toString: " + put.toString()); // ^^ FingerprintExample } }
put.addColumn(FAMILY, QUALIFIER, VALUE); json = put.toJSON(); parsedJSON = mapper.readValue(json, HashMap.class);
String str = "prasad\r\nchowdary"; str = StringEscapeUtils.escapeJava(str); Put p = new Put(Bytes.toBytes(str)); JSONObject json = new JSONObject(p.toJSON()); System.out.println(StringEscapeUtils.unescapeJava(json.getString("row")));
/** * creates a put to be updated into the RAW table for aggregation status * @param row key * @param status of aggregation * @return {@link Put} */ public Put getAggregatedStatusPut(byte[] row, byte[] col, Boolean status) { Put put = new Put(row); put.addColumn(Constants.INFO_FAM_BYTES, col, Bytes.toBytes(status)); try { LOG.info(" agg status " + status + " and put " + put.toJSON()); } catch (IOException e) { // ignore json exception } return put; }
/** * creates a put to be updated into the RAW table for aggregation status * @param row key * @param status of aggregation * @return {@link Put} */ public Put getAggregatedStatusPut(byte[] row, byte[] col, Boolean status) { Put put = new Put(row); put.addColumn(Constants.INFO_FAM_BYTES, col, Bytes.toBytes(status)); try { LOG.info(" agg status " + status + " and put " + put.toJSON()); } catch (IOException e) { // ignore json exception } return put; }