def _make_update_task(self, uda_class, cols, prior_state=None): # Overall layout here: # - task name # - serialized agg class # - prior state flag 1/0 # - (optional) serialized prior state # - serialized table fragment payload = BytesIO() msg_writer = wire.PackedMessageWriter(payload) msg_writer.string('agg-update') msg_writer.string(compat.pickle_dump(uda_class)) if prior_state is not None: msg_writer.uint8(1) msg_writer.string(compat.pickle_dump(prior_state)) else: msg_writer.uint8(0) writer = IbisTableWriter(cols) # Create memory map of the appropriate size path = 'task_%s' % guid() size = writer.total_size() + payload.tell() offset = 0 mm = SharedMmap(path, size, create=True) self.paths_to_delete.append(path) mm.write(payload.getvalue()) writer.write(mm) task = IbisTaskMessage(self.lock.semaphore_id, path, offset, size) return task, mm
def _write_response(self, agg_inst): self.shmem.seek(0) self.mark_success() serialized_inst = compat.pickle_dump(agg_inst) wire.write_string(self.shmem, serialized_inst)