protected DefaultTableModel prepareModel(final CategorizationResult analyzerResult, final Object extraData) { final DefaultTableModel model = new DefaultTableModel(new Object[] { "Match outcome", LabelUtils.COUNT_LABEL }, analyzerResult.getCategoryNames().size()); int row = 0; final Collection<String> categoryNames = analyzerResult.getCategoryNames(); for (final String categoryName : categoryNames) { final AnnotatedRowsResult sample = analyzerResult.getCategoryRowSample(categoryName); final Number count = analyzerResult.getCategoryCount(categoryName); row = addValue(extraData, row, model, categoryName, count.intValue(), sample); } return model; }
@Override public CategorizationResult reduce(final Collection<? extends CategorizationResult> results) { final RowAnnotationFactory annotationFactory = null; final Map<String, RowAnnotation> reducedCategories = new LinkedHashMap<>(); for (final CategorizationResult result : results) { final Collection<String> categoryNames = result.getCategoryNames(); for (final String categoryName : categoryNames) { final RowAnnotation partialAnnotation = result.getCategoryRowAnnotation(categoryName); final RowAnnotation reducedAnnotation = reducedCategories.get(categoryName); if (reducedAnnotation == null) { // adopt the annotation from the partial result final RowAnnotation annotation = _rowAnnotationFactory.createAnnotation(); _rowAnnotationFactory.transferAnnotations(partialAnnotation, annotation); reducedCategories.put(categoryName, annotation); } else { // add records to the existing annotation _rowAnnotationFactory.transferAnnotations(partialAnnotation, reducedAnnotation); } } } return new CategorizationResult(annotationFactory, reducedCategories); }
@Override public JComponent render(final CategorizationResult analyzerResult) { final DefaultPieDataset dataset = new DefaultPieDataset(); final Collection<String> categoryNames = analyzerResult.getCategoryNames(); for (final String categoryName : categoryNames) { final Number count = analyzerResult.getCategoryCount(categoryName); dataset.setValue(categoryName, count);
@Override public Collection<String> getParameterSuggestions() { return getCategoryNames(); } };
@Override public Number getValue(final String parameter) { return getCategoryCount(parameter); }
@Override public CategorizationResult getResult() { final Map<String, RowAnnotation> categories = new LinkedHashMap<>(); categories.put("Match", _matches); categories.put("Miss", _misses); if (cacheLookups) { categories.put("Cached", _cached); } return new CategorizationResult(_annotationFactory, categories); } }
public int getCategoryCount(final String category) { final RowAnnotation annotation = getCategoryRowAnnotation(category); return annotation.getRowCount(); }