@Test public void testMapForInvalidInput() throws Exception { String input = "invalid line"; mapper.map(null, new Text(input), context); verify(context, never()).write(any(), any()); verify(log).error(isA(ArrayIndexOutOfBoundsException.class)); }
@Override protected void map(Writable ignore, Text data, Context context) throws IOException, InterruptedException { try { String[] fields = data.toString().split("\\t"); DocumentSimilarity similarity = new DocumentSimilarity(); similarity.setDocumentId(fields[0]); similarity.setOtherDocumentId(fields[1]); similarity.setSimilarity(Float.parseFloat(fields[2])); context.write(new AvroKey<DocumentSimilarity>(similarity), NullWritable.get()); } catch (Exception e) { log.error(e); } }
TsvToAvroMapper extends Mapper<Writable, Text, AvroKey<DocumentSimilarity>, NullWritable> { @Override protected void map(Writable ignore, Text data, Context context) throws IOException, InterruptedException { try { String[] fields = data.toString().split("\\t"); DocumentSimilarity similarity = new DocumentSimilarity(); similarity.setDocumentId(fields[0]); similarity.setOtherDocumentId(fields[1]); similarity.setSimilarity(Float.parseFloat(fields[2])); context.write(new AvroKey<DocumentSimilarity>(similarity), NullWritable.get()); } catch (Exception e) { log.error(e); } } }
TsvToAvroMapper extends Mapper<Writable, Text, AvroKey<DocumentSimilarity>, NullWritable> { @Override protected void map(Writable ignore, Text data, Context context) throws IOException, InterruptedException { try { String[] fields = data.toString().split("\\t"); DocumentSimilarity similarity = new DocumentSimilarity(); similarity.setDocumentId(fields[0]); similarity.setOtherDocumentId(fields[1]); similarity.setSimilarity(Float.parseFloat(fields[2])); context.write(new AvroKey<DocumentSimilarity>(similarity), NullWritable.get()); } catch (Exception e) { log.error(e); } }  }
TsvToAvroMapper extends Mapper<Writable, Text, AvroKey<DocumentSimilarity>, NullWritable> { @Override protected void map(Writable ignore, Text data, Context context) throws IOException, InterruptedException { try { String[] fields = data.toString().split("\\t"); DocumentSimilarity similarity = new DocumentSimilarity(); similarity.setDocumentId(fields[0]); similarity.setOtherDocumentId(fields[1]); similarity.setSimilarity(Float.parseFloat(fields[2])); context.write(new AvroKey<DocumentSimilarity>(similarity), NullWritable.get()); } catch (Exception e) { log.error(e); } }   }
TsvToAvroMapper extends Mapper<Writable, Text, AvroKey<DocumentSimilarity>, NullWritable> { @Override protected void map(Writable ignore, Text data, Context context) throws IOException, InterruptedException { try { String[] fields = data.toString().split("\\t"); DocumentSimilarity similarity = new DocumentSimilarity(); similarity.setDocumentId(fields[0]); similarity.setOtherDocumentId(fields[1]); similarity.setSimilarity(Float.parseFloat(fields[2])); context.write(new AvroKey<DocumentSimilarity>(similarity), NullWritable.get()); } catch (Exception e) { log.error(e); } }    }