// [END bigtable_filters_limit_value_range] // [START bigtable_filters_limit_value_regex] /// <summary> /// /// Read using a value regex 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 filterLimitValueRegex(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches cells whose value satisfies the given regex RowFilter filter = RowFilters.ValueRegex("PQ2A.*$"); return(readFilter(projectId, instanceId, tableId, filter)); }
public void Chain() { var filter = RowFilters.Chain( RowFilters.CellsPerRowLimit(1), RowFilters.ValueRegex("abc")); Assert.NotNull(filter.Chain); Assert.Equal(2, filter.Chain.Filters.Count); Assert.Equal(RowFilters.CellsPerRowLimit(1), filter.Chain.Filters[0]); Assert.Equal(RowFilters.ValueRegex("abc"), filter.Chain.Filters[1]); }
public void Interleave() { var filter = RowFilters.Interleave( RowFilters.CellsPerRowLimit(1), RowFilters.ValueRegex("abc")); Assert.NotNull(filter.Interleave); Assert.Equal(2, filter.Interleave.Filters.Count); Assert.Equal(RowFilters.CellsPerRowLimit(1), filter.Interleave.Filters[0]); Assert.Equal(RowFilters.ValueRegex("abc"), filter.Interleave.Filters[1]); }
// [END bigtable_reads_prefix] // [START bigtable_reads_filter] /// <summary> /// /// Reads using a 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 readFilter(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { BigtableClient bigtableClient = BigtableClient.Create(); TableName tableName = new TableName(projectId, instanceId, tableId); RowFilter filter = RowFilters.ValueRegex("PQ2A.*"); ReadRowsStream readRowsStream = bigtableClient.ReadRows(tableName, filter: filter); string result = ""; readRowsStream.ForEach(row => result += printRow(row)); return(result); }
/// <summary> /// Check if a row has a certain value then mutate the row if it does. ///</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 writeConditional( string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { BigtableClient bigtableClient = BigtableClient.Create(); TableName tableName = new TableName(projectId, instanceId, tableId); BigtableByteString rowkey = new BigtableByteString("phone#4c410523#20190501"); BigtableVersion timestamp = new BigtableVersion(DateTime.UtcNow); String COLUMN_FAMILY = "stats_summary"; CheckAndMutateRowResponse checkAndMutateRowResponse = bigtableClient.CheckAndMutateRow( tableName, rowkey, RowFilters.Chain( RowFilters.FamilyNameExact(COLUMN_FAMILY), RowFilters.ColumnQualifierExact("os_build"), RowFilters.ValueRegex("PQ2A\\..*")), Mutations.SetCell(COLUMN_FAMILY, "os_name", "android", timestamp)); return($"Successfully updated row's os_name: {checkAndMutateRowResponse.PredicateMatched}"); }
public void ValueRegex() { var filter = RowFilters.ValueRegex("abc"); Assert.Equal(ByteString.CopyFromUtf8("abc"), filter.ValueRegexFilter); }