Skip to content
Permalink
Browse files

LUCENE-6745: fix IndexInput consumers to not share an instance while …

…cloning from another thread
  • Loading branch information...
mikemccand authored and dweiss committed Jan 24, 2016
1 parent bc3e643 commit 74e5f1c6ae45aad2bf2580e10e0712fe35ac0a0b
@@ -278,7 +278,7 @@ public String toString() {

@Override
public void checkIntegrity() throws IOException {
CodecUtil.checksumEntireFile(data);
CodecUtil.checksumEntireFile(data.clone());
}

@Override
@@ -297,6 +297,7 @@ public synchronized NumericDocValues getNumeric(FieldInfo field) throws IOExcept

private NumericRawValues loadNumeric(NumericEntry entry) throws IOException {
NumericRawValues ret = new NumericRawValues();
IndexInput data = this.data.clone();
data.seek(entry.offset + entry.missingBytes);
switch (entry.byteWidth) {
case 1:
@@ -394,6 +395,7 @@ public BytesRef get(int docID) {
}

private BinaryRawValues loadBinary(BinaryEntry entry) throws IOException {
IndexInput data = this.data.clone();
data.seek(entry.offset);
final byte[] bytes = new byte[entry.numBytes];
data.readBytes(bytes, 0, entry.numBytes);
@@ -308,7 +308,7 @@ public long ramBytesUsed() {

@Override
public void checkIntegrity() throws IOException {
CodecUtil.checksumEntireFile(data);
CodecUtil.checksumEntireFile(data.clone());
}

@Override
@@ -323,6 +323,7 @@ public String toString() {

private NumericDocValues loadNumeric(FieldInfo field) throws IOException {
NumericEntry entry = numerics.get(field.name);
IndexInput data = this.data.clone();
data.seek(entry.offset + entry.missingBytes);
switch (entry.format) {
case TABLE_COMPRESSED:
@@ -438,6 +439,7 @@ public BytesRef get(int docID) {
private BytesAndAddresses loadBinary(FieldInfo field) throws IOException {
BytesAndAddresses bytesAndAddresses = new BytesAndAddresses();
BinaryEntry entry = binaries.get(field.name);
IndexInput data = this.data.clone();
data.seek(entry.offset);
PagedBytes bytes = new PagedBytes(16);
bytes.copy(data, entry.numBytes);
@@ -465,6 +467,7 @@ public SortedDocValues getSorted(FieldInfo field) throws IOException {
synchronized(this) {
instance = fstInstances.get(field.name);
if (instance == null) {
IndexInput data = this.data.clone();
data.seek(entry.offset);
instance = new FST<>(data, PositiveIntOutputs.getSingleton());
if (!merging) {
@@ -545,6 +548,7 @@ public SortedNumericDocValues getSortedNumeric(FieldInfo field) throws IOExcepti
synchronized (this) {
MonotonicBlockPackedReader res = addresses.get(field.name);
if (res == null) {
IndexInput data = this.data.clone();
data.seek(entry.addressOffset);
res = MonotonicBlockPackedReader.of(data, entry.packedIntsVersion, entry.blockSize, entry.valueCount, false);
if (!merging) {
@@ -617,6 +621,7 @@ public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException {
synchronized(this) {
instance = fstInstances.get(field.name);
if (instance == null) {
IndexInput data = this.data.clone();
data.seek(entry.offset);
instance = new FST<>(data, PositiveIntOutputs.getSingleton());
if (!merging) {

0 comments on commit 74e5f1c

Please sign in to comment.
You can’t perform that action at this time.