// [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));
        }
Example #2
0
        public static async Task HasNoValuesAsync(
            BigtableClient client,
            TableName tableName,
            BigtableByteString rowKey,
            string familyName = null)
        {
            var filter = familyName == null
                ? RowFilters.PassAllFilter()
                : RowFilters.FamilyNameExact(familyName);

            Assert.Null(await client.ReadRowAsync(tableName, rowKey, filter));
        }
        public void Condition()
        {
            var filter = RowFilters.Condition(
                RowFilters.ColumnQualifierRegex("last_name"),
                RowFilters.RowSample(0.5),
                RowFilters.FamilyNameExact("address"));

            Assert.NotNull(filter.Condition);
            Assert.Equal(
                RowFilters.ColumnQualifierRegex("last_name"),
                filter.Condition.PredicateFilter);
            Assert.Equal(RowFilters.RowSample(0.5), filter.Condition.TrueFilter);
            Assert.Equal(RowFilters.FamilyNameExact("address"), filter.Condition.FalseFilter);
        }
        /// <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 FamilyNameExact_Validations()
 {
     Assert.Throws <ArgumentNullException>(() => RowFilters.FamilyNameExact(null));
 }
        public void FamilyNameExact()
        {
            var filter = RowFilters.FamilyNameExact("a\\b\0c\t");

            Assert.Equal(@"a\\b\x00c\	", filter.FamilyNameRegexFilter);
        }