Skip to content

Commit

Permalink
fix initialization bug in SlowCompositeCodecReaderWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Sokolov committed Oct 18, 2024
1 parent 1a2c3bb commit 568372f
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -887,14 +887,15 @@ public Floats vectors() {
return new Floats() {
int lastSubIndex = 0;
Floats subValues;
// TODO: cache the subValues so we only need to create each one once (same in Bytes below)

@Override
public float[] get(int ord) throws IOException {
assert ord >= 0 && ord < size;
// We need to implement fully random-access API here in order to support callers like
// SortingCodecReader that rely on it.
int newSubIndex = findSub(ord, lastSubIndex, starts);
if (newSubIndex != lastSubIndex) {
if (newSubIndex != lastSubIndex || subValues == null) {
lastSubIndex = newSubIndex;
assert subs.get(lastSubIndex).sub != null;
subValues = subs.get(lastSubIndex).sub.vectors();
Expand Down Expand Up @@ -963,7 +964,7 @@ public int size() {
@Override
public Bytes vectors() {
return new Bytes() {
int lastSubIndex = -1;
int lastSubIndex = 0;
Bytes subValues;

@Override
Expand All @@ -973,7 +974,7 @@ public byte[] get(int ord) throws IOException {
// SortingCodecReader that rely on it. We maintain lastSubIndex since we expect some
// repetition.
int newSubIndex = findSub(ord, lastSubIndex, starts);
if (newSubIndex != lastSubIndex) {
if (newSubIndex != lastSubIndex || subValues == null) {
lastSubIndex = newSubIndex;
assert subs.get(lastSubIndex).sub != null;
subValues = subs.get(lastSubIndex).sub.vectors();
Expand Down

0 comments on commit 568372f

Please sign in to comment.