-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infoschema: move perfschema to infoschema directory, tiny refactor (#…
- Loading branch information
1 parent
0bc0f7d
commit 3b40b14
Showing
8 changed files
with
185 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2017 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package perfschema | ||
|
||
import ( | ||
"github.com/pingcap/parser/model" | ||
"github.com/pingcap/tidb/infoschema" | ||
"github.com/pingcap/tidb/meta/autoid" | ||
"github.com/pingcap/tidb/table" | ||
) | ||
|
||
// perfSchemaTable stands for the fake table all its data is in the memory. | ||
type perfSchemaTable struct { | ||
infoschema.VirtualTable | ||
meta *model.TableInfo | ||
cols []*table.Column | ||
} | ||
|
||
func tableFromMeta(alloc autoid.Allocator, meta *model.TableInfo) (table.Table, error) { | ||
return createPerfSchemaTable(meta), nil | ||
} | ||
|
||
// createPerfSchemaTable creates all perfSchemaTables | ||
func createPerfSchemaTable(meta *model.TableInfo) *perfSchemaTable { | ||
columns := make([]*table.Column, 0, len(meta.Columns)) | ||
for _, colInfo := range meta.Columns { | ||
col := table.ToColumn(colInfo) | ||
columns = append(columns, col) | ||
} | ||
t := &perfSchemaTable{ | ||
meta: meta, | ||
cols: columns, | ||
} | ||
return t | ||
} | ||
|
||
// Cols implements table.Table Type interface. | ||
func (vt *perfSchemaTable) Cols() []*table.Column { | ||
return vt.cols | ||
} | ||
|
||
// WritableCols implements table.Table Type interface. | ||
func (vt *perfSchemaTable) WritableCols() []*table.Column { | ||
return vt.cols | ||
} | ||
|
||
// GetID implements table.Table GetID interface. | ||
func (vt *perfSchemaTable) GetPhysicalID() int64 { | ||
return vt.meta.ID | ||
} | ||
|
||
// Meta implements table.Table Type interface. | ||
func (vt *perfSchemaTable) Meta() *model.TableInfo { | ||
return vt.meta | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.