public void build(InputIterator iterator) throws IOException {if (iterator.hasPayloads()) {throw new IllegalArgumentException("this suggester doesn't support payloads");}if (iterator.hasContexts()) {throw new IllegalArgumentException("this suggester doesn't support contexts");}count = 0;BytesRef scratch = new BytesRef();InputIterator iter = new WFSTInputIterator(tempDir, tempFileNamePrefix, iterator);IntsRefBuilder scratchInts = new IntsRefBuilder();BytesRefBuilder previous = null;PositiveIntOutputs outputs = PositiveIntOutputs.getSingleton();FSTCompiler<Long> fstCompiler = new FSTCompiler<>(FST.INPUT_TYPE.BYTE1, outputs);while ((scratch = iter.next()) != null) {long cost = iter.weight();if (previous == null) {previous = new BytesRefBuilder();} else if (scratch.equals(previous.get())) {continue; }Util.toIntsRef(scratch, scratchInts);fstCompiler.add(scratchInts.get(), cost);previous.copyBytes(scratch);count++;}fst = fstCompiler.compile();}
public override void Build(IInputIterator iterator){if (iterator.HasPayloads){throw new ArgumentException("this suggester doesn't support payloads");}if (iterator.HasContexts){throw new ArgumentException("this suggester doesn't support contexts");}count = 0;var scratch = new BytesRef();IInputIterator iter = new WFSTInputIterator(this, iterator);var scratchInts = new Int32sRef();BytesRef previous = null;var outputs = PositiveInt32Outputs.Singleton;var builder = new Builder<long?>(FST.INPUT_TYPE.BYTE1, outputs);while ((scratch = iter.Next()) != null){long cost = iter.Weight;if (previous == null){previous = new BytesRef();}else if (scratch.Equals(previous)){continue; }Lucene.Net.Util.Fst.Util.ToInt32sRef(scratch, scratchInts);builder.Add(scratchInts, cost);previous.CopyBytes(scratch);count++;}fst = builder.Finish();}