20
20
// / @author Heiko Kernbach
21
21
// //////////////////////////////////////////////////////////////////////////////
22
22
23
+ #include " AqlItemBlockHelper.h"
23
24
#include " RowFetcherHelper.h"
24
25
#include " gtest/gtest.h"
25
26
27
+ #include " Aql/AqlCall.h"
26
28
#include " Aql/AqlItemBlock.h"
27
29
#include " Aql/CountCollectExecutor.h"
28
30
#include " Aql/InputAqlItemRow.h"
@@ -60,7 +62,8 @@ class CountCollectExecutorTest : public ::testing::Test {
60
62
TEST_F (CountCollectExecutorTest, there_are_no_rows_upstream_the_producer_doesnt_wait) {
61
63
CountCollectExecutorInfos infos (1 /* outputRegId */ , 1 /* nrIn */ , nrOutputReg, {}, {});
62
64
VPackBuilder input;
63
- SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (itemBlockManager, input.steal (), false );
65
+ SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (
66
+ itemBlockManager, input.steal (), false );
64
67
CountCollectExecutor testee (fetcher, infos);
65
68
NoStats stats{};
66
69
@@ -81,7 +84,8 @@ TEST_F(CountCollectExecutorTest, there_are_no_rows_upstream_the_producer_doesnt_
81
84
TEST_F (CountCollectExecutorTest, there_are_now_rows_upstream_the_producer_waits) {
82
85
CountCollectExecutorInfos infos (1 /* outputRegId */ , 1 /* nrIn */ , nrOutputReg, {}, {});
83
86
VPackBuilder input;
84
- SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (itemBlockManager, input.steal (), true );
87
+ SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (
88
+ itemBlockManager, input.steal (), true );
85
89
CountCollectExecutor testee (fetcher, infos);
86
90
NoStats stats{};
87
91
@@ -106,7 +110,8 @@ TEST_F(CountCollectExecutorTest, there_are_now_rows_upstream_the_producer_waits)
106
110
TEST_F (CountCollectExecutorTest, there_are_rows_in_the_upstream_the_producer_doesnt_wait) {
107
111
CountCollectExecutorInfos infos (1 /* outputRegId */ , 1 /* nrIn */ , nrOutputReg, {}, {});
108
112
auto input = VPackParser::fromJson (" [ [1], [2], [3] ]" );
109
- SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (itemBlockManager, input->steal (), false );
113
+ SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (
114
+ itemBlockManager, input->steal (), false );
110
115
CountCollectExecutor testee (fetcher, infos);
111
116
NoStats stats{};
112
117
@@ -127,7 +132,8 @@ TEST_F(CountCollectExecutorTest, there_are_rows_in_the_upstream_the_producer_doe
127
132
TEST_F (CountCollectExecutorTest, there_are_rows_in_the_upstream_the_producer_waits) {
128
133
CountCollectExecutorInfos infos (1 /* outputRegId */ , 1 /* nrIn */ , nrOutputReg, {}, {});
129
134
auto input = VPackParser::fromJson (" [ [1], [2], [3] ]" );
130
- SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (itemBlockManager, input->steal (), true );
135
+ SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (
136
+ itemBlockManager, input->steal (), true );
131
137
CountCollectExecutor testee (fetcher, infos);
132
138
NoStats stats{};
133
139
OutputAqlItemRow result{std::move (block), outputRegisters,
@@ -157,6 +163,31 @@ TEST_F(CountCollectExecutorTest, there_are_rows_in_the_upstream_the_producer_wai
157
163
ASSERT_EQ (3 , fetcher.totalSkipped ());
158
164
}
159
165
166
+ TEST_F (CountCollectExecutorTest, test_produce_datarange) {
167
+ CountCollectExecutorInfos infos (1 /* outputRegId */ , 1 /* nrIn */ , nrOutputReg, {}, {});
168
+ auto fakeUnusedBlock = VPackParser::fromJson (" [ ]" );
169
+ SingleRowFetcherHelper<::arangodb::aql::BlockPassthrough::Disable> fetcher (
170
+ itemBlockManager, fakeUnusedBlock->steal (), false );
171
+ CountCollectExecutor testee (fetcher, infos);
172
+
173
+ SharedAqlItemBlockPtr inBlock = buildBlock<1 >(itemBlockManager, {{}});
174
+ AqlItemBlockInputRange input{ExecutorState::DONE, inBlock, 0 , inBlock->size ()};
175
+
176
+ OutputAqlItemRow output (std::move (block), outputRegisters,
177
+ infos.registersToKeep (), infos.registersToClear ());
178
+ EXPECT_EQ (output.numRowsWritten (), 0 );
179
+ auto const [state, stats, call] = testee.produceRows (1000 , input, output);
180
+ ASSERT_EQ (state, ExecutorState::DONE);
181
+ ASSERT_TRUE (output.produced ());
182
+
183
+ auto block = output.stealBlock ();
184
+ AqlValue x = block->getValue (0 , 1 );
185
+ ASSERT_TRUE (x.isNumber ());
186
+ ASSERT_EQ (x.toInt64 (), 0 );
187
+
188
+ ASSERT_EQ (0 , fetcher.totalSkipped ());
189
+ }
190
+
160
191
} // namespace aql
161
192
} // namespace tests
162
193
} // namespace arangodb
0 commit comments