예제 #1
0
        // [END bigtable_filters_limit_row_regex]

        // [START bigtable_filters_limit_cells_per_col]
        /// <summary>
        /// /// Read using a cells per column 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 filterLimitCellsPerCol(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
        {
            // A filter that matches only the most recent 2 cells within each column
            RowFilter filter = RowFilters.CellsPerColumnLimit(2);

            return(readFilter(projectId, instanceId, tableId, filter));
        }
예제 #2
0
        // [END bigtable_filters_modify_apply_label]

        // [START bigtable_filters_composing_chain]
        /// <summary>
        /// /// Read using a chain 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 filterComposingChain(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID")
        {
            // A filter that selects one cell per column AND within the column family cell_plan
            RowFilter filter = RowFilters.Chain(RowFilters.CellsPerColumnLimit(1), RowFilters.FamilyNameExact("cell_plan"));

            return(readFilter(projectId, instanceId, tableId, filter));
        }
예제 #3
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);
            }
        }
        public void TestRowFilter()
        {
            var rowFilter = RowFilters.Chain(
                RowFilters.CellsPerColumnLimit(1),
                RowFilters.CellsPerRowOffset(2),
                RowFilters.CellsPerRowLimit(10));

            ReadRowsRequest originalRequest = CreateRowFilterRequest(rowFilter);

            BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest);

            Assert.Equal(originalRequest, underTest.BuildUpdatedRequest());
        }
        public void TestRowFilter()
        {
            var rowFilter = RowFilters.Chain(
                RowFilters.CellsPerColumnLimit(1),
                RowFilters.CellsPerRowOffset(2),
                RowFilters.CellsPerRowLimit(10));

            var originalRequest = new ReadRowsRequest
            {
                Rows   = RowSet.FromRowKey("a"),
                Filter = rowFilter
            };

            BigtableReadRowsRequestManager underTest = new BigtableReadRowsRequestManager(originalRequest);

            Assert.Equal(originalRequest, underTest.BuildUpdatedRequest());
        }
예제 #6
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)
            });
        }
        public override async Task ReplayMessagesAsync(IActorContext context, string persistenceId, long fromSequenceNr, long toSequenceNr, long max, Action <IPersistentRepresentation> recoveryCallback)
        {
            if (max <= 0 || toSequenceNr < fromSequenceNr)
            {
                return;
            }

            var    startKey = ToRowKeyBigtableByteString(persistenceId, fromSequenceNr);
            var    endKey   = ToRowKeyBigtableByteString(persistenceId, toSequenceNr);
            RowSet rowSet;

            if (fromSequenceNr == toSequenceNr)
            {
                rowSet = RowSet.FromRowKey(startKey);
            }
            else
            {
                rowSet = RowSet.FromRowRanges(RowRange.Closed(startKey, endKey));
            }

            var stream = _bigtableClient.ReadRows(_tableName,
                                                  rows: rowSet,
                                                  filter: RowFilters.CellsPerColumnLimit(1),
                                                  rowsLimit: max);

            using (var asyncEnumerator = stream.GetEnumerator())
            {
                while (await asyncEnumerator.MoveNext().ConfigureAwait(false))
                {
                    var persitentRepresentation = ToPersistentRepresentation(asyncEnumerator.Current);
                    if (persitentRepresentation != null)
                    {
                        recoveryCallback.Invoke(persitentRepresentation);
                    }
                }
            }
        }
예제 #8
0
        public void CellsPerColumnLimit()
        {
            var filter = RowFilters.CellsPerColumnLimit(1);

            Assert.Equal(1, filter.CellsPerColumnLimitFilter);
        }