Ejemplo n.º 1
0
    /// <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);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// <para>
    /// Add a range partition partition to the table with a lower bound and upper
    /// bound.
    /// </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 bounds may be added, but they must not overlap. All split
    /// rows must fall in one of the range bounds. The lower bound must be less
    /// than or equal to the upper bound.
    /// </para>
    ///
    /// <para>
    /// If not provided, the table's range will be unbounded.
    /// </para>
    /// </summary>
    /// <param name="configure">
    /// Delegate to configure the lower bound and the upper bound (in that order).
    /// </param>
    /// <param name="lowerBoundType">The type of the lower bound.</param>
    /// <param name="upperBoundType">The type of the upper bound.</param>
    public TableBuilder AddRangePartition(
        Action <PartialRowOperation, PartialRowOperation> configure,
        RangePartitionBound lowerBoundType,
        RangePartitionBound upperBoundType)
    {
        // TODO: Rework this
        var columns = _createTableRequest.Schema.Columns
                      .Select(c => ColumnSchema.FromProtobuf(c))
                      .ToList();

        var lowerRowOp = lowerBoundType == RangePartitionBound.Inclusive ?
                         RowOperation.RangeLowerBound :
                         RowOperation.ExclusiveRangeLowerBound;

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

        var schema        = new KuduSchema(columns);
        var lowerBoundRow = new PartialRowOperation(schema, lowerRowOp);
        var upperBoundRow = new PartialRowOperation(schema, upperRowOp);

        configure(lowerBoundRow, upperBoundRow);

        _splitRowsRangeBounds.Add(lowerBoundRow);
        _splitRowsRangeBounds.Add(upperBoundRow);

        return(this);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Add a range partition split. The split row must fall in a range partition,
    /// and causes the range partition to split into two contiguous range partitions.
    /// </summary>
    /// <param name="configure">A delegate to configure the split row.</param>
    public TableBuilder AddSplitRow(Action <PartialRowOperation> configure)
    {
        // TODO: Rework this
        var columns = _createTableRequest.Schema.Columns
                      .Select(c => ColumnSchema.FromProtobuf(c))
                      .ToList();

        var schema   = new KuduSchema(columns);
        var splitRow = new PartialRowOperation(schema, RowOperation.SplitRow);

        configure(splitRow);

        _splitRowsRangeBounds.Add(splitRow);

        return(this);
    }
Ejemplo n.º 4
0
    /// <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);
    }
Ejemplo n.º 5
0
 internal PartialRowOperation(PartialRowOperation row, RowOperation operation)
     : base(row)
 {
     Operation = operation;
 }