@Test @Ignore public void testPut() throws ExecutionException, InterruptedException { int count = 1000000; HugeConfig config = HugeConfig.DEFAULT.clone() .setSegments(256) .setSmallEntrySize(72) .setCapacity(count); final HugeHashMap<CharSequence, SampleValues> map = new HugeHashMap<CharSequence, SampleValues>( config, CharSequence.class, SampleValues.class); long start = System.nanoTime(); final SampleValues value = new SampleValues(); StringBuilder user = new StringBuilder(); for (int i = 0; i < count; i++) { value.ee = i; value.gg = i; value.ii = i; map.put(users(user, i), value); } for (int i = 0; i < count; i++) { assertNotNull(map.get(users(user, i), value)); assertEquals(i, value.ee); assertEquals(i, value.gg, 0.0); assertEquals(i, value.ii); } for (int i = 0; i < count; i++) assertNotNull(map.get(users(user, i), value)); for (int i = 0; i < count; i++) map.remove(users(user, i)); long time = System.nanoTime() - start; System.out.printf("Put/get %,d K operations per second%n", (int) (count * 4 * 1e6 / time)); }
@Override public V put(K key, V value) { long hash = hasher.hash(key); int segment = hasher.getSegment(hash); int segmentHash = hasher.segmentHash(hash); segments[segment].put(segmentHash, key, value, true, true); return null; }
HugeHashMap extends AbstractMap<K, V> implements HugeMap<K, V> { @Override public V put(K key, V value) { long hash = hasher.hash(key); int segment = hasher.getSegment(hash); int segmentHash = hasher.segmentHash(hash); segments[segment].put(segmentHash, key, value, true, true); return null; } }
HugeHashMap extends AbstractMap<K, V> implements HugeMap<K, V> { @Override public V put(K key, V value) { long hash = hasher.hash(key); int segment = hasher.getSegment(hash); int segmentHash = hasher.segmentHash(hash); segments[segment].put(segmentHash, key, value, true, true); return null; } HugeHashMap();  HugeHashMap(HugeConfig config, Class<K> kClass, Class<V> vClass); }
HugeHashMap extends AbstractMap<K, V> implements HugeMap<K, V> { @Override public V put(K key, V value) { long hash = hasher.hash(key); int segment = hasher.getSegment(hash); int segmentHash = hasher.segmentHash(hash); segments[segment].put(segmentHash, key, value, true, true); return null; } HugeHashMap();  HugeHashMap(HugeConfig config, Class<K> kClass, Class<V> vClass); @Override V put(K key, V value); @Override V get(Object key); @Override V get(K key, V value); @Override V remove(Object key); @Override boolean containsKey(Object key); @NotNull @Override Set<Entry<K, V>> entrySet(); @Override V putIfAbsent(@NotNull K key, V value); @Override boolean remove(@NotNull Object key, Object value); @Override boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue); @Override V replace(@NotNull K key, @NotNull V value); @Override boolean isEmpty(); @Override int size(); @Override long offHeapUsed(); @Override void clear(); }
HugeHashMap extends AbstractMap<K, V> implements HugeMap<K, V> { @Override public V put(K key, V value) { long hash = hasher.hash(key); int segment = hasher.getSegment(hash); int segmentHash = hasher.segmentHash(hash); segments[segment].put(segmentHash, key, value, true, true); return null; } HugeHashMap();  HugeHashMap(HugeConfig config, Class<K> kClass, Class<V> vClass); @Override V put(K key, V value); @Override V get(Object key); @Override V get(K key, V value); @Override V remove(Object key); @Override boolean containsKey(Object key); @NotNull @Override Set<Entry<K, V>> entrySet(); @Override V putIfAbsent(@NotNull K key, V value); @Override boolean remove(@NotNull Object key, Object value); @Override boolean replace(@NotNull K key, @NotNull V oldValue, @NotNull V newValue); @Override V replace(@NotNull K key, @NotNull V value); @Override boolean isEmpty(); @Override int size(); @Override long offHeapUsed(); @Override void clear();  }