Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix write optimization in update_many #81

Merged
merged 2 commits into from Aug 26, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions whisper.py
Expand Up @@ -650,12 +650,16 @@ def __archive_update_many(fh,header,archive,points):
step = archive['secondsPerPoint']
alignedPoints = [ (timestamp - (timestamp % step), value)
for (timestamp,value) in points ]
alignedPoints = dict(alignedPoints).items() # Take the last val of duplicates
#Create a packed string for each contiguous sequence of points
packedStrings = []
previousInterval = None
currentString = ""
for (interval,value) in alignedPoints:
lenAlignedPoints = len(alignedPoints)
for i in xrange(0,lenAlignedPoints):
#take last point in run of points with duplicate intervals
if i+1 < lenAlignedPoints and alignedPoints[i][0] == alignedPoints[i+1][0]:
continue
(interval,value) = alignedPoints[i]
if (not previousInterval) or (interval == previousInterval + step):
currentString += struct.pack(pointFormat,interval,value)
previousInterval = interval
Expand Down