/** * Returns the number of entries in this region. Note that because of the concurrency properties * of the {@link RegionMap}, the number of entries is only an approximate. That is, other threads * may change the number of entries in this region while this method is being invoked. * * @see RegionMap#size */ public int entryCount() { return getDataView().entryCount(this); }
protected int entryCount(Set<Integer> buckets, boolean estimate) { assert buckets == null : "unexpected buckets " + buckets + " for region " + toString(); return getDataView().entryCount(this); }
@Override public int size() { checkTX(); if (this.iterType == IteratorType.VALUES) { // if this is a values-view, then we have to filter out nulls to // determine the correct size int s = 0; for (Iterator<Object> itr = new EntriesIterator(); itr.hasNext(); itr.next()) { s++; } return s; } else if (this.recursive) { return this.topRegion.allEntriesSize(); } else { return view.entryCount(this.topRegion); } }
@Override @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "UL_UNRELEASED_LOCK", justification = "This method unlocks and then conditionally undoes the unlock in the finally-block. Review again at later time.") public int entryCount(LocalRegion localRegion) { // if size is the first operation in the transaction, then reset the txState boolean resetTXState = this.realDeal == null; TXStateProxy txp = null; boolean txUnlocked = false; if (resetTXState) { txp = getTxMgr().pauseTransaction(); } else { if (getLock().isHeldByCurrentThread()) { txUnlocked = true; // bug #42945 - hang trying to compute size for PR getLock().unlock(); } } try { if (resetTXState) { return localRegion.getSharedDataView().entryCount(localRegion); } return getRealDeal(null, localRegion).entryCount(localRegion); } finally { if (resetTXState) { getTxMgr().unpauseTransaction(txp); } else if (txUnlocked) { getLock().lock(); } } }