[ https://issues.apache.org/jira/browse/LUCENE-9052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Robert Scholte moved MNGSITE-382 to LUCENE-9052: ------------------------------------------------ Key: LUCENE-9052 (was: MNGSITE-382) Lucene Fields: New Workflow: patch-available, re-open possible, new labels (was: Default workflow, editable Closed status) Project: Lucene - Core (was: Maven Project Web Site) > Deprecated method copyChars is used in example > ---------------------------------------------- > > Key: LUCENE-9052 > URL: https://issues.apache.org/jira/browse/LUCENE-9052 > Project: Lucene - Core > Issue Type: Bug > Reporter: gitesh > Priority: Minor > > Following documentation page for FST class has some example code. > [https://lucene.apache.org/core/8_3_0/core/org/apache/lucene/util/fst/package-summary.html] > {code:java} > // Input values (keys). These must be provided to Builder in Unicode > sorted order! > String inputValues[] = {"cat", "dog", "dogs"}; > long outputValues[] = {5, 7, 12}; > > PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(); > Builder<Long> builder = new Builder<Long>(INPUT_TYPE.BYTE1, outputs); > BytesRef scratchBytes = new BytesRef(); > IntsRefBuilder scratchInts = new IntsRefBuilder(); > for (int i = 0; i < inputValues.length; i++) { > scratchBytes.copyChars(inputValues[i]); > builder.add(Util.toIntsRef(scratchBytes, scratchInts), > outputValues[i]); > } > FST<Long> fst = builder.finish(); > {code} > Compilation of above code with Solr 8.3 libraries complains that no method > copyChars found. copyChars method in BytesRef class is deprecated from long > time. We should use BytesRefBuilder class instead. Here is the correct code: > {code:java} > String inputValues[] = {"cat", "dog", "dogs"}; > long outputValues[] = {5, 7, 12}; > PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(); > Builder<Long> builder = new Builder<Long>(FST.INPUT_TYPE.BYTE1, outputs); > BytesRefBuilder scratchBytes = new BytesRefBuilder(); > IntsRefBuilder scratchInts = new IntsRefBuilder(); > for (int i = 0; i < inputValues.length; i++) { > scratchBytes.copyChars(inputValues[i]); > builder.add(Util.toIntsRef(scratchBytes.get(), scratchInts), > outputValues[i]); > } > FST<Long> fst = builder.finish(); > {code} > -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org