* Read tuple(s) for given reader in nowait mode, and load into its tuple * array, until we have MAX_TUPLE_STORE of them or would have to block. */
| 595 | * array, until we have MAX_TUPLE_STORE of them or would have to block. |
| 596 | */ |
| 597 | static void |
| 598 | load_tuple_array(GatherMergeState *gm_state, int reader) |
| 599 | { |
| 600 | GMReaderTupleBuffer *tuple_buffer; |
| 601 | int i; |
| 602 | |
| 603 | /* Don't do anything if this is the leader. */ |
| 604 | if (reader == 0) |
| 605 | return; |
| 606 | |
| 607 | tuple_buffer = &gm_state->gm_tuple_buffers[reader - 1]; |
| 608 | |
| 609 | /* If there's nothing in the array, reset the counters to zero. */ |
| 610 | if (tuple_buffer->nTuples == tuple_buffer->readCounter) |
| 611 | tuple_buffer->nTuples = tuple_buffer->readCounter = 0; |
| 612 | |
| 613 | /* Try to fill additional slots in the array. */ |
| 614 | for (i = tuple_buffer->nTuples; i < MAX_TUPLE_STORE; i++) |
| 615 | { |
| 616 | MinimalTuple tuple; |
| 617 | |
| 618 | tuple = gm_readnext_tuple(gm_state, |
| 619 | reader, |
| 620 | true, |
| 621 | &tuple_buffer->done); |
| 622 | if (!tuple) |
| 623 | break; |
| 624 | tuple_buffer->tuple[i] = tuple; |
| 625 | tuple_buffer->nTuples++; |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | /* |
| 630 | * Store the next tuple for a given reader into the appropriate slot. |
no test coverage detected