public async Task CheckAndMutateRow_Validate_Mutations() { var tableName = new TableName("project", "instance", "table"); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, "abc", RowFilters.PassAllFilter(), null, null); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, "abc", RowFilters.PassAllFilter(), new Mutation[0], new Mutation[0]); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, "abc", RowFilters.PassAllFilter(), new Mutation[] { null }, new[] { Mutations.DeleteFromRow() }, callTrueMutationsOnlyOverload : false); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, "abc", RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new Mutation[] { null }, callTrueMutationsOnlyOverload : false); }
// [END bigtable_filters_limit_timestamp_range] // [START bigtable_filters_limit_block_all] /// <summary> /// /// Read using a block all 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 filterLimitBlockAll(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that does not match any cells RowFilter filter = RowFilters.BlockAllFilter(); return(readFilter(projectId, instanceId, tableId, filter)); }
// [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)); }
// [END bigtable_filters_limit_pass_all] // [START bigtable_filters_modify_strip_value] /// <summary> /// /// Read using a strip value 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 filterModifyStripValue(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that replaces the outputted cell value with the empty string RowFilter filter = RowFilters.StripValueTransformer(); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_row_sample] // [END bigtable_filters_limit_row_regex] // [END bigtable_filters_limit_cells_per_col] // [END bigtable_filters_limit_cells_per_row] // [END bigtable_filters_limit_cells_per_row_offset] // [END bigtable_filters_limit_col_family_regex] // [END bigtable_filters_limit_col_qualifier_regex] // [END bigtable_filters_limit_col_range] // [END bigtable_filters_limit_value_range] // [END bigtable_filters_limit_value_regex] // [END bigtable_filters_limit_timestamp_range] // [END bigtable_filters_limit_block_all] // [END bigtable_filters_limit_pass_all] // [END bigtable_filters_modify_strip_value] // [END bigtable_filters_modify_apply_label] // [END bigtable_filters_composing_chain] // [END bigtable_filters_composing_interleave] // [END bigtable_filters_composing_condition] // [START bigtable_filters_limit_row_sample] /// <summary> /// /// Read using a row sample 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 filterLimitRowSample(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches cells from a row with probability .75 RowFilter filter = RowFilters.RowSample(.75); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_row_sample] // [START bigtable_filters_limit_row_regex] /// <summary> /// /// Read using a row 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 filterLimitRowRegex(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches cells from rows whose keys satisfy the given regex RowFilter filter = RowFilters.RowKeyRegex(".*#20190501$"); return(readFilter(projectId, instanceId, tableId, filter)); }
protected override async Task DeleteAsync(string persistenceId, SnapshotSelectionCriteria criteria) { var filter = RowFilters.Chain ( RowFilters.ColumnQualifierExact(SnapshotMetaDataColumnQualifier), // this filter ensures that we only download snapshot metadata RowFilters.TimestampRange( ToUtc(criteria.MinTimestamp), ToUtc(criteria.MaxTimeStamp)?.AddMilliseconds(1) // add a milliseconds since the upper bound is exclusive ), RowFilters.CellsPerColumnLimit(1) ); var readRowsRequest = new ReadRowsRequest { TableNameAsTableName = _tableName, Filter = filter, Rows = GetRowSet(persistenceId, criteria.MinSequenceNr, criteria.MaxSequenceNr) }; var deleteMutations = await _bigtableClient .ReadRows(readRowsRequest) .Select(SnapshotMetadataFromBigtableRow) .Where(metadata => SatisfiesTimestampCriteria(criteria, metadata)) .Select(metadata => Mutations.CreateEntry(GetRowKey(persistenceId, metadata.SequenceNr), Mutations.DeleteFromRow())) .ToList() .ConfigureAwait(false); if (deleteMutations.Count > 0) { await _bigtableClient.MutateRowsAsync(_tableName, deleteMutations).ConfigureAwait(false); } }
// [END bigtable_filters_limit_cells_per_col] // [START bigtable_filters_limit_cells_per_row] /// <summary> /// /// Read using a cells per row 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 filterLimitCellsPerRow(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches the first 2 cells of each row RowFilter filter = RowFilters.CellsPerRowLimit(2); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_row_regex] // [START bigtable_filters_limit_cells_per_col] /// <summary> /// /// Read using a cells per column 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 filterLimitCellsPerCol(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches only the most recent 2 cells within each column RowFilter filter = RowFilters.CellsPerColumnLimit(2); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_block_all] // [START bigtable_filters_limit_pass_all] /// <summary> /// /// Read using a pass all 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 filterLimitPassAll(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches all cells RowFilter filter = RowFilters.PassAllFilter(); return(readFilter(projectId, instanceId, tableId, filter)); }
public async Task CheckAndMutateRow_Validate_RowKey() { var client = new TestBigtableClient(); var tableName = new TableName("project", "instance", "table"); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, "", RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new[] { Mutations.DeleteFromRow() }); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, new byte[0], RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new[] { Mutations.DeleteFromRow() }); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, ByteString.Empty, RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new[] { Mutations.DeleteFromRow() }); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName,
// [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)); }
// [END bigtable_filters_limit_col_range] // [START bigtable_filters_limit_value_range] /// <summary> /// /// Read using a value range 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 filterLimitValueRange(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches cells whose values are between the given values RowFilter filter = RowFilters.ValueRange(ValueRange.Closed("PQ2A.190405", "PQ2A.190406")); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_col_qualifier_regex] // [START bigtable_filters_limit_col_range] /// <summary> /// /// Read using a qualifer range 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 filterLimitColRange(string projectId = "YOUR-PROJECT-ID", string instanceId = "YOUR-INSTANCE-ID", string tableId = "YOUR-TABLE-ID") { // A filter that matches cells whose column qualifiers are between data_plan_01gb and // data_plan_10gb in the column family cell_plan RowFilter filter = RowFilters.ColumnRange(ColumnRange.ClosedOpen("cell_plan", "data_plan_01gb", "data_plan_10gb")); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_col_family_regex] // [START bigtable_filters_limit_col_qualifier_regex] /// <summary> /// /// Read using a qualifier 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 filterLimitColQualifierRegex( String projectId, String instanceId, String tableId) { // A filter that matches cells whose column qualifier satisfies the given regex RowFilter filter = RowFilters.ColumnQualifierRegex("connected_.*$"); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_cells_per_row_offset] // [START bigtable_filters_limit_col_family_regex] /// <summary> /// /// Read using a family 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 filterLimitColFamilyRegex( String projectId, String instanceId, String tableId) { // A filter that matches cells whose column family satisfies the given regex RowFilter filter = RowFilters.FamilyNameRegex("stats_.*$"); return(readFilter(projectId, instanceId, tableId, filter)); }
// [END bigtable_filters_limit_cells_per_row] // [START bigtable_filters_limit_cells_per_row_offset] /// <summary> /// /// Read using a cells per row offset 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 filterLimitCellsPerRowOffset( String projectId, String instanceId, String tableId) { // A filter that skips the first 2 cells per row RowFilter filter = RowFilters.CellsPerRowOffset(2); return(readFilter(projectId, instanceId, tableId, filter)); }
public void Condition_Validations() { Assert.Throws <ArgumentNullException> (() => RowFilters.Condition(null, RowFilters.PassAllFilter(), RowFilters.PassAllFilter())); // The true/false mutations are allowed to be null. RowFilters.Condition(RowFilters.PassAllFilter(), null, null); }
// [END bigtable_filters_composing_chain] // [START bigtable_filters_composing_interleave] /// <summary> /// /// Read using an interleave 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 filterComposingInterleave( String projectId, String instanceId, String tableId) { // A filter that matches cells with the value true OR with the column qualifier os_build RowFilter filter = RowFilters.Interleave(RowFilters.ValueExact("true"), RowFilters.ColumnQualifierExact("os_build")); return(readFilter(projectId, instanceId, tableId, filter)); }
public void VersionRange_Range() { var range = new BigtableVersionRange(1, 2); var filter = RowFilters.VersionRange(range); Assert.NotNull(filter.TimestampRangeFilter); Assert.Equal(1000, filter.TimestampRangeFilter.StartTimestampMicros); Assert.Equal(2000, filter.TimestampRangeFilter.EndTimestampMicros); }
public async Task CheckAndMutateRow_Validate_TableName() { await CheckAndMutateRow_ValidateArguments <ArgumentNullException>( null, "abc", RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new[] { Mutations.DeleteFromRow() }); }
// [END bigtable_reads_row] // [START bigtable_reads_row_partial] /// <summary> /// /// Reads part of one row 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 readRowPartial(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); String rowkey = "phone#4c410523#20190501"; RowFilter filter = RowFilters.ColumnQualifierExact("os_build"); Row row = bigtableClient.ReadRow(tableName, rowkey, filter); return(printRow(row)); }
// [END bigtable_filters_limit_value_regex] // [START bigtable_filters_limit_timestamp_range] /// <summary> /// /// Read using a timestamp range 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 filterLimitTimestampRange( String projectId, String instanceId, String tableId) { BigtableVersion timestamp_minus_hr = new BigtableVersion(new DateTime(2020, 1, 10, 13, 0, 0, DateTimeKind.Utc)); // A filter that matches cells whose timestamp is from an hour ago or earlier RowFilter filter = RowFilters.TimestampRange(new DateTime(0), timestamp_minus_hr.ToDateTime()); return(readFilter(projectId, instanceId, tableId, filter)); }
public void ColumnRange() { var range = new ColumnRange { StartQualifierClosed = ByteString.CopyFromUtf8("a"), EndQualifierOpen = ByteString.CopyFromUtf8("z") }; var filter = RowFilters.ColumnRange(range); Assert.Equal(range, filter.ColumnRangeFilter); }
public void Chain() { var filter = RowFilters.Chain( RowFilters.CellsPerRowLimit(1), RowFilters.ValueExact("abc")); Assert.NotNull(filter.Chain); Assert.Equal(2, filter.Chain.Filters.Count); Assert.Equal(RowFilters.CellsPerRowLimit(1), filter.Chain.Filters[0]); Assert.Equal(RowFilters.ValueExact("abc"), filter.Chain.Filters[1]); }
public void ValueRange() { var range = new ValueRange { StartValueClosed = ByteString.CopyFromUtf8("a"), EndValueOpen = ByteString.CopyFromUtf8("z") }; var filter = RowFilters.ValueRange(range); Assert.Equal(range, filter.ValueRangeFilter); }
public void Interleave() { var filter = RowFilters.Interleave( RowFilters.CellsPerRowLimit(1), RowFilters.ValueExact("abc")); Assert.NotNull(filter.Interleave); Assert.Equal(2, filter.Interleave.Filters.Count); Assert.Equal(RowFilters.CellsPerRowLimit(1), filter.Interleave.Filters[0]); Assert.Equal(RowFilters.ValueExact("abc"), filter.Interleave.Filters[1]); }
public async Task CheckAndMutateRow_Valid_Request() { var tableName = new TableName("project", "instance", "table"); await CheckAndMutateRow_ValidateArguments <RequestMadeException>( tableName, "abc", RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new[] { Mutations.DeleteFromRow() }); }
public async Task CheckAndMutateRow_Validate_RowKey(BigtableByteString rowKey) { var tableName = new TableName("project", "instance", "table"); await CheckAndMutateRow_ValidateArguments <ArgumentException>( tableName, rowKey, RowFilters.PassAllFilter(), new[] { Mutations.DeleteFromRow() }, new[] { Mutations.DeleteFromRow() }); }
private CheckAndMutateRowRequest ToMutateRowIfNotExistsRequest(IPersistentRepresentation persistent, ActorSystem system) { var request = new CheckAndMutateRowRequest(); request.TableNameAsTableName = _tableName; var payload = PersistentToBytes(persistent, system); request.PredicateFilter = RowFilters.PassAllFilter(); request.RowKey = ByteString.CopyFromUtf8(ToRowKeyString(persistent.PersistenceId, persistent.SequenceNr)); request.FalseMutations.Add(Mutations.SetCell(_family, PayloadColumnQualifier, payload, new BigtableVersion(-1))); return(request); }