Over a million developers have joined DZone.

Hadoop, Pig, and Broken Dreams of Environment Variables

DZone's Guide to

Hadoop, Pig, and Broken Dreams of Environment Variables

· Big Data Zone ·
Free Resource

The open source HPCC Systems platform is a proven, easy to use solution for managing data at scale. Visit our Easy Guide to learn more about this completely free platform, test drive some code in the online Playground, and get started today.

Okay, this post isn't nearly as melodramatic as its title – I’m doing some log analysis with Hadoop and Pig. As the logs are coming from a webserver and are not that far from standard “combined” format, it is most logical to use the time-saving UDFs in Pig’s Piggybank. This is just a set of user-contributed code, but very useful.

Unfortunately there doesn’t seem to be a Debian package for it, at least not in the set of repositories I have available to me on this machine so I thought I’d just compile it – it is dynamically loadable from an arbitrary path in a Pig script so this is not a big issue. The process is two-fold:

  1. Compile Pig itself (or locate the pig-withouthadoop.jar pre-compiled on your system)
  2. Compile Piggybank against that version of Pig

Pig uses the Ant build system, and it really is as trivial as running ant from the top-level directory. I checked out the tagged release of 0.10.0 and successfully built Pig. Building Piggybank against it, however, errored out with something I wasn’t immediately able to find on the interwebs:

$ ant
Buildfile: /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml

    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/classes
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/test
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/test/classes
    [mkdir] Created dir: /home/oliver/release-0.10.0/contrib/piggybank/java/build/docs/api

     [echo]  *** Compiling Pig UDFs ***
    [javac] /home/oliver/release-0.10.0/contrib/piggybank/java/build.xml:92: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 154 source files to /home/oliver/release-0.10.0/contrib/piggybank/java/build/classes
    [javac] error: error reading /home/oliver/release-0.10.0/pig-withouthadoop.jar; invalid header field
    [javac] 1 error

/home/oliver/release-0.10.0/contrib/piggybank/java/build.xml:92: Compile failed; see the compiler error output for details.

Total time: 0 seconds

Now, I’m not a Java guy so this means very little to me. However I do at least know that a Jar file is simply a zip archive so I went digging. Assuming that the ‘invalid header field’ is in the metadata of the Jar file, I looked in the contained META-INF/MANIFEST.MF:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.0
Created-By: 1.6.0_26-b03 (Sun Microsystems Inc.)
Main-Class: org.apache.pig.Main

Name: org/apache/pig
Implementation-Vendor: Apache
Implementation-Title: Pig
Implementation-Version: 0.10.0-SNAPSHOT
Build-TimeStamp: Sep 12 2012, 08:14:45
Svn-Revision: svnversion: warning: cannot set LC_CTYPE locale
 on: warning: environment variable LC_CTYPE is UTF-8
svnversion: warni
 ng: please check that your locale name is correct

It seems that some locale settings in the environment are causing issues with the svnversion program, and indeed when running it separately I can confirm the same issue:

~/release-0.10.0$ svnversion
svnversion: warning: cannot set LC_CTYPE locale
svnversion: warning: environment variable LC_CTYPE is UTF-8
svnversion: warning: please check that your locale name is correct

I’ve been seeing this on a bunch of machines I’ve been using recently but frankly I haven’t had the time to diagnose it. It is easily worked around with unset LC_CTYPE:

~/release-0.10.0$ unset LC_CTYPE
~/release-0.10.0$ svnversion

There's some contention around adding superfluous metadata fields in Ant builds, but again, this is something I don’t particularly care to dive into at the moment. An acceptable alternative workaround in this case would have been to remove the additional metadata generation in the Ant build.xml.

Rebuilding Pig now and Piggybank against it works. Huzzah! On to the next problem.

Managing data at scale doesn’t have to be hard. Find out how the completely free, open source HPCC Systems platform makes it easier to update, easier to program, easier to integrate data, and easier to manage clusters. Download and get started today.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}