Skip to content

Commit

Permalink
move updateAndGet last to establish happens-before for the actual encode
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Jan 9, 2025
1 parent 72044bf commit 9143fd3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public MutablePQVectors(ProductQuantization pq) {
@Override
public void encodeAndSet(int ordinal, VectorFloat<?> vector) {
ensureChunkCapacity(ordinal);
vectorCount.updateAndGet(current -> max(current, ordinal + 1));
pq.encodeTo(vector, get(ordinal));
vectorCount.updateAndGet(current -> max(current, ordinal + 1));
}

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

private void ensureChunkCapacity(int ordinal) {
Expand Down

0 comments on commit 9143fd3

Please sign in to comment.