Skip to content

Commit

Permalink
moving updateAndGet last is not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Jan 9, 2025
1 parent 9143fd3 commit 0017908
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ public MutablePQVectors(ProductQuantization pq) {
@Override
public void encodeAndSet(int ordinal, VectorFloat<?> vector) {
ensureChunkCapacity(ordinal);
pq.encodeTo(vector, get(ordinal));
// increase count first so get() works
vectorCount.updateAndGet(current -> max(current, ordinal + 1));
pq.encodeTo(vector, get(ordinal));
}

@Override
public void setZero(int ordinal) {
ensureChunkCapacity(ordinal);
get(ordinal).zero();
// increase count first so get() works
vectorCount.updateAndGet(current -> max(current, ordinal + 1));
get(ordinal).zero();
}

private void ensureChunkCapacity(int ordinal) {
Expand Down

0 comments on commit 0017908

Please sign in to comment.