@Override protected void set(long idx) { value = values.get(idx); } }
private void addNew(long address) throws IOException { long pos = hash(address) & mask; int c = 0; while(true) { if (table.get(pos) == 0) { table.set(pos, address); break; } // 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); } } } }
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 int addOrdinal(int docID, long ordinal) { final long position = positions.get(docID); if (position == 0L) { // on the first level return firstLevel(docID, ordinal); } else { return nonFirstLevel(docID, ordinal, position); } }
return; long sliceID = firstNextLevelSlices.get(docID); if (sliceID == 0L) { return; final long offset = startOffset(level, sliceID); for (int j = 0; j < numSlots; ++j) { final long ord = ordinals[level].get(offset + j); if (ord == 0L) { return; return; sliceID = nextLevelSlices[level].get(sliceID); if (sliceID == 0L) { return;
@Override protected void set(long idx) { value = values.get(idx); } }
private void addNew(long address) throws IOException { long pos = hash(address) & mask; int c = 0; while(true) { if (table.get(pos) == 0) { table.set(pos, address); break; } // quadratic probe pos = (pos + (++c)) & mask; } }
public int addOrdinal(int docID, long ordinal) { final long position = positions.get(docID); if (position == 0L) { // on the first level return firstLevel(docID, ordinal); } else { return nonFirstLevel(docID, ordinal, position); } }
@Override protected void swap(int i, int j) { long tmpDoc = docs.get(j); docs.set(j, docs.get(i)); docs.set(i, tmpDoc); long tmpOffset = offsets.get(j); offsets.set(j, offsets.get(i)); offsets.set(i, tmpOffset); long tmpLength = lengths.get(j); lengths.set(j, lengths.get(i)); lengths.set(i, tmpLength); }
private void addNew(long address) throws IOException { long pos = hash(address) & mask; int c = 0; while(true) { if (table.get(pos) == 0) { table.set(pos, address); break; } // quadratic probe pos = (pos + (++c)) & mask; } }
public int addOrdinal(int docID, long ordinal) { final long position = positions.get(docID); if (position == 0L) { // on the first level return firstLevel(docID, ordinal); } else { return nonFirstLevel(docID, ordinal, position); } }
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); } } } }