github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/disttae/logtailreplay/utils.go (about)

     1  // Copyright 2023 Matrix Origin
     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 logtailreplay
    16  
    17  import (
    18  	"regexp"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/container/vector"
    21  	"github.com/matrixorigin/matrixone/pkg/pb/api"
    22  )
    23  
    24  var metaTableMatchRegexp = regexp.MustCompile(`\_\d+\_(meta|seg)`)
    25  var blkTableMatchRegexp = regexp.MustCompile(`\_\d+\_meta`)
    26  var objTableMatchRegexp = regexp.MustCompile(`\_\d+\_obj`)
    27  
    28  func IsMetaTable(name string) bool {
    29  	return metaTableMatchRegexp.MatchString(name)
    30  }
    31  
    32  func IsBlkTable(name string) bool {
    33  	return blkTableMatchRegexp.MatchString(name)
    34  }
    35  
    36  func IsObjTable(name string) bool {
    37  	return objTableMatchRegexp.MatchString(name)
    38  }
    39  
    40  func mustVectorFromProto(v api.Vector) *vector.Vector {
    41  	ret, err := vector.ProtoVectorToVector(v)
    42  	if err != nil {
    43  		panic(err)
    44  	}
    45  	return ret
    46  }
    47  
    48  func mustVectorToProto(v *vector.Vector) api.Vector {
    49  	ret, err := vector.VectorToProtoVector(v)
    50  	if err != nil {
    51  		panic(err)
    52  	}
    53  	return ret
    54  }