github.com/matrixorigin/matrixone@v1.2.0/pkg/vm/engine/memoryengine/binded.go (about)

     1  // Copyright 2022 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 memoryengine
    16  
    17  import (
    18  	"context"
    19  
    20  	pb "github.com/matrixorigin/matrixone/pkg/pb/statsinfo"
    21  	"github.com/matrixorigin/matrixone/pkg/pb/timestamp"
    22  	"github.com/matrixorigin/matrixone/pkg/sql/plan"
    23  	"github.com/matrixorigin/matrixone/pkg/txn/client"
    24  	"github.com/matrixorigin/matrixone/pkg/vm/engine"
    25  )
    26  
    27  type BindedEngine struct {
    28  	txnOp  client.TxnOperator
    29  	engine *Engine
    30  }
    31  
    32  func (e *Engine) Bind(txnOp client.TxnOperator) *BindedEngine {
    33  	return &BindedEngine{
    34  		txnOp:  txnOp,
    35  		engine: e,
    36  	}
    37  }
    38  
    39  var _ engine.Engine = new(BindedEngine)
    40  
    41  func (b *BindedEngine) Commit(ctx context.Context, _ client.TxnOperator) error {
    42  	return b.engine.Commit(ctx, b.txnOp)
    43  }
    44  
    45  func (b *BindedEngine) Create(ctx context.Context, databaseName string, _ client.TxnOperator) error {
    46  	return b.engine.Create(ctx, databaseName, b.txnOp)
    47  }
    48  
    49  func (b *BindedEngine) Database(ctx context.Context, databaseName string, _ client.TxnOperator) (engine.Database, error) {
    50  	return b.engine.Database(ctx, databaseName, b.txnOp)
    51  }
    52  
    53  func (b *BindedEngine) Databases(ctx context.Context, _ client.TxnOperator) (databaseNames []string, err error) {
    54  	return b.engine.Databases(ctx, b.txnOp)
    55  }
    56  
    57  func (b *BindedEngine) Delete(ctx context.Context, databaseName string, _ client.TxnOperator) error {
    58  	return b.engine.Delete(ctx, databaseName, b.txnOp)
    59  }
    60  
    61  func (b *BindedEngine) Hints() engine.Hints {
    62  	return b.engine.Hints()
    63  }
    64  
    65  func (b *BindedEngine) NewBlockReader(_ context.Context, _ int, _ timestamp.Timestamp,
    66  	_ *plan.Expr, _ []byte, _ *plan.TableDef, _ any) ([]engine.Reader, error) {
    67  	return nil, nil
    68  }
    69  
    70  func (b *BindedEngine) New(ctx context.Context, _ client.TxnOperator) error {
    71  	return b.engine.New(ctx, b.txnOp)
    72  }
    73  
    74  func (b *BindedEngine) Nodes(isInternal bool, tenant string, username string, cnLabel map[string]string) (cnNodes engine.Nodes, err error) {
    75  	return b.engine.Nodes(isInternal, tenant, username, cnLabel)
    76  }
    77  
    78  func (b *BindedEngine) Rollback(ctx context.Context, _ client.TxnOperator) error {
    79  	return b.engine.Rollback(ctx, b.txnOp)
    80  }
    81  
    82  func (b *BindedEngine) GetNameById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, err error) {
    83  	return b.engine.GetNameById(ctx, op, tableId)
    84  }
    85  
    86  func (b *BindedEngine) GetRelationById(ctx context.Context, op client.TxnOperator, tableId uint64) (dbName string, tblName string, rel engine.Relation, err error) {
    87  	return b.engine.GetRelationById(ctx, op, tableId)
    88  }
    89  
    90  func (b *BindedEngine) AllocateIDByKey(ctx context.Context, key string) (uint64, error) {
    91  	return b.engine.AllocateIDByKey(ctx, key)
    92  }
    93  
    94  func (b *BindedEngine) TryToSubscribeTable(ctx context.Context, dbID, tbID uint64) error {
    95  	return b.engine.TryToSubscribeTable(ctx, dbID, tbID)
    96  }
    97  
    98  func (b *BindedEngine) UnsubscribeTable(ctx context.Context, dbID, tbID uint64) error {
    99  	return b.engine.UnsubscribeTable(ctx, dbID, tbID)
   100  }
   101  
   102  func (b *BindedEngine) Stats(ctx context.Context, key pb.StatsInfoKey, sync bool) *pb.StatsInfo {
   103  	return b.engine.Stats(ctx, key, sync)
   104  }