Пример #1
0
        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);
        }
Пример #2
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);
        }
Пример #3
0
 /// <summary>Snippet for ModifyColumnFamilies</summary>
 public void ModifyColumnFamilies_RequestObject()
 {
     // Snippet: ModifyColumnFamilies(ModifyColumnFamiliesRequest,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
     {
         TableName     = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
         Modifications = { },
     };
     // Make the request
     Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
     // End snippet
 }
 /// <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 ModifyColumnFamiliesRequestObject()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
     {
         TableName     = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]"),
         Modifications =
         {
             new ModifyColumnFamiliesRequest.Types.Modification(),
         },
     };
     // Make the request
     Table response = bigtableTableAdminClient.ModifyColumnFamilies(request);
 }
        /// <summary>Snippet for ModifyColumnFamiliesAsync</summary>
        public async Task ModifyColumnFamiliesAsync_RequestObject()
        {
            // Snippet: ModifyColumnFamiliesAsync(ModifyColumnFamiliesRequest,CallSettings)
            // Additional: ModifyColumnFamiliesAsync(ModifyColumnFamiliesRequest,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
            {
                TableName     = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
                Modifications = { },
            };
            // Make the request
            Table response = await bigtableTableAdminClient.ModifyColumnFamiliesAsync(request);

            // End snippet
        }
Пример #6
0
        public void ModifyColumnFamilies2()
        {
            Mock <BigtableTableAdmin.BigtableTableAdminClient> mockGrpcClient = new Mock <BigtableTableAdmin.BigtableTableAdminClient>(MockBehavior.Strict);
            ModifyColumnFamiliesRequest request = new ModifyColumnFamiliesRequest
            {
                TableName     = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
                Modifications = { },
            };
            Table expectedResponse = new Table
            {
                TableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
            };

            mockGrpcClient.Setup(x => x.ModifyColumnFamilies(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            BigtableTableAdminClient client = new BigtableTableAdminClientImpl(mockGrpcClient.Object, null);
            Table response = client.ModifyColumnFamilies(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #7
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);
        }
Пример #8
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);
        }