public void TestListOfOutputs() { PositiveIntOutputs _outputs = PositiveIntOutputs.Singleton; ListOfOutputs <long?> outputs = new ListOfOutputs <long?>(_outputs); Builder <object> builder = new Builder <object>(Lucene.Net.Util.Fst.FST.INPUT_TYPE.BYTE1, outputs); IntsRef scratch = new IntsRef(); // Add the same input more than once and the outputs // are merged: builder.Add(Util.ToIntsRef(new BytesRef("a"), scratch), 1L); builder.Add(Util.ToIntsRef(new BytesRef("a"), scratch), 3L); builder.Add(Util.ToIntsRef(new BytesRef("a"), scratch), 0L); builder.Add(Util.ToIntsRef(new BytesRef("b"), scratch), 17L); FST <object> fst = builder.Finish(); object output = Util.Get(fst, new BytesRef("a")); assertNotNull(output); IList <long?> outputList = outputs.AsList(output); assertEquals(3, outputList.size()); assertEquals(1L, outputList[0]); assertEquals(3L, outputList[1]); assertEquals(0L, outputList[2]); output = Util.Get(fst, new BytesRef("b")); assertNotNull(output); outputList = outputs.AsList(output); assertEquals(1, outputList.size()); assertEquals(17L, outputList[0]); }
public void TestListOfOutputsEmptyString() { PositiveIntOutputs _outputs = PositiveIntOutputs.Singleton; ListOfOutputs <long?> outputs = new ListOfOutputs <long?>(_outputs); Builder <object> builder = new Builder <object>(FST.INPUT_TYPE.BYTE1, outputs); IntsRef scratch = new IntsRef(); builder.Add(scratch, 0L); builder.Add(scratch, 1L); builder.Add(scratch, 17L); builder.Add(scratch, 1L); builder.Add(Util.ToIntsRef(new BytesRef("a"), scratch), 1L); builder.Add(Util.ToIntsRef(new BytesRef("a"), scratch), 3L); builder.Add(Util.ToIntsRef(new BytesRef("a"), scratch), 0L); builder.Add(Util.ToIntsRef(new BytesRef("b"), scratch), 0L); FST <object> fst = builder.Finish(); object output = Util.Get(fst, new BytesRef("")); assertNotNull(output); IList <long?> outputList = outputs.AsList(output); assertEquals(4, outputList.size()); assertEquals(0L, outputList[0]); assertEquals(1L, outputList[1]); assertEquals(17L, outputList[2]); assertEquals(1L, outputList[3]); output = Util.Get(fst, new BytesRef("a")); assertNotNull(output); outputList = outputs.AsList(output); assertEquals(3, outputList.size()); assertEquals(1L, outputList[0]); assertEquals(3L, outputList[1]); assertEquals(0L, outputList[2]); output = Util.Get(fst, new BytesRef("b")); assertNotNull(output); outputList = outputs.AsList(output); assertEquals(1, outputList.size()); assertEquals(0L, outputList[0]); }