{"record":{"id":"fcc26be4a0cacb51","repo":"prestodb/presto","slug":"generic-insufficient-resources-fcc26b","errorCode":"GENERIC_INSUFFICIENT_RESOURCES","errorMessage":"Size of hash table cannot exceed 1 billion entries","messagePattern":"Size of hash table cannot exceed 1 billion entries","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/KeyValuePairs.java","lineNumber":161,"sourceCode":"    private int getHashPositionOfKey(Block key, int position)\n    {\n        int hashPosition = getMaskedHash(hashPosition(keyType, key, position));\n        while (true) {\n            if (keyPositionByHash[hashPosition] == EMPTY_SLOT) {\n                return hashPosition;\n            }\n            else if (positionEqualsPosition(keyType, keyBlockBuilder, keyPositionByHash[hashPosition], key, position)) {\n                return hashPosition;\n            }\n            hashPosition = getMaskedHash(hashPosition + 1);\n        }\n    }\n\n    private void rehash()\n    {\n        long newCapacityLong = hashCapacity * 2L;\n        if (newCapacityLong > Integer.MAX_VALUE) {\n            throw new PrestoException(GENERIC_INSUFFICIENT_RESOURCES, \"Size of hash table cannot exceed 1 billion entries\");\n        }\n        int newCapacity = (int) newCapacityLong;\n        hashCapacity = newCapacity;\n        hashMask = newCapacity - 1;\n        maxFill = calculateMaxFill(newCapacity);\n        keyPositionByHash = new int[newCapacity];\n        Arrays.fill(keyPositionByHash, EMPTY_SLOT);\n        for (int position = 0; position < keyBlockBuilder.getPositionCount(); position++) {\n            keyPositionByHash[getHashPositionOfKey(keyBlockBuilder, position)] = position;\n        }\n    }\n\n    private static int calculateMaxFill(int hashSize)\n    {\n        checkArgument(hashSize > 0, \"hashSize must be greater than 0\");\n        int maxFill = (int) Math.ceil(hashSize * FILL_RATIO);\n        if (maxFill == hashSize) {\n            maxFill--;","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/KeyValuePairs.java#L143-L179","documentation":"Capacity guard in KeyValuePairs.rehash: the open-addressed hash table backing an aggregation (e.g. map keys or distinct values) would need to exceed one billion entries after doubling, which Presto refuses to allocate; the aggregation aborts.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/KeyValuePairs.java:161 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce input cardinality by pre-aggregating or filtering the data","Use approx_set or other sketch-based aggregations for very high cardinality","Split the query or increase cluster memory so grouping can complete within limits"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}