Use half-open intervals for time ranges

This commit is contained in:
Marko Durkovic
2021-07-04 22:27:52 +02:00
parent 5175c349aa
commit 12acb677e6
5 changed files with 12 additions and 12 deletions
+3 -3
View File
@@ -94,7 +94,7 @@ class Chunk(NamedTuple):
class TopicInfo(NamedTuple):
"""Topic information."""
conn_count: int
conncount: int
msgcount: int
msgdef: str
msgtype: str
@@ -472,7 +472,7 @@ class Reader:
@property
def end_time(self) -> int:
"""Timestamp in nanoseconds of the latest message."""
"""Timestamp in nanoseconds after the latest message."""
return max(x.end_time for x in self.chunk_infos)
@property
@@ -517,7 +517,7 @@ class Reader:
chunk_pos = header.get_uint64('chunk_pos')
start_time = header.get_time('start_time')
end_time = header.get_time('end_time')
end_time = header.get_time('end_time') + 1
count = header.get_uint32('count')
self.bio.seek(4, os.SEEK_CUR)
+2 -2
View File
@@ -121,7 +121,7 @@ class Reader:
@property
def duration(self) -> int:
"""Duration in nanoseconds between earliest and latest messages."""
return self.metadata['duration']['nanoseconds']
return self.metadata['duration']['nanoseconds'] + 1
@property
def start_time(self) -> int:
@@ -130,7 +130,7 @@ class Reader:
@property
def end_time(self) -> int:
"""Timestamp in nanoseconds of the latest message."""
"""Timestamp in nanoseconds after the latest message."""
return self.start_time + self.duration
@property
+1 -1
View File
@@ -185,7 +185,7 @@ class Writer: # pylint: disable=too-many-instance-attributes
self.cursor = None
duration, start, count = self.conn.execute(
'SELECT max(timestamp) - min(timestamp) + 1, min(timestamp), count(*) FROM messages',
'SELECT max(timestamp) - min(timestamp), min(timestamp), count(*) FROM messages',
).fetchone()
self.conn.commit()