-
Notifications
You must be signed in to change notification settings - Fork 3
Conversation
Totktonada
commented
Mar 3, 2018
- Fixes Support index lookup by partial value #30.
- Fixes Improve algorithm of choosing an index for top-level objects #38.
26cefbc
to
5ed3cea
Compare
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.
Watched all except last two commits
@@ -1,5 +1,7 @@ | |||
#!/usr/bin/env tarantool |
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.
There is a typo in commit message (tarantoo) 08529e9
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.
Fixed.
test/shard_servers/master.lua
Outdated
@@ -1,5 +1,7 @@ | |||
#!/usr/bin/env tarantool | |||
|
|||
shard_initialized = false |
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.
Can the variable be local for the module?
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.
Thanks! Fixed.
local variables_1_3 = {user_str = 'user_str_b'} | ||
local result = gql_query_1:execute(variables_1_3) | ||
results = results .. print_and_return( | ||
('RESULT\n%s'):format(yaml.encode(result))) |
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.
Please, If you write rests this way, at least give any unique identifiers to its output.
What I see in a result file is a lot of data and I can not find there the result of the particular query.
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.
Those tests do not check if new functions work correctly(
Tests on added feature needed.
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.
- Done in the latter commit.
- We check here that functionality was not broken after the change. Index lookup check depends on metainfo (Add query meta #71), will be tracked by Test we use index lookup as expected for top-level collections #72.
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.
@Khatskevich Are you about that here?
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.
👍
@@ -231,6 +231,13 @@ function compound_index_testdata.run_queries(gql_wrapper) | |||
('RESULT\n%s'):format(yaml.encode(result))) | |||
end) | |||
|
|||
utils.show_trace(function() | |||
local variables_1_3 = {user_str = 'user_str_b'} |
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.
This test tests that the result is correct (user_str is user_str_b), however, does it test if the index is really used?
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.
Will be done in the scope of non-prio1 issues, tracked by #72.
graphql/accessor_general.lua
Outdated
get_best_matched_index(successor_node, new_filter) | ||
if branch_index_name ~= nil and branch_len > max_len then | ||
index_name = branch_index_name | ||
max_len = branch_len |
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.
Should max_len = max_len + 1 be moved here?
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.
Nope. It needed for comparing branches. I’ll rename it to max_branch_len
to avoid confusion.
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.
Also I’ll change description of len
return argument as (matched parts + 1) and will describe the reason why.
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.
Moved branch_len = branch_len + 1 to here.
graphql/accessor_general.lua
Outdated
--- `value_list` | ||
--- | ||
--- @treturn table `value_list` (optional) is values list from the `filter` | ||
--- argument ordered in the such way that can be passed to the found index (has |
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.
in such way that it can be passed
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.
Fixed.
--- @treturn table `value_list` is values list from the `filter` argument | ||
--- ordered in the such way that can be passed to the found index (has some | ||
--- meaning only when `index_name ~= nil`) | ||
--- @treturn table `new_filter` is the filter value w/o values extracted into |
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 suggest name brute_filter
(or scan_filter
) for more semantics
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 generally agree that common names are bad for domain-specific things. I’ll consider post_filter
names or smth like so when there will less pending PRs.
There are related questions / points:
post_filter
(postprocessing filter) name will loose some of its meaning once we’ll support pushdown filtering to sotrage nodes.- There are two other things of the same (at least for now) structure: pivot.filter (slow case of offset) and determinator of union-type connections (Support destination_collection deducible from a parent object #8).
@@ -402,6 +441,34 @@ local function build_lookup_index_name(indexes) | |||
return lookup_index_name | |||
end | |||
|
|||
--- Build `parts_tree` to use in @{get_index_name} for lookup best matching | |||
--- index. | |||
--- |
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.
It required from me some time to get the return value structure.
I suppose it would be great if you draw small schematic image here. e.g.
transformation example
i1: f1 f2 f3 f4
i2: f1 f2 f4
become
f1--- f2 -- f3 -- f4 --> i1
`-- f4 --> i2
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.
Done.
--- @tparam table filter map of key-value to filter objects against | ||
--- | ||
--- @treturn string `index_name` or `nil` is found index | ||
--- |
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 want some information about its running time here.
I tried to calculate it and I suppose it is something like O(CNT(prefix tree nodes)*SIZE(filter)) in worst case which is good for most use cases.
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.
Added.
@@ -14,6 +14,11 @@ local function print_and_return(...) | |||
return table.concat({...}, ' ') .. '\n' | |||
end | |||
|
|||
local function format_result(name, query, variables, result) |
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.
This feature makes review process much easier)
However to make the previous commit readable, could you please move this commit on top?)
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.
Actually, I do not want you to waste your time. By now it is not important anymore.
5ed3cea
to
5550c3e
Compare
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.
Main points are negotiated verbally.
I have made minor comments, while overall it looks good enough for me.
local variables_1_3 = {user_str = 'user_str_b'} | ||
local result = gql_query_1:execute(variables_1_3) | ||
results = results .. print_and_return( | ||
('RESULT\n%s'):format(yaml.encode(result))) |
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.
👍
graphql/accessor_general.lua
Outdated
--- Future optimizations | ||
--- -------------------- | ||
--- | ||
--- * replace table.copy() with something more light (maybe 'closed set' of |
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.
We can delete item before recursive call and insert it back after
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 suspect that it is not so easy, because of pairs() invalidation.
graphql/accessor_general.lua
Outdated
--- (M * K)). Nodes count (M * K) can be limited upside as count of index | ||
--- parts in all indexes, so we have O(N^2 * COUNT(index parts)). | ||
--- | ||
--- We can consider worst case scenario when any node has any of filter keys as |
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 do not think it is useful. But it took effort and I do not insist on it's deletion.
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.
Different views on the complexity problem: dependency of filter size in context of fixed indexes or in context of worst-case indexes. Maybe it is something one should not consider.
local new_filter = table.copy(filter) | ||
new_filter[k] = nil | ||
local branch_index_name, branch_len = | ||
get_best_matched_index(successor_node, new_filter) |
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.
Please, move + 1 here
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.
Done. Still don’t see why it is better, but changed because of lack of any opinion about that.
graphql/accessor_general.lua
Outdated
--- Complexity | ||
--- ---------- | ||
--- | ||
--- In short: O(N^2 * COUNT(index parts)). |
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.
Provide here information, that n= len(filter)
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.
Done.
graphql/accessor_general.lua
Outdated
--- \ \ | ||
--- \ + --> abc | ||
--- \ | ||
--- + ------> abc --> efg --> hij |
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.
Please draw also index names as leaf nodes
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.
Leaf nodes are actually 'abc', 'hij' and so on, but I added index names.
5550c3e
to
9243e2c
Compare
The change is about code readability only, because we don't run `app = tarantool` default server from existing snapshots. No functional changes made.
The change is needed because we allow user to provide its own `get_index` function. Lack of index existence check can lead to an error that can be hard to debug.
The case described in [1]. The function proposed to including into shard in [2]. [1]: tarantool/shard#59 [2]: tarantool/shard#60
9243e2c
to
db859fa
Compare