Reputation: 364
I have following insert statement.
Put put = new Put(UserId.getBytes(charSet));
put.add("Actor".getBytes(charSet), "Verified".getBytes(charSet),Bytes.toBytes(verified));
put.add("Actor".getBytes(charSet), "UtcOffset".getBytes(charSet),Bytes.toBytes(utcOffset));
put.add("Actor".getBytes(charSet), "PreferredUsername".getBytes(charSet),preferredUserName.getBytes(charSet));
table.put(put);
Now I want to update inserted value preferredUserName with new preferredUsername. Please help me
Upvotes: 1
Views: 5960
Reputation: 103
In HBase, you can update values in different column-qualifiers separately, and the old value in one column-qualifer will be "shadowed" by the new value. Strictly speaking, the new value forms a new version, and by default you always Get the latest version if you don't specify timestamps in Get/Scan.
So just "Put" the new preferredUsername into "PreferredUsername" column-qualifier.
Put put = new Put(UserId.getBytes(charSet));
put.add("Actor".getBytes(charSet), "PreferredUsername".getBytes(charSet),newPreferredUserName.getBytes(charSet));
table.put(put);
This will "shadow" inserted preferredUserName with newPreferredUserName for the "UserId" row.
Upvotes: 6