private EhcacheConcurrentOffHeapClockCache<K, OffHeapValueHolder<V>> createBackingMap(long size, Serializer<K> keySerializer, Serializer<V> valueSerializer, SwitchableEvictionAdvisor<K, OffHeapValueHolder<V>> evictionAdvisor) { HeuristicConfiguration config = new HeuristicConfiguration(size); PageSource source = new UpfrontAllocatingPageSource(getBufferSource(), config.getMaximumSize(), config.getMaximumChunkSize(), config.getMinimumChunkSize()); Portability<K> keyPortability = new SerializerPortability<>(keySerializer); Portability<OffHeapValueHolder<V>> elementPortability = new OffHeapValueHolderPortability<>(valueSerializer); Factory<OffHeapBufferStorageEngine<K, OffHeapValueHolder<V>>> storageEngineFactory = OffHeapBufferStorageEngine.createFactory(PointerSize.INT, source, config .getSegmentDataPageSize(), keyPortability, elementPortability, false, true); Factory<? extends PinnableSegment<K, OffHeapValueHolder<V>>> segmentFactory = new EhcacheSegmentFactory<>( source, storageEngineFactory, config.getInitialSegmentTableSize(), evictionAdvisor, mapEvictionListener); return new EhcacheConcurrentOffHeapClockCache<>(evictionAdvisor, segmentFactory, config.getConcurrency()); }
@Override public String toString() { return "OffHeapBufferStorageEngine allocated=" + DebuggingUtils.toBase2SuffixedString(getAllocatedMemory()) + "B " + "occupied=" + DebuggingUtils.toBase2SuffixedString(getOccupiedMemory()) + "B\n" + "Storage Area: " + storageArea; }
public static <K, V> Factory<OffHeapBufferStorageEngine<K, V>> createFactory(final PointerSize width, final PageSource source, final int initialPageSize, final int maximalPageSize, final Portability<? super K> keyPortability, final Portability<? super V> valuePortability, final boolean thief, final boolean victim) { return () -> new OffHeapBufferStorageEngine<>(width, source, initialPageSize, maximalPageSize, keyPortability, valuePortability, thief, victim); }
@Override protected WriteContext getKeyWriteContext(long address) { int keyLength = storageArea.readInt(address + KEY_LENGTH_OFFSET); return getWriteContext(address + DATA_OFFSET, keyLength); }
@Override public long getDataSize() { //TODO This is an overestimate. return getOccupiedMemory(); }
@Override public boolean moved(long from, long to) { return owner.updateEncoding(readKeyHash(to), from, to, ~0); }
@Override public long getVitalMemory() { return getAllocatedMemory(); }
@Override public String toString() { return "OffHeapBufferStorageEngine allocated=" + DebuggingUtils.toBase2SuffixedString(getAllocatedMemory()) + "B " + "occupied=" + DebuggingUtils.toBase2SuffixedString(getOccupiedMemory()) + "B\n" + "Storage Area: " + storageArea; }
public static <K, V> Factory<OffHeapBufferStorageEngine<K, V>> createFactory(final PointerSize width, final PageSource source, final int initialPageSize, final int maximalPageSize, final Portability<? super K> keyPortability, final Portability<? super V> valuePortability, final boolean thief, final boolean victim, final float compressThreshold) { return () -> new OffHeapBufferStorageEngine<>(width, source, initialPageSize, maximalPageSize, keyPortability, valuePortability, thief, victim, compressThreshold); }
@Override protected WriteContext getKeyWriteContext(long address) { int keyLength = storageArea.readInt(address + KEY_LENGTH_OFFSET); return getWriteContext(address + DATA_OFFSET, keyLength); }
@Override public long getDataSize() { //TODO This is an overestimate. return getOccupiedMemory(); }
@Override public boolean moved(long from, long to) { return owner.updateEncoding(readKeyHash(to), from, to, ~0); }
@Override public long getVitalMemory() { return getAllocatedMemory(); }
Portability<String> keyPortability = new SerializerPortability<>(keySerializer); Portability<String> elementPortability = new SerializerPortability<>(valueSerializer); Factory<OffHeapBufferStorageEngine<String, String>> storageEngineFactory = OffHeapBufferStorageEngine.createFactory(PointerSize.INT, pageSource, configuration.getInitialSegmentTableSize(), keyPortability, elementPortability, false, true); SwitchableEvictionAdvisor<String, String> wrappedEvictionAdvisor = new SwitchableEvictionAdvisor<String, String>() {
public static <K, V> Factory<OffHeapBufferStorageEngine<K, V>> createFactory(final PointerSize width, final PageSource source, final int pageSize, final Portability<? super K> keyPortability, final Portability<? super V> valuePortability, final boolean thief, final boolean victim) { return () -> new OffHeapBufferStorageEngine<>(width, source, pageSize, keyPortability, valuePortability, thief, victim); }
@Override protected WriteContext getValueWriteContext(long address) { int keyLength = storageArea.readInt(address + KEY_LENGTH_OFFSET); int valueLength = storageArea.readInt(address + VALUE_LENGTH_OFFSET); return getWriteContext(address + DATA_OFFSET + keyLength, valueLength); }
Portability<String> keyPortability = new SerializerPortability<>(keySerializer); Portability<String> elementPortability = new SerializerPortability<>(valueSerializer); Factory<OffHeapBufferStorageEngine<String, String>> storageEngineFactory = OffHeapBufferStorageEngine.createFactory(PointerSize.INT, pageSource, configuration.getInitialSegmentTableSize(), keyPortability, elementPortability, false, true); SwitchableEvictionAdvisor<String, String> wrappedEvictionAdvisor = new SwitchableEvictionAdvisor<String, String>() {
public static <K, V> Factory<OffHeapBufferStorageEngine<K, V>> createFactory(final PointerSize width, final PageSource source, final int pageSize, final Portability<? super K> keyPortability, final Portability<? super V> valuePortability, final boolean thief, final boolean victim) { return () -> new OffHeapBufferStorageEngine<>(width, source, pageSize, keyPortability, valuePortability, thief, victim); }
@Override protected WriteContext getValueWriteContext(long address) { int keyLength = storageArea.readInt(address + KEY_LENGTH_OFFSET); int valueLength = storageArea.readInt(address + VALUE_LENGTH_OFFSET); return getWriteContext(address + DATA_OFFSET + keyLength, valueLength); }
private EhcacheConcurrentOffHeapClockCache<K, OffHeapValueHolder<V>> createBackingMap(long size, Serializer<K> keySerializer, Serializer<V> valueSerializer, SwitchableEvictionAdvisor<K, OffHeapValueHolder<V>> evictionAdvisor) { HeuristicConfiguration config = new HeuristicConfiguration(size); PageSource source = new UpfrontAllocatingPageSource(getBufferSource(), config.getMaximumSize(), config.getMaximumChunkSize(), config.getMinimumChunkSize()); Portability<K> keyPortability = new SerializerPortability<>(keySerializer); Portability<OffHeapValueHolder<V>> elementPortability = new OffHeapValueHolderPortability<>(valueSerializer); Factory<OffHeapBufferStorageEngine<K, OffHeapValueHolder<V>>> storageEngineFactory = OffHeapBufferStorageEngine.createFactory(PointerSize.INT, source, config .getSegmentDataPageSize(), keyPortability, elementPortability, false, true); Factory<? extends PinnableSegment<K, OffHeapValueHolder<V>>> segmentFactory = new EhcacheSegmentFactory<>( source, storageEngineFactory, config.getInitialSegmentTableSize(), evictionAdvisor, mapEvictionListener); return new EhcacheConcurrentOffHeapClockCache<>(evictionAdvisor, segmentFactory, config.getConcurrency()); }