Database Reference
In-Depth Information
Please note the use of email varchar[] for the definition of the array. Now you
can store as many emails as you want. What is especially nice is that you can avoid
the use of fields such as email1 , email2 , email3 , and so on, which leave much to
be desired. There is no way to reorder e-mails in one operation; for example, some
people might have five or even ten emails and they might run out of fields, while
some have only one and might waste the space.
With pure lists, you can prepend and append items to the list, while in HBase
Phoenix, you can only set, read, or write the whole array. However, this is good
enough to store emails.
The SQL ARRAY functionality exists in Phoenix, starting with the 3.0 release. If you are
unable to find a ready release to download, you can clone it from GitHub and build
it yourself. That is what I have done. At this point, I would like to thank the Phoenix
team for providing me with the help and documentation at the time of writing.
Sets, maps, and lists
HBase and Phoenix are under constant development. While sets, maps, and lists'
features are not complete right now, they might be included by the time you read
this topic. For now, we have implemented these in our companion code on GitHub.
Generating the test data
Ideally, we would like to generate data in order to be able to test our solution.
Here too, Phoenix comes to the rescue because it allows us to generate SQL
statements that can then be executed. The code to do this is found in HDPP at
https://github.com/markkerzner/hbase-book/blob/master/src/main/java/
com/elephantscale/hbase/book/chapter3/GenerateUsers.java under the
GenerateUsers.java file.
The following is the main method for date generation:
public static void main(String argv[]) {
if (argv.length != 2) {
System.out.println("Arguments: number-users, number-emails-per-
user");
System.exit(0);
}
GenerateUsers generator = new GenerateUsers();
int nUsers = Integer.parseInt(argv[0]);
int nEmails = Integer.parseInt(argv[1]);
try {
 
Search WWH ::




Custom Search