SegmentServiceImpl(SegmentKelpBuilder builder){
  _path=builder.path();
  _ampManager=builder.ampManager();
  Objects.requireNonNull(_path);
  ArrayList<Integer> segmentSizes=builder.getSegmentSizes();
  if (segmentSizes.size() == 0) {
    segmentSizes=new ArrayList<>();
    segmentSizes.add(1024 * 1024);
  }
  Collections.sort(segmentSizes);
  SegmentMeta[] segmentMeta=new SegmentMeta[segmentSizes.size()];
  for (int i=0; i < segmentMeta.length; i++) {
    segmentMeta[i]=new SegmentMeta(segmentSizes.get(i));
  }
  _compressor=builder.compressor();
  Objects.requireNonNull(_compressor);
  try {
    if (Files.exists(_path) && initImpl()) {
    }
 else     if (builder.isCreate()) {
      Files.deleteIfExists(_path);
      create(segmentMeta,builder.ampManager());
    }
 else {
      throw new IllegalStateException(L.l("load failed but create forbidden"));
    }
  }
 catch (  RuntimeException e) {
    throw e;
  }
catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

SegmentServiceImpl ( SegmentKelpBuilder builder ) { _path = builder . path ( ) ; _ampManager = builder . ampManager ( ) ; Objects . requireNonNull ( _path ) ; ArrayList < Integer > segmentSizes = builder . getSegmentSizes ( ) ; if ( segmentSizes . size ( ) == 0 ) { segmentSizes = new ArrayList < > ( ) ; segmentSizes . add ( 1024 * 1024 ) ; } Collections . sort ( segmentSizes ) ; SegmentMeta [ ] segmentMeta = new SegmentMeta [ segmentSizes . size ( ) ] ; for ( int i = 0 ; i < segmentMeta . length ; i ++ ) { segmentMeta [ i ] = new SegmentMeta ( segmentSizes . get ( i ) ) ; } _compressor = builder . compressor ( ) ; Objects . requireNonNull ( _compressor ) ; try { if ( Files . exists ( _path ) && initImpl ( ) ) { } else if ( builder . isCreate ( ) ) { Files . deleteIfExists ( _path ) ; create ( segmentMeta , builder . ampManager ( ) ) ; } else { throw new IllegalStateException ( L . l ( "load failed but create forbidden" ) ) ; } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
creates a new store .
