Skip to content

Commit

Permalink
remove unused code (#18517)
Browse files Browse the repository at this point in the history
remove unused code

Approved by: @LeftHandCold, @triump2020
  • Loading branch information
XuPeng-SH committed Sep 4, 2024
1 parent 86dbf35 commit ad803bc
Show file tree
Hide file tree
Showing 35 changed files with 45 additions and 191 deletions.
22 changes: 17 additions & 5 deletions pkg/vm/engine/tae/common/generator.go → pkg/objectio/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package common
package objectio

type RowGen interface {
HasNext() bool
Next() uint32
}
import (
"math"

"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
)

const (
BlockMaxRows = 8192

SEQNUM_UPPER = math.MaxUint16 - 5 // reserved 5 column for special committs、committs etc.
SEQNUM_ROWID = math.MaxUint16
SEQNUM_ABORT = math.MaxUint16 - 1
SEQNUM_COMMITTS = math.MaxUint16 - 2
)

const ZoneMapSize = index.ZMSize
10 changes: 0 additions & 10 deletions pkg/objectio/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,19 @@ package objectio

import (
"context"
"math"

"github.com/matrixorigin/matrixone/pkg/common/mpool"
"github.com/matrixorigin/matrixone/pkg/container/batch"
"github.com/matrixorigin/matrixone/pkg/fileservice"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
)

const (
SEQNUM_UPPER = math.MaxUint16 - 5 // reserved 5 column for special committs、committs etc.
SEQNUM_ROWID = math.MaxUint16
SEQNUM_ABORT = math.MaxUint16 - 1
SEQNUM_COMMITTS = math.MaxUint16 - 2
)

type WriteType int8

const (
WriteTS WriteType = iota
)

const ZoneMapSize = index.ZMSize

type ZoneMap = index.ZM
type StaticFilter = index.StaticFilter

Expand Down
11 changes: 5 additions & 6 deletions pkg/vm/engine/disttae/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/logtailreplay"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/blockio"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options"
"github.com/matrixorigin/matrixone/pkg/vm/process"
)

