github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/db/helper.go (about)

     1  // Copyright 2021 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 db
    16  
    17  import (
    18  	"math"
    19  
    20  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/catalog"
    21  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common"
    22  )
    23  
    24  var dbScope = common.ID{
    25  	TableID: math.MaxUint64 / 2,
    26  }
    27  
    28  func MakeDBScopes(entry *catalog.DBEntry) (scopes []common.ID) {
    29  	scope := dbScope
    30  	scope.SegmentID = entry.GetID()
    31  	scopes = append(scopes, scope)
    32  	return
    33  }
    34  
    35  func MakeTableScopes(entries ...*catalog.TableEntry) (scopes []common.ID) {
    36  	for _, entry := range entries {
    37  		scopes = append(scopes, *entry.AsCommonID())
    38  	}
    39  	return
    40  }
    41  
    42  func MakeSegmentScopes(entries ...*catalog.SegmentEntry) (scopes []common.ID) {
    43  	for _, entry := range entries {
    44  		scopes = append(scopes, *entry.AsCommonID())
    45  	}
    46  	return
    47  }
    48  
    49  func MakeBlockScopes(entries ...*catalog.BlockEntry) (scopes []common.ID) {
    50  	for _, entry := range entries {
    51  		scopes = append(scopes, *entry.AsCommonID())
    52  	}
    53  	return
    54  }