
上QQ阅读APP看书,第一时间看更新
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are a few examples of these styles and an explanation of their meaning.
Code words in text are shown as follows: "From this point onward, we shall call the unpacked Hadoop directory HADOOP_HOME
."
A block of code for UDFs written in Java is set as follows:
package com.pigdesignpatterns.myudfs; public class DeIdentifyUDF extends EvalFunc<String> { @Override public String exec(Tuple input){ try { String plainText = (String)input.get(0); String encryptKey = (String)input.get(1); String str=""; str = encrypt(plainText,encryptKey.getBytes()); return str; } catch (NullPointerException npe) { warn(npe.toString(), PigWarning.UDF_WARNING_2); return null; } catch (StringIndexOutOfBoundsException npe) { warn(npe.toString(), PigWarning.UDF_WARNING_3); return null; } catch (ClassCastException e) { warn(e.toString(), PigWarning.UDF_WARNING_4); return null; }
Pig Script is displayed as follows:
Users = load 'users' as (name, age); Fltrd = filter Users by age >= 18 and age <= 25; Pages = load 'pages' as (user, url); Jnd = join Fltrd by name, Pages by user; Grpd = group Jnd by url; Smmd = foreach Grpd generate group, COUNT(Jnd) as clicks; Srtd = order Smmd by clicks desc; Top5 = limit Srtd 5; store Top5 into 'top5sites'
Any command-line input or output is written as follows:
>tar -zxvf hadoop-1.x.x.tar.gz
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Clicking the Next button moves you to the next screen."