Fix for source code error in Hadoop: The Definitive Guide (3rd Ed) – HBaseStationCli.java

I recently started working through Hadoop: The Definitive Guide (3rd Ed) by Tom White.  One of the things you need to do is compile all the source files and examples that come with the book.  This is done via an ant build.xml.  One of those targets is for hbase, and it fails like so:

 

 

 

[root@hadoop01 hadoop-book]# ant hbase
Buildfile: build.xml

init:

retrieve-dependencies:
[ivy:retrieve] :: Apache Ivy 2.3.0-rc1 – 20120416000235 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: url = jar:file:/usr/share/ant/lib/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml

hbase.compile:
[javac] Compiling 5 source files to /root/hadoop-book/build/classes
[javac] /root/hadoop-book/ch13/src/main/java/HBaseStationCli.java:23: addColumn(byte[],byte[]) in org.apache.hadoop.hbase.client.Get cannot be applied to (byte[])
[javac] get.addColumn(INFO_COLUMNFAMILY);
[javac] ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] 1 error

BUILD FAILED
/root/hadoop-book/build.xml:126: Compile failed; see the compiler error output for details.

Total time: 2 seconds

The issue appears to be documented in an Unconfirmed Errata for the book:

http://oreilly.com/catalog/errataunconfirmed.csp?isbn=0636920010388

However, there is no fix, and no information on how to resolve this available online.

The issue appears to be with this line, from ch13/src/main/java/HBaseStationCli.java:

get.addColumn(INFO_COLUMNFAMILY);

The method addColumn from the class org.apache.hadoop.hbase.client.Get is documented here:

http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Get.html

You can see that this method expects two parameters of type byte[], a family name and a column qualifier:

It’s obvious the code is not correct.  I believe Tom White mean’t instead to call the addFamily method, which expects just a family name and it gets all columns from the given family:

So the solution is to change line 126 like so:
 get.addFamily(INFO_COLUMNFAMILY);

 

Please let me know if this has been helpful and if you have any thoughts on this errata.  Hopefully in short order Tom White will update the problem to the confirmed errata and make the official correction.

This entry was posted in Data Analytics. Bookmark the permalink.

Leave a Reply