void core_map_clear(struct core_map *self) { int key_size; int value_size; struct core_memory_pool *pool; /* * Save key_size, value_size, and memory pool. */ key_size = core_map_get_key_size(self); value_size = core_map_get_value_size(self); pool = core_map_memory_pool(self); core_map_destroy(self); core_map_init(self, key_size, value_size); core_map_set_memory_pool(self, pool); /* * TODO: implement the clear operation directly inside * the lower layer (core_dynamic_hash_table + core_hash_table) */ /*core_dynamic_hash_table_clear(&self->table);*/ }
void biosal_assembly_graph_store_receive(struct thorium_actor *self, struct thorium_message *message) { int tag; /*void *buffer;*/ struct biosal_assembly_graph_store *concrete_self; double value; struct biosal_dna_kmer kmer; /*struct core_memory_pool *ephemeral_memory;*/ int customer; int big_key_size; int big_value_size; if (thorium_actor_take_action(self, message)) { return; } /*ephemeral_memory = thorium_actor_get_ephemeral_memory(self);*/ concrete_self = thorium_actor_concrete_actor(self); tag = thorium_message_action(message); /*buffer = thorium_message_buffer(message);*/ if (tag == ACTION_SET_KMER_LENGTH) { thorium_message_unpack_int(message, 0, &concrete_self->kmer_length); biosal_dna_kmer_init_mock(&kmer, concrete_self->kmer_length, &concrete_self->storage_codec, thorium_actor_get_ephemeral_memory(self)); concrete_self->key_length_in_bytes = biosal_dna_kmer_pack_size(&kmer, concrete_self->kmer_length, &concrete_self->storage_codec); biosal_dna_kmer_destroy(&kmer, thorium_actor_get_ephemeral_memory(self)); big_key_size = concrete_self->key_length_in_bytes; big_value_size = sizeof(struct biosal_assembly_vertex); core_map_init(&concrete_self->table, big_key_size, big_value_size); core_map_set_memory_pool(&concrete_self->table, &concrete_self->persistent_memory); printf("DEBUG big_key_size %d big_value_size %d\n", big_key_size, big_value_size); /* * Configure the map for better performance. */ core_map_disable_deletion_support(&concrete_self->table); /* * The threshold of the map is not very important because * requests that hit the map have to first arrive as messages, * which are slow. */ core_map_set_threshold(&concrete_self->table, 0.95); thorium_actor_send_reply_empty(self, ACTION_SET_KMER_LENGTH_REPLY); } else if (tag == ACTION_ASSEMBLY_GET_KMER_LENGTH) { thorium_actor_send_reply_int(self, ACTION_ASSEMBLY_GET_KMER_LENGTH_REPLY, concrete_self->kmer_length); } else if (tag == ACTION_RESET) { /* * Reset the iterator. */ core_map_iterator_init(&concrete_self->iterator, &concrete_self->table); printf("DEBUG unitig_vertex_count %d\n", concrete_self->unitig_vertex_count); thorium_actor_send_reply_empty(self, ACTION_RESET_REPLY); } else if (tag == ACTION_SEQUENCE_STORE_REQUEST_PROGRESS_REPLY) { thorium_message_unpack_double(message, 0, &value); core_map_set_current_size_estimate(&concrete_self->table, value); } else if (tag == ACTION_ASK_TO_STOP) { printf("%s/%d received %d arc blocks\n", thorium_actor_script_name(self), thorium_actor_name(self), concrete_self->received_arc_block_count); thorium_actor_ask_to_stop(self, message); } else if (tag == ACTION_SET_CONSUMER) { thorium_message_unpack_int(message, 0, &customer); printf("%s/%d will use coverage distribution %d\n", thorium_actor_script_name(self), thorium_actor_name(self), customer); concrete_self->customer = customer; thorium_actor_send_reply_empty(self, ACTION_SET_CONSUMER_REPLY); } else if (tag == ACTION_PUSH_DATA) { printf("%s/%d receives ACTION_PUSH_DATA\n", thorium_actor_script_name(self), thorium_actor_name(self)); biosal_assembly_graph_store_push_data(self, message); } else if (tag == ACTION_STORE_GET_ENTRY_COUNT) { thorium_actor_send_reply_uint64_t(self, ACTION_STORE_GET_ENTRY_COUNT_REPLY, concrete_self->received); } else if (tag == ACTION_GET_RECEIVED_ARC_COUNT) { thorium_actor_send_reply_uint64_t(self, ACTION_GET_RECEIVED_ARC_COUNT_REPLY, concrete_self->received_arc_count); } }
void biosal_coverage_distribution_receive(struct thorium_actor *self, struct thorium_message *message) { int tag; struct core_map map; struct core_map_iterator iterator; int *coverage_from_message; uint64_t *count_from_message; uint64_t *frequency; int count; void *buffer; struct biosal_coverage_distribution *concrete_actor; int name; int source; struct core_memory_pool *ephemeral_memory; ephemeral_memory = thorium_actor_get_ephemeral_memory(self); name = thorium_actor_name(self); source = thorium_message_source(message); concrete_actor = (struct biosal_coverage_distribution *)thorium_actor_concrete_actor(self); tag = thorium_message_action(message); count = thorium_message_count(message); buffer = thorium_message_buffer(message); if (tag == ACTION_PUSH_DATA) { core_map_init(&map, 0, 0); core_map_set_memory_pool(&map, ephemeral_memory); core_map_unpack(&map, buffer); core_map_iterator_init(&iterator, &map); while (core_map_iterator_has_next(&iterator)) { core_map_iterator_next(&iterator, (void **)&coverage_from_message, (void **)&count_from_message); #ifdef BIOSAL_COVERAGE_DISTRIBUTION_DEBUG thorium_actor_log(self, "DEBUG DATA %d %d\n", (int)*coverage_from_message, (int)*count_from_message); #endif frequency = core_map_get(&concrete_actor->distribution, coverage_from_message); if (frequency == NULL) { frequency = core_map_add(&concrete_actor->distribution, coverage_from_message); (*frequency) = 0; } (*frequency) += (*count_from_message); } core_map_iterator_destroy(&iterator); thorium_actor_send_reply_empty(self, ACTION_PUSH_DATA_REPLY); concrete_actor->actual++; thorium_actor_log(self, "distribution/%d receives coverage data from producer/%d, %d entries / %d bytes %d/%d\n", name, source, (int)core_map_size(&map), count, concrete_actor->actual, concrete_actor->expected); if (concrete_actor->expected != 0 && concrete_actor->expected == concrete_actor->actual) { thorium_actor_log(self, "received everything %d/%d\n", concrete_actor->actual, concrete_actor->expected); biosal_coverage_distribution_write_distribution(self); thorium_actor_send_empty(self, concrete_actor->source, ACTION_NOTIFY); } core_map_destroy(&map); } else if (tag == ACTION_ASK_TO_STOP) { biosal_coverage_distribution_ask_to_stop(self, message); } else if (tag == ACTION_SET_EXPECTED_MESSAGE_COUNT) { concrete_actor->source = source; thorium_message_unpack_int(message, 0, &concrete_actor->expected); thorium_actor_log(self, "distribution %d expects %d messages\n", thorium_actor_name(self), concrete_actor->expected); thorium_actor_send_reply_empty(self, ACTION_SET_EXPECTED_MESSAGE_COUNT_REPLY); } }