Browse Source

Fix stream_extract/stream_intervals restart around timestamp == 0.

tags/nilmdb-1.4.2
Jim Paris 11 years ago
parent
commit
caf63ab01f
2 changed files with 13 additions and 13 deletions
  1. +11
    -11
      nilmdb/server/nilmdb.py
  2. +2
    -2
      nilmdb/server/server.py

+ 11
- 11
nilmdb/server/nilmdb.py View File

@@ -334,14 +334,14 @@ class NilmDB(object):

Returns (intervals, restart) tuple.

intervals is a list of [start,end] timestamps of all intervals
'intervals' is a list of [start,end] timestamps of all intervals
that exist for path, between start and end.

restart, if nonzero, means that there were too many results to
return in a single request. The data is complete from the
starting timestamp to the point at which it was truncated,
and a new request with a start time of 'restart' will fetch
the next block of data.
'restart', if not None, means that there were too many results
to return in a single request. The data is complete from the
starting timestamp to the point at which it was truncated, and
a new request with a start time of 'restart' will fetch the
next block of data.
"""
stream_id = self._stream_id(path)
intervals = self._get_intervals(stream_id)
@@ -363,7 +363,7 @@ class NilmDB(object):
break
result.append([i.start, i.end])
else:
restart = 0
restart = None
return (result, restart)

def stream_create(self, path, layout_name):
@@ -521,10 +521,10 @@ class NilmDB(object):
"""
Returns (data, restart) tuple.

data is ASCII-formatted data from the database, formatted
'data' is ASCII-formatted data from the database, formatted
according to the layout of the stream.

restart, if nonzero, means that there were too many results to
'restart', if not None, means that there were too many results to
return in a single request. The data is complete from the
starting timestamp to the point at which it was truncated,
and a new request with a start time of 'restart' will fetch
@@ -543,7 +543,7 @@ class NilmDB(object):
result = []
matched = 0
remaining = self.max_results
restart = 0
restart = None
for interval in intervals.intersection(requested):
# Reading single rows from the table is too slow, so
# we use two bisections to find both the starting and
@@ -568,7 +568,7 @@ class NilmDB(object):
# Count them
remaining -= row_end - row_start

if restart:
if restart is not None:
break

if count:


+ 2
- 2
nilmdb/server/server.py View File

@@ -386,7 +386,7 @@ class Stream(NilmApp):
diffpath)
response = ''.join([ json.dumps(i) + "\r\n" for i in ints ])
yield response
if restart == 0:
if restart is None:
break
start = restart
return content(start, end)
@@ -432,7 +432,7 @@ class Stream(NilmApp):
(data, restart) = self.db.stream_extract(path, start, end)
yield data

if restart == 0:
if restart is None:
return
start = restart
return content(start, end, count)


Loading…
Cancel
Save