Delete data

Deletes are handled through the insertion of special "delete" records (or tombstones) that indicate that some portion of a row's cells have been deleted.

 

In order to delete cells you have to obtain a ITableMutator from a ITable interface, for example delete an entire row:

using (var mutator = table.CreateMutator())
  mutator.Delete("row");
}

 

The Key class can be used to delete, for a given row, all of the cells in a qualified column, all the cells in a column family, or all of the cells in the row. If the Timestamp property has been specified, then the delete will only apply to those cells whose timestamp field is equal to or less than the given timestamp. For example delete cells in a column family:

using (var mutator = table.CreateMutator())
  var key = new Key("row", "name");
  mutator.Delete(key);
}

Or delete cells in a qualified column older than the date time specified:

using (var mutator = table.CreateMutator())
  var key = new Key("row", "name", "column-qualifier", new DateTime(2013, 7, 1));
  mutator.Delete(key);
}

 

Alternative use the Cell class to delete cells, for example delete cells in a column family:

using (var mutator = table.CreateMutator())
  var key = new Key("row", "name");
  var cell = new Cell(key, CellFlag.DeleteColumnFamily);
  mutator.Delete(key);
}

Using the Cell class allows you to mix inserts, updates and deletes in a single call by passing a bunch of cells to the table mutator. Valid CellFlag are:

CellFlag valueDescription
DeleteRow Deletes all cells in a particular row.
DeleteColumnFamily Deletes all cells in a particular row/column family.
DeleteCell Deletes all versions of a particular cell. Requires a fully qualified key.
DeleteCellVersion Deletes a particular cell version. Requires a fully qualified key, including the cell's timestamp.

 

Deletes passed to the ITableMutator are not immediately send to the database server; the Flush method causes any buffered data to be comitted to the database server:

mutator.Flush();