@Test public void skip() throws Exception { Counter skippedInstances = EasyMock.createMock(Counter.class); EasyMock.expect(ctx.getCounter(IndexInstancesMapper.Counter.SKIPPED_INSTANCES)).andReturn(skippedInstances); skippedInstances.increment(1); EasyMock.replay(ctx, skippedInstances); IndexInstancesMapper indexInstances = new IndexInstancesMapper(); setField(indexInstances, "labelIndex", labelIndex); indexInstances.map(new Text("/fish/"), instance, ctx); EasyMock.verify(ctx, skippedInstances); }
@Override protected void map(Text labelText, VectorWritable instance, Context ctx) throws IOException, InterruptedException { String label = SLASH.split(labelText.toString())[1]; if (labelIndex.containsKey(label)) { ctx.write(new IntWritable(labelIndex.get(label)), instance); } else { ctx.getCounter(Counter.SKIPPED_INSTANCES).increment(1); } }
IndexInstancesMapper extends Mapper<Text, VectorWritable, IntWritable, VectorWritable> { @Override protected void map(Text labelText, VectorWritable instance, Context ctx) throws IOException, InterruptedException { String label = SLASH.split(labelText.toString())[1]; if (labelIndex.containsKey(label)) { ctx.write(new IntWritable(labelIndex.get(label)), instance); } else { ctx.getCounter(Counter.SKIPPED_INSTANCES).increment(1); } } }
IndexInstancesMapper extends Mapper<Text, VectorWritable, IntWritable, VectorWritable> { @Override protected void map(Text labelText, VectorWritable instance, Context ctx) throws IOException, InterruptedException { String label = SLASH.split(labelText.toString())[1]; if (labelIndex.containsKey(label)) { ctx.write(new IntWritable(labelIndex.get(label)), instance); } else { ctx.getCounter(Counter.SKIPPED_INSTANCES).increment(1); } }  }
IndexInstancesMapper extends Mapper<Text, VectorWritable, IntWritable, VectorWritable> { @Override protected void map(Text labelText, VectorWritable instance, Context ctx) throws IOException, InterruptedException { String label = SLASH.split(labelText.toString())[1]; if (labelIndex.containsKey(label)) { ctx.write(new IntWritable(labelIndex.get(label)), instance); } else { ctx.getCounter(Counter.SKIPPED_INSTANCES).increment(1); } }   }
IndexInstancesMapper extends Mapper<Text, VectorWritable, IntWritable, VectorWritable> { @Override protected void map(Text labelText, VectorWritable instance, Context ctx) throws IOException, InterruptedException { String label = SLASH.split(labelText.toString())[1]; if (labelIndex.containsKey(label)) { ctx.write(new IntWritable(labelIndex.get(label)), instance); } else { ctx.getCounter(Counter.SKIPPED_INSTANCES).increment(1); } }    }