Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        // [END bigtable_filters_limit_value_regex]

        // [START bigtable_filters_limit_timestamp_range]
        /// <summary>
        /// /// Read using a timestamp range filter from an existing table.
        ///</summary>
        /// <param name="projectId">Your Google Cloud Project ID.</param>
        /// <param name="instanceId">Your Google Cloud Bigtable Instance ID.</param>
        /// <param name="tableId">Your Google Cloud Bigtable table ID.</param>

        public string filterLimitTimestampRange(
            String projectId, String instanceId, String tableId)
        {
            BigtableVersion timestamp_minus_hr = new BigtableVersion(new DateTime(2020, 1, 10, 13, 0, 0, DateTimeKind.Utc));

            // A filter that matches cells whose timestamp is from an hour ago or earlier
            RowFilter filter = RowFilters.TimestampRange(new DateTime(0), timestamp_minus_hr.ToDateTime());

            return(readFilter(projectId, instanceId, tableId, filter));
        }
Exemplo n.º 3
0
        public void TimestampRange()
        {
            var start  = DateTime.UtcNow;
            var end    = start.AddDays(1);
            var filter = RowFilters.TimestampRange(start, end);

            Assert.NotNull(filter.TimestampRangeFilter);
            var startMicros = ((start.Ticks - BigtableVersion.UnixEpoch.Ticks) / 10000) * 1000;
            var endMicros   = ((end.Ticks - BigtableVersion.UnixEpoch.Ticks) / 10000) * 1000;

            Assert.Equal(startMicros, filter.TimestampRangeFilter.StartTimestampMicros);
            Assert.Equal(endMicros, filter.TimestampRangeFilter.EndTimestampMicros);
        }
Exemplo n.º 4
0
        private ReadRowsRequest GetReadRowsRequest(string persistenceId, SnapshotSelectionCriteria criteria)
        {
            var filter = RowFilters.Chain
                         (
                RowFilters.TimestampRange(
                    ToUtc(criteria.MinTimestamp)?.AddMilliseconds(-1),
                    // subtract millisecond since bigtable only has millisecond granularity
                    ToUtc(criteria.MaxTimeStamp)?.AddMilliseconds(1)
                    // add a milliseconds since the upper bound is exclusive
                    ),
                RowFilters.CellsPerColumnLimit(1)
                         );

            return(new ReadRowsRequest
            {
                TableNameAsTableName = _tableName,
                Filter = filter,
                Rows = GetRowSet(persistenceId, criteria.MinSequenceNr, criteria.MaxSequenceNr)
            });
        }