Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # user >> Converting a tuple to rows


+
Xavier Stevens 2011-06-02, 18:38
Copy link to this message
-
Re: Converting a tuple to rows
one_word_per_line = FOREACH words GENERATE FLATTEN(TOBAG(*));

-Thejas
On 6/2/11 11:38 AM, "Xavier Stevens" <[EMAIL PROTECTED]> wrote:

I'm currently trying to write a pig script to output a feature index. Is
there a built-in function for converting an unknown length tuple to
output once for each item in the tuple?

Example code:

raw = LOAD 'hbase://mytable' USING HBaseStorage('data:json') AS
json:chararray;
genmap = FOREACH raw GENERATE com.mozilla.pig.eval.json.JsonMap(json) AS
json_map:map[];
words = FOREACH genmap GENERATE
FLATTEN(com.mozilla.pig.eval.text.Normalize(json_map#'text')) AS word_tuple;
dump words;
(the,quick,brown,fox,jumped,over,the,lazy,dog)

I want to get:

the
quick
brown
fox
jumped
over
lazy
dog

Thanks,

-Xavier

--

+
Xavier Stevens 2011-06-02, 18:57
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB