1

provied that there's a Map like,,,

map.text

[key1#v1]
[key2#v2]
[key3#v3]

then, if I try to find 'value of 'key2'',

A = load ‘map.text’ as (M:map[]);
B = foreach A generate M#'key2';
C = filter B by $0!='';     // to get rid of empty value like (), (), ().
dump C;

is there any other way to find key2? with using 'filter by' only.

thxs ya.

4

1 回答 1

0

There is no need to GENERATE a field and then use it in a FILTER; you can include it in the FILTER statement to begin with:

A = load 'map.text' as (M:map[]);
B = filter A by M#'key2' != '';
dump B;

On your data, this returns one record:

([key2#v2])

As a side note, in case empty strings are ever valid values, the criterion you might rather use is by M#'key2' is not null.

于 2013-09-03T17:00:46.940 回答