private static object CreateMaxVersionsFamily(string tableId) { // [START bigtable_create_bigtableTableAdminClient] BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // [END bigtable_create_bigtableTableAdminClient] Console.WriteLine("Creating column family cf2 with max versions GC rule..."); // [START bigtable_create_family_gc_max_versions] // Create a column family with GC policy : most recent N versions // where 1 = most recent version // Initialize request argument(s). // Define the GC policy to retain only the most recent 2 versions GcRule maxVersionsRule = new GcRule { MaxNumVersions = 2 }; // Column family to create ColumnFamily columnFamily = new ColumnFamily { GcRule = maxVersionsRule }; TableName tableName = new TableName(projectId, instanceId, tableId); // Modification to create column family ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification { Create = columnFamily, Id = "cf2" }; 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_max_versions] // Print table information. GetTable(tableId); // [START bigtable_create_family_gc_max_versions] } catch (Exception ex) { Console.WriteLine($"Error creating column family {ex.Message}"); } // [END bigtable_create_family_gc_max_versions] return(0); }
private static object UpdateFamily(string tableId) { // [START bigtable_create_bigtableTableAdminClient] BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // [END bigtable_create_bigtableTableAdminClient] Console.WriteLine("Updating column family cf1 GC rule..."); // [START bigtable_update_gc_rule] // Update the column family metadata to update the GC rule. // Initialize request argument(s). // Updated column family GC rule. GcRule maxVersionsRule = new GcRule { MaxNumVersions = 1 }; // Column family to create ColumnFamily columnFamily = new ColumnFamily { GcRule = maxVersionsRule }; TableName tableName = new TableName(projectId, instanceId, tableId); // Modification to update column family ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification { Update = columnFamily, Id = "cf1" }; ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest { TableName = tableName, Modifications = { modification } }; try { // Make the request Table response = bigtableTableAdminClient.ModifyColumnFamilies(request); Console.WriteLine("Updated column family"); // [END bigtable_update_gc_rule] // Print table information. GetTable(tableId); // [START bigtable_update_gc_rule] } catch (Exception ex) { Console.WriteLine($"Error updating column family {ex.Message}"); } // [END bigtable_update_gc_rule] return(0); }
private static object CreateMaxAgeFamily(string tableId) { // [START bigtable_create_bigtableTableAdminClient] BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // [END bigtable_create_bigtableTableAdminClient] Console.WriteLine("Creating column family cf1 with max age GC rule..."); // [START bigtable_create_family_gc_max_age] // Create a column family with GC policy : maximum age // where age = current time minus cell timestamp // Initialize request argument(s). // Define the GC rule to retain data with max age of 5 days GcRule MaxAgeRule = new GcRule { MaxAge = Duration.FromTimeSpan(TimeSpan.FromDays(5.0)) }; // Column family to create ColumnFamily columnFamily = new ColumnFamily { GcRule = MaxAgeRule }; TableName tableName = new TableName(projectId, instanceId, tableId); // Modification to create column family ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification { Create = columnFamily, Id = "cf1" }; 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_bigtableTableAdminClient] // Print table information. GetTable(tableId); // [START bigtable_create_bigtableTableAdminClient] } catch (Exception ex) { Console.WriteLine($"Error creating column family {ex.Message}"); } // [END bigtable_create_family_gc_max_age] return(0); }
/// <summary>Snippet for ModifyColumnFamilies</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void ModifyColumnFamiliesResourceNames() { // Create client BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // Initialize request argument(s) TableName name = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]"); IEnumerable <ModifyColumnFamiliesRequest.Types.Modification> modifications = new ModifyColumnFamiliesRequest.Types.Modification[] { new ModifyColumnFamiliesRequest.Types.Modification(), }; // Make the request Table response = bigtableTableAdminClient.ModifyColumnFamilies(name, modifications); }
/// <summary>Snippet for ModifyColumnFamilies</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void ModifyColumnFamilies() { // Create client BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/instances/[INSTANCE]/tables/[TABLE]"; IEnumerable <ModifyColumnFamiliesRequest.Types.Modification> modifications = new ModifyColumnFamiliesRequest.Types.Modification[] { new ModifyColumnFamiliesRequest.Types.Modification(), }; // Make the request Table response = bigtableTableAdminClient.ModifyColumnFamilies(name, modifications); }
private static object DeleteFamily(string tableId) { // [START bigtable_create_bigtableTableAdminClient] BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create(); // [END bigtable_create_bigtableTableAdminClient] Console.WriteLine("Deleting column family cf2 GC rule..."); // [START bigtable_delete_family] // Delete a column family. // Initialize request argument(s). GcRule maxVersionsRule = new GcRule { MaxNumVersions = 1 }; TableName tableName = new TableName(projectId, instanceId, tableId); // Modification to update column family ModifyColumnFamiliesRequest.Types.Modification modification = new ModifyColumnFamiliesRequest.Types.Modification { Drop = true, Id = "cf2" }; ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest { TableName = tableName, Modifications = { modification } }; try { // Make the request Table response = bigtableTableAdminClient.ModifyColumnFamilies(request); Console.WriteLine("Deleted column family"); // [END bigtable_delete_family] // Print table information. GetTable(tableId); // [START bigtable_delete_family] } catch (Exception ex) { Console.WriteLine($"Error deleting column family {ex.Message}"); } // [END bigtable_delete_family] return(0); }
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); }