{"record":{"id":"784bbfef9d4a0b38","repo":"apache/cassandra","slug":"compressor-does-not-support-dictionary-training","errorCode":null,"errorMessage":"Compressor does not support dictionary training: <compressor>","messagePattern":"Compressor does not support dictionary training: <compressor>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/ICompressionDictionaryTrainer.java","lineNumber":124,"sourceCode":"    void setDictionaryTrainedListener(Consumer<CompressionDictionary> listener);\n\n    /**\n     * Factory method to create appropriate trainer based on compression parameters.\n     *\n     * @param keyspaceName the keyspace name for logging\n     * @param tableName the table name for logging\n     * @param params the compression parameters\n     * @return a dictionary trainer for the specified compression algorithm\n     * @throws IllegalArgumentException if no dictionary trainer is available for the compression algorithm\n     */\n    static ICompressionDictionaryTrainer create(String keyspaceName,\n                                                String tableName,\n                                                CompressionParams params)\n    {\n        ICompressor compressor = params.getSstableCompressor();\n        if (!(compressor instanceof IDictionaryCompressor))\n        {\n            throw new IllegalArgumentException(\"Compressor does not support dictionary training: \" + params.getSstableCompressor());\n        }\n\n        IDictionaryCompressor<?> dictionaryCompressor = (IDictionaryCompressor<?>) compressor;\n        return dictionaryCompressor.acceptableDictionaryKind().createTrainer(keyspaceName, tableName, compressor);\n    }\n\n    enum TrainingStatus\n    {\n        NOT_STARTED,\n        SAMPLING,\n        TRAINING,\n        COMPLETED,\n        FAILED\n    }\n}\n","sourceCodeStart":106,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/ICompressionDictionaryTrainer.java#L106-L140","documentation":"Thrown by ICompressionDictionaryTrainer.create when the table's SSTable compressor does not implement IDictionaryCompressor, meaning dictionary training is impossible for that compressor. It is an IllegalArgumentException signaling programmatic misuse of the training API.","triggerScenarios":"Invoking dictionary training (create) on a table whose compression params use a non-dictionary compressor such as LZ4Compressor without dictionary support, Snappy, Deflate, or Zstd configured without dictionary capability.","commonSituations":"Running training tools against tables compressed with algorithms that lack dictionary support; assuming all compressors support training; misconfigured compression class in the table schema.","solutions":["Switch the table's compressor to a dictionary-capable one (e.g. Zstd dictionary compressor) via ALTER TABLE compression options","Check params.getSstableCompressor() instanceof IDictionaryCompressor before calling create","Refrain from training on tables that do not opt into dictionary compression"],"exampleFix":"// before\nICompressionDictionaryTrainer.create(ks, table, tableMetadata.params()); // throws for non-dictionary compressor\n// after\nif (params.getSstableCompressor() instanceof IDictionaryCompressor)\n    ICompressionDictionaryTrainer.create(ks, table, params);","handlingStrategy":"type-guard","validationCode":"boolean canTrain(CompressionParams p) { return p.getSstableCompressor() instanceof IDictionaryCompressor; }","typeGuard":"if (!(params.getSstableCompressor() instanceof IDictionaryCompressor)) return null;","tryCatchPattern":"try { trainer = ICompressionDictionaryTrainer.create(ks, table, params); } catch (IllegalArgumentException e) { /* fall back to non-dictionary path */ }","preventionTips":["Check compressor capability before invoking training APIs","Only enable training on tables using dictionary-capable compressors","Document compressor constraints in operational runbooks"],"tags":["compression","cassandra","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}