The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

Pig Forum

Elephant-bird to analyse Tweets

  • #45901
    Rodulfo
    Participant

    Hello I wanted to use Twitters Elephant-bird, to analyze Tweets without having to save them in another format like csv and leave them in their original JSON format.

    I have built Elephant-bird and I wrote the following simple code to load tweets from a file, following some examples I saw:


    REGISTER /user/rmrodriguez/jar/json-simple-1.1.jar;
    REGISTER /user/rmrodriguez/jar/elephant-bird-pig-4.4.jar;
    REGISTER /user/rmrodriguez/jar/elephant-bird-core-4.4.jar;
    REGISTER /user/rmrodriguez/jar/google-collections-1.0.jar;

    A = LOAD 'tweets.20131201-215958.json' USING com.twitter.elephantbird.pig.load.JsonLoader('-nestedLoad');

    tweets = FOREACH A GENERATE (CHARARRAY)$0#'id' AS id;

    DUMP tweets;

    and I get the following error:

    2013-12-19 07:55:55,364 [main] INFO org.apache.pig.tools.pigstats.ScriptState - Pig script settings are added to the job
    2013-12-19 07:55:55,367 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.JobControlCompiler - mapred.job.reduce.markreset.buffer.percent is not set, set to default 0.3
    2013-12-19 07:55:55,370 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2998: Unhandled internal error. com/twitter/elephantbird/util/HadoopCompat
    Details at logfile: /hadoop/yarn/local/usercache/rmrodriguez/appcache/application_1387366430472_0012/container_1387366430472_0012_01_000002/pig_1387457753323.log

    Anyone has experience with elephant-bird that might know the cause for the error or can suggest another way for loading tweets in JSON format?

    Greetings,
    Rod

  • Author
    Replies
  • #46226

    check the logfile ‘pig_1387457753323.log’. you may need to register the HadoopCompat jar in your pig script

    #46254
    Rodulfo
    Participant

    Thank you Ramanan,

    That was it,. I just needed to register the HadoopCompat.jar. Now it works!

    #57215
    Hadoop Developer
    Participant

    Hi,

    I have 3 records in json format in source file but after processing in PIG it only throws back 1 record. Please suggest how to proceed on this.
    Here is the detailed description:

    Source Data :

    hadoop fs -cat /tmp/json.txt

    [
    {“key”: “313032”,”columns”: [[“name”,”name102″,1405333129634000]]},
    {“key”: “313030”,”columns”: [[“name”,”name1″,1405333115374000]]},
    {“key”: “313031”,”columns”: [[“name”,”name101″,1405333123538000]]}
    ]

    Pig Code:

    register /tmp/jsontest/elephant-bird-pig-4.4.jar;
    register /tmp/jsontest/elephant-bird-core-4.4.jar;
    register ‘/tmp/jsontest/elephant-bird-hadoop-compat-4.4.jar’;
    register ‘/tmp/jsontest/google-collections-1.0-rc1.jar’;
    register ‘/tmp/jsontest/json_simple-1.1.jar’;

    a = load ‘/tmp/json.txt’ using com.twitter.elephantbird.pig.load.JsonLoader(‘-nestedLoad’) ;
    dump a;

    Output:

    ([columns#{({(name),(name101),(1405333123538000)})},key#313031])

    #64201
    rameshn
    Participant

    grunt> data = LOAD ‘/input/pig/service.json’ USING com.twitter.elephantbird.pig.load.JsonLoader(‘-nestedLoad’) AS (json:map[]);
    grunt> tweets = FOREACH data GENERATE (CHARARRAY)$0#’id’ AS id;
    grunt> dump tweets;
    2014-11-24 15:33:42,973 [main] INFO org.apache.pig.tools.pigstats.ScriptState – Pig features used in the script: UNKNOWN
    2014-11-24 15:33:42,974 [main] INFO org.apache.pig.newplan.logical.rules.ColumnPruneVisitor – Map key required for data: $0->[id]

    2014-11-24 15:33:42,977 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MRCompiler – File concatenation threshold: 100 optimistic? false
    2014-11-24 15:33:42,978 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MultiQueryOptimizer – MR plan size before optimization: 1
    2014-11-24 15:33:42,978 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MultiQueryOptimizer – MR plan size after optimization: 1
    2014-11-24 15:33:42,979 [main] INFO org.apache.pig.tools.pigstats.ScriptState – Pig script settings are added to the job
    2014-11-24 15:33:42,987 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.JobControlCompiler – mapred.job.reduce.markreset.buffer.percent is not set, set to default 0.3
    2014-11-24 15:33:42,988 [main] ERROR org.apache.pig.tools.grunt.Grunt – ERROR 2998: Unhandled internal error. Could not initialize class com.twitter.elephantbird.util.HadoopCompat

    I’m getting above error when executing pig script. Can anyone help me..?

The forum ‘Pig’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.