Database Reference
In-Depth Information
split_time.py'
AS (hr,loglevel,min,sec,fulltime) from logs l;
Figure 9.17 Splitting the time into hours, minutes, and seconds
The preceding script was a mapping script. You can also create reduce
scripts for your custom processing. A reduce script takes tab-delimited
columns from the input and produces tab-delimited output columns just
like a map script. The difference is the reduce script combines rows in
the process, and the rows out should be less than the rows put in. To run
a reduce script, you need to have a mapping script. The mapping script
provides the key/value pairs for the reducer. The Python script in Figure
9.18 is a mapping script that takes the input and checks whether it starts
with a [ character. If it does, it outputs it to a line and gives it a count of one.
Figure 9.18 Mapping logging levels
Figure 9.19 shows a sample output from the script.
 
 
 
 
Search WWH ::




Custom Search