github.com/hasnat/dolt/go@v0.0.0-20210628190320-9eb5d843fbb7/libraries/doltcore/table/pipeline/transform_collection.go (about)

     1  // Copyright 2019 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package pipeline
    16  
    17  // TransformCollection is a collection of transforms to be applied in order in a pipeline
    18  type TransformCollection struct {
    19  	// Transforms is a slice of named transforms stored in the order they will be applied
    20  	Transforms []NamedTransform
    21  }
    22  
    23  // NewTransformCollection creates a TransformCollection from NamedTransforms
    24  func NewTransformCollection(namedTransforms ...NamedTransform) *TransformCollection {
    25  	return &TransformCollection{namedTransforms}
    26  }
    27  
    28  // AppendTransform will mutate the internal slice of transforms by appending this new transform to the slice of
    29  // Transforms
    30  func (tc *TransformCollection) AppendTransforms(nt ...NamedTransform) {
    31  	tc.Transforms = append(tc.Transforms, nt...)
    32  }
    33  
    34  // NumTransforms returns the number of NamedTransforms in the collection
    35  func (tc *TransformCollection) NumTransforms() int {
    36  	return len(tc.Transforms)
    37  }
    38  
    39  // TransformAt returns the NamedTransform at a given index
    40  func (tc *TransformCollection) TransformAt(idx int) NamedTransform {
    41  	return tc.Transforms[idx]
    42  }