private SegmentCommitInfo copySegmentAsIs(SegmentCommitInfo info,String segName,IOContext context) throws IOException {
  SegmentInfo newInfo=new SegmentInfo(directoryOrig,info.info.getVersion(),segName,info.info.maxDoc(),info.info.getUseCompoundFile(),info.info.getCodec(),info.info.getDiagnostics(),info.info.getId(),info.info.getAttributes(),info.info.getIndexSort());
  SegmentCommitInfo newInfoPerCommit=new SegmentCommitInfo(newInfo,info.getDelCount(),info.getDelGen(),info.getFieldInfosGen(),info.getDocValuesGen());
  newInfo.setFiles(info.files());
  boolean success=false;
  Set<String> copiedFiles=new HashSet<>();
  try {
    for (    String file : info.files()) {
      final String newFileName=newInfo.namedForThisSegment(file);
      directory.copyFrom(info.info.dir,file,newFileName,context);
      copiedFiles.add(newFileName);
    }
    success=true;
  }
  finally {
    if (!success) {
      deleteNewFiles(copiedFiles);
    }
  }
  assert copiedFiles.equals(newInfoPerCommit.files());
  return newInfoPerCommit;
}

private SegmentCommitInfo copySegmentAsIs ( SegmentCommitInfo info , String segName , IOContext context ) throws IOException { SegmentInfo newInfo = new SegmentInfo ( directoryOrig , info . info . getVersion ( ) , segName , info . info . maxDoc ( ) , info . info . getUseCompoundFile ( ) , info . info . getCodec ( ) , info . info . getDiagnostics ( ) , info . info . getId ( ) , info . info . getAttributes ( ) , info . info . getIndexSort ( ) ) ; SegmentCommitInfo newInfoPerCommit = new SegmentCommitInfo ( newInfo , info . getDelCount ( ) , info . getDelGen ( ) , info . getFieldInfosGen ( ) , info . getDocValuesGen ( ) ) ; newInfo . setFiles ( info . files ( ) ) ; boolean success = false ; Set < String > copiedFiles = new HashSet < > ( ) ; try { for ( String file : info . files ( ) ) { final String newFileName = newInfo . namedForThisSegment ( file ) ; directory . copyFrom ( info . info . dir , file , newFileName , context ) ; copiedFiles . add ( newFileName ) ; } success = true ; } finally { if ( ! success ) { deleteNewFiles ( copiedFiles ) ; } } assert copiedFiles . equals ( newInfoPerCommit . files ( ) ) ; return newInfoPerCommit ; }
copies the segment files as - is into the indexwriter ' s directory .
