def probeAndInsert2(self, resource, tuple, table1, table2, time): record = Record(tuple, time, 0) if resource in table1: records = table1[resource] for t in records: if t.ats > record.ats: continue x = t.tuple.copy() x.update(tuple) self.qresults.put(x) p = table2.get(resource, []) p.append(record) table2[resource] = p
def insertAndProbe(self, tuple, input, table1, table2): # Insert the tuple in its corresponding partition and probe. # Get the attribute(s) to apply hash. att = '' for var in self.vars: att = att + tuple[var] i = hash(att) % table1.size # Insert record in partition. record = Record(tuple, time(), 0) table1.insertRecord(i, record) # Probe the record against its partition in the other table. self.probe(record, table2.partitions[i], self.vars)
def stage1(self, tuple, input, table1, table2): # Stage 1: While both sources are sending data. # Get the attribute(s) to apply hash. att = '' for var in self.vars: att = att + tuple[var] i = hash(att) % table1.size # Insert record in partition. #record = Record(tuple, time(), 0) record = Record(tuple, self.timestamp, float("inf")) table1.insertRecord(i, record) # Probe the record against its partition in the other table. self.probe(record, table2.partitions[i], self.vars)
def probeAndInsert1(self, tuple, table1, table2, time): record = Record(tuple, time, 0) r = self.getResource(tuple) if r in table1: records = table1[r] for t in records: if t.ats > record.ats: continue x = t.tuple.copy() x.update(tuple) self.qresults.put(x) p = table2.get(r, []) i = (p == []) p.append(record) table2[r] = p return i
def probeAndInsert2(self, resource, tuple, table1, table2, time): #print "probeAndInsert2", tuple record = Record(tuple, time, 0) if resource in table1: records = table1[resource] for t in records: if t.ats > record.ats: continue x = t.tuple.copy() x.update(tuple) self.qresults.put(x) # Delete tuple from bag. try: self.bag.remove(t.tuple) except ValueError: pass p = table2.get(resource, []) p.append(record) table2[resource] = p