github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/soliton/plancodec/id.go (about)

     1  // Copyright 2020 WHTCORPS INC, Inc.
     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  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package plancodec
    15  
    16  import "strconv"
    17  
    18  const (
    19  	// TypeSel is the type of Selection.
    20  	TypeSel = "Selection"
    21  	// TypeSet is the type of Set.
    22  	TypeSet = "Set"
    23  	// TypeProj is the type of Projection.
    24  	TypeProj = "Projection"
    25  	// TypeAgg is the type of Aggregation.
    26  	TypeAgg = "Aggregation"
    27  	// TypeStreamAgg is the type of StreamAgg.
    28  	TypeStreamAgg = "StreamAgg"
    29  	// TypeHashAgg is the type of HashAgg.
    30  	TypeHashAgg = "HashAgg"
    31  	// TypeShow is the type of show.
    32  	TypeShow = "Show"
    33  	// TypeJoin is the type of Join.
    34  	TypeJoin = "Join"
    35  	// TypeUnion is the type of Union.
    36  	TypeUnion = "Union"
    37  	// TypePartitionUnion is the type of PartitionUnion
    38  	TypePartitionUnion = "PartitionUnion"
    39  	// TypeBlockScan is the type of BlockScan.
    40  	TypeBlockScan = "BlockScan"
    41  	// TypeMemBlockScan is the type of BlockScan.
    42  	TypeMemBlockScan = "MemBlockScan"
    43  	// TypeUnionScan is the type of UnionScan.
    44  	TypeUnionScan = "UnionScan"
    45  	// TypeIdxScan is the type of IndexScan.
    46  	TypeIdxScan = "IndexScan"
    47  	// TypeSort is the type of Sort.
    48  	TypeSort = "Sort"
    49  	// TypeTopN is the type of TopN.
    50  	TypeTopN = "TopN"
    51  	// TypeLimit is the type of Limit.
    52  	TypeLimit = "Limit"
    53  	// TypeHashJoin is the type of hash join.
    54  	TypeHashJoin = "HashJoin"
    55  	// TypeBroadcastJoin is the type of broad cast join.
    56  	TypeBroadcastJoin = "BroadcastJoin"
    57  	// TypeMergeJoin is the type of merge join.
    58  	TypeMergeJoin = "MergeJoin"
    59  	// TypeIndexJoin is the type of index look up join.
    60  	TypeIndexJoin = "IndexJoin"
    61  	// TypeIndexMergeJoin is the type of index look up merge join.
    62  	TypeIndexMergeJoin = "IndexMergeJoin"
    63  	// TypeIndexHashJoin is the type of index nested loop hash join.
    64  	TypeIndexHashJoin = "IndexHashJoin"
    65  	// TypeApply is the type of Apply.
    66  	TypeApply = "Apply"
    67  	// TypeMaxOneRow is the type of MaxOneRow.
    68  	TypeMaxOneRow = "MaxOneRow"
    69  	// TypeExists is the type of Exists.
    70  	TypeExists = "Exists"
    71  	// TypeDual is the type of BlockDual.
    72  	TypeDual = "BlockDual"
    73  	// TypeLock is the type of SelectLock.
    74  	TypeLock = "SelectLock"
    75  	// TypeInsert is the type of Insert
    76  	TypeInsert = "Insert"
    77  	// TypeUFIDelate is the type of UFIDelate.
    78  	TypeUFIDelate = "UFIDelate"
    79  	// TypeDelete is the type of Delete.
    80  	TypeDelete = "Delete"
    81  	// TypeIndexLookUp is the type of IndexLookUp.
    82  	TypeIndexLookUp = "IndexLookUp"
    83  	// TypeBlockReader is the type of BlockReader.
    84  	TypeBlockReader = "BlockReader"
    85  	// TypeIndexReader is the type of IndexReader.
    86  	TypeIndexReader = "IndexReader"
    87  	// TypeWindow is the type of Window.
    88  	TypeWindow = "Window"
    89  	// TypeShuffle is the type of Shuffle.
    90  	TypeShuffle = "Shuffle"
    91  	// TypeShuffleDataSourceStub is the type of Shuffle.
    92  	TypeShuffleDataSourceStub = "ShuffleDataSourceStub"
    93  	// TypeEinsteinDBSingleGather is the type of EinsteinDBSingleGather.
    94  	TypeEinsteinDBSingleGather = "EinsteinDBSingleGather"
    95  	// TypeIndexMerge is the type of IndexMergeReader
    96  	TypeIndexMerge = "IndexMerge"
    97  	// TypePointGet is the type of PointGetCauset.
    98  	TypePointGet = "Point_Get"
    99  	// TypeShowDBSJobs is the type of show dbs jobs.
   100  	TypeShowDBSJobs = "ShowDBSJobs"
   101  	// TypeBatchPointGet is the type of BatchPointGetCauset.
   102  	TypeBatchPointGet = "Batch_Point_Get"
   103  	// TypeClusterMemBlockReader is the type of BlockReader.
   104  	TypeClusterMemBlockReader = "ClusterMemBlockReader"
   105  	// TypeDataSource is the type of DataSource.
   106  	TypeDataSource = "DataSource"
   107  )
   108  
   109  // plan id.
   110  // Attention: for compatibility of encode/decode plan, The plan id shouldn't be changed.
   111  const (
   112  	typeSelID                 int = 1
   113  	typeSetID                 int = 2
   114  	typeProjID                int = 3
   115  	typeAggID                 int = 4
   116  	typeStreamAggID           int = 5
   117  	typeHashAggID             int = 6
   118  	typeShowID                int = 7
   119  	typeJoinID                int = 8
   120  	typeUnionID               int = 9
   121  	typeBlockScanID           int = 10
   122  	typeMemBlockScanID        int = 11
   123  	typeUnionScanID           int = 12
   124  	typeIdxScanID             int = 13
   125  	typeSortID                int = 14
   126  	typeTopNID                int = 15
   127  	typeLimitID               int = 16
   128  	typeHashJoinID            int = 17
   129  	typeMergeJoinID           int = 18
   130  	typeIndexJoinID           int = 19
   131  	typeIndexMergeJoinID      int = 20
   132  	typeIndexHashJoinID       int = 21
   133  	typeApplyID               int = 22
   134  	typeMaxOneRowID           int = 23
   135  	typeExistsID              int = 24
   136  	typeDualID                int = 25
   137  	typeLockID                int = 26
   138  	typeInsertID              int = 27
   139  	typeUFIDelateID              int = 28
   140  	typeDeleteID              int = 29
   141  	typeIndexLookUpID         int = 30
   142  	typeBlockReaderID         int = 31
   143  	typeIndexReaderID         int = 32
   144  	typeWindowID              int = 33
   145  	typeEinsteinDBSingleGatherID    int = 34
   146  	typeIndexMergeID          int = 35
   147  	typePointGet              int = 36
   148  	typeShowDBSJobs           int = 37
   149  	typeBatchPointGet         int = 38
   150  	typeClusterMemBlockReader int = 39
   151  	typeDataSourceID          int = 40
   152  )
   153  
   154  // TypeStringToPhysicalID converts the plan type string to plan id.
   155  func TypeStringToPhysicalID(tp string) int {
   156  	switch tp {
   157  	case TypeSel:
   158  		return typeSelID
   159  	case TypeSet:
   160  		return typeSetID
   161  	case TypeProj:
   162  		return typeProjID
   163  	case TypeAgg:
   164  		return typeAggID
   165  	case TypeStreamAgg:
   166  		return typeStreamAggID
   167  	case TypeHashAgg:
   168  		return typeHashAggID
   169  	case TypeShow:
   170  		return typeShowID
   171  	case TypeJoin:
   172  		return typeJoinID
   173  	case TypeUnion:
   174  		return typeUnionID
   175  	case TypeBlockScan:
   176  		return typeBlockScanID
   177  	case TypeMemBlockScan:
   178  		return typeMemBlockScanID
   179  	case TypeUnionScan:
   180  		return typeUnionScanID
   181  	case TypeIdxScan:
   182  		return typeIdxScanID
   183  	case TypeSort:
   184  		return typeSortID
   185  	case TypeTopN:
   186  		return typeTopNID
   187  	case TypeLimit:
   188  		return typeLimitID
   189  	case TypeHashJoin:
   190  		return typeHashJoinID
   191  	case TypeMergeJoin:
   192  		return typeMergeJoinID
   193  	case TypeIndexJoin:
   194  		return typeIndexJoinID
   195  	case TypeIndexMergeJoin:
   196  		return typeIndexMergeJoinID
   197  	case TypeIndexHashJoin:
   198  		return typeIndexHashJoinID
   199  	case TypeApply:
   200  		return typeApplyID
   201  	case TypeMaxOneRow:
   202  		return typeMaxOneRowID
   203  	case TypeExists:
   204  		return typeExistsID
   205  	case TypeDual:
   206  		return typeDualID
   207  	case TypeLock:
   208  		return typeLockID
   209  	case TypeInsert:
   210  		return typeInsertID
   211  	case TypeUFIDelate:
   212  		return typeUFIDelateID
   213  	case TypeDelete:
   214  		return typeDeleteID
   215  	case TypeIndexLookUp:
   216  		return typeIndexLookUpID
   217  	case TypeBlockReader:
   218  		return typeBlockReaderID
   219  	case TypeIndexReader:
   220  		return typeIndexReaderID
   221  	case TypeWindow:
   222  		return typeWindowID
   223  	case TypeEinsteinDBSingleGather:
   224  		return typeEinsteinDBSingleGatherID
   225  	case TypeIndexMerge:
   226  		return typeIndexMergeID
   227  	case TypePointGet:
   228  		return typePointGet
   229  	case TypeShowDBSJobs:
   230  		return typeShowDBSJobs
   231  	case TypeBatchPointGet:
   232  		return typeBatchPointGet
   233  	case TypeClusterMemBlockReader:
   234  		return typeClusterMemBlockReader
   235  	case TypeDataSource:
   236  		return typeDataSourceID
   237  	}
   238  	// Should never reach here.
   239  	return 0
   240  }
   241  
   242  // PhysicalIDToTypeString converts the plan id to plan type string.
   243  func PhysicalIDToTypeString(id int) string {
   244  	switch id {
   245  	case typeSelID:
   246  		return TypeSel
   247  	case typeSetID:
   248  		return TypeSet
   249  	case typeProjID:
   250  		return TypeProj
   251  	case typeAggID:
   252  		return TypeAgg
   253  	case typeStreamAggID:
   254  		return TypeStreamAgg
   255  	case typeHashAggID:
   256  		return TypeHashAgg
   257  	case typeShowID:
   258  		return TypeShow
   259  	case typeJoinID:
   260  		return TypeJoin
   261  	case typeUnionID:
   262  		return TypeUnion
   263  	case typeBlockScanID:
   264  		return TypeBlockScan
   265  	case typeMemBlockScanID:
   266  		return TypeMemBlockScan
   267  	case typeUnionScanID:
   268  		return TypeUnionScan
   269  	case typeIdxScanID:
   270  		return TypeIdxScan
   271  	case typeSortID:
   272  		return TypeSort
   273  	case typeTopNID:
   274  		return TypeTopN
   275  	case typeLimitID:
   276  		return TypeLimit
   277  	case typeHashJoinID:
   278  		return TypeHashJoin
   279  	case typeMergeJoinID:
   280  		return TypeMergeJoin
   281  	case typeIndexJoinID:
   282  		return TypeIndexJoin
   283  	case typeIndexMergeJoinID:
   284  		return TypeIndexMergeJoin
   285  	case typeIndexHashJoinID:
   286  		return TypeIndexHashJoin
   287  	case typeApplyID:
   288  		return TypeApply
   289  	case typeMaxOneRowID:
   290  		return TypeMaxOneRow
   291  	case typeExistsID:
   292  		return TypeExists
   293  	case typeDualID:
   294  		return TypeDual
   295  	case typeLockID:
   296  		return TypeLock
   297  	case typeInsertID:
   298  		return TypeInsert
   299  	case typeUFIDelateID:
   300  		return TypeUFIDelate
   301  	case typeDeleteID:
   302  		return TypeDelete
   303  	case typeIndexLookUpID:
   304  		return TypeIndexLookUp
   305  	case typeBlockReaderID:
   306  		return TypeBlockReader
   307  	case typeIndexReaderID:
   308  		return TypeIndexReader
   309  	case typeWindowID:
   310  		return TypeWindow
   311  	case typeEinsteinDBSingleGatherID:
   312  		return TypeEinsteinDBSingleGather
   313  	case typeIndexMergeID:
   314  		return TypeIndexMerge
   315  	case typePointGet:
   316  		return TypePointGet
   317  	case typeShowDBSJobs:
   318  		return TypeShowDBSJobs
   319  	case typeBatchPointGet:
   320  		return TypeBatchPointGet
   321  	case typeClusterMemBlockReader:
   322  		return TypeClusterMemBlockReader
   323  	}
   324  
   325  	// Should never reach here.
   326  	return "UnknownCausetID" + strconv.Itoa(id)
   327  }