Skip to content

Commit 3cb85c8

Browse files
committed
Fix codestyle violations, refactor tests.
1 parent 102b202 commit 3cb85c8

File tree

8 files changed

+193
-60
lines changed

8 files changed

+193
-60
lines changed

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/cursors/RecursiveCursor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@
2626
import com.apple.foundationdb.record.RecordCoreException;
2727
import com.apple.foundationdb.record.RecordCursor;
2828
import com.apple.foundationdb.record.RecordCursorContinuation;
29-
import com.apple.foundationdb.record.RecordCursorEndContinuation;
3029
import com.apple.foundationdb.record.RecordCursorProto;
3130
import com.apple.foundationdb.record.RecordCursorResult;
3231
import com.apple.foundationdb.record.RecordCursorStartContinuation;
3332
import com.apple.foundationdb.record.RecordCursorVisitor;
34-
import com.apple.foundationdb.record.query.plan.plans.QueryResult;
3533
import com.apple.foundationdb.tuple.ByteArrayUtil2;
3634
import com.google.protobuf.ByteString;
3735
import com.google.protobuf.InvalidProtocolBufferException;

fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/rules/ImplementRecursiveDfsUnionRule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import static com.apple.foundationdb.record.query.plan.cascades.matching.structure.RelationalExpressionMatchers.tempTableInsertExpression;
5555
import static com.apple.foundationdb.record.query.plan.cascades.matching.structure.SetMatcher.exactlyInAnyOrder;
5656

