/// <summary>
    /// <para>
    /// Drop the range partition from the table with with an identical lower
    /// bound and upper bound.
    /// </para>
    ///
    /// <para>
    /// If a range column is missing a value, the logical minimum value for that
    /// column type will be used as the default.
    /// </para>
    ///
    /// <para>
    /// Multiple range partitions may be dropped as part of a single alter table
    /// transaction by calling this method multiple times.
    /// </para>
    /// </summary>
    /// <param name="configure">Delegate to configure the partition row.</param>
    public AlterTableBuilder DropRangePartition(
        Action <PartialRowOperation> configure)
    {
        var schema        = _table.Schema;
        var lowerBoundRow = new PartialRowOperation(
            schema, RowOperation.RangeLowerBound);

        configure(lowerBoundRow);

        var upperBoundRow = new PartialRowOperation(
            lowerBoundRow, RowOperation.InclusiveRangeUpperBound);

        _request.AlterSchemaSteps.Add(new Step
        {
            Type = StepType.DropRangePartition,
            DropRangePartition = new DropRangePartition
            {
                RangeBounds = ProtobufHelper.EncodeRowOperations(
                    lowerBoundRow, upperBoundRow)
            }
        });

        if (_request.Schema is null)
        {
            _request.Schema = _table.SchemaPbNoIds.Schema;
        }

        return(this);
    }
示例#2
0
    public CreateTableRequestPB Build()
    {
        if (_splitRowsRangeBounds.Count > 0)
        {
            _createTableRequest.SplitRowsRangeBounds =
                ProtobufHelper.EncodeRowOperations(_splitRowsRangeBounds);
        }

        return(_createTableRequest);
    }
    /// <summary>
    /// <para>
    /// Add a range partition to the table with dimension label.
    /// </para>
    ///
    /// <para>
    /// If either row is empty, then that end of the range will be unbounded.
    /// If a range column is missing a value, the logical minimum value for that
    /// column type will be used as the default.
    /// </para>
    ///
    /// <para>
    /// Multiple range partitions may be added as part of a single alter table
    /// transaction by calling this method multiple times. Added range partitions
    /// must not overlap with each other or any existing range partitions (unless
    /// the existing range partitions are dropped as part of the alter transaction
    /// first). The lower bound must be less than the upper bound.
    /// </para>
    ///
    /// <para>
    /// This client will immediately be able to write and scan the new tablets when
    /// the alter table operation returns success, however other existing clients may
    /// have to wait for a timeout period to elapse before the tablets become visible.
    /// This period is configured by the master's 'table_locations_ttl_ms' flag, and
    /// defaults to 5 minutes.
    /// </para>
    ///
    /// <para>
    /// By default, the master will try to place newly created tablet replicas on
    /// tablet servers with a small number of tablet replicas. If the dimension label
    /// is provided, newly created replicas will be evenly distributed in the cluster
    /// based on the dimension label.In other words, the master will try to place newly
    /// created tablet replicas on tablet servers with a small number of tablet replicas
    /// belonging to this dimension label.
    /// </para>
    /// </summary>
    /// <param name="configure">
    /// Delegate to configure the lower bound and the upper bound (in that order).
    /// </param>
    /// <param name="dimensionLabel">The dimension label for the tablet to be created.</param>
    /// <param name="lowerBoundType">The type of the lower bound.</param>
    /// <param name="upperBoundType">The type of the upper bound.</param>
    public AlterTableBuilder AddRangePartition(
        Action <PartialRowOperation, PartialRowOperation> configure,
        string?dimensionLabel,
        RangePartitionBound lowerBoundType,
        RangePartitionBound upperBoundType)
    {
        var lowerRowOp = lowerBoundType == RangePartitionBound.Inclusive ?
                         RowOperation.RangeLowerBound :
                         RowOperation.ExclusiveRangeLowerBound;

        var upperRowOp = upperBoundType == RangePartitionBound.Exclusive ?
                         RowOperation.RangeUpperBound :
                         RowOperation.InclusiveRangeUpperBound;

        var schema        = _table.Schema;
        var lowerBoundRow = new PartialRowOperation(schema, lowerRowOp);
        var upperBoundRow = new PartialRowOperation(schema, upperRowOp);

        configure(lowerBoundRow, upperBoundRow);

        var addRangePartition = new AddRangePartition
        {
            RangeBounds = ProtobufHelper.EncodeRowOperations(
                lowerBoundRow, upperBoundRow)
        };

        if (dimensionLabel is not null)
        {
            addRangePartition.DimensionLabel = dimensionLabel;
        }

        _request.AlterSchemaSteps.Add(new Step
        {
            Type = StepType.AddRangePartition,
            AddRangePartition = addRangePartition
        });

        if (_request.Schema is null)
        {
            _request.Schema = _table.SchemaPbNoIds.Schema;
        }

        return(this);
    }