github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/entire_engine.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 engine
    16  
    17  import (
    18  	"context"
    19  	"strings"
    20  
    21  	"github.com/matrixorigin/matrixone/pkg/common/moerr"
    22  	"github.com/matrixorigin/matrixone/pkg/defines"
    23  	"github.com/matrixorigin/matrixone/pkg/pb/plan"
    24  	pb "github.com/matrixorigin/matrixone/pkg/pb/statsinfo"
    25  	"github.com/matrixorigin/matrixone/pkg/pb/timestamp"
    26  	"github.com/matrixorigin/matrixone/pkg/txn/client"
    27  )
    28  
    29  func GetTempTableName(DbName string, TblName string) string {
    30  	return strings.ReplaceAll(DbName, ".", "DOT") + "." + strings.ReplaceAll(TblName, ".", "DOT")
    31  }
    32  
    33  func (e *EntireEngine) New(ctx context.Context, op client.TxnOperator) error {
    34  	err := e.Engine.New(ctx, op)
    35  	if err == nil && e.TempEngine != nil {
    36  		return e.TempEngine.New(ctx, op)
    37  	}
    38  	return err
    39  }
    40  
    41  func (e *EntireEngine) Delete(ctx context.Context, databaseName string, op client.TxnOperator) error {
    42  	return e.Engine.Delete(ctx, databaseName, op)
    43  }
    44  
    45  func (e *EntireEngine) Create(ctx context.Context, databaseName string, op client.TxnOperator) error {
    46  	return e.Engine.Create(ctx, databaseName, op)
    47  }
    48  
    49  func (e *EntireEngine) Databases(ctx context.Context, op client.TxnOperator) (databaseNames []string, err error) {
    50  	return e.Engine.Databases(ctx, op)
    51  }
    52  
    53  func (e *EntireEngine) Database(ctx context.Context, databaseName string, op client.TxnOperator) (Database, error) {
    54  	if databaseName == defines.TEMPORARY_DBNAME {
    55  		if e.TempEngine != nil {
    56  			return e.TempEngine.Database(ctx, defines.TEMPORARY_DBNAME, op)
    57  		} else {
    58  			return nil, moerr.NewInternalError(ctx, "temporary engine not init yet")
    59  		}
    60  	}
    61  	return e.Engine.Database(ctx, databaseName, op)
    62  }
    63  
    64  func (e *EntireEngine) Nodes(
    65  	isInternal bool, tenant string, username string, cnLabel map[string]string) (cnNodes Nodes, err error,
    66  ) {
    67  	return e.Engine.Nodes(isInternal, tenant, username, cnLabel)
    68  }
    69  
    70  func (e *EntireEngine) Hints() Hints {
    71  	return e.Engine.Hints()
    72  }
    73  
    74  func (e *EntireEngine) NewBlockReader(ctx context.Context, num int, ts timestamp.Timestamp,
    75  	expr *plan.Expr, ranges []byte, tblDef *plan.TableDef, proc any) ([]Reader, error) {
    76  	return e.Engine.NewBlockReader(ctx, num, ts, expr, ranges, tblDef, proc)
    77  }
    78  
    79  func (e *EntireEngine) GetNameById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, err error) {
    80  	return e.Engine.GetNameById(ctx, op, tableId)
    81  }
    82  
    83  func (e *EntireEngine) GetRelationById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, rel Relation, err error) {
    84  	return e.Engine.GetRelationById(ctx, op, tableId)
    85  }
    86  
    87  func (e *EntireEngine) AllocateIDByKey(ctx context.Context, key string) (uint64, error) {
    88  	return e.Engine.AllocateIDByKey(ctx, key)
    89  }
    90  
    91  func (e *EntireEngine) TryToSubscribeTable(ctx context.Context, dbID, tbID uint64) error {
    92  	return e.Engine.TryToSubscribeTable(ctx, dbID, tbID)
    93  }
    94  
    95  func (e *EntireEngine) UnsubscribeTable(ctx context.Context, dbID, tbID uint64) error {
    96  	return e.Engine.UnsubscribeTable(ctx, dbID, tbID)
    97  }
    98  
    99  func (e *EntireEngine) Stats(ctx context.Context, key pb.StatsInfoKey, sync bool) *pb.StatsInfo {
   100  	return e.Engine.Stats(ctx, key, sync)
   101  }