Skip to content

Instantly share code, notes, and snippets.

View pamio's full-sized avatar

Pramod Solanky pamio

View GitHub Profile
A = load '/tmp/alice.txt';
B = foreach A generate flatten(TOKENIZE((chararray)$0)) as word;
C = filter B by word matches '\\w+';
D = group C by word;
E = foreach D generate COUNT(C), group;
store E into '/tmp/alice_wordcount';
REGISTER contrib/piggybank/java/piggybank.jar
DEFINE SUBSTRING org.apache.pig.piggybank.evaluation.string.SUBSTRING();
A = load 'gutenberg/sample.txt';
C = foreach A generate SUBSTRING((chararray)$0, 0, 5);
dump C;
input = {"Root"=>[{"1"=>[{"4"=>"leaf4", "5"=>"leaf5"}]}, {"2"=>[{"6"=>"leaf6", "7"=>"leaf7"}]}]}
def traverse(path = "")
self.each do|key, value|
if value.is_a?(Hash)
path += "#{key}=>"
value.traverse(path)
else
if value.is_a?(Array)
path += "#{key}=>"