private CompiledNode CompileNode(UnCompiledNode <T> nodeIn, int tailLength) { long node; if (dedupHash != null && (doShareNonSingletonNodes || nodeIn.NumArcs <= 1) && tailLength <= shareMaxTailLength) { if (nodeIn.NumArcs == 0) { node = fst.AddNode(nodeIn); } else { node = dedupHash.Add(nodeIn); } } else { node = fst.AddNode(nodeIn); } if (Debugging.AssertsEnabled) { Debugging.Assert(node != -2); } nodeIn.Clear(); return(new CompiledNode { Node = node }); }
private CompiledNode CompileNode(UnCompiledNode <T> nodeIn, int tailLength) { long node; if (dedupHash != null && (doShareNonSingletonNodes || nodeIn.NumArcs <= 1) && tailLength <= shareMaxTailLength) { if (nodeIn.NumArcs == 0) { node = fst.AddNode(nodeIn); } else { node = dedupHash.Add(nodeIn); } } else { node = fst.AddNode(nodeIn); } Debug.Assert(node != -2); nodeIn.Clear(); CompiledNode fn = new CompiledNode(); fn.Node = node; return(fn); }
public long Add(Builder.UnCompiledNode <T> nodeIn) { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); long h = Hash(nodeIn); long pos = h & mask; int c = 0; while (true) { long v = table.Get(pos); if (v == 0) { // freeze & add long node = fst.AddNode(nodeIn); //System.out.println(" now freeze node=" + node); if (Debugging.AssertsEnabled) { // LUCENENET specific - store hash value and reuse it, since it might be expensive to create long hash = Hash(node); Debugging.Assert(hash == h, "frozenHash={0} vs h={1}", hash, h); } count++; table.Set(pos, node); // Rehash at 2/3 occupancy: if (count > 2 * table.Count / 3) { Rehash(); } return(node); } else if (NodesEqual(nodeIn, v)) { // same node is already here return(v); } // quadratic probe pos = (pos + (++c)) & mask; } }
public long Add(Builder.UnCompiledNode <T> nodeIn) { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); long h = Hash(nodeIn); long pos = h & mask; int c = 0; while (true) { long v = table.Get(pos); if (v == 0) { // freeze & add long node = fst.AddNode(nodeIn); //System.out.println(" now freeze node=" + node); if (Debugging.AssertsEnabled) { Debugging.Assert(Hash(node) == h, () => "frozenHash=" + Hash(node) + " vs h=" + h); } count++; table.Set(pos, node); // Rehash at 2/3 occupancy: if (count > 2 * table.Count / 3) { Rehash(); } return(node); } else if (NodesEqual(nodeIn, v)) { // same node is already here return(v); } // quadratic probe pos = (pos + (++c)) & mask; } }
public long Add(Builder <T> .UnCompiledNode <T> nodeIn) { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); long h = Hash(nodeIn); long pos = h & Mask; int c = 0; while (true) { long v = Table.Get(pos); if (v == 0) { // freeze & add long node = Fst.AddNode(nodeIn); //System.out.println(" now freeze node=" + node); long hashNode = Hash(node); Debug.Assert(hashNode == h, "frozenHash=" + hashNode + " vs h=" + h); Count++; Table.Set(pos, node); // Rehash at 2/3 occupancy: if (Count > 2 * Table.Size() / 3) { Rehash(); } return(node); } else if (NodesEqual(nodeIn, v)) { // same node is already here return(v); } // quadratic probe pos = (pos + (++c)) & Mask; } }