Skip to content

Commit

Permalink
Merge pull request #81 from timob/fixupdatemany2
Browse files Browse the repository at this point in the history
fix write optimization in update_many
  • Loading branch information
obfuscurity committed Aug 26, 2014
2 parents 8ff94ff + 8b3ebba commit 964fc1b
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 964fc1b

Please sign in to comment.