apache pig - Looking up variable keys in pig map -
i'm trying use pig break text lowercased words, , each word in map. here's example map, have in map.txt (it 1 line long):
[this#1.9,is#2.5my#3.3,vocabulary#4.1]
i load so:
m = load 'mapping.txt' using pigstorage (mp: map[float]);
which works fine. following load text , break lowercased words:
lines = load 'test.txt' using textloader() (line:chararray); tokens = foreach lines generate flatten(tokenize(lower(line))) (word:chararray);
now, i'd this:
results = foreach tokens generate m.mp#word;
so if have line "this my vocabulary", i'd following output: 1 3 3 4 , keep getting various errors. how can variable values in map?
i've looked @ how can use map datatype in apache pig? , http://pig.apache.org/docs/r0.10.0/basic.html#map-schema , these if i'm looking fixed value in map, example m.mp#'this', not want here.
you can flatten m , join m , lines based on token/word (you can 'replicated' join on m copies each mapper
Comments
Post a Comment