private static object CreateNestedFamily(string tableId) { // [START bigtable_create_bigtableTableAdminClient] BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // [END bigtable_create_bigtableTableAdminClient] Console.WriteLine("Creating column family cf5 with a nested GC rule..."); // [START bigtable_create_family_gc_nested] // Create a nested GC rule: // Drop cells that are either older than the 10 recent versions // OR // Drop cells that are older than a month AND older than the 2 recent versions. // Initialize request argument(s). GcRule.Types.Intersection intersectionRule = new GcRule.Types.Intersection { Rules = { new GcRule { MaxNumVersions = 2 }, new GcRule { MaxAge = Duration.FromTimeSpan(TimeSpan.FromDays(5)) } } }; GcRule.Types.Union nestedRule = new GcRule.Types.Union { Rules = { new GcRule { MaxNumVersions = 10 }, new GcRule { Intersection = intersectionRule } } }; GcRule gcRule = new GcRule { Union = nestedRule }; // Column family to create ColumnFamily columnFamily = new ColumnFamily { GcRule = gcRule }; TableName tableName = new TableName(projectId, instanceId, tableId); // Modification to create column family ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification { Create = columnFamily, Id = "cf5" }; ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest { TableName = tableName, Modifications = { modification } }; try { // Make the request Table response = bigtableTableAdminClient.ModifyColumnFamilies(request); Console.WriteLine("Created column family"); // [END bigtable_create_family_gc_nested] // Print table information. GetTable(tableId); // [START bigtable_create_family_gc_nested] } catch (Exception ex) { Console.WriteLine($"Error creating column family {ex.Message}"); } // [END bigtable_create_family_gc_nested] return(0); }
private static object CreateIntersectionFamily(string tableId) { // [START bigtable_create_bigtableTableAdminClient] BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // [END bigtable_create_bigtableTableAdminClient] Console.WriteLine("Creating column family cf4 with intersect GC rule..."); // [START bigtable_create_family_gc_intersection] // Create a column family with GC policy to drop data that matches all conditions. // Initialize request argument(s). // GC rule: Drop cells older than 5 days AND older than the most recent 2 versions. GcRule.Types.Intersection intersectionRule = new GcRule.Types.Intersection { Rules = { new GcRule { MaxNumVersions = 2 }, new GcRule { MaxAge = Duration.FromTimeSpan(TimeSpan.FromDays(5)) } } }; GcRule gcRule = new GcRule { Intersection = intersectionRule }; // Column family to create ColumnFamily columnFamily = new ColumnFamily { GcRule = gcRule }; TableName tableName = new TableName(projectId, instanceId, tableId); // Modification to create column family ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification { Create = columnFamily, Id = "cf4" }; ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest { TableName = tableName, Modifications = { modification } }; try { // Make the request Table response = bigtableTableAdminClient.ModifyColumnFamilies(request); Console.WriteLine("Created column family"); // [END bigtable_create_family_gc_intersection] // Print table information. GetTable(tableId); // [START bigtable_create_family_gc_intersection] } catch (Exception ex) { Console.WriteLine($"Error creating column family {ex.Message}"); } // [END bigtable_create_family_gc_intersection] return(0); }