code: public TableModel toDistinctValuesTableModel(InputColumn<?> inputColumnOfInterest) {
          final Map<Object, Integer> valueCounts;
          final RowAnnotationFactory annotationFactory = _annotationFactoryRef.get();
          if (annotationFactory == null) {
              valueCounts = Collections.emptyMap();
          } else {
              valueCounts = annotationFactory.getValueCounts(getAnnotation(), inputColumnOfInterest);
          }
          DefaultTableModel tableModel = new DefaultTableModel(new String[] { inputColumnOfInterest.getName(),
                  "Count in dataset" }, valueCounts.size());
  
          // sort the set
          TreeSet<Entry<Object, Integer>> set = new TreeSet<Entry<Object, Integer>>(
                  new Comparator<Entry<Object, Integer>>() {
                      @Override
                      public int compare(Entry<Object, Integer> o1, Entry<Object, Integer> o2) {
                          int countDiff = o2.getValue().intValue() - o1.getValue().intValue();
                          if (countDiff == 0) {
                              return -1;
                          }
                          return countDiff;
                      }
                  });
          set.addAll(valueCounts.entrySet());
  
          int i = 0;
          for (Entry<Object, Integer> entry : set) {
              tableModel.setValueAt(entry.getKey(), i, 0);
              tableModel.setValueAt(entry.getValue(), i, 1);
              i++;
          }
  
          return tableModel;
      }
docs: Creates a table model containing only distinct values from a particular
  input column, and the counts of those distinct values. Note that the
  counts may only be the count from the data that is available in the
  annotation row storage, which may just be a preview/subset of the actual
  data.
  
  @param inputColumnOfInterest
  @return