mirror of https://gitee.com/bigwinds/arangodb
Fixed test usage of MultiDependencySingleRowFetcher (#9060)
* Fixed assertion to not have side effects * init dependencies in test explicitly
This commit is contained in:
parent
8ebcdfda16
commit
f1dd0659fa
|
@ -60,14 +60,19 @@ RegisterId MultiDependencySingleRowFetcher::getNrInputRegisters() const {
|
|||
return _dependencyProxy->getNrInputRegisters();
|
||||
}
|
||||
|
||||
size_t MultiDependencySingleRowFetcher::numberDependencies() {
|
||||
if (_dependencyInfos.empty()) {
|
||||
void MultiDependencySingleRowFetcher::initDependencies() {
|
||||
// Need to setup the dependencies, they are injected lazily.
|
||||
TRI_ASSERT(_dependencyProxy->numberDependencies() > 0);
|
||||
TRI_ASSERT(_dependencyInfos.empty());
|
||||
_dependencyInfos.reserve(_dependencyProxy->numberDependencies());
|
||||
for (size_t i = 0; i < _dependencyProxy->numberDependencies(); ++i) {
|
||||
_dependencyInfos.emplace_back(DependencyInfo{});
|
||||
}
|
||||
}
|
||||
|
||||
size_t MultiDependencySingleRowFetcher::numberDependencies() {
|
||||
if (_dependencyInfos.empty()) {
|
||||
initDependencies();
|
||||
}
|
||||
return _dependencyInfos.size();
|
||||
}
|
||||
|
|
|
@ -117,6 +117,9 @@ class MultiDependencySingleRowFetcher {
|
|||
return {state, available};
|
||||
}
|
||||
|
||||
// May only be called once, after the dependencies are injected.
|
||||
void initDependencies();
|
||||
|
||||
size_t numberDependencies();
|
||||
|
||||
/**
|
||||
|
@ -131,7 +134,7 @@ class MultiDependencySingleRowFetcher {
|
|||
*
|
||||
* @return A pair with the following properties:
|
||||
* ExecutionState:
|
||||
* WAITING => IO going on, immediatly return to caller.
|
||||
* WAITING => IO going on, immediately return to caller.
|
||||
* DONE => No more to expect from Upstream, if you are done with
|
||||
* this row return DONE to caller.
|
||||
* HASMORE => There is potentially more from above, call again if
|
||||
|
@ -145,7 +148,7 @@ class MultiDependencySingleRowFetcher {
|
|||
// NOLINTNEXTLINE google-default-arguments
|
||||
TEST_VIRTUAL std::pair<ExecutionState, InputAqlItemRow> fetchRowForDependency(
|
||||
size_t dependency, size_t atMost = ExecutionBlock::DefaultBatchSize()) {
|
||||
TRI_ASSERT(dependency < numberDependencies());
|
||||
TRI_ASSERT(dependency < _dependencyInfos.size());
|
||||
auto& depInfo = _dependencyInfos[dependency];
|
||||
// Fetch a new block iff necessary
|
||||
if (!indexIsValid(depInfo) && !isDone(depInfo)) {
|
||||
|
|
|
@ -65,6 +65,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
ASSERT_TRUE(state == ExecutionState::DONE);
|
||||
ASSERT_TRUE(!row);
|
||||
|
@ -87,6 +89,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
ASSERT_TRUE(state == ExecutionState::WAITING);
|
||||
ASSERT_TRUE(!row);
|
||||
|
@ -113,6 +117,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
ASSERT_TRUE(state == ExecutionState::DONE);
|
||||
ASSERT_TRUE(row);
|
||||
|
@ -138,6 +144,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
ASSERT_TRUE(state == ExecutionState::HASMORE);
|
||||
ASSERT_TRUE(row);
|
||||
|
@ -167,6 +175,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
ASSERT_TRUE(state == ExecutionState::WAITING);
|
||||
ASSERT_TRUE(!row);
|
||||
|
@ -197,6 +207,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
ASSERT_TRUE(state == ExecutionState::WAITING);
|
||||
ASSERT_TRUE(!row);
|
||||
|
@ -236,6 +248,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
int64_t rowIdxAndValue;
|
||||
for (rowIdxAndValue = 1; rowIdxAndValue <= 5; rowIdxAndValue++) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
|
@ -276,6 +290,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
int64_t rowIdxAndValue;
|
||||
for (rowIdxAndValue = 1; rowIdxAndValue <= 5; rowIdxAndValue++) {
|
||||
if (rowIdxAndValue == 1 || rowIdxAndValue == 4) {
|
||||
|
@ -328,6 +344,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (int64_t rowIdxAndValue = 1; rowIdxAndValue <= 6; rowIdxAndValue++) {
|
||||
if (rowIdxAndValue == 1 || rowIdxAndValue == 4 || rowIdxAndValue == 6) {
|
||||
// wait at the beginning of the 1st, 2nd and 3rd block
|
||||
|
@ -368,6 +386,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (size_t i = 0; i < numDeps; ++i) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(i);
|
||||
ASSERT_TRUE(state == ExecutionState::DONE);
|
||||
|
@ -395,6 +415,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (size_t i = 0; i < numDeps; ++i) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(i);
|
||||
ASSERT_TRUE(state == ExecutionState::WAITING);
|
||||
|
@ -432,6 +454,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (size_t i = 0; i < numDeps; ++i) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(i);
|
||||
ASSERT_TRUE(state == ExecutionState::DONE);
|
||||
|
@ -474,6 +498,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (size_t i = 0; i < numDeps; ++i) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(i);
|
||||
ASSERT_TRUE(state == ExecutionState::HASMORE);
|
||||
|
@ -522,6 +548,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (size_t i = 0; i < numDeps; ++i) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(i);
|
||||
ASSERT_TRUE(state == ExecutionState::WAITING);
|
||||
|
@ -573,6 +601,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
for (size_t i = 0; i < numDeps; ++i) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(i);
|
||||
ASSERT_TRUE(state == ExecutionState::WAITING);
|
||||
|
@ -636,6 +666,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
int64_t rowIdxAndValue;
|
||||
for (rowIdxAndValue = 1; rowIdxAndValue <= 5; rowIdxAndValue++) {
|
||||
std::tie(state, row) = testee.fetchRowForDependency(0);
|
||||
|
@ -719,6 +751,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
int64_t rowIdxAndValue;
|
||||
for (rowIdxAndValue = 1; rowIdxAndValue <= 5; rowIdxAndValue++) {
|
||||
if (rowIdxAndValue == 1 || rowIdxAndValue == 4) {
|
||||
|
@ -828,6 +862,8 @@ TEST_F(MultiDependencySingleRowFetcherTest,
|
|||
{
|
||||
MultiDependencySingleRowFetcher testee(dependencyProxyMock);
|
||||
|
||||
testee.initDependencies();
|
||||
|
||||
int64_t rowIdxAndValue;
|
||||
for (rowIdxAndValue = 1; rowIdxAndValue <= 5; rowIdxAndValue++) {
|
||||
if (rowIdxAndValue == 1 || rowIdxAndValue == 4) {
|
||||
|
|
Loading…
Reference in New Issue