{"record":{"id":"0f1fc779bf029d7c","repo":"languagetool-org/languagetool","slug":"too-many-values-valuecount-the-storage","errorCode":null,"errorMessage":"Too many values (\" + valueCount + \"), the storage needs adjusting","messagePattern":"Too many values \\(\" \\+ valueCount \\+ \"\\), the storage needs adjusting","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"languagetool-core/src/main/java/org/languagetool/synthesis/ManualSynthesizer.java","lineNumber":77,"sourceCode":"  private static final int MAX_OFFSET = (1 << 32 - OFFSET_SHIFT) - 1;\n  private static final int ENTRY_SIZE = 3;\n  private final String[] data;\n\n  /** A map from lemma+POS hashes to encoded lemma+POS+word tuple offsets in {@link #data} */\n  private final Int2IntMap map;\n\n  private final static String DEFAULT_SEPARATOR = \"\\t\";\n\n  public ManualSynthesizer(InputStream inputStream) throws IOException {\n    Map<TaggedWord, List<String>> mapping = loadMapping(inputStream);\n    Int2ObjectOpenHashMap<List<Triple<String, String, String>>> byHash = groupByHash(mapping);\n\n    map = new Int2IntOpenHashMap(byHash.size());\n    int valueCount = mapping.values().stream().mapToInt(v -> v.size()).sum();\n    int firstIndex = ENTRY_SIZE; // skip an entry, as 0 means an absent value in TObjectIntHashMap\n    data = new String[valueCount * ENTRY_SIZE + firstIndex];\n    if (valueCount > MAX_OFFSET) {\n      throw new UnsupportedOperationException(\"Too many values (\" + valueCount + \"), the storage needs adjusting\");\n    }\n    byHash.int2ObjectEntrySet().fastForEach(new Consumer<Int2ObjectMap.Entry<List<Triple<String, String, String>>>>() {\n      int index = firstIndex;\n\n      @Override\n      public void accept(Int2ObjectMap.Entry<List<Triple<String, String, String>>> listEntry) {\n        int hash = listEntry.getIntKey();\n        List<Triple<String, String, String>> value = listEntry.getValue();\n        if (value.size() > MAX_LENGTH) {\n          throw new UnsupportedOperationException(\n            \"Too many lemmas (\" + value.size() + \" for the same hash \" + value + \", the storage needs adjusting\");\n        }\n        map.put(hash, ((index / ENTRY_SIZE) << OFFSET_SHIFT) | value.size());\n        for (Triple<String, String, String> triple : value) {\n          data[index++] = intern(triple.getLeft());\n          data[index++] = intern(triple.getMiddle());\n          data[index++] = intern(triple.getRight());\n        }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-core/src/main/java/org/languagetool/synthesis/ManualSynthesizer.java#L59-L95","documentation":"Capacity guard in the ManualSynthesizer constructor: after loading the lemma/POS/word-form mapping from the input stream, the total number of stored values exceeds the maximum offset the compact offset encoding can represent (MAX_OFFSET). The input at fault is the synthesizer data file being loaded; the implementation's storage scheme, not the caller, is the limit.","triggerScenarios":"Thrown at languagetool-core/src/main/java/org/languagetool/synthesis/ManualSynthesizer.java:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase OFFSET_SHIFT (widening the offset field) so MAX_OFFSET covers the value count","Reduce the size of the synthesizer data file by removing unused lemma/POS entries"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}