def process(self, tup): word = tup.values[0]; if (random() < 0.75): storm.emit([word + 'lalala'], anchors=[tup]) storm.ack(tup) else: storm.log(word + ' randomly skipped!')
def process(self, tup): segments = tup.values[1].rstrip('/').rsplit('/', 1) path = segments[0] if self.match(segments[-1]) else '/'.join(segments) event = dict(timestamp=tup.values[0], path=path) kwargs = dict(id=tup.values[2]) try: # TODO: Retrieve users from all indicies. events = self.es.get(self.index, kwargs['id'], 'user', preference='_primary') kwargs['version'] = events['_version'] body = {'events': events['_source']['events'] + [event]} except NotFoundError: kwargs['op_type'] = 'create' body = {'events': [event]} try: body['rank'] = math.log10(len(body['events'])) / 2 self.es.index(self.index, 'user', body, **kwargs) paths = list(event['path'] for event in body['events']) emit([kwargs['id'], paths]) ack(tup) except TransportError: fail(tup)
def process(self, tup): word = tup.values[0] if (random() < 0.75): storm.emit([word + 'lalala'], anchors=[tup]) storm.ack(tup) else: storm.log(word + ' randomly skipped!')
def process(self, tup): segments = tup.values[1].rstrip('/').rsplit('/', 1) path = segments[0] if self.match(segments[-1]) else '/'.join(segments) event = dict( timestamp=tup.values[0], path=path ) kwargs = dict( id=tup.values[2] ) try: # TODO: Retrieve users from all indicies. events = self.es.get(self.index, kwargs['id'], 'user', preference='_primary') kwargs['version'] = events['_version'] body = {'events': events['_source']['events'] + [event]} except NotFoundError: kwargs['op_type'] = 'create' body = {'events': [event]} try: body['rank'] = math.log10(len(body['events'])) / 2 self.es.index(self.index, 'user', body, **kwargs) paths = list(event['path'] for event in body['events']) emit([kwargs['id'], paths]) ack(tup) except TransportError: fail(tup)
def process(self, tup): url = tup.values[0] storm.log("HARing "+url) output = self.get_har_with_image(url) if output is not "FAIL": storm.emit(output, anchors=[tup]) storm.ack(tup)
def process(self, tup): frame = base64.b64decode(tup.values[0]) self.p.stdin.write(frame) t = tup.values[2] sensorId = tup.values[1] curtime = int(round(time.time() * 1000)) self.local_time_queue.put(curtime) self.time_queue.put([t, sensorId]) self.tuple_count += 1 with lock: storm.ack(tup)
def process(self, tup): path = tup.values[0].rstrip('/') if self.match(path): path = path.rsplit('/', 1)[0] try: doc = self.get_doc(path) if self.es.index(self.index, 'item', doc).get('ok', False): emit([path]) ack(tup) except: fail(tup)
def process(self, tup): message = tup.values[0] if is_valid_json(message): event = json.loads(message) period = event['period'] clock = event['game_clock'] team_id = event['team_id'] event_type = event['event_type'] game_id = event['game_id'] event_id = event['event_id'] ast = event['team_stats']['assist'] ft = event['team_stats']['freethrowmade'] pt = event['team_stats']['points'] stl = event['team_stats']['steal'] three = event['team_stats']['threepointmade'] tov = event['team_stats']['turnover'] trb = event['team_stats']['rebound'] two = event['team_stats']['twopointmade'] storm.emit([period, clock, team_id, event_type, game_id, event_id, ast, ft, pt, stl, three, tov, trb, two]) storm.ack(tup)
def process(self, tup): storm.emit([tup.values[0]+"lalala"]) storm.ack(tup)
def process(self, tup): words = tup.values[0].split(" ") for word in words: storm.emit([word]) storm.ack(tup)