| 67 | } |
| 68 | |
| 69 | static void TimedTestBigNested(benchmark::State& state) { |
| 70 | // schema for input fields |
| 71 | auto fielda = field("a", int32()); |
| 72 | auto schema = arrow::schema({fielda}); |
| 73 | auto pool_ = arrow::default_memory_pool(); |
| 74 | |
| 75 | // output fields |
| 76 | auto field_result = field("res", int32()); |
| 77 | |
| 78 | // build expression. |
| 79 | // if (a < 10) |
| 80 | // 10 |
| 81 | // else if (a < 20) |
| 82 | // 20 |
| 83 | // .. |
| 84 | // .. |
| 85 | // else if (a < 190) |
| 86 | // 190 |
| 87 | // else |
| 88 | // 200 |
| 89 | auto node_a = TreeExprBuilder::MakeField(fielda); |
| 90 | auto top_node = TreeExprBuilder::MakeLiteral(200); |
| 91 | for (int thresh = 190; thresh > 0; thresh -= 10) { |
| 92 | auto literal = TreeExprBuilder::MakeLiteral(thresh); |
| 93 | auto condition = |
| 94 | TreeExprBuilder::MakeFunction("less_than", {node_a, literal}, boolean()); |
| 95 | auto if_node = TreeExprBuilder::MakeIf(condition, literal, top_node, int32()); |
| 96 | top_node = if_node; |
| 97 | } |
| 98 | auto expr = TreeExprBuilder::MakeExpression(top_node, field_result); |
| 99 | |
| 100 | // Build a projector for the expressions. |
| 101 | std::shared_ptr<Projector> projector; |
| 102 | ASSERT_OK(Projector::Make(schema, {expr}, TestConfiguration(), &projector)); |
| 103 | |
| 104 | BoundedInt32DataGenerator data_generator(250); |
| 105 | ProjectEvaluator evaluator(projector); |
| 106 | |
| 107 | Status status = TimedEvaluate<arrow::Int32Type, int32_t>( |
| 108 | schema, evaluator, data_generator, pool_, 1 * MILLION, 16 * THOUSAND, state); |
| 109 | ASSERT_TRUE(status.ok()); |
| 110 | } |
| 111 | |
| 112 | static void TimedTestExtractYear(benchmark::State& state) { |
| 113 | // schema for input fields |
nothing calls this directly
no test coverage detected