mirror of https://github.com/apache/druid.git
LongsLongEncodingReader: Implement "duplicate", fixing concurrency bug. (#11098)
Regression introduced in #11004 due to overzealous optimization. Even though we replaced stateful usage of ByteBuffer with stateless usage of Memory, we still need to create a new object on "duplicate" due to semantics of setBuffer.
This commit is contained in:
parent
f60d8ea1c3
commit
c8e394015d
|
@ -287,6 +287,11 @@ public class CompressionFactory
|
|||
|
||||
int read(long[] out, int outPosition, int[] indexes, int length, int indexOffset, int limit);
|
||||
|
||||
/**
|
||||
* Duplicates this reader, creating a new reader that does not share any state. Important to achieve thread-safety,
|
||||
* because a common pattern is to duplicate a reader multiple times and then call {@link #setBuffer} on the
|
||||
* various duplicates.
|
||||
*/
|
||||
LongEncodingReader duplicate();
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,6 @@ public class LongsLongEncodingReader implements CompressionFactory.LongEncodingR
|
|||
@Override
|
||||
public CompressionFactory.LongEncodingReader duplicate()
|
||||
{
|
||||
return this;
|
||||
return new LongsLongEncodingReader(buffer.getByteBuffer(), buffer.getTypeByteOrder());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue