* Enter "spill mode", meaning that no new groups are added to any of the hash * tables. Tuples that would create a new group are instead spilled, and * processed later. */
| 1950 | * processed later. |
| 1951 | */ |
| 1952 | static void |
| 1953 | hash_agg_enter_spill_mode(AggState *aggstate) |
| 1954 | { |
| 1955 | if (aggstate->streaming) |
| 1956 | { |
| 1957 | /* don't spill, only mark the hash table as filled. */ |
| 1958 | aggstate->table_filled = true; |
| 1959 | return; |
| 1960 | } |
| 1961 | |
| 1962 | aggstate->hash_spill_mode = true; |
| 1963 | hashagg_recompile_expressions(aggstate, aggstate->table_filled, true); |
| 1964 | |
| 1965 | if (!aggstate->hash_ever_spilled) |
| 1966 | { |
| 1967 | Assert(aggstate->hash_tapeinfo == NULL); |
| 1968 | Assert(aggstate->hash_spills == NULL); |
| 1969 | |
| 1970 | aggstate->hash_ever_spilled = true; |
| 1971 | |
| 1972 | hashagg_tapeinfo_init(aggstate); |
| 1973 | |
| 1974 | aggstate->hash_spills = palloc(sizeof(HashAggSpill) * aggstate->num_hashes); |
| 1975 | |
| 1976 | for (int setno = 0; setno < aggstate->num_hashes; setno++) |
| 1977 | { |
| 1978 | AggStatePerHash perhash = &aggstate->perhash[setno]; |
| 1979 | HashAggSpill *spill = &aggstate->hash_spills[setno]; |
| 1980 | |
| 1981 | hashagg_spill_init(aggstate, spill, aggstate->hash_tapeinfo, 0, |
| 1982 | perhash->aggnode->numGroups, |
| 1983 | aggstate->hashentrysize); |
| 1984 | perhash->num_spill_parts += spill->npartitions; |
| 1985 | } |
| 1986 | |
| 1987 | if (aggstate->ss.ps.instrument) |
| 1988 | { |
| 1989 | aggstate->ss.ps.instrument->workfileCreated = true; |
| 1990 | } |
| 1991 | } |
| 1992 | } |
| 1993 | |
| 1994 | /* |
| 1995 | * Update metrics after filling the hash table. |
no test coverage detected