github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/iface/data/block.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 data
    16  
    17  import (
    18  	"bytes"
    19  	"time"
    20  
    21  	"github.com/matrixorigin/matrixone/pkg/objectio"
    22  
    23  	"github.com/matrixorigin/matrixone/pkg/container/types"
    24  
    25  	"github.com/RoaringBitmap/roaring"
    26  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/buffer/base"
    27  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common"
    28  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/containers"
    29  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/handle"
    30  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/iface/txnif"
    31  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/model"
    32  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/tasks"
    33  	"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/wal"
    34  )
    35  
    36  type CheckpointUnit interface {
    37  	MutationInfo() string
    38  	RunCalibration() int
    39  	EstimateScore(time.Duration, bool) int
    40  	BuildCompactionTaskFactory() (tasks.TxnTaskFactory, tasks.TaskType, []common.ID, error)
    41  }
    42  
    43  type BlockAppender interface {
    44  	GetID() *common.ID
    45  	GetMeta() any
    46  	PrepareAppend(rows uint32,
    47  		txn txnif.AsyncTxn) (
    48  		node txnif.AppendNode, created bool, n uint32, err error)
    49  	ApplyAppend(bat *containers.Batch,
    50  		txn txnif.AsyncTxn,
    51  	) (int, error)
    52  	IsAppendable() bool
    53  	ReplayAppend(bat *containers.Batch,
    54  		txn txnif.AsyncTxn) (int, error)
    55  	Close()
    56  }
    57  
    58  type BlockReplayer interface {
    59  	OnReplayDelete(node txnif.DeleteNode) (err error)
    60  	OnReplayAppend(node txnif.AppendNode) (err error)
    61  	OnReplayAppendPayload(bat *containers.Batch) (err error)
    62  }
    63  
    64  type Block interface {
    65  	CheckpointUnit
    66  	BlockReplayer
    67  
    68  	DeletesInfo() string
    69  
    70  	GetRowsOnReplay() uint64
    71  	GetID() *common.ID
    72  	IsAppendable() bool
    73  	PrepareCompact() bool
    74  
    75  	Rows() int
    76  	GetColumnDataByNames(txn txnif.AsyncTxn, attrs []string, buffers []*bytes.Buffer) (*model.BlockView, error)
    77  	GetColumnDataByIds(txn txnif.AsyncTxn, colIdxes []int, buffers []*bytes.Buffer) (*model.BlockView, error)
    78  	GetColumnDataByName(txn txnif.AsyncTxn, attr string, buffer *bytes.Buffer) (*model.ColumnView, error)
    79  	GetColumnDataById(txn txnif.AsyncTxn, colIdx int, buffer *bytes.Buffer) (*model.ColumnView, error)
    80  	GetMeta() any
    81  	GetBufMgr() base.INodeManager
    82  
    83  	MakeAppender() (BlockAppender, error)
    84  	RangeDelete(txn txnif.AsyncTxn, start, end uint32, dt handle.DeleteType) (txnif.DeleteNode, error)
    85  
    86  	GetTotalChanges() int
    87  	CollectChangesInRange(startTs, endTs types.TS) (*model.BlockView, error)
    88  	CollectAppendLogIndexes(startTs, endTs types.TS) ([]*wal.Index, error)
    89  
    90  	// check wether any delete intents with prepared ts within [from, to]
    91  	HasDeleteIntentsPreparedIn(from, to types.TS) bool
    92  
    93  	BatchDedup(txn txnif.AsyncTxn, pks containers.Vector, rowmask *roaring.Bitmap, precommit bool) error
    94  	GetByFilter(txn txnif.AsyncTxn, filter *handle.Filter) (uint32, error)
    95  	GetValue(txn txnif.AsyncTxn, row, col int) (any, error)
    96  	PPString(level common.PPLevel, depth int, prefix string) string
    97  
    98  	Init() error
    99  	TryUpgrade() error
   100  	CollectAppendInRange(start, end types.TS, withAborted bool) (*containers.Batch, error)
   101  	CollectDeleteInRange(start, end types.TS, withAborted bool) (*containers.Batch, error)
   102  	// GetAppendNodeByRow(row uint32) (an txnif.AppendNode)
   103  	// GetDeleteNodeByRow(row uint32) (an txnif.DeleteNode)
   104  	GetFs() *objectio.ObjectFS
   105  
   106  	Close()
   107  }