@SuppressWarnings("ConstantConditions") @Override public String toString() { List<Pair<RowSnapshot, Integer>> pList = new ArrayList<Pair<RowSnapshot, Integer>>(this.hMap.size()); this.hMap.forEach((rs, j) -> pList.add(new Pair<RowSnapshot, Integer>(rs, j))); pList.sort((p1, p2) -> Integer.compare(p2.second, p1.second)); final StringBuilder builder = new StringBuilder(); pList.forEach(p -> builder.append(p.first.toString()).append(": ").append(p.second) .append(System.getProperty("line.separator"))); return builder.toString(); } }
public List<Pair<RowSnapshot, Integer>> getSortedList() { this.hMap.forEach((rs, j) -> this.pList.add(new Pair<RowSnapshot, Integer>(rs, j))); this.pList.sort((p1, p2) -> Integer.compare(Converters.checkNull(p2.second), Converters.checkNull(p1.second))); return this.pList; }
@Override public NextKList getTop(Schema schema) { this.filter(); this.hMap.forEach((rs, j) -> this.pList.add(new Pair<RowSnapshot, Integer>(rs, j))); return sortTopK(schema); } }
/** * We return all elements whose fractional counts that could possibly be above epsilon, using * the error bound calculation in getErrBound() */ @Override public NextKList getTop(Schema schema) { this.filter(); this.hMap.forEach((rs, j) -> this.pList.add(new Pair<RowSnapshot, Integer>(rs, j))); return this.sortTopK(schema); } }
/** * Since counts are approximate, we keep all elements that are have observed relative * frequencies above 0.5*epsilon, but only report those that are above epsilon. */ @Override public NextKList getTop(Schema schema) { /* Needed here because this list is used for further filtering*/ this.fkFilter(0.5 * epsilon * this.sampleSize); this.hMap.forEach((rs, j) -> { double fraction = ((double) j) / this.sampleSize; if (fraction >= epsilon) { int k = (int) (fraction * this.totalRows); this.pList.add(new Pair<RowSnapshot, Integer>(rs, k)); } }); return sortTopK(schema); }