Codota Logo
org.h2.mvstore.cache
Code IndexAdd Codota to your IDE (free)

How to use org.h2.mvstore.cache

Best Java code snippets using org.h2.mvstore.cache (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
StringBuilder s =
  • Codota Iconnew StringBuilder()
  • Codota Iconnew StringBuilder(32)
  • Codota IconString str;new StringBuilder(str)
  • Smart code suggestions by Codota
}
origin: com.h2database/h2

/**
 * Check whether there is a resident entry for the given key. This
 * method does not adjust the internal state of the cache.
 *
 * @param key the key (may not be null)
 * @return true if there is a resident entry
 */
public boolean containsKey(long key) {
  int hash = getHash(key);
  return getSegment(hash).containsKey(key, hash);
}
origin: com.h2database/h2

/**
 * Get the value for the given key if the entry is cached. This method
 * adjusts the internal state of the cache sometimes, to ensure commonly
 * used entries stay in the cache.
 *
 * @param key the key (may not be null)
 * @return the value, or null if there is no resident entry
 */
public V get(long key) {
  int hash = getHash(key);
  return getSegment(hash).get(key, hash);
}
origin: com.h2database/h2

/**
 * Get the memory used for the given key.
 *
 * @param key the key (may not be null)
 * @return the memory, or 0 if there is no resident entry
 */
public int getMemory(long key) {
  int hash = getHash(key);
  return getSegment(hash).getMemory(key, hash);
}
origin: com.h2database/h2

private void clearCache(ByteBuffer src, long position) {
  if (cache.size() > 0) {
    int len = src.remaining();
    long p = getCachePos(position);
    while (len > 0) {
      cache.remove(p);
      p += CACHE_BLOCK_SIZE;
      len -= CACHE_BLOCK_SIZE;
    }
  }
}
origin: com.h2database/h2

private Entry<V> find(long key) {
  int hash = getHash(key);
  return getSegment(hash).find(key, hash);
}
origin: com.h2database/h2

/**
 * Add an entry to the cache using the average memory size.
 *
 * @param key the key (may not be null)
 * @param value the value (may not be null)
 * @return the old value, or null if there was no resident entry
 */
public V put(long key, V value) {
  return put(key, value, sizeOf(value));
}
origin: com.h2database/h2

/**
 * Ensure the last entry of the stack is cold.
 */
private void pruneStack() {
  while (true) {
    Entry<V> last = stack.stackPrev;
    // must stop at a hot entry or the stack head,
    // but the stack head itself is also hot, so we
    // don't have to test it
    if (last.isHot()) {
      break;
    }
    // the cold entry is still in the queue
    removeFromStack(last);
  }
}
origin: com.h2database/h2

@Override
public FileChannel open(String mode) throws IOException {
  return new FileCache(getBase().open(mode));
}
origin: com.h2database/h2

/**
 * Remove all entries.
 */
public void clear() {
  long max = getMaxItemSize();
  for (int i = 0; i < segmentCount; i++) {
    segments[i] = new Segment<>(
        max, stackMoveDistance, 8, nonResidentQueueSize);
  }
}
origin: com.h2database/h2

/**
 * Put the page in the cache.
 *
 * @param pos the page position
 * @param page the page
 * @param memory the memory used
 */
void cachePage(long pos, Page page, int memory) {
  if (cache != null) {
    cache.put(pos, page, memory);
  }
}
origin: com.h2database/h2

/**
 * Get the amount of memory used for caching, in MB.
 * Note that this does not include the page chunk references cache, which is
 * 25% of the size of the page cache.
 *
 * @return the amount of memory used for caching
 */
public int getCacheSizeUsed() {
  if (cache == null) {
    return 0;
  }
  return (int) (cache.getUsedMemory() / 1024 / 1024);
}
origin: com.h2database/h2

/**
 * Get the maximum cache size, in MB.
 * Note that this does not include the page chunk references cache, which is
 * 25% of the size of the page cache.
 *
 * @return the cache size
 */
public int getCacheSize() {
  if (cache == null) {
    return 0;
  }
  return (int) (cache.getMaxMemory() / 1024 / 1024);
}
origin: com.h2database/h2

/**
 * Get the memory used for the given key.
 *
 * @param key the key (may not be null)
 * @param hash the hash
 * @return the memory, or 0 if there is no resident entry
 */
int getMemory(long key, int hash) {
  Entry<V> e = find(key, hash);
  return e == null ? 0 : e.memory;
}
origin: com.h2database/h2

/**
 * Check whether the cache is empty.
 *
 * @return true if it is empty
 */
public boolean isEmpty() {
  return size() == 0;
}
origin: com.h2database/h2

/**
 * Evict cold entries (resident and non-resident) until the memory limit
 * is reached. The new entry is added as a cold entry, except if it is
 * the only entry.
 */
private void evict() {
  do {
    evictBlock();
  } while (usedMemory > maxMemory);
}
origin: com.h2database/h2

private static <V> Entry<V> copy(Entry<V> old) {
  Entry<V> e = new Entry<>();
  e.key = old.key;
  e.value = old.value;
  e.memory = old.memory;
  e.topMove = old.topMove;
  return e;
}
origin: com.h2database/h2

private void addToMap(Entry<V> e) {
  int index = getHash(e.key) & mask;
  e.mapNext = entries[index];
  entries[index] = e;
  usedMemory += e.memory;
  mapSize++;
}
origin: com.h2database/h2

/**
 * Get the value for the given key if the entry is cached. This method does
 * not modify the internal state.
 *
 * @param key the key (may not be null)
 * @return the value, or null if there is no resident entry
 */
public V peek(long key) {
  Entry<V> e = find(key);
  return e == null ? null : e.value;
}
origin: com.h2database/h2

private Segment<V> getSegment(int hash) {
  return segments[getSegmentIndex(hash)];
}
origin: com.h2database/h2

/**
 * Check whether there is a resident entry for the given key. This
 * method does not adjust the internal state of the cache.
 *
 * @param key the key (may not be null)
 * @param hash the hash
 * @return true if there is a resident entry
 */
boolean containsKey(long key, int hash) {
  Entry<V> e = find(key, hash);
  return e != null && e.value != null;
}
org.h2.mvstore.cache

Most used classes

  • CacheLongKeyLIRS
    A scan resistant cache that uses keys of type long. It is meant to cache objects that are relatively
  • CacheLongKeyLIRS$Config
    The cache configuration.
  • CacheLongKeyLIRS$Entry
    A cache entry. Each entry is either hot (low inter-reference recency; LIR), cold (high inter-referen
  • CacheLongKeyLIRS$Segment
    A cache segment
  • FilePathCache$FileCache
    A file with a read cache.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now