Skip to content

Commit

Permalink
pipelining like a motherfucker
Browse files Browse the repository at this point in the history
  • Loading branch information
leewardbound committed Apr 25, 2012
1 parent 6563aa0 commit 2a54d9d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hailwhale/whale.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,23 +454,27 @@ def count_now(cls, pk, dimensions='_', metrics=None, at=False):
# [b, x, 1],
# [b, y],
# [b, y, 2]
pipe = cls.whale_driver().pipeline(transaction=False)
for pkk, dimension, (period, dt, metric, i) in itertools.product(
iterate_dimensions(pk),
iterate_dimensions(dimensions, add_root=True),
generate_increments(metrics, periods, at)):
if i == 0:
continue
_increment(cls.whale_driver(), pkk, dimension, metric, period, dt, i)
_increment(pipe, pkk, dimension, metric, period, dt, i)
pipe.execute()

@classmethod
def update_count_to(cls, pk, dimensions='_', metrics=None, period=False,
at=False, rank=False):
period = Period.get(period)
at = at or times.now()
dt = period.flatten_str(at)
pipe = cls.whale_driver().pipeline(transaction=False)
for (metric, i) in metrics.iteritems():
_store(cls.whale_driver(), pk, dimensions, metric, period, dt, i,
_store(pipe, pk, dimensions, metric, period, dt, i,
rank=rank)
pipe.execute()

@classmethod
def zranked(cls, pk, parent_dimension='_', metric='hits', period=None,
Expand Down

0 comments on commit 2a54d9d

Please sign in to comment.