Uploaded image for project: 'Apache Storm'
  1. Apache Storm
  2. STORM-3375

Date.getTime() can be changed to System.currentTimeMillis()

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0
    • Component/s: None
    • Flags:
      Patch

      Description

      Hello,
      I found two locations of Date.getTime() which can be replaced with System.currentTimeMillis().
      (1) external/storm-hive/src/main/java/org/apache/storm/hive/bolt/mapper/DelimitedRecordHiveMapper.java:134
      (2) external/storm-hive/src/main/java/org/apache/storm/hive/bolt/mapper/JsonRecordHiveMapper.java:121

      Since new Date() is a thin wrapper of method System.currentTimeMillis(). The performance will be greatly damaged if it is invoked too much times.
      According to my local testing at the same environment, System.currentTimeMillis() can achieve a speedup to 5 times (435ms vs 2073ms), when these two methods are invoked 5,000,000 times.
      Therefore, if only getTime() is used for Date object, the light method System.currentTimeMillis() is recommended, which can also avoid creating the temporary Date object.

        Attachments

        1. 1.patch
          1 kB
          bd2019us

          Issue Links

            Activity

              People

              • Assignee:
                bd2019us bd2019us
                Reporter:
                bd2019us bd2019us
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h