From d94f4fba04d8599000ac89c1551b37245a18a7c3 Mon Sep 17 00:00:00 2001 From: Wenbin1002 Date: Mon, 24 Jun 2024 13:59:29 +0800 Subject: [PATCH] make BlockRead a singleton #16953 --- pkg/vm/engine/tae/blockio/read.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/vm/engine/tae/blockio/read.go b/pkg/vm/engine/tae/blockio/read.go index e6856ad4a546..4ff74afcbe7e 100644 --- a/pkg/vm/engine/tae/blockio/read.go +++ b/pkg/vm/engine/tae/blockio/read.go @@ -17,6 +17,7 @@ package blockio import ( "context" "math" + "sync" "time" "github.com/matrixorigin/matrixone/pkg/common/mpool" @@ -676,11 +677,19 @@ func FindIntervalForBlock(rowids []types.Rowid, id *types.Blockid) (start int, e type BlockReadImpl struct{} +var ( + instance *BlockReadImpl + once sync.Once +) + func (blk *BlockReadImpl) LoadTableByBlock(loc objectio.Location, fs fileservice.FileService) (bat *batch.Batch, release func(), err error) { bat, release, err = LoadTombstoneColumns(context.Background(), []uint16{0}, nil, fs, loc, nil) return bat, release, err } func NewBlockRead() *BlockReadImpl { - return &BlockReadImpl{} + once.Do(func() { + instance = &BlockReadImpl{} + }) + return instance }