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:
# ant hbaseBuildfile: build.xml init: retrieve-dependencies: :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ :: :: loading settings :: url = jar:file:/usr/share/ant/lib/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml hbase.compile: Compiling 5 source files to /root/hadoop-book/build/classes /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[]) get.addColumn(INFO_COLUMNFAMILY); ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 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:
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:
# ant hbaseBuildfile: build.xml init: retrieve-dependencies: :: Apache Ivy 2.3.0-rc1 - 20120416000235 :: http://ant.apache.org/ivy/ :: :: loading settings :: url = jar:file:/usr/share/ant/lib/ivy.jar!/org/apache/ivy/core/settings/ivysettings.xml hbase.compile: Compiling 5 source files to /root/hadoop-book/build/classes /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[]) get.addColumn(INFO_COLUMNFAMILY); ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 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:
public Get addColumn(byte[] family, byte[] 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:
public Get addFamily(byte[] 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.
Recent Posts
See AllRecently I was working on a problem with Time Series. Time Series can quickly add up to a lot of data, as you are using previous...
One of the biggest bottlenecks in Deep Learning is loading data. having fast drives and access to the data is important, especially if...
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.TableName;...
Comments