@Override public void close(boolean abort) throws IOException {
    try {
      if (!abort) {
        final List<SegmentIdWithShardSpec> segmentsToPush = Lists.newArrayList();
        segmentsToPush.addAll(appenderator.getSegments());
        pushSegments(segmentsToPush);
      }
      appenderator.clear();
    } catch (InterruptedException e) {
      Throwables.propagate(e);
    } finally {
      try {
        FileUtils.deleteDirectory(tuningConfig.getBasePersistDirectory());
      } catch (Exception e) {
        LOG.error("error cleaning of base persist directory", e);
      }
      appenderator.close();
    }
  }
This function computes the segment identifier and push the current open segment
The push will occur if max size is reached or the event belongs to the next interval.
Note that this function assumes that timestamps are pseudo sorted.
This function will close and move to the next segment granularity as soon as
an event from the next interval appears. The sorting is done by the previous stage.

@return segmentIdentifier with of the truncatedTime and maybe push the current open segment.
druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidRecordWriter.java