From 59a8e83520e2b9075f189c5ecf7e9867ea26b937 Mon Sep 17 00:00:00 2001 From: Tomoko Uchida Date: Wed, 29 Apr 2020 15:41:18 +0900 Subject: [PATCH] LUCENE-9089: update FST usage example --- .../apache/lucene/util/fst/package-info.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/package-info.java b/lucene/core/src/java/org/apache/lucene/util/fst/package-info.java index 8ab7b66b8ac..ade82b13573 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/package-info.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/package-info.java @@ -41,14 +41,14 @@ * long outputValues[] = {5, 7, 12}; * * PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton(); - * Builder<Long> builder = new Builder<Long>(INPUT_TYPE.BYTE1, outputs); - * BytesRef scratchBytes = new BytesRef(); + * FSTCompiler<Long> fstCompiler = new FSTCompiler<Long>(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, scratchInts), outputValues[i]); + * fstCompiler.add(Util.toIntsRef(scratchBytes.toBytesRef(), scratchInts), outputValues[i]); * } - * FST<Long> fst = builder.finish(); + * FST<Long> fst = fstCompiler.compile(); * * Retrieval by key: *
@@ -79,11 +79,11 @@
  *       }
  *     };
  *     Arc<Long> firstArc = fst.getFirstArc(new Arc<Long>());
- *     MinResult<Long> paths[] = Util.shortestPaths(fst, firstArc, comparator, 2);
- *     System.out.println(Util.toBytesRef(paths[0].input, scratchBytes).utf8ToString()); // cat
- *     System.out.println(paths[0].output); // 5
- *     System.out.println(Util.toBytesRef(paths[1].input, scratchBytes).utf8ToString()); // dog
- *     System.out.println(paths[1].output); // 7
+ *     Util.TopResults<Long> paths = Util.shortestPaths(fst, firstArc, fst.outputs.getNoOutput(), comparator, 3, true);
+ *     System.out.println(Util.toBytesRef(paths.topN.get(0).input, scratchBytes).utf8ToString()); // cat
+ *     System.out.println(paths.topN.get(0).output); // 5
+ *     System.out.println(Util.toBytesRef(paths.topN.get(1).input, scratchBytes).utf8ToString()); // dog
+ *     System.out.println(paths.topN.get(1).output); // 7
  * 
*/ package org.apache.lucene.util.fst;