{"record":{"id":"fca7f47e01e06983","repo":"apache/iceberg","slug":"getclass-getname-does-not-support-serialize","errorCode":null,"errorMessage":"${getClass().getName()} does not support serialize","messagePattern":"(.+?) does not support serialize","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/deletes/PositionDeleteIndex.java","lineNumber":102,"sourceCode":"   *\n   * @return delete files that this index was created from\n   */\n  default Collection<DeleteFile> deleteFiles() {\n    return ImmutableList.of();\n  }\n\n  /** Returns the cardinality of this index. */\n  default long cardinality() {\n    throw new UnsupportedOperationException(getClass().getName() + \" does not support cardinality\");\n  }\n\n  /**\n   * Serializes this index.\n   *\n   * @return a buffer containing the serialized index\n   */\n  default ByteBuffer serialize() {\n    throw new UnsupportedOperationException(getClass().getName() + \" does not support serialize\");\n  }\n\n  /**\n   * Deserializes a position delete index.\n   *\n   * @param bytes an array containing the serialized index\n   * @param deleteFile the delete file that the index is created for\n   * @return the deserialized index\n   */\n  static PositionDeleteIndex deserialize(byte[] bytes, DeleteFile deleteFile) {\n    return BitmapPositionDeleteIndex.deserialize(bytes, deleteFile);\n  }\n\n  /** Returns an empty immutable position delete index. */\n  static PositionDeleteIndex empty() {\n    return EmptyPositionDeleteIndex.get();\n  }\n}","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/deletes/PositionDeleteIndex.java#L84-L120","documentation":"PositionDeleteIndex.serialize() converts the index into a serialized ByteBuffer; the interface default throws UnsupportedOperationException because serialization is only meaningful for implementations with a binary encoding (e.g. Roaring bitmaps). Callers such as toBlob, bytes, and buffer invoke it when persisting indexes (e.g. in deletion vectors).","triggerScenarios":"Calling serialize() (directly or via toBlob/bytes/buffer helpers) on an implementation that has not overridden the default method.","commonSituations":"A custom PositionDeleteIndex implementation being written into a deletion vector blob or Puffin file, without a binary encoding defined.","solutions":["Implement serialize() to write a binary representation (and matching deserialize) in the implementation","Use BitmapPositionDeleteIndex, whose serialize() produces the standard Roaring-bitmap encoding","Do not route non-encodable indexes into deletion-vector/persisted-blob code paths"],"exampleFix":"// before\n@Override public ByteBuffer serialize() { throw new UnsupportedOperationException(...); }\n// after\n@Override public ByteBuffer serialize() { return bitmap.toByteBuffer(); }","handlingStrategy":"type-guard","validationCode":"if (index instanceof BitmapPositionDeleteIndex) { ByteBuffer buf = index.serialize(); } else { throw new IllegalStateException(\"Index has no binary encoding\"); }","typeGuard":"boolean supportsSerialize(PositionDeleteIndex idx) { return idx instanceof BitmapPositionDeleteIndex; }","tryCatchPattern":"try { ByteBuffer buf = index.serialize(); } catch (UnsupportedOperationException e) { throw new IllegalStateException(\"Cannot persist this index type\", e); }","preventionTips":["Persist only indexes with a defined binary encoding","Pair serialize() and deserialize() implementations and round-trip test them","Route DV-blob creation exclusively through BitmapPositionDeleteIndex"],"tags":["java","deletes","serialization"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}