{"record":{"id":"c8069d46dff22d88","repo":"prestodb/presto","slug":"generic-insufficient-resources-c8069d","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/approxmostfrequent/stream/StreamSummary.java","lineNumber":184,"sourceCode":"            int newBlockPos = newHeapBlockBuilder.getPositionCount();\n            StreamDataEntity heapEntry = minHeap.get(heapPosition);\n            int oldBlockPosition = getBlockPosition(heapEntry);\n            type.appendTo(heapBlockBuilder, oldBlockPosition, newHeapBlockBuilder);\n            newBlockPositionToCount.set(newBlockPos, blockPositionToCount.get(oldBlockPosition));\n            newBlockToHeapIndex.set(newBlockPos, heapPosition);\n            hashToBlockPosition.set(heapEntry.getHashPosition(), newBlockPos);\n        }\n        blockPositionToCount = newBlockPositionToCount;\n        heapBlockBuilder = newHeapBlockBuilder;\n        blockToHeapIndex = newBlockToHeapIndex;\n        rehash();\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        int newMask = newCapacity - 1;\n        IntBigArray newHashToBlockPosition = new IntBigArray(EMPTY);\n        newHashToBlockPosition.ensureCapacity(newCapacity);\n\n        for (int heapPosition = 0; heapPosition < getHeapSize(); heapPosition++) {\n            StreamDataEntity heapEntry = minHeap.get(heapPosition);\n            int blockPosition = getBlockPosition(heapEntry);\n            // find an empty slot for the address\n            int hashPosition = getBucketId(TypeUtils.hashPosition(type, heapBlockBuilder, blockPosition), newMask);\n\n            while (newHashToBlockPosition.get(hashPosition) != EMPTY) {\n                hashPosition = (hashPosition + 1) & newMask;\n            }\n            // record the mapping\n            newHashToBlockPosition.set(hashPosition, blockPosition);\n            heapEntry.setHashPosition(hashPosition);","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/approxmostfrequent/stream/StreamSummary.java#L166-L202","documentation":"Capacity guard in StreamSummary.rehash (approx_most_frequent stream summary): growing the internal hash table would push it past one billion entries, beyond the implementation's structural limit, so the aggregation aborts.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/approxmostfrequent/stream/StreamSummary.java:184 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase the capacity argument passed to approx_most_frequent appropriately or reduce input cardinality","Filter or pre-aggregate the input stream to fewer distinct keys","Use approx_set-based approaches if only heavy hitters matter"],"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"}