-
Notifications
You must be signed in to change notification settings - Fork 109
sql/index/pilosa: return all index ids in lookups #586
Conversation
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
sql/index/pilosa/lookup.go
Outdated
@@ -63,6 +64,7 @@ type ( | |||
keys []interface{} | |||
expressions []string | |||
operations []*lookupOperation | |||
indexes []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be map[string]int
, where key is an index name and value will be order id.
So we'll have auto-uniques (because of map), and then we can sort map entries by value, sth. like:
m := make(map[string]int)
m[indexName] = len(m)
//...
indexes := make([]string, len(m))
for k, v := range m {
index[v] = k
}
//...
return indexes
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the int
? We can just use a map[string]struct{}
and then sort them.
Also, even if indexes
is a map, it may not be unique, because id
can be inside that map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int just because we can store in what order we "got" indexes, so at the end you can just re-write it into the slice in the values order (instead of sorting, first).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is how do we want to show indexes (sorted in the order how filter was parsed, or sorted by name)?
On the other hand, these are "small" numbers so most likely keep the most readable version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will use the struct{}
only because the int requires some explanation at first sight and the other doesn't. Regarding the order, I think it does not matter much, so we can just sort.
The thing is: with a map we start requiring constructors and so on and before you could just &indexLookup{id: whatever}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so let's keep it what we have so far. I suppose, there is no many cases where we'll use the same index more than once, so maybe map can be kind of overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after @kuba-- comments
Done, though I think it unnecessarily complicates the code for very little gain. |
Btw, we have to fix old "merge" tests: https://github.com/src-d/go-mysql-server/pull/586/files#diff-136ffc4118af2fd83a7cbf2bc27fe357R215 |
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
abc02f0
to
71a114a
Compare
Fixes #585