{"record":{"id":"f5d50f0860d58a56","repo":"prestodb/presto","slug":"generic-insufficient-resources-f5d50f","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/SetOfValues.java","lineNumber":144,"sourceCode":"    private boolean isContainedAt(Block firstBlock, int positionWithinFirstBlock, Block secondBlock, int positionWithinSecondBlock)\n    {\n        boolean firstValueNull = firstBlock.isNull(positionWithinFirstBlock);\n        Object firstValue = firstValueNull ? defaultValue(valueType.getJavaType()) : readNativeValue(valueType, firstBlock, positionWithinFirstBlock);\n        boolean secondValueNull = secondBlock.isNull(positionWithinSecondBlock);\n        Object secondValue = secondValueNull ? defaultValue(valueType.getJavaType()) : readNativeValue(valueType, secondBlock, positionWithinSecondBlock);\n        try {\n            return !(boolean) elementIsDistinctFrom.invoke(firstValue, firstValueNull, secondValue, secondValueNull);\n        }\n        catch (Throwable t) {\n            throw internalError(t);\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        valuePositionByHash = new int[newCapacity];\n        Arrays.fill(valuePositionByHash, EMPTY_SLOT);\n        for (int position = 0; position < valueBlockBuilder.getPositionCount(); position++) {\n            valuePositionByHash[getHashPositionOfValue(valueBlockBuilder, 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":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/SetOfValues.java#L126-L162","documentation":"Capacity guard in SetOfValues.rehash: the hash set backing a set aggregation would exceed one billion entries while growing, exceeding the implementation's addressing limit; the aggregation fails rather than corrupt state.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/aggregation/SetOfValues.java:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce distinct-value cardinality with filters or pre-aggregation","Use approx_set or a sketch function for very large distinct sets","Increase memory and accept that the one-billion-entry structural limit still applies"],"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"}