Issue #38: Fix unrelated filters, using join

Signed-off-by: Lucas Fernandes de Oliveira's avatarLucas Fernandes de Oliveira <lfo14@inf.ufpr.br>
parent 69a6dc23
Pipeline #11506 passed with stage
in 43 seconds
......@@ -312,8 +312,8 @@ export class Graph {
const dimensions = q.dimensions;
const clauses = (q.clauses) ? q.clauses : [];
let output: View[] = [];
let verticesIds = metrics.map((met) => met.name);
verticesIds = verticesIds.concat(dimensions.map((dim) => dim.name));
let verticesIds = this.verticesInQuery(q);
for (let i = 0; i < this.vertices.length; ++i) {
// Get the vertices and set their status and parent
this.vertices[i].state = State.UNVISITED;
......@@ -364,8 +364,7 @@ export class Graph {
// Recover the list of vertices
let dimToCover = dimensions.map((dim) => dim);
let metToCover = metrics.map((met) => met);
verticesIds = metrics.map((met) => met.name);
verticesIds = verticesIds.concat(dimensions.map((dim) => dim.name));
verticesIds = this.verticesInQuery(q);
while (verticesIds.length > 0) {
// Choose a vertex and walks to his ancestors until
// reach the root, when walking this path choose
......@@ -538,4 +537,33 @@ export class Graph {
}
private verticesInQuery(q: Query): string[] {
const metrics = q.metrics;
const dimensions = q.dimensions;
const clauses = (q.clauses) ? q.clauses : [];
let verticesIds = metrics.map((met) => met.name);
verticesIds = verticesIds.concat(dimensions.map((dim) => dim.name));
for (let i = 0; i < clauses.length; ++i) {
verticesIds = verticesIds.concat(clauses[i].filters.map((filter) => {
return filter.target.name;
}));
}
const sorted = verticesIds.sort();
if (sorted.length > 0) {
const unique = [sorted[0]];
for (let i = 1; i < sorted.length; ++i) {
if (sorted[i - 1] !== sorted[i]) {
unique.push(sorted[i]);
}
}
return unique;
}
else {
return [];
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment