List of usage examples for org.apache.hadoop.io Text toString
@Override
public String toString()
From source file:Assignment1_Wordcount.WordCount_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { StringTokenizer itr = new StringTokenizer(value.toString()); System.out.println("Content on line " + key.toString() + " :- " + value.toString()); while (itr.hasMoreTokens()) { word.set(itr.nextToken());/*w w w . j a va2 s. c om*/ context.write(word, one); } }
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); }/*from w ww . jav 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);// w w w . j a v a2 s . c o m }
From source file:Assignment2_P4_MovieRatingCount.MovieRating_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[] movieInfo = value.toString().split("::"); //System.out.println("String is split now "); if (!movieInfo[1].trim().toLowerCase().equals("movieid")) { movieID = new IntWritable(Integer.parseInt(movieInfo[1])); //System.out.println("MovieId extracted " + movieID.toString()); context.write(movieID, one);/*w ww .j a v a 2s . com*/ } }
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);// ww w.j av a2s . 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 {//from w ww . j a v a2s . co 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); } } }
From source file:Assignment3_P5_Top25Movies.Top25MovieRating_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { String[] movieInfo = value.toString().split("::"); if (!movieInfo[1].trim().toLowerCase().equals("movieid")) { movieID = new IntWritable(Integer.parseInt(movieInfo[1])); rating = new FloatWritable(Float.parseFloat(movieInfo[2])); //System.out.println("MovieId extracted " + movieID.toString()); context.write(movieID, rating);//from w ww. ja v a2 s . com } }
From source file:Assignment3_P5_Top25Movies.Top25MovieRating_Mapper1.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { String[] movieInfo = value.toString().split("\t"); movieID = new IntWritable(Integer.parseInt(movieInfo[0])); rating = new FloatWritable(Float.parseFloat(movieInfo[1])); context.write(rating, movieID);// ww w . j a va2s . com }
From source file:Assignment4_P2_StockAverageWithCombiner.StockAverage_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")) { String[] dateParts = stockInfo[2].split("-"); Text year = new Text(dateParts[0]); stockPriceAdjCompositeObj.setCount(1); stockPriceAdjCompositeObj.setAverage(stockInfo[8]); context.write(year, stockPriceAdjCompositeObj); }/* w w w .j a va 2 s .co m*/ }
From source file:Assignment4_P3_InMemoryStdDeviation.MovieRatingStdDev_Mapper.java
public void map(Object key, Text value, Context context) throws IOException, InterruptedException { String[] movieInfo = value.toString().split("::"); if (!movieInfo[1].trim().toLowerCase().equals("movieid")) { movieID = new IntWritable(Integer.parseInt(movieInfo[1])); rating = new FloatWritable(Float.parseFloat(movieInfo[2])); context.write(movieID, rating);//from ww w. j a v a 2s.com } }