提交 76d268fb authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Convert duplicate anonymous classes in TableFilter to nested for reuse

上级 03e45626
...@@ -664,18 +664,9 @@ public class TableFilter implements ColumnResolver { ...@@ -664,18 +664,9 @@ public class TableFilter implements ColumnResolver {
if (on != null) { if (on != null) {
on.mapColumns(this, 0); on.mapColumns(this, 0);
if (session.getDatabase().getSettings().nestedJoins) { if (session.getDatabase().getSettings().nestedJoins) {
visit(new TableFilterVisitor() { TableFilterVisitor visitor = new MapColumnsVisitor(on);
@Override visit(visitor);
public void accept(TableFilter f) { filter.visit(visitor);
on.mapColumns(f, 0);
}
});
filter.visit(new TableFilterVisitor() {
@Override
public void accept(TableFilter f) {
on.mapColumns(f, 0);
}
});
} }
} }
if (nested && session.getDatabase().getSettings().nestedJoins) { if (nested && session.getDatabase().getSettings().nestedJoins) {
...@@ -685,12 +676,7 @@ public class TableFilter implements ColumnResolver { ...@@ -685,12 +676,7 @@ public class TableFilter implements ColumnResolver {
nestedJoin = filter; nestedJoin = filter;
filter.joinOuter = outer; filter.joinOuter = outer;
if (outer) { if (outer) {
visit(new TableFilterVisitor() { visit(new JOIVisitor());
@Override
public void accept(TableFilter f) {
f.joinOuterIndirect = true;
}
});
} }
if (on != null) { if (on != null) {
filter.mapAndAddFilter(on); filter.mapAndAddFilter(on);
...@@ -701,12 +687,7 @@ public class TableFilter implements ColumnResolver { ...@@ -701,12 +687,7 @@ public class TableFilter implements ColumnResolver {
filter.joinOuter = outer; filter.joinOuter = outer;
if (session.getDatabase().getSettings().nestedJoins) { if (session.getDatabase().getSettings().nestedJoins) {
if (outer) { if (outer) {
filter.visit(new TableFilterVisitor() { filter.visit(new JOIVisitor());
@Override
public void accept(TableFilter f) {
f.joinOuterIndirect = true;
}
});
} }
} else { } else {
if (outer) { if (outer) {
...@@ -1219,4 +1200,34 @@ public class TableFilter implements ColumnResolver { ...@@ -1219,4 +1200,34 @@ public class TableFilter implements ColumnResolver {
*/ */
void accept(TableFilter f); void accept(TableFilter f);
} }
/**
* A visitor that maps columns.
*/
private static final class MapColumnsVisitor implements TableFilterVisitor {
private final Expression on;
MapColumnsVisitor(Expression on) {
this.on = on;
}
@Override
public void accept(TableFilter f) {
on.mapColumns(f, 0);
}
}
/**
* A visitor that sets joinOuterIndirect to true.
*/
private static final class JOIVisitor implements TableFilterVisitor {
JOIVisitor() {
}
@Override
public void accept(TableFilter f) {
f.joinOuterIndirect = true;
}
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论