Segment( HugeConfig config, Hasher hasher, boolean csKey, boolean bytesMarshallable, Class<V> vClass) { this.csKey = csKey; this.hasher = hasher; this.bytesMarshallable = bytesMarshallable; this.vClass = vClass; smallEntrySize = (config.getSmallEntrySize() + 7) & ~7; // round to next multiple of 8. entriesPerSegment = config.getEntriesPerSegment(); store = new DirectStore(bmf, smallEntrySize * entriesPerSegment, false); usedSet = new BitSet(config.getEntriesPerSegment()); smallMap = new IntIntMultiMap(entriesPerSegment * 2); tmpBytes = new DirectStore(bmf, 64 * smallEntrySize, false).createSlice(); offHeapUsed = tmpBytes.capacity() + store.size(); sbKey = csKey ? new StringBuilder() : null; }
public HugeHashMap(HugeConfig config, Class<K> kClass, Class<V> vClass) { // this.kClass = kClass; // this.vClass = vClass; final int segmentCount = config.getSegments(); hasher = new Hasher(kClass, segmentCount); boolean bytesMarshallable = BytesMarshallable.class.isAssignableFrom(vClass); //noinspection unchecked segments = (Segment<K, V>[]) new Segment[segmentCount]; for (int i = 0; i < segmentCount; i++) segments[i] = new Segment<K, V>( config, hasher, CharSequence.class.isAssignableFrom(kClass), bytesMarshallable, vClass); }