| 58 | } |
| 59 | |
| 60 | void validate(bool isSerial = false) const { |
| 61 | std::unique_ptr<main::QueryResult> countResult; |
| 62 | if (isSerial) { |
| 63 | countResult = conn->query("MATCH (t:TestSerial) RETURN COUNT(*)"); |
| 64 | } else { |
| 65 | countResult = conn->query("MATCH (t:Test) RETURN COUNT(*)"); |
| 66 | } |
| 67 | ASSERT_TRUE(countResult->isSuccess()) << countResult->toString(); |
| 68 | ASSERT_EQ(countResult->getNumTuples(), 1); |
| 69 | ASSERT_EQ(countResult->getNext()->getValue(0)->getValue<int64_t>(), totalTuples); |
| 70 | |
| 71 | std::random_device dev; |
| 72 | std::mt19937 rng(dev()); |
| 73 | std::uniform_int_distribution<std::mt19937::result_type> dist(0, totalTuples - 1); |
| 74 | // Sample and check up to 1000 random elements in the range |
| 75 | if (isSerial) { |
| 76 | for (size_t i = 0; i < std::min(static_cast<size_t>(1000), totalTuples); i++) { |
| 77 | auto index = dist(rng); |
| 78 | auto result = conn->query( |
| 79 | std::format("MATCH (t:TestSerial) WHERE t.id = {} RETURN t.id", index)); |
| 80 | ASSERT_TRUE(result->isSuccess()) << result->toString(); |
| 81 | ASSERT_EQ(result->getNumTuples(), 1) << "ID " << index << " is missing"; |
| 82 | } |
| 83 | } else { |
| 84 | for (size_t i = 0; i < std::min(static_cast<size_t>(1000), totalTuples); i++) { |
| 85 | auto index = dist(rng); |
| 86 | auto result = |
| 87 | conn->query(std::format("MATCH (t:Test) WHERE t.id = {} RETURN t.id", index)); |
| 88 | ASSERT_TRUE(result->isSuccess()) << result->toString(); |
| 89 | ASSERT_EQ(result->getNumTuples(), 1) << "ID " << index << " is missing"; |
| 90 | ASSERT_EQ(result->getNext()->getValue(0)->getValue<int32_t>(), index); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | private: |
| 96 | size_t totalTuples = 0; |