List of usage examples for org.apache.hadoop.io Text Text
public Text(byte[] utf8)
From source file:analysis3.crimeScoreMapper.java
public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException { StringTokenizer tokenizer = new StringTokenizer(value.toString(), ","); if (tokenizer.countTokens() != 0) { String[] data = new String[tokenizer.countTokens()]; int i = 0; while (tokenizer.hasMoreTokens()) { data[i] = tokenizer.nextToken(); i++;/*from w w w.j a v a 2s.co m*/ } String type = data[2]; type = type.trim(); int weight = 0; if (type.equalsIgnoreCase("arson")) { weight = 2; } else if (type.equalsIgnoreCase("theft")) { weight = 3; } else if (type.equalsIgnoreCase("assault")) { weight = 2; } else if (type.equalsIgnoreCase("battery")) { weight = 4; } else if (type.equalsIgnoreCase("robbery")) { weight = 3; } else if (type.equalsIgnoreCase("burglary")) { weight = 3; } else if (type.equalsIgnoreCase("gambling")) { weight = 1; } else if (type.equalsIgnoreCase("homicide")) { weight = 4; } else if (type.equalsIgnoreCase("stalking")) { weight = 1; } else if (type.equalsIgnoreCase("narcotics")) { weight = 2; } else if (type.equalsIgnoreCase("obscenity")) { weight = 1; } else if (type.equalsIgnoreCase("kidnapping")) { weight = 3; } else if (type.equalsIgnoreCase("sex offense")) { weight = 3; } else if (type.equalsIgnoreCase("intimidation")) { weight = 2; } else if (type.equalsIgnoreCase("non - criminal")) { weight = 1; } else if (type.equalsIgnoreCase("prostitution")) { weight = 2; } else if (type.equalsIgnoreCase("other offense")) { weight = 1; } else if (type.equalsIgnoreCase("non-criminal")) { weight = 1; } else if (type.equalsIgnoreCase("criminal damage")) { weight = 2; } else if (type.equalsIgnoreCase("public indecency")) { weight = 2; } else if (type.equalsIgnoreCase("criminal trespass")) { weight = 2; } else if (type.equalsIgnoreCase("human trafficking")) { weight = 3; } else if (type.equalsIgnoreCase("weapons violation")) { weight = 2; } else if (type.equalsIgnoreCase("deceptive practice")) { weight = 2; } else if (type.equalsIgnoreCase("crim sexual assault")) { weight = 4; } else if (type.equalsIgnoreCase("motor vehicle theft")) { weight = 2; } else if (type.equalsIgnoreCase("liquor law violation")) { weight = 1; } else if (type.equalsIgnoreCase("public peace violation")) { weight = 1; } else if (type.equalsIgnoreCase("other narcotic violation")) { weight = 1; } else if (type.equalsIgnoreCase("offense involving children")) { weight = 3; } else if (type.equalsIgnoreCase("interference with public officer")) { weight = 1; } else if (type.equalsIgnoreCase("concealed carry license violation")) { weight = 2; } if (data[3].trim().startsWith("60")) output.collect(new Text(data[3].trim()), new IntWritable(weight)); else output.collect(new Text(data[4].trim() + "," + data[3].trim()), new IntWritable(weight)); } else { output.collect(new Text("ProBLEMMMMMMMMMMMMMMMMMMMMM"), new IntWritable(1)); } }
From source file:application.Globals.java
License:Open Source License
public void setOUTPUT1(String oUTPUT1) { OUTPUT1 = new Text(oUTPUT1); }
From source file:application.Globals.java
License:Open Source License
public void setOUTPUT2(String oUTPUT2) { OUTPUT2 = new Text(oUTPUT2); }
From source file:application.Globals.java
License:Open Source License
public void setTRAIN_FILE_NAME(String tRAIN_FILE_NAME) { TRAIN_FILE_NAME = new Text(tRAIN_FILE_NAME); }
From source file:application.Globals.java
License:Open Source License
public void setTEST_FILE_NAME(String tEST_FILE_NAME) { TEST_FILE_NAME = new Text(tEST_FILE_NAME); }
From source file:application.Globals.java
License:Open Source License
public void setSPLIT_TOKEN(String sPLIT_TOKEN) { SPLIT_TOKEN = new Text(sPLIT_TOKEN); }
From source file:Assignment2_P2_StockExchangeCount.StockPrice_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { //System.out.println("Content on line " + key.toString() + " :- " + value.toString() ); String[] stockInfo = value.toString().split(","); //System.out.println("String is split now "); if (!stockInfo[1].trim().equals("stock_symbol")) { Text stockName = new Text(stockInfo[1]); //System.out.println("Stockname extracted " + stockName.toString()); FloatWritable highestPrice = new FloatWritable(Float.parseFloat(stockInfo[4])); //System.out.println("So is the price " + highestPrice); context.write(stockName, highestPrice); }// w w w .j a v a 2 s . c o m }
From source file:Assignment2_P3_GenderMovieCount.GenderMovieRating_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { //System.out.println("Content on line " + key.toString() + " :- " + value.toString() ); String[] userInfo = value.toString().split("::"); //System.out.println("String is split now "); gender = new Text(userInfo[1]); //System.out.println("MovieId extracted " + movieID.toString()); context.write(gender, one);/*from ww w . j a v a 2 s. co m*/ }
From source file:Assignment2_P5_IPAddressCount.IPAddress_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { //System.out.println("Content on line " + key.toString() + " :- " + value.toString() ); String[] ipInfo = value.toString().split("-"); //System.out.println("String is split now "); ipaddr = new Text(ipInfo[0].trim()); //System.out.println("MovieId extracted " + movieID.toString()); context.write(ipaddr, one);/*from w w w .j av a2 s .c o m*/ }
From source file:Assignment3_P4_DateStock.DateStock_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { String[] stockInfo = value.toString().split(","); if (!stockInfo[1].trim().equals("stock_symbol")) { try {/* w w w . j ava 2s. c o m*/ Text stockName = new Text(stockInfo[1]); DateStock_CompositeValueWritable dcvw = new DateStock_CompositeValueWritable(stockInfo[2], stockInfo[7], stockInfo[8]); context.write(stockName, dcvw); } catch (IOException | InterruptedException ex) { Logger.getLogger(DateStock_Mapper.class.getName()).log(Level.SEVERE, null, ex); } } }