kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpe...@apache.org
Subject [2/3] kudu git commit: monotime: use a signed integer for the value
Date Sun, 14 Aug 2016 04:20:37 GMT
monotime: use a signed integer for the value

MonoTime previously used a uint64_t to store its value. This caused
problems in code patterns like:

  MonoTime gc_point = now;
  if (gc_point.ComesBefore(some_other_time)) {

In particular, the subtraction from 'gc_point' caused the unsigned
integer to wrap around such that _no_ time came before it.

One solution would have been to avoid the above pattern and only allow
adding positive deltas to a MonoTime. But, an easier one is to just use
a signed integer for the internal representation.

Change-Id: I68ce7b73a9a67becf91863161f0ae769153fe438
Reviewed-on: http://gerrit.cloudera.org:8080/3963
Tested-by: Kudu Jenkins
Reviewed-by: Mike Percy <mpercy@apache.org>

Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/b489f6ed
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b489f6ed
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b489f6ed

Branch: refs/heads/master
Commit: b489f6edc63a6a7126af6ff44b31edb03435a2d3
Parents: 587f33d
Author: Todd Lipcon <todd@apache.org>
Authored: Fri Aug 12 19:45:16 2016 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Sat Aug 13 03:34:36 2016 +0000

 src/kudu/util/monotime.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/kudu/util/monotime.h b/src/kudu/util/monotime.h
index de1c1e9..4e27d18 100644
--- a/src/kudu/util/monotime.h
+++ b/src/kudu/util/monotime.h
@@ -236,7 +236,7 @@ class KUDU_EXPORT MonoTime {
   explicit MonoTime(const struct timespec &ts);
   explicit MonoTime(int64_t nanos);
   double ToSeconds() const;
-  uint64_t nanos_;
+  int64_t nanos_;
 /// Sleep for an interval specified by a MonoDelta instance.

View raw message