code: private Segment nextSegment(boolean newOnly) throws IOException {
          int index;
          Segment seg;
  
          if (newOnly) {
              index = _segList.size();
          } else {
              if (_recycleList.size() > 0) {
                  seg = _recycleList.remove();
                  seg.reinit();
  
                  _segList.set(seg.getSegmentId(), seg);
                  _log.info("reinit Segment " + seg.getSegmentId());
                  return seg;
              }
  
              for (index = 0; index < _segList.size(); index++) {
                  if (_segList.get(index) == null)
                      break;
              }
          }
  
          // Always create next segment as READ_WRITE
          File segFile = getSegmentFile(index);
          seg = getSegmentFactory().createSegment(index, segFile, _segFileSizeMB, Segment.Mode.READ_WRITE);
  
          if (index < _segList.size())
              _segList.set(index, seg);
          else
              _segList.add(seg);
  
          return seg;
      }
docs: Gets the next segment available for read and write.
  
  @param newOnly
  If true, create a new segment from scratch. Otherwise, reuse
  the first free segment.
  @return
  @throws IOException