public static SegmentConfig getSegmentConfig(Map<String, String> taskConfig) {
    SegmentConfig.Builder segmentConfigBuilder = new SegmentConfig.Builder();
    String maxNumRecordsPerSegment = taskConfig.get(MergeTask.MAX_NUM_RECORDS_PER_SEGMENT_KEY);
    if (maxNumRecordsPerSegment != null) {
      segmentConfigBuilder.setMaxNumRecordsPerSegment(Integer.parseInt(maxNumRecordsPerSegment));
    }
    String segmentMapperFileSizeThreshold = taskConfig.get(MergeTask.SEGMENT_MAPPER_FILE_SIZE_IN_BYTES);
    if (segmentMapperFileSizeThreshold != null) {
      segmentConfigBuilder.setIntermediateFileSizeThreshold(Long.parseLong(segmentMapperFileSizeThreshold));
    }
    segmentConfigBuilder.setSegmentNamePrefix(taskConfig.get(MergeTask.SEGMENT_NAME_PREFIX_KEY));
    segmentConfigBuilder.setSegmentNamePostfix(taskConfig.get(MergeTask.SEGMENT_NAME_POSTFIX_KEY));
    segmentConfigBuilder.setFixedSegmentName(taskConfig.get(MergeTask.FIXED_SEGMENT_NAME_KEY));
    return segmentConfigBuilder.build();
  }
@Test
  public void testGetSegmentConfig() {
    Map<String, String> taskConfig = new HashMap<>();
    taskConfig.put(MergeTask.MAX_NUM_RECORDS_PER_SEGMENT_KEY, "10000");
    taskConfig.put(MergeTask.SEGMENT_NAME_PREFIX_KEY, "myPrefix");
    taskConfig.put(MergeTask.SEGMENT_NAME_POSTFIX_KEY, "myPostfix");
    taskConfig.put(MergeTask.FIXED_SEGMENT_NAME_KEY, "mySegment");
    taskConfig.put(MergeTask.SEGMENT_MAPPER_FILE_SIZE_IN_BYTES, "1000000000");
    SegmentConfig segmentConfig = MergeTaskUtils.getSegmentConfig(taskConfig);
    assertEquals(segmentConfig.getMaxNumRecordsPerSegment(), 10000);
    assertEquals(segmentConfig.getSegmentNamePrefix(), "myPrefix");
    assertEquals(segmentConfig.getSegmentNamePostfix(), "myPostfix");
    assertEquals(segmentConfig.getSegmentNamePostfix(), "myPostfix");
    assertEquals(segmentConfig.getFixedSegmentName(), "mySegment");
    assertEquals(segmentConfig.getIntermediateFileSizeThreshold(), 1000000000L);
    assertEquals(segmentConfig.toString(),
        "SegmentConfig{_maxNumRecordsPerSegment=10000, _segmentMapperFileSizeThresholdInBytes=1000000000, "
            + "_segmentNamePrefix='myPrefix', _segmentNamePostfix='myPostfix', _fixedSegmentName='mySegment'}");

    segmentConfig = MergeTaskUtils.getSegmentConfig(Collections.emptyMap());
    assertEquals(segmentConfig.getMaxNumRecordsPerSegment(), SegmentConfig.DEFAULT_MAX_NUM_RECORDS_PER_SEGMENT);
    assertNull(segmentConfig.getSegmentNamePrefix());
    assertNull(segmentConfig.getSegmentNamePostfix());
    assertNull(segmentConfig.getFixedSegmentName());
  }