protected override async Task DeleteAsync(string persistenceId, SnapshotSelectionCriteria criteria) { var filter = RowFilters.Chain ( RowFilters.ColumnQualifierExact(SnapshotMetaDataColumnQualifier), // this filter ensures that we only download snapshot metadata RowFilters.TimestampRange( ToUtc(criteria.MinTimestamp), ToUtc(criteria.MaxTimeStamp)?.AddMilliseconds(1) // add a milliseconds since the upper bound is exclusive ), RowFilters.CellsPerColumnLimit(1) ); var readRowsRequest = new ReadRowsRequest { TableNameAsTableName = _tableName, Filter = filter, Rows = GetRowSet(persistenceId, criteria.MinSequenceNr, criteria.MaxSequenceNr) }; var deleteMutations = await _bigtableClient .ReadRows(readRowsRequest) .Select(SnapshotMetadataFromBigtableRow) .Where(metadata => SatisfiesTimestampCriteria(criteria, metadata)) .Select(metadata => Mutations.CreateEntry(GetRowKey(persistenceId, metadata.SequenceNr), Mutations.DeleteFromRow())) .ToList() .ConfigureAwait(false); if (deleteMutations.Count > 0) { await _bigtableClient.MutateRowsAsync(_tableName, deleteMutations).ConfigureAwait(false); } }
protected override async Task DeleteMessagesToAsync(string persistenceId, long toSequenceNr) { var rows = RowSet.FromRowRanges(RowRange.Closed(ToRowKeyBigtableByteString(persistenceId, 0), ToRowKeyBigtableByteString(persistenceId, toSequenceNr))); var stream = _bigtableClient.ReadRows(_tableName, rows: rows); var deleteEntries = new List <MutateRowsRequest.Types.Entry>(); using (var enumerator = stream.GetEnumerator()) { while (await enumerator.MoveNext().ConfigureAwait(false)) { deleteEntries.Add(Mutations.CreateEntry(enumerator.Current.Key, Mutations.DeleteFromRow())); } } if (deleteEntries.Any()) { var last = deleteEntries.LastOrDefault(); deleteEntries.RemoveAt(deleteEntries.Count - 1); deleteEntries.Add(Mutations.CreateEntry(last.RowKey, Mutations.SetCell(_family, PayloadColumnQualifier, ByteString.Empty, new BigtableVersion(-1)))); await _bigtableClient.MutateRowsAsync(_tableName, deleteEntries); } }