docs: public final Collection<Cell> parseKeyValue(final TSDB tsdb, final KeyValue kv) {
      if (kv.qualifier().length != 3 || kv.qualifier()[0] != APPEND_COLUMN_PREFIX) {
        // it's really not an issue if the offset is not 0, maybe in the future
        // we'll support appends at different offsets.
        throw new IllegalArgumentException("Can not parse cell, it is not " +
          " an appended cell. It has a different qualifier " + 
          Bytes.pretty(kv.qualifier()) + ", row key " + Bytes.pretty(kv.key()));
      }
      final boolean repair = tsdb.getConfig().repair_appends();
      final long base_time;
      try {
        base_time = Internal.baseTime(tsdb, kv.key());
      } catch (ArrayIndexOutOfBoundsException oob) {
        throw new IllegalDataException("Corrupted value: invalid row key: " + kv, 
            oob);
      }
  
      int val_idx = 0;
      int val_length = 0;
      int qual_length = 0;
      int last_delta = -1;  // Time delta, extracted from the qualifier.
      
      final Map<Integer, Internal.Cell> deltas = new TreeMap<Integer, Cell>();
      boolean has_duplicates = false;
      boolean out_of_order = false;
      boolean needs_repair = false;
      
      try {
        while (val_idx < kv.value().length) {
          byte[] q = Internal.extractQualifier(kv.value(), val_idx);
          System.arraycopy(kv.value(), val_idx, q, 0, q.length);
          val_idx=val_idx + q.length;
          
          int vlen = Internal.getValueLengthFromQualifier(q, 0);
          byte[] v = new byte[vlen];
          System.arraycopy(kv.value(), val_idx, v, 0, vlen);
          val_idx += vlen;
          int delta = Internal.getOffsetFromQualifier(q);
      
          final Cell duplicate = deltas.get(delta);
          if (duplicate != null) {
            // This is a duplicate cell, skip it
            has_duplicates = true;
            qual_length -= duplicate.qualifier.length;
            val_length -= duplicate.value.length;
          }
    
          qual_length += q.length;
          val_length += vlen;
          final Cell cell = new Cell(q, v);
          deltas.put(delta, cell);
    
          if (!out_of_order) {
            // Data points needs to be sorted if we find at least one out of 
            // order data
            if (delta <= last_delta) {
              out_of_order = true;
            }
            last_delta = delta;
          }
        }
      } catch (ArrayIndexOutOfBoundsException oob) {
        throw new IllegalDataException("Corrupted value: couldn't break down"
            + " into individual values (consumed " + val_idx + " bytes, but was"
            + " expecting to consume " + (kv.value().length) + "): " + kv
            + ", cells so far: " + deltas.values(), oob);
      }
      
      if (has_duplicates || out_of_order) {
        if ((DateTime.currentTimeMillis() / 1000) - base_time > REPAIR_THRESHOLD) {
          needs_repair = true;
        }
      }
  
      // Check we consumed all the bytes of the value.
      if (val_idx != kv.value().length) {
        throw new IllegalDataException("Corrupted value: couldn't break down"
        + " into individual values (consumed " + val_idx + " bytes, but was"
        + " expecting to consume " + (kv.value().length) + "): " + kv
        + ", cells so far: " + deltas.values());
      }
  
      val_idx = 0;
      int qual_idx = 0;
      byte[] healed_cell = null;
      int healed_index = 0;
      
      this.value = new byte[val_length];
      this.qualifier = new byte[qual_length];
      
      if (repair && needs_repair) {
        healed_cell = new byte[val_length+qual_length];
      }
      
      for (final Cell cell: deltas.values()) {
        System.arraycopy(cell.qualifier, 0, this.qualifier, qual_idx, 
            cell.qualifier.length);
        qual_idx += cell.qualifier.length;
        System.arraycopy(cell.value, 0, this.value, val_idx, cell.value.length);
        val_idx += cell.value.length;
  
        if (repair && needs_repair) {
          System.arraycopy(cell.qualifier, 0, healed_cell, healed_index, 
              cell.qualifier.length);
          healed_index += cell.qualifier.length;
          System.arraycopy(cell.value, 0, healed_cell, healed_index, cell.value.length);
          healed_index += cell.value.length;          
        }
      }
        
      if (repair && needs_repair) {
        LOG.debug("Repairing appended data column " + kv);
        final PutRequest put = RequestBuilder.buildPutRequest(tsdb.getConfig(), tsdb.table, kv.key(),
            TSDB.FAMILY(), kv.qualifier(), healed_cell, kv.timestamp());
        repaired_deferred = tsdb.getClient().put(put);
      }
      
      return deltas.values();
    }