Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Ld index bugs #865

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
7600222
Fixed a bug in index assignments involving a where clause for indexes…
zachmu Oct 28, 2019
96e4761
Fixed misspelling in unmergeable.
zachmu Oct 28, 2019
1643ae7
Moved index types out of the main test package, with the intention of…
zachmu Oct 28, 2019
120ddc0
Added tests for getIndexes for or and in for various mergeable and un…
zachmu Oct 28, 2019
1b35295
Apparently forgot how to name go files
zachmu Oct 28, 2019
5074435
Closer to adding an index driver to engine test. Factored out a metho…
zachmu Oct 29, 2019
5409063
Checkpoint. Realizing that the in-memory databases and the index impl…
zachmu Oct 29, 2019
1c8fd6f
Moved index implementations to the memory package, made engine_test r…
zachmu Oct 29, 2019
79f34fb
First pass at complete index.Values implementation. This just iterate…
zachmu Oct 30, 2019
cc69039
Finally have a failing test case with new index driver.
zachmu Oct 30, 2019
5545932
Reverted failing buggy code in assign_indexes.go after verifying new …
zachmu Oct 31, 2019
f3cb328
Fixed bug in assign_indexes for or statements
zachmu Oct 31, 2019
39bfdb8
Added some more test indexes, fixed a bug where I wasn't correctly al…
zachmu Oct 31, 2019
dbc915d
Better mechanism for sharing dummy index value iter code
zachmu Nov 1, 2019
63090f1
Dummy indexValueIter
zachmu Nov 1, 2019
1986999
assign index tests now compiling, trying to get them passing
zachmu Nov 1, 2019
dc6dc0e
Patching up all the tests with the new memory index implementations
zachmu Nov 1, 2019
6c622a1
More progress on getting the tests to pass. Now to clean up the union…
zachmu Nov 1, 2019
fa72192
Fixed PK NN behavior to match MySQL
Hydrocharged Nov 1, 2019
e82528c
Mostly formatting changes, about to attmpe to get rid of MergableIndex
zachmu Nov 4, 2019
8c0102b
Better version of union and intersection. Still have bugs
zachmu Nov 4, 2019
78e8b08
Separated out intersection and union logic again
zachmu Nov 4, 2019
b3534e3
Updated expected test result for squashed union logic
zachmu Nov 4, 2019
5ecc6bb
Fixed another test (error in expected value declaration)
zachmu Nov 4, 2019
1bd5bc9
One more fixed test
zachmu Nov 4, 2019
966fd5a
One more fixed test (misunderstood the semantics of union / intersect…
zachmu Nov 4, 2019
aee8179
Fixed remaining tests for assign_indexes
zachmu Nov 4, 2019
8ccf639
Added a second kind of index driver to engine tests. Still getting al…
zachmu Nov 5, 2019
7b8c17b
Fixed several NPEs in tests
zachmu Nov 5, 2019
5894576
All tests running with mergable indexes without panics. Now to fix fa…
zachmu Nov 5, 2019
feb7eaf
Fixed a couple typos in ascend / descend, which fixed the last of the…
zachmu Nov 5, 2019
e97734a
Fixed timezone bug in time_test.go
zachmu Nov 5, 2019
0d85dd3
Fixing up index assignment tests broken by the addition of new fields…
zachmu Nov 5, 2019
7d34f8d
Fixed the remaining GetIndexes tests.
zachmu Nov 5, 2019
a0434f8
Fixed last of failing index tests
zachmu Nov 5, 2019
74ad438
Fixed pushdown test
zachmu Nov 5, 2019
99566c9
Amended comment in pushdown_test
zachmu Nov 5, 2019
c18edf9
Removed unncessary slice of expressions for row matching
zachmu Nov 5, 2019
2f78b7f
Cleaned up and added better comments on a couple types
zachmu Nov 5, 2019
cc348d5
Renamed UnmergeableDummyIndex and MergeableDummyIndex to remove the D…
zachmu Nov 5, 2019
d166b52
Standardized panic messages
zachmu Nov 6, 2019
697bc20
Merge pull request #22 from liquidata-inc/zachmu/index-or-bug-fix
zachmu Nov 6, 2019
5914125
Removed unused variable assignments
zachmu Nov 6, 2019
148b4e2
Merge pull request #23 from liquidata-inc/zachmu/index-or-bug-fix
zachmu Nov 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 217 additions & 51 deletions engine_test.go

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions memory/ascend_index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package memory

import (
"github.com/src-d/go-mysql-server/sql"
"github.com/src-d/go-mysql-server/sql/expression"
)

type AscendIndexLookup struct {
id string
Gte []interface{}
Lt []interface{}
Index ExpressionsIndex
}

var _ memoryIndexLookup = (*AscendIndexLookup)(nil)

func (l *AscendIndexLookup) ID() string { return l.id }

func (l *AscendIndexLookup) Values(p sql.Partition) (sql.IndexValueIter, error) {
return &indexValIter{
tbl: l.Index.MemTable(),
partition: p,
matchExpression: l.EvalExpression(),
}, nil
}

func (l *AscendIndexLookup) Indexes() []string {
return []string{l.id}
}

func (l *AscendIndexLookup) IsMergeable(lookup sql.IndexLookup) bool {
_, ok := lookup.(MergeableLookup)
return ok
}

func (l *AscendIndexLookup) Union(lookups ...sql.IndexLookup) sql.IndexLookup {
return union(l.Index, l, lookups...)
}

func (l *AscendIndexLookup) EvalExpression() sql.Expression {
if len(l.Index.ColumnExpressions()) > 1 {
panic("Ascend index unsupported for multi-column indexes")
}

lt, typ := getType(l.Lt[0])
ltexpr := expression.NewLessThan(l.Index.ColumnExpressions()[0], expression.NewLiteral(lt, typ))
if len(l.Gte) > 0 {
gte, _ := getType(l.Gte[0])
return and(
ltexpr,
expression.NewGreaterThanOrEqual(l.Index.ColumnExpressions()[0], expression.NewLiteral(gte, typ)),
)
}
return ltexpr
}

func (*AscendIndexLookup) Difference(...sql.IndexLookup) sql.IndexLookup {
panic("ascendIndexLookup.Difference is not implemented")
}

func (l *AscendIndexLookup) Intersection(lookups ...sql.IndexLookup) sql.IndexLookup {
return intersection(l.Index, l, lookups...)
}
64 changes: 64 additions & 0 deletions memory/descend_index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package memory

import (
"github.com/src-d/go-mysql-server/sql"
"github.com/src-d/go-mysql-server/sql/expression"
)

type DescendIndexLookup struct {
id string
Gt []interface{}
Lte []interface{}
Index ExpressionsIndex
}

var _ memoryIndexLookup = (*DescendIndexLookup)(nil)

func (l *DescendIndexLookup) ID() string { return l.id }

func (l *DescendIndexLookup) Values(p sql.Partition) (sql.IndexValueIter, error) {
return &indexValIter{
tbl: l.Index.MemTable(),
partition: p,
matchExpression: l.EvalExpression(),
}, nil
}

func (l *DescendIndexLookup) EvalExpression() sql.Expression {
if len(l.Index.ColumnExpressions()) > 1 {
panic("Descend index unsupported for multi-column indexes")
}

gt, typ := getType(l.Gt[0])
gtexpr := expression.NewGreaterThan(l.Index.ColumnExpressions()[0], expression.NewLiteral(gt, typ))
if len(l.Lte) > 0 {
lte, _ := getType(l.Lte[0])
return and(
gtexpr,
expression.NewLessThanOrEqual(l.Index.ColumnExpressions()[0], expression.NewLiteral(lte, typ)),
)
}
return gtexpr
}

func (l *DescendIndexLookup) Indexes() []string {
return []string{l.id}
}

func (l *DescendIndexLookup) IsMergeable(lookup sql.IndexLookup) bool {
_, ok := lookup.(MergeableLookup)
return ok
}

func (l *DescendIndexLookup) Union(lookups ...sql.IndexLookup) sql.IndexLookup {
return union(l.Index, l, lookups...)
}

func (*DescendIndexLookup) Difference(...sql.IndexLookup) sql.IndexLookup {
panic("descendIndexLookup.Difference is not implemented")
}

func (l *DescendIndexLookup) Intersection(lookups ...sql.IndexLookup) sql.IndexLookup {
return intersection(l.Index, l, lookups...)
}

43 changes: 43 additions & 0 deletions memory/index_driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package memory

import (
"github.com/src-d/go-mysql-server/sql"
)

const IndexDriverId = "MemoryIndexDriver"

// TestIndexDriver is a non-performant index driver meant to aid in verification of engine correctness. It can not
// create or delete indexes, but will use the index types defined in this package to alter how queries are executed,
// retrieving values from the indexes rather than from the tables directly.
type TestIndexDriver struct {
db string
indexes map[string][]sql.Index
}

// NewIndexDriver returns a new index driver for database and the indexes given, keyed by the table name.
func NewIndexDriver(db string, indexes map[string][]sql.Index) *TestIndexDriver {
return &TestIndexDriver{db: db, indexes: indexes}
}

func (d *TestIndexDriver) ID() string {
return IndexDriverId
}

func (d *TestIndexDriver) LoadAll(db, table string) ([]sql.Index, error) {
if d.db != db {
return nil, nil
}
return d.indexes[table], nil
}

func (d *TestIndexDriver) Save(*sql.Context, sql.Index, sql.PartitionIndexKeyValueIter) error {
panic("not implemented")
}

func (d *TestIndexDriver) Delete(sql.Index, sql.PartitionIter) error {
panic("not implemented")
}

func (d *TestIndexDriver) Create(db, table, id string, expressions []sql.Expression, config map[string]string) (sql.Index, error) {
panic("not implemented")
}
Loading