private void rehash() throws IOException { final PagedGrowableWriter oldTable = table; table = new PagedGrowableWriter(2*oldTable.size(), 1<<30, PackedInts.bitsRequired(count), PackedInts.COMPACT); mask = table.size()-1; for(long idx=0;idx<oldTable.size();idx++) { final long address = oldTable.get(idx); if (address != 0) { addNew(address); } } } }
public long add(Builder<T> builder, Builder.UnCompiledNode<T> nodeIn) throws IOException { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); final long h = hash(nodeIn); long pos = h & mask; int c = 0; while(true) { final long v = table.get(pos); if (v == 0) { // freeze & add final long node = fst.addNode(builder, nodeIn); //System.out.println(" now freeze node=" + node); assert hash(node) == h : "frozenHash=" + hash(node) + " 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; } }
private void rehash() throws IOException { final PagedGrowableWriter oldTable = table; table = new PagedGrowableWriter(2*oldTable.size(), 1<<30, PackedInts.bitsRequired(count), PackedInts.COMPACT); mask = table.size()-1; for(long idx=0;idx<oldTable.size();idx++) { final long address = oldTable.get(idx); if (address != 0) { addNew(address); } } } }
private void rehash() throws IOException { final PagedGrowableWriter oldTable = table; table = new PagedGrowableWriter(2*oldTable.size(), 1<<30, PackedInts.bitsRequired(count), PackedInts.COMPACT); mask = table.size()-1; for(long idx=0;idx<oldTable.size();idx++) { final long address = oldTable.get(idx); if (address != 0) { addNew(address); } } } }
private void rehash() throws IOException { final PagedGrowableWriter oldTable = table; table = new PagedGrowableWriter(2*oldTable.size(), 1<<30, PackedInts.bitsRequired(count), PackedInts.COMPACT); mask = table.size()-1; for(long idx=0;idx<oldTable.size();idx++) { final long address = oldTable.get(idx); if (address != 0) { addNew(address); } } } }
public long add(Builder<T> builder, Builder.UnCompiledNode<T> nodeIn) throws IOException { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); final long h = hash(nodeIn); long pos = h & mask; int c = 0; while(true) { final long v = table.get(pos); if (v == 0) { // freeze & add final long node = fst.addNode(builder, nodeIn); //System.out.println(" now freeze node=" + node); assert hash(node) == h : "frozenHash=" + hash(node) + " 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; } }
public long add(Builder<T> builder, Builder.UnCompiledNode<T> nodeIn) throws IOException { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); final long h = hash(nodeIn); long pos = h & mask; int c = 0; while(true) { final long v = table.get(pos); if (v == 0) { // freeze & add final long node = fst.addNode(builder, nodeIn); //System.out.println(" now freeze node=" + node); assert hash(node) == h : "frozenHash=" + hash(node) + " 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; } }
public long add(Builder<T> builder, Builder.UnCompiledNode<T> nodeIn) throws IOException { //System.out.println("hash: add count=" + count + " vs " + table.size() + " mask=" + mask); final long h = hash(nodeIn); long pos = h & mask; int c = 0; while(true) { final long v = table.get(pos); if (v == 0) { // freeze & add final long node = fst.addNode(builder, nodeIn); //System.out.println(" now freeze node=" + node); assert hash(node) == h : "frozenHash=" + hash(node) + " 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; } }