private synchronized int addInternal(int doc, long hasValueMask) { if (finished) { throw new IllegalStateException("already finished"); } assert doc < maxDoc; // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == Integer.MAX_VALUE) { throw new IllegalStateException("cannot support more than Integer.MAX_VALUE doc/value entries"); } // grow the structures to have room for more elements if (docs.size() == size) { grow(size+1); } docs.set(size, (((long)doc) << SHIFT) | hasValueMask); ++size; return size-1; }
/** Freezes internal data structures and sorts updates by docID for efficient iteration. */ final synchronized void finish() { if (finished) { throw new IllegalStateException("already finished"); } finished = true; // shrink wrap if (size < docs.size()) { resize(size); } new InPlaceMergeSorter() { @Override protected void swap(int i, int j) { DocValuesFieldUpdates.this.swap(i, j); } @Override protected int compare(int i, int j) { // increasing docID order: // NOTE: we can have ties here, when the same docID was updated in the same segment, in which case we rely on sort being // stable and preserving original order so the last update to that docID wins return Long.compare(docs.get(i)>>>1, docs.get(j)>>>1); } }.sort(0, size); }
private synchronized int addInternal(int doc, long hasValueMask) { if (finished) { throw new IllegalStateException("already finished"); } assert doc < maxDoc; // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == Integer.MAX_VALUE) { throw new IllegalStateException("cannot support more than Integer.MAX_VALUE doc/value entries"); } // grow the structures to have room for more elements if (docs.size() == size) { grow(size+1); } docs.set(size, (((long)doc) << SHIFT) | hasValueMask); ++size; return size-1; }
/** Freezes internal data structures and sorts updates by docID for efficient iteration. */ final synchronized void finish() { if (finished) { throw new IllegalStateException("already finished"); } finished = true; // shrink wrap if (size < docs.size()) { resize(size); } new InPlaceMergeSorter() { @Override protected void swap(int i, int j) { DocValuesFieldUpdates.this.swap(i, j); } @Override protected int compare(int i, int j) { // increasing docID order: // NOTE: we can have ties here, when the same docID was updated in the same segment, in which case we rely on sort being // stable and preserving original order so the last update to that docID wins return Long.compare(docs.get(i)>>>1, docs.get(j)>>>1); } }.sort(0, size); }
@Override public void add(int doc, Object value) { // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == Integer.MAX_VALUE) { throw new IllegalStateException("cannot support more than Integer.MAX_VALUE doc/value entries"); } Long val = (Long) value; // grow the structures to have room for more elements if (docs.size() == size) { docs = docs.grow(size + 1); values = values.grow(size + 1); } docs.set(size, doc); values.set(size, val.longValue()); ++size; }
@Override public void add(int doc, Object value) { // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == Integer.MAX_VALUE) { throw new IllegalStateException("cannot support more than Integer.MAX_VALUE doc/value entries"); } Long val = (Long) value; // grow the structures to have room for more elements if (docs.size() == size) { docs = docs.grow(size + 1); values = values.grow(size + 1); } docs.set(size, doc); values.set(size, val.longValue()); ++size; }
@Override public void add(int doc, Object value) { // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == Integer.MAX_VALUE) { throw new IllegalStateException("cannot support more than Integer.MAX_VALUE doc/value entries"); } BytesRef val = (BytesRef) value; // grow the structures to have room for more elements if (docs.size() == size) { docs = docs.grow(size + 1); offsets = offsets.grow(size + 1); lengths = lengths.grow(size + 1); } docs.set(size, doc); offsets.set(size, values.length()); lengths.set(size, val.length); values.append(val); ++size; }
@Override public void add(int doc, Object value) { // TODO: if the Sorter interface changes to take long indexes, we can remove that limitation if (size == Integer.MAX_VALUE) { throw new IllegalStateException("cannot support more than Integer.MAX_VALUE doc/value entries"); } BytesRef val = (BytesRef) value; // grow the structures to have room for more elements if (docs.size() == size) { docs = docs.grow(size + 1); offsets = offsets.grow(size + 1); lengths = lengths.grow(size + 1); } docs.set(size, doc); offsets.set(size, values.length()); lengths.set(size, val.length); values.append(val); ++size; }