Github user kumarvishal09 commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2588#discussion_r208161675 --- Diff: processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/merger/UnsafeIntermediateMerger.java --- @@ -111,18 +108,15 @@ public void addFileToMerge(File sortTempFile) { } public void startFileMergingIfPossible() { - File[] fileList = null; - synchronized (lockObject) { - if (procFiles.size() >= parameters.getNumberOfIntermediateFileToBeMerged()) { + File[] fileList; + if (procFiles.size() >= parameters.getNumberOfIntermediateFileToBeMerged()) { + synchronized (lockObject) { fileList = procFiles.toArray(new File[procFiles.size()]); --- End diff -- When size is passed Array list directly copy the data from one array(array list) to other when size is less than array list size in that case it will create another array and then it will copy, so passing the size is better
---