{"record":{"id":"0730464ed62bf299","repo":"prestodb/presto","slug":"offset-must-be-0-or-8-073046","errorCode":null,"errorMessage":"offset must be 0 or 8","messagePattern":"offset must be 0 or 8","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/block/Int128ArrayBlockBuilder.java","lineNumber":225,"sourceCode":"    }\n\n    @Override\n    public int getPositionCount()\n    {\n        return positionCount;\n    }\n\n    @Override\n    public long getLong(int position, int offset)\n    {\n        checkReadablePosition(position);\n        if (offset == 0) {\n            return values[position * 2];\n        }\n        if (offset == 8) {\n            return values[(position * 2) + 1];\n        }\n        throw new IllegalArgumentException(\"offset must be 0 or 8\");\n    }\n\n    /**\n     * Get the Slice starting at {@code this.positionOffset + offset} in the value at {@code position} with {@code length} bytes.\n     *\n     * @param position The logical position of the 128-bit integer in the values array.\n     *                 For example, position = 0 refers to the 128-bit integer at values[2] and values[3] if this.positionOffset = 1.\n     * @param offset The offset to the position in the unit of 128-bit integers.\n     *               For example, offset = 1 means the next position (one 128-bit integer or 16 bytes) to the specified position.\n     *               This means we always compare bytes starting at 128-bit integer boundaries.\n     * @param length The length in bytes. It has to be a multiple of 16.\n     */\n    @Override\n    public Slice getSlice(int position, int offset, int length)\n    {\n        checkValidRegion(positionCount, offset, length / SIZE_OF_LONG / 2);\n        return getSliceUnchecked(position + getOffsetBase(), offset, length);\n    }","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/block/Int128ArrayBlockBuilder.java#L207-L243","documentation":"getLong(position, offset) on Int128ArrayBlockBuilder exposes the two 64-bit halves of a 128-bit integer; only offsets 0 (high word) and 8 (low word) are meaningful because values are stored as pairs of longs. Any other offset is a protocol violation and throws IllegalArgumentException.","triggerScenarios":"Calling getLong(position, offset) with offset values other than 0 or 8 — e.g. byte-level offsets like 4 or 16, or passing a byte offset computed for a Slice-based block.","commonSituations":"Generic block-reading code written for VariableWidthBlock (byte offsets) reused against Int128ArrayBlockBuilder; hand-written SerDe loops that advance an offset by 4 bytes per int.","solutions":["Pass only 0 or 8 as offset; use getLong(position, 0) and getLong(position, 8) for the two halves.","For multi-byte reads use getLongUnchecked internal position API or getSlice/getBytesRange instead of arbitrary offsets.","Fix offset computation in generic readers to treat 128-bit ints as two long words."],"exampleFix":"// before\nlong v = blockBuilder.getLong(position, 4); // IllegalArgumentException\n// after\nlong high = blockBuilder.getLong(position, 0);\nlong low = blockBuilder.getLong(position, 8);","handlingStrategy":"validation","validationCode":"if (offset != 0 && offset != 8) {\n    throw new IllegalArgumentException(\"Int128 offsets must be 0 or 8, got \" + offset);\n}\nlong v = block.getLong(position, offset);","typeGuard":null,"tryCatchPattern":"try {\n    long v = block.getLong(position, offset);\n} catch (IllegalArgumentException e) {\n    // fall back to reading both halves\n    long high = block.getLong(position, 0);\n    long low = block.getLong(position, 8);\n}","preventionTips":["Remember Int128 blocks expose two long words, not byte offsets","Wrap Int128 reads in helper methods that only accept 0/8","Do not reuse Slice-style byte-offset logic against Int128 blocks"],"tags":["presto","block","illegal-argument","int128"],"backgroundTag":"invalid-offset","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"}