| 28 | namespace acero { |
| 29 | |
| 30 | TEST(JitterNode, Basic) { |
| 31 | static constexpr random::SeedType kTestSeed = 42; |
| 32 | static constexpr int kMaxJitterMod = 4; |
| 33 | static constexpr int kNumBatches = 256; |
| 34 | RegisterTestNodes(); |
| 35 | std::shared_ptr<Table> input = |
| 36 | gen::Gen({gen::Constant(std::make_shared<Int32Scalar>(0))}) |
| 37 | ->FailOnError() |
| 38 | ->Table(1, kNumBatches); |
| 39 | Declaration plan = |
| 40 | Declaration::Sequence({{"table_source", TableSourceNodeOptions(input)}, |
| 41 | {"jitter", JitterNodeOptions(kTestSeed, kMaxJitterMod)}}); |
| 42 | QueryOptions query_options; |
| 43 | query_options.sequence_output = false; |
| 44 | ASSERT_OK_AND_ASSIGN(BatchesWithCommonSchema batches_and_schema, |
| 45 | DeclarationToExecBatches(std::move(plan), query_options)); |
| 46 | |
| 47 | ASSERT_EQ(kNumBatches, static_cast<int>(batches_and_schema.batches.size())); |
| 48 | int numOutOfPlace = 0; |
| 49 | for (int idx = 0; idx < kNumBatches; idx++) { |
| 50 | const ExecBatch& batch = batches_and_schema.batches[idx]; |
| 51 | int jitter = std::abs(idx - static_cast<int>(batch.index)); |
| 52 | if (jitter > 0) { |
| 53 | numOutOfPlace++; |
| 54 | } |
| 55 | } |
| 56 | ASSERT_GT(numOutOfPlace, 0); |
| 57 | } |
| 58 | |
| 59 | } // namespace acero |
| 60 | } // namespace arrow |
nothing calls this directly
no test coverage detected