ColumnIndex finds the index for a column.
(col *Column)
| 162 | |
| 163 | // ColumnIndex finds the index for a column. |
| 164 | func (s *Schema) ColumnIndex(col *Column) int { |
| 165 | backupIdx := -1 |
| 166 | for i, c := range s.Columns { |
| 167 | if c.UniqueID == col.UniqueID { |
| 168 | backupIdx = i |
| 169 | if c.IsPrefix { |
| 170 | // instead of returning a prefix column |
| 171 | // prefer to find a full column |
| 172 | // only clustered index table can meet this: |
| 173 | // same column `c1` maybe appear in both primary key and secondary index |
| 174 | // so secondary index itself can have two `c1` column one for indexKey and one for handle |
| 175 | continue |
| 176 | } |
| 177 | return i |
| 178 | } |
| 179 | } |
| 180 | return backupIdx |
| 181 | } |
| 182 | |
| 183 | // Contains checks if the schema contains the column. |
| 184 | func (s *Schema) Contains(col *Column) bool { |
no outgoing calls