Skip to content

Commit

Permalink
fix smart_size in _win.py, stream_snapshot method
Browse files Browse the repository at this point in the history
  • Loading branch information
jeog committed Dec 3, 2015
1 parent 665f926 commit fce04bf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python/tosdb/_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,16 +532,22 @@ def stream_snapshot(self, item, topic, date_time=False, end=-1, beg=0,
if end < 0:
end += self._block_size
if beg < 0:
beg += self._block_size
if smart_size:
end = min(end, self.stream_occupancy(item, topic) - 1)
beg += self._block_size
size = (end - beg) + 1
if beg < 0 \
or end < 0 \
or beg >= self._block_size \
or end >= self._block_size \
or size <= 0:
raise TOSDB_IndexError("invalid 'beg' and/or 'end' index value(s)")

if smart_size:
so = self.stream_occupancy(item, topic)
if so == 0 or so <= beg:
return []
end = min(end, so - 1)
beg = min(beg, so - 1)
size = (end - beg) + 1

dtss = (_DateTimeStamp * size)()
tbits = type_bits(topic)
Expand Down Expand Up @@ -635,7 +641,7 @@ def stream_snapshot_from_marker(self, item, topic, date_time=False, beg=0,
date_time: (True/False) attempt to retrieve a TOSDB_DateTime object
beg: index of most recent data-point (beginning of the snapshot)
margin_of_safety: (True/False) error margin for async stream growth
throw_if_data_loss: (True/False) how to handle error states (see above)
throw_if_data_lost: (True/False) how to handle error states (see above)
data_str_max: the maximum length of string data returned
if beg > internal marker value: returns -> None
Expand Down

0 comments on commit fce04bf

Please sign in to comment.