Ejemplo n.º 1
0
  public void trim(ColumnFamily cf, int trimTo, long now) {
    // each cell can increment the count by at most one, so if we have fewer cells than trimTo, we
    // can skip trimming
    if (cf.getColumnCount() < trimTo) return;

    ColumnCounter counter = columnCounter(cf.getComparator(), now);

    Collection<Cell> cells = reversed ? cf.getReverseSortedColumns() : cf.getSortedColumns();

    DeletionInfo.InOrderTester tester = cf.deletionInfo().inOrderTester(reversed);

    for (Iterator<Cell> iter = cells.iterator(); iter.hasNext(); ) {
      Cell cell = iter.next();
      counter.count(cell, tester);

      if (counter.live() > trimTo) {
        iter.remove();
        while (iter.hasNext()) {
          iter.next();
          iter.remove();
        }
      }
    }
  }
 protected static Column lastColumn(ColumnFamily cf) {
   return cf.getReverseSortedColumns().iterator().next();
 }