Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 978DE1098C for ; Thu, 13 Feb 2014 15:45:28 +0000 (UTC) Received: (qmail 37997 invoked by uid 500); 13 Feb 2014 15:45:27 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 37990 invoked by uid 99); 13 Feb 2014 15:45:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Feb 2014 15:45:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Feb 2014 15:45:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EC93323889FD; Thu, 13 Feb 2014 15:45:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1567954 - in /lucene/dev/trunk/lucene: CHANGES.txt core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java Date: Thu, 13 Feb 2014 15:45:02 -0000 To: commits@lucene.apache.org From: shaie@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140213154502.EC93323889FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: shaie Date: Thu Feb 13 15:45:02 2014 New Revision: 1567954 URL: http://svn.apache.org/r1567954 Log: LUCENE-5443: DocValuesProducer.ramBytesUsed throws ConcurrentModificationException Modified: lucene/dev/trunk/lucene/CHANGES.txt lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java Modified: lucene/dev/trunk/lucene/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1567954&r1=1567953&r2=1567954&view=diff ============================================================================== --- lucene/dev/trunk/lucene/CHANGES.txt (original) +++ lucene/dev/trunk/lucene/CHANGES.txt Thu Feb 13 15:45:02 2014 @@ -263,6 +263,9 @@ Bug fixes loop. ReferenceManager now throws IllegalStateException if currently managed resources ref count is 0. (Simon Willnauer) +* LUCENE-5443: Lucene45DocValuesProducer.ramBytesUsed() may throw + ConcurrentModificationException. (Shai Erera, Simon Willnauer) + API Changes * LUCENE-5339: The facet module was simplified/reworked to make the Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java?rev=1567954&r1=1567953&r2=1567954&view=diff ============================================================================== --- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java (original) +++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/codecs/lucene45/Lucene45DocValuesProducer.java Thu Feb 13 15:45:02 2014 @@ -31,6 +31,7 @@ import java.io.Closeable; // javadocs import java.io.IOException; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; import org.apache.lucene.codecs.CodecUtil; import org.apache.lucene.codecs.DocValuesProducer; @@ -53,6 +54,7 @@ import org.apache.lucene.util.Bits; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.LongValues; +import org.apache.lucene.util.RamUsageEstimator; import org.apache.lucene.util.packed.BlockPackedReader; import org.apache.lucene.util.packed.MonotonicBlockPackedReader; import org.apache.lucene.util.packed.PackedInts; @@ -64,6 +66,7 @@ public class Lucene45DocValuesProducer e private final Map sortedSets; private final Map ords; private final Map ordIndexes; + private final AtomicLong ramBytesUsed; private final IndexInput data; private final int maxDoc; private final int version; @@ -116,6 +119,8 @@ public class Lucene45DocValuesProducer e IOUtils.closeWhileHandlingException(this.data); } } + + ramBytesUsed = new AtomicLong(RamUsageEstimator.shallowSizeOfInstance(getClass())); } private void readSortedField(int fieldNumber, IndexInput meta, FieldInfos infos) throws IOException { @@ -286,14 +291,7 @@ public class Lucene45DocValuesProducer e @Override public long ramBytesUsed() { - long sizeInBytes = 0; - for(MonotonicBlockPackedReader monotonicBlockPackedReader: addressInstances.values()) { - sizeInBytes += Integer.SIZE + monotonicBlockPackedReader.ramBytesUsed(); - } - for(MonotonicBlockPackedReader monotonicBlockPackedReader: ordIndexInstances.values()) { - sizeInBytes += Integer.SIZE + monotonicBlockPackedReader.ramBytesUsed(); - } - return sizeInBytes; + return ramBytesUsed.get(); } LongValues getNumeric(NumericEntry entry) throws IOException { @@ -377,6 +375,7 @@ public class Lucene45DocValuesProducer e data.seek(bytes.addressesOffset); addrInstance = new MonotonicBlockPackedReader(data, bytes.packedIntsVersion, bytes.blockSize, bytes.count, false); addressInstances.put(field.number, addrInstance); + ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT); } addresses = addrInstance; } @@ -427,6 +426,7 @@ public class Lucene45DocValuesProducer e } addrInstance = new MonotonicBlockPackedReader(data, bytes.packedIntsVersion, bytes.blockSize, size, false); addressInstances.put(field.number, addrInstance); + ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT); } addresses = addrInstance; } @@ -498,6 +498,7 @@ public class Lucene45DocValuesProducer e data.seek(entry.offset); ordIndexInstance = new MonotonicBlockPackedReader(data, entry.packedIntsVersion, entry.blockSize, entry.count, false); ordIndexInstances.put(field.number, ordIndexInstance); + ramBytesUsed.addAndGet(ordIndexInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT); } ordIndex = ordIndexInstance; }