Expand Down Expand Up @@ -586,7 +585,7 @@ func (ls *LocalDataSource) filterInMemUnCommittedInserts(

rows := 0
writes := ls.table.getTxn().writes
maxRows := int(options.DefaultBlockMaxRows)
maxRows := objectio.BlockMaxRows
if len(writes) == 0 {
return nil
}
Expand Down Expand Up @@ -655,7 +654,7 @@ func (ls *LocalDataSource) filterInMemCommittedInserts(
// ls.rc.SkipPStateDeletes = false
//}()

if bat.RowCount() >= int(options.DefaultBlockMaxRows) {
if bat.RowCount() >= objectio.BlockMaxRows {
return nil
}

Expand Down Expand Up @@ -698,9 +697,9 @@ func (ls *LocalDataSource) filterInMemCommittedInserts(
applyOffset := 0

goon := true
for goon && bat.Vecs[0].Length() < int(options.DefaultBlockMaxRows) {
for goon && bat.Vecs[0].Length() < int(objectio.BlockMaxRows) {
//minTS = types.MaxTs()
for bat.Vecs[0].Length() < int(options.DefaultBlockMaxRows) {
for bat.Vecs[0].Length() < int(objectio.BlockMaxRows) {
if goon = ls.pStateRows.insIter.Next(); !goon {
break
}
Expand Down Expand Up @@ -1211,7 +1210,7 @@ func (ls *LocalDataSource) batchApplyTombstoneObjects(
return nil, err
}

location = obj.ObjectStats.BlockLocation(uint16(idx), options.DefaultBlockMaxRows)
location = obj.ObjectStats.BlockLocation(uint16(idx), objectio.BlockMaxRows)

if loaded, persistedByCN, release, err = blockio.ReadBlockDelete(ls.ctx, location, ls.fs); err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions pkg/vm/engine/disttae/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
v2 "github.com/matrixorigin/matrixone/pkg/util/metric/v2"
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/logtailreplay"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options"
"github.com/matrixorigin/matrixone/pkg/vm/process"
)

Expand Down Expand Up @@ -1144,9 +1143,9 @@ func ExecuteBlockFilter(
var rows uint32
if objRows := objStats.Rows(); objRows != 0 {
if pos < blockCnt-1 {
rows = options.DefaultBlockMaxRows
rows = objectio.BlockMaxRows
} else {
rows = objRows - options.DefaultBlockMaxRows*uint32(pos)
rows = objRows - objectio.BlockMaxRows*uint32(pos)
}
} else {
if blkMeta == nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/engine/disttae/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (t *cnMergeTask) GetAccBlkCnts() []int {
}

func (t *cnMergeTask) GetBlockMaxRows() uint32 {
return options.DefaultBlockMaxRows
return objectio.BlockMaxRows
}

func (t *cnMergeTask) GetObjectMaxBlocks() uint16 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/vm/engine/disttae/tombstones.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sort"

"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options"
"go.uber.org/zap"

"github.com/matrixorigin/matrixone/pkg/common/moerr"
Expand Down Expand Up @@ -226,7 +225,7 @@ func (tomb *tombstoneData) PrefetchTombstones(
for i, end := 0, tomb.files.Len(); i < end; i++ {
stats := tomb.files.Get(i)
for j := 0; j < int(stats.BlkCnt()); j++ {
loc := stats.BlockLocation(uint16(j), options.DefaultBlockMaxRows)
loc := stats.BlockLocation(uint16(j), objectio.BlockMaxRows)
if err := blockio.Prefetch(
srvId,
[]uint16{0, 1, 2},
Expand Down
5 changes: 2 additions & 3 deletions pkg/vm/engine/disttae/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/cache"
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae/logtailreplay"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/blockio"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options"
"github.com/matrixorigin/matrixone/pkg/vm/process"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -1435,7 +1434,7 @@ func NewStatsBlkIter(stats *objectio.ObjectStats, meta objectio.ObjectDataMeta)
cur: -1,
accRows: 0,
totalRows: stats.Rows(),
curBlkRows: options.DefaultBlockMaxRows,
curBlkRows: objectio.BlockMaxRows,
meta: meta,
}
}
Expand All @@ -1453,7 +1452,7 @@ func (i *StatsBlkIter) Entry() objectio.BlockInfo {
i.cur = 0
}

// assume that all blks have DefaultBlockMaxRows, except the last one
// assume that all blks have BlockMaxRows, except the last one
if i.meta.IsEmpty() {
if i.cur == int(i.blkCnt-1) {
i.curBlkRows = i.totalRows - i.accRows
Expand Down
3 changes: 1 addition & 2 deletions pkg/vm/engine/disttae/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/matrixorigin/matrixone/pkg/sql/plan/function"
"github.com/matrixorigin/matrixone/pkg/testutil"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/index"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -305,7 +304,7 @@ func mockStatsList(t *testing.T, statsCnt int) (statsList []objectio.ObjectStats
stats := objectio.NewObjectStats()
blkCnt := rand.Uint32()%100 + 1
require.Nil(t, objectio.SetObjectStatsBlkCnt(stats, blkCnt))
require.Nil(t, objectio.SetObjectStatsRowCnt(stats, options.DefaultBlockMaxRows*(blkCnt-1)+options.DefaultBlockMaxRows*6/10))
require.Nil(t, objectio.SetObjectStatsRowCnt(stats, objectio.BlockMaxRows*(blkCnt-1)+objectio.BlockMaxRows*6/10))
require.Nil(t, objectio.SetObjectStatsObjectName(stats, objectio.BuildObjectName(objectio.NewSegmentid(), uint16(blkCnt))))
require.Nil(t, objectio.SetObjectStatsExtent(stats, objectio.NewExtent(0, 0, 0, 0)))
require.Nil(t, objectio.SetObjectStatsSortKeyZoneMap(stats, index.NewZM(types.T_bool, 1)))
Expand Down
3 changes: 1 addition & 2 deletions pkg/vm/engine/tae/blockio/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/matrixorigin/matrixone/pkg/fileservice"
"github.com/matrixorigin/matrixone/pkg/objectio"
v2 "github.com/matrixorigin/matrixone/pkg/util/metric/v2"
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/options"
)

func GetTombstonesByBlockId(
Expand All @@ -36,7 +35,7 @@ func GetTombstonesByBlockId(
) (err error) {
loadedBlkCnt := 0
onBlockSelectedFn := func(tombstoneObject *objectio.ObjectStats, pos int) (bool, error) {
location := tombstoneObject.BlockLocation(uint16(pos), options.DefaultBlockMaxRows)
location := tombstoneObject.BlockLocation(uint16(pos), objectio.BlockMaxRows)
if mask, err := FillBlockDeleteMask(
ctx, ts, blockId, location, fs,
); err != nil {
Expand Down
24 changes: 0 additions & 24 deletions pkg/vm/engine/tae/catalog/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,6 @@ func (be *BaseEntryImpl[T]) CreateWithTxnLocked(txn txnif.AsyncTxn, baseNode T)
be.InsertLocked(node)
}

func (be *BaseEntryImpl[T]) TryGetTerminatedTS(waitIfcommitting bool) (terminated bool, TS types.TS) {
be.RLock()
defer be.RUnlock()
return be.TryGetTerminatedTSLocked(waitIfcommitting)
}

func (be *BaseEntryImpl[T]) TryGetTerminatedTSLocked(waitIfcommitting bool) (terminated bool, TS types.TS) {
node := be.GetLatestCommittedNodeLocked()
if node == nil {
return
}
if node.HasDropCommitted() {
return true, node.DeletedAt
}
return
}
func (be *BaseEntryImpl[T]) PrepareAdd(txn txnif.TxnReader) (err error) {
if err = be.ConflictCheck(txn); err != nil {
return
Expand Down Expand Up @@ -203,14 +187,6 @@ func (be *BaseEntryImpl[T]) HasDropCommittedLocked() bool {
return un.HasDropCommitted()
}

func (be *BaseEntryImpl[T]) HasDropIntentLocked() bool {
un := be.GetLatestNodeLocked()
if un == nil {
return false
}
return un.HasDropIntent()
}

func (be *BaseEntryImpl[T]) ensureVisibleAndNotDroppedLocked(txn txnif.TxnReader) bool {
visible, dropped := be.GetVisibilityLocked(txn)
if !visible {
Expand Down
7 changes: 0 additions & 7 deletions pkg/vm/engine/tae/catalog/basemvccnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ type BaseNode[T any] interface {
CloneData() T
String() string
Update(vun T)
IdempotentUpdate(vun T)
WriteTo(w io.Writer) (n int64, err error)
ReadFromWithVersion(r io.Reader, ver uint16) (n int64, err error)
}
Expand Down Expand Up @@ -254,12 +253,6 @@ func (e *MVCCNode[T]) Update(un *MVCCNode[T]) {
e.BaseNode.Update(un.BaseNode)
}

func (e *MVCCNode[T]) IdempotentUpdate(un *MVCCNode[T]) {
e.CreatedAt = un.CreatedAt
e.DeletedAt = un.DeletedAt
e.BaseNode.Update(un.BaseNode)
}

func (e *MVCCNode[T]) ApplyCommit(id string) (err error) {
var commitTS types.TS
commitTS, err = e.TxnMVCCNode.ApplyCommit(id)
Expand Down
3 changes: 1 addition & 2 deletions pkg/vm/engine/tae/catalog/dbmvccnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func (e *EmptyMVCCNode) String() string {
}

// for create drop in one txn
func (e *EmptyMVCCNode) Update(vun *EmptyMVCCNode) {}
func (e *EmptyMVCCNode) IdempotentUpdate(vun *EmptyMVCCNode) {}
func (e *EmptyMVCCNode) Update(vun *EmptyMVCCNode) {}

func (e *EmptyMVCCNode) WriteTo(w io.Writer) (n int64, err error) { return }

Expand Down
18 changes: 0 additions & 18 deletions pkg/vm/engine/tae/catalog/metamvccnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ func (e *MetadataMVCCNode) Update(un *MetadataMVCCNode) {
e.DeltaLoc = un.DeltaLoc
}
}
func (e *MetadataMVCCNode) IdempotentUpdate(un *MetadataMVCCNode) {
if !un.MetaLoc.IsEmpty() {
e.MetaLoc = un.MetaLoc
}
if !un.DeltaLoc.IsEmpty() {
e.DeltaLoc = un.DeltaLoc
}
}
func (e *MetadataMVCCNode) WriteTo(w io.Writer) (n int64, err error) {
var sn int64
if sn, err = objectio.WriteBytes(e.MetaLoc, w); err != nil {
Expand Down Expand Up @@ -154,16 +146,6 @@ func (e *ObjectMVCCNode) String() string {
func (e *ObjectMVCCNode) Update(vun *ObjectMVCCNode) {
e.ObjectStats = *vun.ObjectStats.Clone()
}
func (e *ObjectMVCCNode) IdempotentUpdate(vun *ObjectMVCCNode) {
if e.ObjectStats.IsZero() {
e.ObjectStats = *vun.ObjectStats.Clone()
} else {
if e.IsEmpty() && !vun.IsEmpty() {
e.ObjectStats = *vun.ObjectStats.Clone()

}
}
}
func (e *ObjectMVCCNode) WriteTo(w io.Writer) (n int64, err error) {
var sn int
if sn, err = w.Write(e.ObjectStats[:]); err != nil {
Expand Down
27 changes: 0 additions & 27 deletions pkg/vm/engine/tae/catalog/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type ObjectEntry struct {
table *TableEntry
ObjectNode
objData data.Object
deleteCount atomic.Uint32
ObjectState uint8

HasPrintedPrepareComapct atomic.Bool
Expand All @@ -64,13 +63,6 @@ func (entry *ObjectEntry) GetLoaded() bool {
return stats.Rows() != 0
}

func (entry *ObjectEntry) AddDeleteCount(count uint32) {
entry.deleteCount.Add(count)
}
func (entry *ObjectEntry) GetDeleteCount() uint32 {
return entry.deleteCount.Load()
}

func (entry *ObjectEntry) GetSortKeyZonemap() index.ZM {
stats := entry.GetObjectStats()
return stats.SortKeyZoneMap()
Expand Down Expand Up @@ -398,7 +390,6 @@ func (entry *ObjectEntry) getBlockCntFromStats() (blkCnt uint32) {

func (entry *ObjectEntry) IsAppendable() bool {
return entry.ObjectStats.GetAppendable()
// return entry.state == ES_Appendable
}

func (entry *ObjectEntry) IsSorted() bool {
Expand Down Expand Up @@ -433,7 +424,6 @@ func (entry *ObjectEntry) GetLatestCommittedNode() *txnbase.TxnMVCCNode {
}
return nil
}
func (entry *ObjectEntry) GetCatalog() *Catalog { return entry.table.db.catalog }

func (entry *ObjectEntry) PrepareRollback() (err error) {
lastNode := entry.table.getObjectList(entry.IsTombstone).GetLastestNode(entry.SortHint)
Expand Down Expand Up @@ -488,23 +478,6 @@ func (entry *ObjectEntry) TreeMaxDropCommitEntry() (BaseEntry, *ObjectEntry) {
return nil, nil
}

// GetTerminationTS is coarse API: no consistency check
func (entry *ObjectEntry) GetTerminationTS() (ts types.TS, terminated bool) {
tableEntry := entry.GetTable()
dbEntry := tableEntry.GetDB()

dbEntry.RLock()
terminated, ts = dbEntry.TryGetTerminatedTSLocked(true)
if terminated {
dbEntry.RUnlock()
return
}
dbEntry.RUnlock()

terminated, ts = tableEntry.TryGetTerminatedTS(true)
return
}

func (entry *ObjectEntry) GetSchema() *Schema {
return entry.table.GetLastestSchema(entry.IsTombstone)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/vm/engine/tae/catalog/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func NewEmptySchema(name string) *Schema {
SeqnumMap: make(map[uint16]int),
Extra: &apipb.SchemaExtra{},
}
schema.BlockMaxRows = options.DefaultBlockMaxRows
schema.BlockMaxRows = objectio.BlockMaxRows
schema.ObjectMaxBlocks = options.DefaultBlocksPerObject
return schema
}
Expand Down
9 changes: 0 additions & 9 deletions pkg/vm/engine/tae/catalog/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,6 @@ func (entry *TableEntry) IsActive() bool {
return !entry.HasDropCommitted()
}

// GetTerminationTS is coarse API: no consistency check
func (entry *TableEntry) GetTerminationTS() (ts types.TS, terminated bool) {
dbEntry := entry.GetDB()

terminated, ts = dbEntry.TryGetTerminatedTS(true)

return
}

func (entry *TableEntry) AlterTable(ctx context.Context, txn txnif.TxnReader, req *apipb.AlterTableReq) (isNewNode bool, newSchema *Schema, err error) {
entry.Lock()
defer entry.Unlock()
Expand Down
Loading

0 comments on commit ad803bc

Please sign in to comment.