示例#1
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);
    }
示例#2
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);
    }