/**
  * Returns the first non-static cell in the ColumnFamily. This is necessary to avoid recording a
  * static column as the "last" cell seen in a reversed query. Because we will always query static
  * columns alongside the normal data for a page, they are not a good indicator of where paging
  * should resume. When we begin the next page, we need to start from the last non-static cell.
  */
 protected Column firstNonStaticColumn(ColumnFamily cf) {
   for (Column column : cf) {
     ColumnDefinition def = cfm.getColumnDefinitionFromColumnName(column.name());
     if (def == null || def.type != ColumnDefinition.Type.STATIC) return column;
   }
   return null;
 }
  private int discardHead(
      ColumnFamily cf,
      int toDiscard,
      ColumnFamily copy,
      Iterator<Column> iter,
      DeletionInfo.InOrderTester tester) {
    ColumnCounter counter = columnCounter();

    List<Column> staticColumns = new ArrayList<>(cfm.staticColumns().size());

    // Discard the first 'toDiscard' live, non-static columns
    while (iter.hasNext()) {
      Column c = iter.next();

      // if it's a static column, don't count it and save it to add to the trimmed results
      ColumnDefinition columnDef = cfm.getColumnDefinitionFromColumnName(c.name());
      if (columnDef != null && columnDef.type == ColumnDefinition.Type.STATIC) {
        staticColumns.add(c);
        continue;
      }

      counter.count(c, tester);

      // once we've discarded the required amount, add the rest
      if (counter.live() > toDiscard) {
        for (Column staticColumn : staticColumns) copy.addColumn(staticColumn);

        copy.addColumn(c);
        while (iter.hasNext()) copy.addColumn(iter.next());
      }
    }
    return Math.min(counter.live(), toDiscard);
  }