github.com/dolthub/go-mysql-server@v0.18.0/memory/index_driver.go (about) 1 // Copyright 2020-2021 Dolthub, 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 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package memory 16 17 import ( 18 "github.com/dolthub/go-mysql-server/sql" 19 ) 20 21 const IndexDriverId = "MemoryIndexDriver" 22 23 // TestIndexDriver is a non-performant index driver meant to aid in verification of engine correctness. It can not 24 // create or delete indexes, but will use the index types defined in this package to alter how queries are executed, 25 // retrieving values from the indexes rather than from the tables directly. 26 type TestIndexDriver struct { 27 db string 28 indexes map[string][]sql.DriverIndex 29 } 30 31 // NewIndexDriver returns a new index driver for database and the indexes given, keyed by the table name. 32 func NewIndexDriver(db string, indexes map[string][]sql.DriverIndex) *TestIndexDriver { 33 return &TestIndexDriver{db: db, indexes: indexes} 34 } 35 36 func (d *TestIndexDriver) ID() string { 37 return IndexDriverId 38 } 39 40 func (d *TestIndexDriver) LoadAll(ctx *sql.Context, db, table string) ([]sql.DriverIndex, error) { 41 if d.db != db { 42 return nil, nil 43 } 44 return d.indexes[table], nil 45 } 46 47 func (d *TestIndexDriver) Save(*sql.Context, sql.DriverIndex, sql.PartitionIndexKeyValueIter) error { 48 panic("not implemented") 49 } 50 51 func (d *TestIndexDriver) Delete(sql.DriverIndex, sql.PartitionIter) error { 52 panic("not implemented") 53 } 54 55 func (d *TestIndexDriver) Create(db, table, id string, expressions []sql.Expression, config map[string]string) (sql.DriverIndex, error) { 56 panic("not implemented") 57 }