Database Reference
In-Depth Information
The lesson that we learn here is that UUID is a prime citizen in the NoSQL world.
Why do we need it? We want to enable distributed systems to uniquely identify
information without significant central coordination.
Please note that unique means practically unique rather than guaranteed unique .
Since the identifiers have a finite size, it is possible for two different items to
share the same identifier.
Today, in the life of an HBase developer using Java, generating UUIDs is easy.
Here is a code snippet that lets you do this:
import java.util.UUID;
String my_uuid = UUID.randomUUID().toString();
Once you generate the UUID, you can use it to store the large files, or any HBase
row for that matter.
What follows next is an example of a small program generating the UUIDs,
just to give you a feel for them (taken from http://www.portablefreeware.
com/?id=2042 ):
Now, in your HBase application, you can use something similar to this
code fragment:
byte [] key = UUID.randomUUID().toString();
Put put = new Put (key);
put.add(Bytes.toBytes(familyName), Bytes.toBytes("email"),
Bytes.toBytes(email));
put.add(Bytes.toBytes(familyName), Bytes.toBytes("phone"),
Bytes.toBytes(phone));
 
Search WWH ::




Custom Search