New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lookup with missing attributes #685
Comments
Alternatively, we could make |
Ok, let's compare a couple of approaches. First, current code for optimized scans (which is pasted here to serve as a baseline): case "e***":
this.setProposal(curIndex.eavIndex.lookup(e), this.a, scopeIx);
break;
case "ea**":
this.setProposal(curIndex.eavIndex.lookup(e,a), this.v, scopeIx);
break;
case "eav*":
this.setProposal(curIndex.eavIndex.lookup(e,a,v), this.node, scopeIx);
break;
case "*a**":
this.setProposal(curIndex.aveIndex.lookup(a), this.v, scopeIx);
break;
case "*av*":
this.setProposal(curIndex.aveIndex.lookup(a,v), this.e, scopeIx);
break;
case "***n":
this.setProposal(curIndex.neavIndex.lookup(node), this.e, scopeIx);
break;
case "e**n":
this.setProposal(curIndex.neavIndex.lookup(node,e), this.a, scopeIx);
break;
case "ea*n":
this.setProposal(curIndex.neavIndex.lookup(node,e,a), this.v, scopeIx);
break; Let's compare with using '_' to denote a missing variable. The same optimized scans will look like case "e*__":
case "e**_":
case "e*_*":
case "e***":
this.setProposal(curIndex.eavIndex.lookup(e), this.a, scopeIx);
break;
case "ea*_":
case "ea**":
this.setProposal(curIndex.eavIndex.lookup(e,a), this.v, scopeIx);
break;
case "eav*":
this.setProposal(curIndex.eavIndex.lookup(e,a,v), this.node, scopeIx);
break;
case "_a*_":
case "_a**":
case "*a*_":
case "*a**":
this.setProposal(curIndex.aveIndex.lookup(a), this.v, scopeIx);
break;
case "*av_":
case "*av*":
this.setProposal(curIndex.aveIndex.lookup(a,v), this.e, scopeIx);
break;
case "*__n":
case "*_*n":
case "**_n":
case "***n":
this.setProposal(curIndex.neavIndex.lookup(node), this.e, scopeIx);
break;
case "e*_n":
case "e**n":
this.setProposal(curIndex.neavIndex.lookup(node,e), this.a, scopeIx);
break;
case "ea*n":
this.setProposal(curIndex.neavIndex.lookup(node,e,a), this.v, scopeIx);
break; But in addition there will be new cases where intermediate variables are missing (I mean the situation like I'm separating these cases from optimized ones since we can't use an exact cardinality for If there were estimates for each level of index (like there is a And if indeed And if we will use a case "e***":
indexPos = curIndex.eavIndex.lookup(e)
indexVar = this.a
break;
case "ea**":
indexPos = curIndex.eavIndex.lookup(e,a)
indexVar = this.v
break;
case "eav*":
indexPos = curIndex.eavIndex.lookup(e,a,v)
indexVar = this.node
break;
case "*a**":
indexPos = curIndex.aveIndex.lookup(a)
indexVar = this.v
break;
case "*av*":
indexPos = curIndex.aveIndex.lookup(a,v)
indexVar = this.e
break;
case "***n":
indexPos = curIndex.neavIndex.lookup(node)
indexVar = this.e
break;
case "e**n":
indexPos = curIndex.neavIndex.lookup(node,e)
indexVar = this.a
break;
case "ea*n":
indexPos = curIndex.neavIndex.lookup(node,e,a)
indexVar = this.v
break; if (indexVar) {
this.setProposal(indexPos, indexVar, scopeIx);
} else {
// proposal for optimized fullscan (which will use appropriate index (indexPos) and appropriate depth)
} What do you think? |
Seems like solid reasoning. I think this is a relatively rare case as is, so I'm not sure it makes too much of a difference anyways. I agree that we should try to stick to the simpler approach, which is what it sounds like you're advocating for :) As an aside, we should make |
Good idea with ave-index 👍 Regarding the simplest approach, it will depend on whether an optimized full-scan (which will pick the best index based on present variables) will be useful in other contexts. If yes, then adding support for partial lookups via full-scan will be simple (the complex part is optimized full-scan) and efficient way to go. If no, then usual variables are the simplest approach (even though not efficient). Judging by your previous comment in another PR it seems optimized full-scan will be useful. But still would like to have your official confirmation on this :-) |
Nevermind, I'll send the PR today, and you'll decide then :-) |
Hello,
As I've previously mentioned in #611 (comment), currently
lookup
works only if record-attribute-value or record-attribute-value-node specified. If any of record/attribute/value is missing thenlookup
will break.There are multiple ways to fix it.
For example, substitute missing parts with new variables brainopia@0d8209a. But then unnecessary variables will be solved for.
Or introduce hidden variables brainopia@c32bbd1 then only intermediate hidden variables that are needed will be solved for. But there is still overhead from extra round solving wasted on intermediate variables instead of solving directly appropriate variables at once.
A faster approach would look like brainopia@692024d but since it relies on full-scan when missing variable is solved for, it'd need a full-scan optimization like @ibdknox mentioned at #611 (review). If we decide to pursue this approach I'll update full-scan implementation with appropriate index selection. The main disadvantage is that it requires more changes compared with previous approaches.
So which way would you prefer to fix this? I'll prepare the appropriate PR after you decide.
The text was updated successfully, but these errors were encountered: