mirror of https://github.com/apache/lucene.git
LUCENE-3059: don't leak memory in TermState for pulsing/sep codecs
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1098741 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ab33f1b258
commit
60e5f02062
|
@ -68,15 +68,8 @@ public class PulsingPostingsReaderImpl extends PostingsReaderBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
PulsingTermState clone;
|
PulsingTermState clone = new PulsingTermState();
|
||||||
clone = (PulsingTermState) super.clone();
|
clone.copyFrom(this);
|
||||||
if (postingsSize != -1) {
|
|
||||||
clone.postings = new byte[postingsSize];
|
|
||||||
System.arraycopy(postings, 0, clone.postings, 0, postingsSize);
|
|
||||||
} else {
|
|
||||||
assert wrappedTermState != null;
|
|
||||||
clone.wrappedTermState = (BlockTermState) wrappedTermState.clone();
|
|
||||||
}
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +83,10 @@ public class PulsingPostingsReaderImpl extends PostingsReaderBase {
|
||||||
postings = new byte[ArrayUtil.oversize(other.postingsSize, 1)];
|
postings = new byte[ArrayUtil.oversize(other.postingsSize, 1)];
|
||||||
}
|
}
|
||||||
System.arraycopy(other.postings, 0, postings, 0, other.postingsSize);
|
System.arraycopy(other.postings, 0, postings, 0, other.postingsSize);
|
||||||
} else {
|
} else if (wrappedTermState != null) {
|
||||||
wrappedTermState.copyFrom(other.wrappedTermState);
|
wrappedTermState.copyFrom(other.wrappedTermState);
|
||||||
|
} else {
|
||||||
|
wrappedTermState = (BlockTermState) other.wrappedTermState.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: we do not copy the
|
// NOTE: we do not copy the
|
||||||
|
|
|
@ -151,14 +151,8 @@ public class SepPostingsReaderImpl extends PostingsReaderBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
SepTermState other = (SepTermState) super.clone();
|
SepTermState other = new SepTermState();
|
||||||
other.docIndex = (IntIndexInput.Index) docIndex.clone();
|
other.copyFrom(this);
|
||||||
if (freqIndex != null) {
|
|
||||||
other.freqIndex = (IntIndexInput.Index) freqIndex.clone();
|
|
||||||
}
|
|
||||||
if (posIndex != null) {
|
|
||||||
other.posIndex = (IntIndexInput.Index) posIndex.clone();
|
|
||||||
}
|
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,12 +160,28 @@ public class SepPostingsReaderImpl extends PostingsReaderBase {
|
||||||
public void copyFrom(TermState _other) {
|
public void copyFrom(TermState _other) {
|
||||||
super.copyFrom(_other);
|
super.copyFrom(_other);
|
||||||
SepTermState other = (SepTermState) _other;
|
SepTermState other = (SepTermState) _other;
|
||||||
docIndex.set(other.docIndex);
|
if (docIndex == null) {
|
||||||
if (freqIndex != null && other.freqIndex != null) {
|
docIndex = (IntIndexInput.Index) other.docIndex.clone();
|
||||||
freqIndex.set(other.freqIndex);
|
} else {
|
||||||
|
docIndex.set(other.docIndex);
|
||||||
}
|
}
|
||||||
if (posIndex != null && other.posIndex != null) {
|
if (other.freqIndex != null) {
|
||||||
posIndex.set(other.posIndex);
|
if (freqIndex == null) {
|
||||||
|
freqIndex = (IntIndexInput.Index) other.freqIndex.clone();
|
||||||
|
} else {
|
||||||
|
freqIndex.set(other.freqIndex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
freqIndex = null;
|
||||||
|
}
|
||||||
|
if (other.posIndex != null) {
|
||||||
|
if (posIndex == null) {
|
||||||
|
posIndex = (IntIndexInput.Index) other.posIndex.clone();
|
||||||
|
} else {
|
||||||
|
posIndex.set(other.posIndex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
posIndex = null;
|
||||||
}
|
}
|
||||||
payloadFP = other.payloadFP;
|
payloadFP = other.payloadFP;
|
||||||
skipFP = other.skipFP;
|
skipFP = other.skipFP;
|
||||||
|
|
Loading…
Reference in New Issue