|
18 | 18 | import org.elasticsearch.common.util.concurrent.EsExecutors; |
19 | 19 | import org.elasticsearch.compute.data.Block; |
20 | 20 | import org.elasticsearch.compute.data.BlockFactory; |
21 | | -import org.elasticsearch.compute.data.BlockUtils; |
22 | 21 | import org.elasticsearch.compute.data.BooleanBlock; |
23 | 22 | import org.elasticsearch.compute.data.BytesRefBlock; |
24 | 23 | import org.elasticsearch.compute.data.DoubleBlock; |
|
32 | 31 | import org.elasticsearch.compute.operator.SourceOperator; |
33 | 32 | import org.elasticsearch.compute.test.AbstractBlockSourceOperator; |
34 | 33 | import org.elasticsearch.compute.test.OperatorTestCase; |
| 34 | +import org.elasticsearch.core.TimeValue; |
35 | 35 | import org.elasticsearch.inference.InferenceServiceResults; |
36 | 36 | import org.elasticsearch.test.client.NoOpClient; |
37 | 37 | import org.elasticsearch.threadpool.FixedExecutorBuilder; |
@@ -89,7 +89,7 @@ protected int remaining() { |
89 | 89 | protected Page createPage(int positionOffset, int length) { |
90 | 90 | try (var builder = blockFactory.newBytesRefVectorBuilder(length)) { |
91 | 91 | for (int i = 0; i < length; i++) { |
92 | | - builder.appendBytesRef(new BytesRef(randomAlphaOfLength(10))); |
| 92 | + builder.appendBytesRef(new BytesRef(randomAlphaOfLength(1000))); |
93 | 93 | } |
94 | 94 | currentPosition += length; |
95 | 95 | return new Page(builder.build().asBlock()); |
@@ -120,13 +120,21 @@ protected <Request extends ActionRequest, Response extends ActionResponse> void |
120 | 120 | Request request, |
121 | 121 | ActionListener<Response> listener |
122 | 122 | ) { |
123 | | - if (action == InferenceAction.INSTANCE && request instanceof InferenceAction.Request inferenceRequest) { |
124 | | - InferenceAction.Response inferenceResponse = new InferenceAction.Response(mockInferenceResult(inferenceRequest)); |
125 | | - listener.onResponse((Response) inferenceResponse); |
126 | | - return; |
127 | | - } |
| 123 | + Runnable runnable = () -> { |
| 124 | + if (action == InferenceAction.INSTANCE && request instanceof InferenceAction.Request inferenceRequest) { |
| 125 | + InferenceAction.Response inferenceResponse = new InferenceAction.Response(mockInferenceResult(inferenceRequest)); |
| 126 | + listener.onResponse((Response) inferenceResponse); |
| 127 | + return; |
| 128 | + } |
128 | 129 |
|
129 | | - fail("Unexpected call to action [" + action.name() + "]"); |
| 130 | + fail("Unexpected call to action [" + action.name() + "]"); |
| 131 | + }; |
| 132 | + |
| 133 | + if (randomBoolean()) { |
| 134 | + runnable.run(); |
| 135 | + } else { |
| 136 | + threadPool.schedule(runnable, TimeValue.timeValueNanos(between(1, 100)), threadPool.executor(ThreadPool.Names.SEARCH)); |
| 137 | + } |
130 | 138 | } |
131 | 139 | }; |
132 | 140 |
|
@@ -187,7 +195,9 @@ protected EvalOperator.ExpressionEvaluator.Factory evaluatorFactory(int channel) |
187 | 195 | return context -> new EvalOperator.ExpressionEvaluator() { |
188 | 196 | @Override |
189 | 197 | public Block eval(Page page) { |
190 | | - return BlockUtils.deepCopyOf(page.getBlock(channel), context.blockFactory()); |
| 198 | + Block b = page.getBlock(channel); |
| 199 | + b.incRef(); |
| 200 | + return b; |
191 | 201 | } |
192 | 202 |
|
193 | 203 | @Override |
|
0 commit comments