public VanillaSharedHashMap(
      SharedHashMapBuilder builder, File file, Class<K> kClass, Class<V> vClass)
      throws IOException {
    this.kClass = kClass;
    this.vClass = vClass;

    lockTimeOutNS = builder.lockTimeOutMS() * 1000000;

    this.replicas = builder.replicas();
    this.entrySize = builder.entrySize();

    this.errorListener = builder.errorListener();
    this.generatedKeyType = builder.generatedKeyType();
    this.generatedValueType = builder.generatedValueType();
    this.putReturnsNull = builder.putReturnsNull();
    this.removeReturnsNull = builder.removeReturnsNull();

    int segments = builder.actualSegments();
    this.segmentBits = Maths.intLog2(segments);
    int entriesPerSegment = builder.actualEntriesPerSegment();
    this.entriesPerSegment = entriesPerSegment;

    @SuppressWarnings("unchecked")
    Segment[] ss = (VanillaSharedHashMap.Segment[]) new VanillaSharedHashMap.Segment[segments];
    this.segments = ss;

    this.ms = new MappedStore(file, FileChannel.MapMode.READ_WRITE, sizeInBytes());

    long offset = SharedHashMapBuilder.HEADER_SIZE;
    long segmentSize = segmentSize();
    for (int i = 0; i < this.segments.length; i++) {
      this.segments[i] = new Segment(ms.createSlice(offset, segmentSize));
      offset += segmentSize;
    }
  }
  public VanillaSharedHashMap(
      SharedHashMapBuilder builder, MappedStore ms, Class<K> kClass, Class<V> vClass) {
    this.builder = builder;
    lockTimeOutNS = builder.lockTimeOutMS() * 1000000;
    this.ms = ms;
    this.kClass = kClass;
    this.vClass = vClass;

    @SuppressWarnings("unchecked")
    Segment[] segments =
        (VanillaSharedHashMap<K, V>.Segment[]) new VanillaSharedHashMap.Segment[builder.segments()];
    this.segments = segments;

    long offset = SharedHashMapBuilder.HEADER_SIZE;
    long segmentSize = builder.segmentSize();
    for (int i = 0; i < this.segments.length; i++) {
      this.segments[i] = new Segment(ms.createSlice(offset, segmentSize));
      offset += segmentSize;
    }
  }