This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}=>" |
NewerOlder