57+
@SuppressWarnings("PMD.TooManyStaticImports")
5758
public class ImplementRecursiveDfsUnionRule extends ImplementationCascadesRule<RecursiveUnionExpression> {
5859

5960
@Nonnull

fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/query/TempTableTestBase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import java.util.Optional;
6969
import java.util.Queue;
7070
import java.util.Random;
71-
import java.util.function.Function;
7271
import java.util.function.Supplier;
7372

7473
import static com.apple.foundationdb.record.query.plan.cascades.matching.structure.RecordQueryPlanMatchers.mapPlan;

fdb-relational-core/src/main/java/com/apple/foundationdb/relational/recordlayer/query/visitors/QueryVisitor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
import java.util.Set;
6969

7070
import static com.apple.foundationdb.relational.generated.RelationalParser.ALL;
71-
import static com.apple.foundationdb.relational.generated.RelationalParser.TRAVERSAL;
7271

7372
@API(API.Status.EXPERIMENTAL)
7473
public final class QueryVisitor extends DelegatingVisitor<BaseVisitor> {

yaml-tests/src/test/java/YamlIntegrationTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import com.apple.foundationdb.relational.yamltests.MaintainYamlTestConfig;
2222
import com.apple.foundationdb.relational.yamltests.YamlTest;
2323
import com.apple.foundationdb.relational.yamltests.YamlTestConfigFilters;
24-
import com.sun.tools.javadoc.Main;
2524
import org.junit.jupiter.api.Disabled;
26-
import org.junit.jupiter.api.Test;
2725
import org.junit.jupiter.api.TestTemplate;
2826

2927
/**

yaml-tests/src/test/resources/recursive-cte.metrics.binpb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,50 @@
175175
rankDir=LR;
176176
3 -> 4 [ color="red" style="invis" ];
177177
}
178+
}�<
179+
�
180+
recursive-cte-tests�EXPLAIN with recursive allDescendants as ( with recursive ancestorsOf250 as ( select id, parent from t1 where id = 250 union all select b.id, b.parent from ancestorsOf250 as a, t1 as b where a.parent = b.id) select id, parent from ancestorsOf250 union all select b.id, b.parent from allDescendants as a, t1 as b where a.id = b.parent) select id, parent from allDescendants�9
181+
����#� ��� (�0��8�@�RUNION-DFS q0 { RUNION-DFS q1 { ISCAN(CHILDIDX [EQUALS promote(@c20 AS LONG)]) } { RECURSIVE COVERING(PARENTIDX <,> -> [ID: KEY[1], PARENT: KEY[0]]) | FILTER q1.PARENT EQUALS _.ID | MAP (_.ID AS ID, _.PARENT AS PARENT) } | MAP (_.ID AS ID, _.PARENT AS PARENT) } { RECURSIVE COVERING(PARENTIDX <,> -> [ID: KEY[1], PARENT: KEY[0]]) | FILTER q0.ID EQUALS _.PARENT | MAP (_.ID AS ID, _.PARENT AS PARENT) } | MAP (_.ID AS ID, _.PARENT AS PARENT)�5digraph G {
182+
fontname=courier;
183+
rankdir=BT;
184+
splines=polyline;
185+
1 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Value Computation</td></tr><tr><td align="left">MAP (q38.ID AS ID, q38.PARENT AS PARENT)</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
186+
2 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Nested Loop Join</td></tr><tr><td align="left">RECURSIVE derived(q32, q34)</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
187+
3 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Value Computation</td></tr><tr><td align="left">MAP (q20.ID AS ID, q20.PARENT AS PARENT)</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
188+
4 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Value Computation</td></tr><tr><td align="left">MAP (q448.ID AS ID, q448.PARENT AS PARENT)</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
189+
5 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Nested Loop Join</td></tr><tr><td align="left">RECURSIVE derived(q14, q16)</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
190+
6 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Predicate Filter</td></tr><tr><td align="left">WHERE q26.ID EQUALS q440.PARENT</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
191+
7 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Index Scan</td></tr><tr><td align="left">comparisons: [EQUALS promote(@c20 AS LONG)]</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
192+
8 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Value Computation</td></tr><tr><td align="left">MAP (q360.ID AS ID, q360.PARENT AS PARENT)</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
193+
9 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Covering Index Scan</td></tr><tr><td align="left">range: &lt;-∞, ∞&gt;</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
194+
10 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Index</td></tr><tr><td align="left">CHILDIDX</td></tr></table>> color="black" shape="plain" style="filled" fillcolor="lightblue" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
195+
11 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Predicate Filter</td></tr><tr><td align="left">WHERE q8.PARENT EQUALS q352.ID</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
196+
12 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Index</td></tr><tr><td align="left">PARENTIDX</td></tr></table>> color="black" shape="plain" style="filled" fillcolor="lightblue" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
197+
13 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Covering Index Scan</td></tr><tr><td align="left">range: &lt;-∞, ∞&gt;</td></tr></table>> color="black" shape="plain" style="solid" fillcolor="black" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
198+
14 [ label=<<table border="0" cellborder="1" cellspacing="0" cellpadding="8"><tr><td align="left">Index</td></tr><tr><td align="left">PARENTIDX</td></tr></table>> color="black" shape="plain" style="filled" fillcolor="lightblue" fontname="courier" fontsize="8" tooltip="RELATION(LONG AS ID, LONG AS PARENT)" ];
199+
3 -> 2 [ label=<&nbsp;q32> label="q32" color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
200+
4 -> 2 [ label=<&nbsp;q34> label="q34" color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
201+
5 -> 3 [ label=<&nbsp;q20> label="q20" color="gray20" style="bold" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
202+
6 -> 4 [ label=<&nbsp;q448> label="q448" color="gray20" style="bold" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
203+
7 -> 5 [ label=<&nbsp;q14> label="q14" color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
204+
8 -> 5 [ label=<&nbsp;q16> label="q16" color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
205+
9 -> 6 [ label=<&nbsp;q440> label="q440" color="gray20" style="bold" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
206+
10 -> 7 [ color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
207+
11 -> 8 [ label=<&nbsp;q360> label="q360" color="gray20" style="bold" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
208+
12 -> 9 [ color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
209+
13 -> 11 [ label=<&nbsp;q352> label="q352" color="gray20" style="bold" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
210+
14 -> 13 [ color="gray20" style="solid" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
211+
2 -> 1 [ label=<&nbsp;q38> label="q38" color="gray20" style="bold" fontname="courier" fontsize="8" arrowhead="normal" arrowtail="none" dir="both" ];
212+
{
213+
rank=same;
214+
rankDir=LR;
215+
3 -> 4 [ color="red" style="invis" ];
216+
}
217+
{
218+
rank=same;
219+
rankDir=LR;
220+
7 -> 8 [ color="red" style="invis" ];
221+
}
178222
}�c
179223
�
180224
recursive-cte-tests�EXPLAIN with recursive (traversal = level) allDescendants as ( with recursive (traversal = level) ancestorsOf250 as ( select id, parent from t1 where id = 250 union all select b.id, b.parent from ancestorsOf250 as a, t1 as b where a.parent = b.id) select id, parent from ancestorsOf250 union all select b.id, b.parent from allDescendants as a, t1 as b where a.id = b.parent) select id, parent from allDescendants�_

yaml-tests/src/test/resources/recursive-cte.metrics.yaml

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,24 @@ recursive-cte-tests:
7272
insert_time_ms: 4
7373
insert_new_count: 318
7474
insert_reused_count: 9
75-
- query: EXPLAIN with recursive (traversal = level) allDescendants as ( with recursive
76-
(traversal = level) ancestorsOf250 as ( select id, parent from t1 where id
77-
= 250 union all select b.id, b.parent from ancestorsOf250 as a, t1 as b where
78-
a.parent = b.id) select id, parent from ancestorsOf250 union all select b.id,
79-
b.parent from allDescendants as a, t1 as b where a.id = b.parent) select id,
80-
parent from allDescendants
81-
explain: RUNION q0, q1 { INITIAL { RUNION q2, q3 { INITIAL { ISCAN(CHILDIDX [EQUALS
82-
promote(@c30 AS LONG)]) | INSERT INTO TEMP q3 } RECURSIVE { ISCAN(CHILDIDX
83-
<,>) | FLATMAP q4 -> { TEMP SCAN base() | FILTER _.PARENT EQUALS q4.ID AS
84-
q5 RETURN (q4.ID AS ID, q4.PARENT AS PARENT) } | INSERT INTO TEMP q3 }} |
85-
MAP (_.ID AS ID, _.PARENT AS PARENT) | INSERT INTO TEMP q1 } RECURSIVE {
86-
ISCAN(CHILDIDX <,>) | FLATMAP q6 -> { TEMP SCAN base() | FILTER _.ID EQUALS
87-
q6.PARENT AS q7 RETURN (q6.ID AS ID, q6.PARENT AS PARENT) } | INSERT INTO
88-
TEMP q1 }} | MAP (_.ID AS ID, _.PARENT AS PARENT)
89-
task_count: 2124
75+
- query: EXPLAIN with recursive allDescendants as ( with recursive ancestorsOf250
76+
as ( select id, parent from t1 where id = 250 union all select b.id, b.parent
77+
from ancestorsOf250 as a, t1 as b where a.parent = b.id) select id, parent
78+
from ancestorsOf250 union all select b.id, b.parent from allDescendants as
79+
a, t1 as b where a.id = b.parent) select id, parent from allDescendants
80+
explain: 'RUNION-DFS q0 { RUNION-DFS q1 { ISCAN(CHILDIDX [EQUALS promote(@c20
81+
AS LONG)]) } { RECURSIVE COVERING(PARENTIDX <,> -> [ID: KEY[1], PARENT: KEY[0]])
82+
| FILTER q1.PARENT EQUALS _.ID | MAP (_.ID AS ID, _.PARENT AS PARENT) } |
83+
MAP (_.ID AS ID, _.PARENT AS PARENT) } { RECURSIVE COVERING(PARENTIDX <,>
84+
-> [ID: KEY[1], PARENT: KEY[0]]) | FILTER q0.ID EQUALS _.PARENT | MAP (_.ID
85+
AS ID, _.PARENT AS PARENT) } | MAP (_.ID AS ID, _.PARENT AS PARENT)'
86+
task_count: 3567
9087
task_total_time_ms: 75
91-
transform_count: 523
92-
transform_time_ms: 31
93-
transform_yield_count: 150
88+
transform_count: 719
89+
transform_time_ms: 24
90+
transform_yield_count: 202
9491
insert_time_ms: 6
95-
insert_new_count: 300
92+
insert_new_count: 516
9693
insert_reused_count: 15
9794
- query: EXPLAIN with recursive (traversal = level) c1 as ( select id, parent from
9895
t1 where parent = -1 union all select b.id, b.parent from c1 as a, t1 as b
@@ -109,6 +106,21 @@ recursive-cte-tests:
109106
insert_time_ms: 1
110107
insert_new_count: 185
111108
insert_reused_count: 9
109+
- query: EXPLAIN with recursive c1 as ( select id, parent from t1 where parent =
110+
-1 union all select b.id, b.parent from c1 as a, t1 as b where a.id = b.parent)
111+
select id from c1
112+
explain: 'RUNION-DFS q0 { ISCAN(PARENTIDX [EQUALS promote(@c15 AS LONG)]) } {
113+
RECURSIVE COVERING(PARENTIDX <,> -> [ID: KEY[1], PARENT: KEY[0]]) | FILTER
114+
q0.ID EQUALS _.PARENT | MAP (_.ID AS ID, _.PARENT AS PARENT) } | MAP (_.ID
115+
AS ID)'
116+
task_count: 2289
117+
task_total_time_ms: 316
118+
transform_count: 450
119+
transform_time_ms: 160
120+
transform_yield_count: 132
121+
insert_time_ms: 24
122+
insert_new_count: 327
123+
insert_reused_count: 9
112124
- query: EXPLAIN with recursive (traversal = level) allDescendants as ( with recursive
113125
(traversal = level) ancestorsOf250 as ( select id, parent from t1 where id
114126
= 250 union all select b.id, b.parent from ancestorsOf250 as a, t1 as b where

0 commit comments

Comments
 (0)