You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
QueryGraph edge-explorer cache does not work for edge-based CH. #1623
will return the same edge-explorer instance for all subsequent calls of DefaultEdgeFilter.inEdges, DefaultEdgeFilter.outEdges, DefaultEdgeFilter.allEdges and EdgeFilter.ALL_EDGES (for each of these filters there will be a separate edge-explorer instance).
The problem is that in some cases we explicitly need to create two different instances for the same filter. This is not needed very often, but for example here:
there is a nested loop over edge iterators where the 'inner' explorer must be different to the 'outer' one.
Because of this using the edge-explorer cache with edge-based CH fails at the moment.
I started adding a test for the query graph behavior here: 58e7ac1, but so far it does not show much, obviously if we use the same instance of the edge explorer within an inner loop the outer loop will be messed up.
Maybe add a second parameter to createEdgeExplorer that is used as an 'id' to identify the explorer ?
EdgeExplorer createEdgeExplorer(EdgeFilter filter) {
return createEdgeExplorer(filter, DEFAULT_ID);
}
EdgeExplorer createEdgeExplorer(EdgeFilter filter, int explorerId) {
// use the filter type like we do so far, but also take into account the explorerId to identify the explorer
}
Not very pretty thats for sure, but we would need a way to express that we want another instance (and ideally this other instance would still be cached / we do not want another instance for every call).
but at least the query graph cache is described as an 'experimental' feature at the moment :)
Ups, you are right. (please remove whenever you like :) )
The problem is that in some cases we explicitly need to create two different instances for the same filter
Did you mean the same edge explorer for two different filters? (Because we should return two different instances for the two different filters "inEdges" and "outEdges")
Did you mean the same edge explorer for two different filters?
No I mean two different explorers for the same filter. Sure there are different instances if we first use an inEdge and then an outEdge filter. But here the problem is that for example we need two different explorers for the inEdge filter.
What about instead of two methods DefaultEdgeFilter.acceptsForward/acceptsBackward creating the unique integer in QueryGraph via using just one hashCode() method? Then for these special cases we could overload them or do
EdgeExplorerexp1 = graph.createEdgeExplorer(DefaultEdgeFilter.inEdges(1));
EdgeExplorerexp2 = graph.createEdgeExplorer(DefaultEdgeFilter.inEdges(2/* forces different EdgeExplorer instance*/));
// DefaultEdgeFilter:inthashCode() {
intval = additionalValue; // in this example 1 or 2if (acceptsBackward())
val += 1;
if (acceptsForward())
val += 2;
...
returnval;
}
We could then also make this independent of the DefaultEdgeFilter via a CachableEdgeFilter interface or something.
if query graph cache is enabled createEdgeExplorer returns the same instance for all filters that are equal in the equals/java sense. This caching mechanism will become independent of DefaultEdgeFilter etc.
provide creator, hashCode and equals methods for DefaultEdgeFilter as you suggested so it is easy to create equal instances of the different default edge filter at different code locations.
Is this what you meant ? I do not think we need a CacheableEdgeFilter and we would also get rid of the previous limitation that the caching did not work for custom filters. To use createEdgeExplorer with the query graph cache one would only have to make sure that equals does what it should for the custom filter.
Activity
easbar commentedon May 27, 2019
Was about to add the 'bug' label, but at least the query graph cache is described as an 'experimental' feature at the moment :)
easbar commentedon May 27, 2019
Maybe add a second parameter to
createEdgeExplorerthat is used as an 'id' to identify the explorer ?Not very pretty thats for sure, but we would need a way to express that we want another instance (and ideally this other instance would still be cached / we do not want another instance for every call).
karussell commentedon May 27, 2019
Ups, you are right. (please remove whenever you like :) )
Did you mean the same edge explorer for two different filters? (Because we should return two different instances for the two different filters "inEdges" and "outEdges")
easbar commentedon May 27, 2019
no no its fine ;)
No I mean two different explorers for the same filter. Sure there are different instances if we first use an inEdge and then an outEdge filter. But here the problem is that for example we need two different explorers for the inEdge filter.
Obviously if
exp1==exp2this will fail / do something very unexpected.karussell commentedon May 27, 2019
What about instead of two methods DefaultEdgeFilter.acceptsForward/acceptsBackward creating the unique integer in QueryGraph via using just one hashCode() method? Then for these special cases we could overload them or do
We could then also make this independent of the DefaultEdgeFilter via a CachableEdgeFilter interface or something.
easbar commentedon May 27, 2019
Yeah, I like the idea. So two things basically:
if query graph cache is enabled
createEdgeExplorerreturns the same instance for all filters that are equal in theequals/java sense. This caching mechanism will become independent ofDefaultEdgeFilteretc.provide creator, hashCode and equals methods for
DefaultEdgeFilteras you suggested so it is easy to create equal instances of the different default edge filter at different code locations.Is this what you meant ? I do not think we need a
CacheableEdgeFilterand we would also get rid of the previous limitation that the caching did not work for custom filters. To usecreateEdgeExplorerwith the query graph cache one would only have to make sure thatequalsdoes what it should for the custom filter.karussell commentedon May 27, 2019
Much clearer for me now due to your explanation, but yes 👍