public static int capacity(HashConfigWrapper conf, int size) { return capacity(conf, size, false); }
final void postInsertHook() { if (++size > maxSize) { /* if LHash hash */ int capacity = capacity(); if (!isMaxCapacity(capacity)) { rehash(capacity << 1); } /* elif !(LHash hash) */ tryRehashForExpansion(grownCapacity()); /* endif */ } }
@Override public final HashFloatLongMapFactory withHashConfig(@Nonnull HashConfig hashConf) { if (configIsSuitableForMutableLHash(hashConf)) return lHashLikeThisWith(hashConf, getDefaultExpectedSize() ); return qHashLikeThisWith(hashConf, getDefaultExpectedSize() ); }
private boolean isMaxCapacity(int capacity) { return LHashCapacities.isMaxCapacity(capacity, doubleSizedArrays()); }
public static long capacity(HashConfigWrapper conf, long size, boolean doubleSizedArrays) { assert size >= 0L : "size must be non-negative"; long desiredCapacity = conf.targetCapacity(size); if (desiredCapacity <= (long) MIN_CAPACITY) return (long) MIN_CAPACITY; long maxCapacity = MAX_LONG_CAPACITY; if (doubleSizedArrays) maxCapacity >>= 1L; if (desiredCapacity < maxCapacity) { if (isPowerOf2(desiredCapacity)) return desiredCapacity; long lesserCapacity = highestOneBit(desiredCapacity); long greaterCapacity = lesserCapacity << 1; return chooseBetter(conf, size, desiredCapacity, lesserCapacity, greaterCapacity, greaterCapacity); } return maxCapacity; }
private boolean isMaxCapacity(int capacity) { return LHashCapacities.isMaxCapacity(capacity, doubleSizedArrays()); }
public static int capacity(HashConfigWrapper conf, int size, boolean doubleSizedArrays) { assert size >= 0 : "size must be non-negative"; int desiredCapacity = conf.targetCapacity(size); if (desiredCapacity <= MIN_CAPACITY) return MIN_CAPACITY; int maxCapacity = MAX_INT_CAPACITY; if (doubleSizedArrays) maxCapacity >>= 1; if (desiredCapacity < maxCapacity) { if (isPowerOf2(desiredCapacity)) return desiredCapacity; int lesserCapacity = highestOneBit(desiredCapacity); int greaterCapacity = lesserCapacity << 1; return chooseBetter(conf, size, desiredCapacity, lesserCapacity, greaterCapacity, greaterCapacity); } return maxCapacity; }
public static int capacity(HashConfigWrapper conf, int size) { return capacity(conf, size, false); }
@Override public final HashFloatObjMapFactory<V> withHashConfig(@Nonnull HashConfig hashConf) { if (configIsSuitableForMutableLHash(hashConf)) return lHashLikeThisWith(hashConf, getDefaultExpectedSize() ); return qHashLikeThisWith(hashConf, getDefaultExpectedSize() ); }
final void postInsertHook() { if (++size > maxSize) { /* if LHash hash */ int capacity = capacity(); if (!isMaxCapacity(capacity)) { rehash(capacity << 1); } /* elif !(LHash hash) */ tryRehashForExpansion(grownCapacity()); /* endif */ } }
private boolean isMaxCapacity(int capacity) { return LHashCapacities.isMaxCapacity(capacity, doubleSizedArrays()); }
public static int capacity(HashConfigWrapper conf, int size, boolean doubleSizedArrays) { assert size >= 0 : "size must be non-negative"; int desiredCapacity = conf.targetCapacity(size); if (desiredCapacity <= MIN_CAPACITY) return MIN_CAPACITY; int maxCapacity = MAX_INT_CAPACITY; if (doubleSizedArrays) maxCapacity >>= 1; if (desiredCapacity < maxCapacity) { if (isPowerOf2(desiredCapacity)) return desiredCapacity; int lesserCapacity = highestOneBit(desiredCapacity); int greaterCapacity = lesserCapacity << 1; return chooseBetter(conf, size, desiredCapacity, lesserCapacity, greaterCapacity, greaterCapacity); } return maxCapacity; }
public static long capacity(HashConfigWrapper conf, long size) { return capacity(conf, size, false); }
@Override public final HashFloatLongMapFactory withHashConfig(@Nonnull HashConfig hashConf) { if (configIsSuitableForMutableLHash(hashConf)) return lHashLikeThisWith(hashConf, getDefaultExpectedSize() ); return qHashLikeThisWith(hashConf, getDefaultExpectedSize() ); }
final int newMaxSize = !LHashCapacities.isMaxCapacity(capacity, false) ? config.maxSize(capacity) : capacity - 1; final int newBatches = (int) Math.ceil( capacity / (MAX_VALUES_PER_BATCH * 1.0d) );
public static long capacity(HashConfigWrapper conf, long size, boolean doubleSizedArrays) { assert size >= 0L : "size must be non-negative"; long desiredCapacity = conf.targetCapacity(size); if (desiredCapacity <= (long) MIN_CAPACITY) return (long) MIN_CAPACITY; long maxCapacity = MAX_LONG_CAPACITY; if (doubleSizedArrays) maxCapacity >>= 1L; if (desiredCapacity < maxCapacity) { if (isPowerOf2(desiredCapacity)) return desiredCapacity; long lesserCapacity = highestOneBit(desiredCapacity); long greaterCapacity = lesserCapacity << 1; return chooseBetter(conf, size, desiredCapacity, lesserCapacity, greaterCapacity, greaterCapacity); } return maxCapacity; }
public static long capacity(HashConfigWrapper conf, long size) { return capacity(conf, size, false); }
@Override public final HashDoubleLongMapFactory withHashConfig(@Nonnull HashConfig hashConf) { if (configIsSuitableForMutableLHash(hashConf)) return lHashLikeThisWith(hashConf, getDefaultExpectedSize() ); return qHashLikeThisWith(hashConf, getDefaultExpectedSize() ); }
private void internalInit(final int capacity) { // capacity is power of two. assert (capacity & (capacity - 1)) == 0; initTimer.start(); this.capacity = capacity; this.maxSize = !LHashCapacities.isMaxCapacity(capacity, false) ? config.maxSize(capacity) : capacity - 1; this.batches = (int) Math.ceil( capacity / (MAX_VALUES_PER_BATCH * 1.0d) ); final ControlBlock[] newControlBlocks = new ControlBlock[batches]; tableControlAddresses = new long[batches]; capacityMask = capacity - 1; try(RollbackCloseable rollbackable = new RollbackCloseable()) { for(int i =0; i < batches; i++){ newControlBlocks[i] = new ControlBlock(allocator, MAX_VALUES_PER_BATCH); rollbackable.add(newControlBlocks[i]); tableControlAddresses[i] = newControlBlocks[i].getMemoryAddress(); final long addr = newControlBlocks[i].getMemoryAddress(); final long max = addr + MAX_VALUES_PER_BATCH * CONTROL_WIDTH; for(long l = addr; l < max; l+= LBlockHashTable.CONTROL_WIDTH){ PlatformDependent.putLong(l, LBlockHashTable.LFREE); } } this.controlBlocks = newControlBlocks; rollbackable.commit(); } catch (Exception e) { throw Throwables.propagate(e); } initTimer.stop(); }
static boolean configIsSuitableForImmutableHash(HashConfigWrapper conf, int size) { assert size >= 0; int desiredCapacity = conf.targetCapacity(size); if (desiredCapacity <= MIN_CAPACITY) return MIN_CAPACITY <= conf.maxCapacity(size); if (desiredCapacity < MAX_INT_CAPACITY) { if (isPowerOf2(desiredCapacity)) return true; int lesserCapacity = highestOneBit(desiredCapacity); int greaterCapacity = lesserCapacity << 1; int c = chooseBetter(conf, size, desiredCapacity, lesserCapacity, greaterCapacity, -1); return c > 0; } return false; }