コード例 #1
0
 /**
  * Temporarily disables auto-compaction. MUST be followed by calling {@link
  * #reenableAutoCompaction}.
  *
  * @see gnu.trove.impl.hash.THash#tempDisableAutoCompaction()
  */
 public void tempDisableAutoCompaction() {
   try {
     lock.xlock();
     cache.tempDisableAutoCompaction();
   } finally {
     lock.xunlock();
   }
 }
コード例 #2
0
 /**
  * Re-enable auto-compaction after it was disabled via {@link #tempDisableAutoCompaction()}.
  *
  * @param check_for_compaction True if compaction should be performed if needed before returning.
  *     If false, no compaction will be performed.
  * @see gnu.trove.impl.hash.THash#reenableAutoCompaction(boolean)
  */
 public void reenableAutoCompaction(boolean check_for_compaction) {
   try {
     lock.xlock();
     cache.reenableAutoCompaction(check_for_compaction);
   } finally {
     lock.xunlock();
   }
 }
コード例 #3
0
 /**
  * The auto-compaction factor controls whether and when a table performs a compaction
  * automatically after a certain number of remove operations. If the value is non-zero, the number
  * of removes that need to occur for auto-compaction is the size of table at the time of the
  * previous compaction (or the initial capacity) multiplied by this factor.
  *
  * <p>Setting this value to zero will disable auto-compaction.
  *
  * @param factor a <tt>float</tt> that indicates the auto-compaction factor
  * @see gnu.trove.impl.hash.THash#setAutoCompactionFactor(float)
  */
 public void setAutoCompactionFactor(float factor) {
   try {
     lock.xlock();
     cache.setAutoCompactionFactor(factor);
   } finally {
     lock.xunlock();
   }
 }
コード例 #4
0
 /**
  * Returns the cache's auto compaction factor
  *
  * @return a <<tt>float</tt> that represents the auto-compaction factor.
  * @see gnu.trove.impl.hash.THash#getAutoCompactionFactor()
  */
 public float getAutoCompactionFactor() {
   try {
     lock.xlock();
     return cache.getAutoCompactionFactor();
   } finally {
     lock.xunlock();
   }
 }
コード例 #5
0
 /**
  * Compresses the cache to the minimum prime size
  *
  * @see gnu.trove.impl.hash.THash#trimToSize()
  */
 public final void trimToSize() {
   try {
     lock.xlock();
     cache.trimToSize();
   } finally {
     lock.xunlock();
   }
 }
コード例 #6
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#size()
  */
 @Override
 public int size() {
   try {
     lock.xlock();
     return cache.size();
   } finally {
     lock.xunlock();
   }
 }
コード例 #7
0
 /**
  * Adjusts the primitive value mapped to the key if the key is present in the map.
  *
  * @param key The stringy key
  * @param value The value
  * @return true if a mapping was found and modified.
  * @see gnu.trove.map.hash.TObjectLongHashMap#adjustValue(java.lang.Object, long)
  */
 public boolean adjustValue(CharSequence key, long value) {
   if (key == null) throw new IllegalArgumentException("The passed key was null");
   try {
     lock.xlock();
     return cache.adjustValue(wrap(key), value);
   } finally {
     lock.xunlock();
   }
 }
コード例 #8
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#clear()
  */
 @Override
 public void clear() {
   try {
     lock.xlock();
     cache.clear();
   } finally {
     lock.xunlock();
   }
 }
コード例 #9
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#remove(java.lang.CharSequence)
  */
 @Override
 public long remove(CharSequence key) {
   if (key == null) throw new IllegalArgumentException("The passed key was null");
   try {
     lock.xlock();
     return cache.remove(wrap(key));
   } finally {
     lock.xunlock();
   }
 }
コード例 #10
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#putIfAbsent(java.lang.CharSequence,
  *     long)
  */
 @Override
 public long putIfAbsent(CharSequence key, long value) {
   if (key == null) throw new IllegalArgumentException("The passed key was null");
   try {
     lock.xlock();
     return cache.putIfAbsent(wrap(key), value);
   } finally {
     lock.xunlock();
   }
 }
コード例 #11
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IKeyCache#purge()
  */
 @Override
 public void purge() {
   try {
     lock.xlock();
     cache.clear();
     cache.trimToSize();
   } finally {
     lock.xunlock();
   }
 }
コード例 #12
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#get(java.lang.CharSequence)
  */
 @Override
 public long get(CharSequence key) {
   if (key == null) return NO_ENTRY_VALUE;
   try {
     lock.xlock();
     if (cache.isEmpty()) return NO_ENTRY_VALUE;
     return cache.get(wrap(key));
   } finally {
     lock.xunlock();
   }
 }
コード例 #13
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#containsKey(java.lang.CharSequence)
  */
 @Override
 public boolean containsKey(CharSequence key) {
   if (key == null) return false;
   try {
     lock.xlock();
     if (cache.isEmpty()) return false;
     return cache.containsKey(wrap(key));
   } finally {
     lock.xunlock();
   }
 }
コード例 #14
0
 /**
  * {@inheritDoc}
  *
  * @see org.helios.rindle.store.chronicle.IStringKeyCache#putAll(java.util.Map)
  */
 @Override
 public void putAll(Map<? extends CharSequence, ? extends Long> map) {
   if (map == null) throw new IllegalArgumentException("The passed map was null");
   if (map.isEmpty()) return;
   try {
     lock.xlock();
     for (Map.Entry<? extends CharSequence, ? extends Long> entry : map.entrySet()) {
       _put(entry.getKey(), entry.getValue().longValue());
     }
   } finally {
     lock.xunlock();
   }
 }