SerializableEEException::SerializableEEException(VoltEEExceptionType exceptionType, std::string message) : m_exceptionType(exceptionType), m_message(message) { VOLT_DEBUG("Created SerializableEEException: type: %s message: %s", translateVoltEEExceptionTypeToString(exceptionType), message.c_str()); }
/** * Reserve some tuples when an eviction requested. */ void EvictionIterator::reserve(int64_t amount) { VOLT_DEBUG("amount: %ld\n", amount); char* addr = NULL; PersistentTable* ptable = static_cast<PersistentTable*>(table); int tuple_size = ptable->m_schema->tupleLength() + TUPLE_HEADER_SIZE; int active_tuple = (int)ptable->activeTupleCount(); int evict_num = 0; int64_t used_tuple = ptable->usedTupleCount(); #ifdef ANTICACHE_TIMESTAMPS_PRIME uint32_t tuples_per_block = ptable->m_tuplesPerBlock; #endif if (active_tuple) evict_num = (int)(amount / (tuple_size + ptable->nonInlinedMemorySize() / active_tuple)); else evict_num = (int)(amount / tuple_size); VOLT_DEBUG("Count: %lu %lu\n", ptable->usedTupleCount(), ptable->activeTupleCount()); if (evict_num > active_tuple) evict_num = active_tuple; int pick_num = evict_num * RANDOM_SCALE; int block_num = (int)ptable->m_data.size(); int block_size = ptable->m_tuplesPerBlock; int location_size; #ifndef ANTICACHE_TIMESTAMPS_PRIME int block_location; #endif srand((unsigned int)time(0)); VOLT_INFO("evict pick num: %d %d\n", evict_num, pick_num); VOLT_INFO("active_tuple: %d\n", active_tuple); VOLT_INFO("block number: %d\n", block_num); m_size = 0; current_tuple_id = 0; #ifdef ANTICACHE_TIMESTAMPS_PRIME int pick_num_block = (int)(((int64_t)pick_num * tuples_per_block) / used_tuple); int last_full_block = (int)(used_tuple / block_size); VOLT_INFO("LOG: %d %d %ld\n", last_full_block, tuples_per_block, used_tuple); int last_block_size = (int)(used_tuple % block_size); int pick_num_last_block = pick_num - pick_num_block * last_full_block; #endif // If we'll evict the entire table, we should do a scan instead of sampling. // The main reason we should do that is to past the test... if (evict_num < active_tuple) { candidates = new EvictionTuple[pick_num]; #ifdef ANTICACHE_TIMESTAMPS_PRIME for (int i = 0; i < last_full_block; ++i) { /** * if this is a beginning of a loop of scan, find a proper step to let it sample tuples from almost the whole block * TODO: Here we use a method that every time try a different prime number from what we use last time. Is it better? * That would need further analysis. */ if (ptable->m_stepPrime[i] < 0) { int ideal_step = (rand() % 5) * tuples_per_block / pick_num_block; int old_prime = - ptable->m_stepPrime[i]; for (int j = prime_size - 1; j >= 0; --j) { if (prime_list[j] != old_prime && (tuples_per_block % prime_list[j]) > 0) { ptable->m_stepPrime[i] = prime_list[j]; VOLT_TRACE("DEBUG: %d %d\n", tuples_per_block, ptable->m_stepPrime[i]); } if (prime_list[j] <= ideal_step) break; } VOLT_INFO("Prime of block %d: %d %d\n", i, tuples_per_block, ptable->m_stepPrime[i]); } // now scan the block with a step of we select. // if we go across the boundry, minus it back to the beginning (like a mod operation) int step_prime = ptable->m_stepPrime[i]; int step_offset = step_prime * tuple_size; int block_size_bytes = block_size * tuple_size; addr = ptable->m_data[i] + ptable->m_evictPosition[i]; uint64_t end_of_block = (uint64_t)ptable->m_data[i] + block_size_bytes; bool flag_new = false; for (int j = 0; j < pick_num_block; ++j) { VOLT_TRACE("Flip addr: %p %p %lu\n", addr, ptable->m_data[i], ((uint64_t)addr - (uint64_t)ptable->m_data[i]) / 1024); current_tuple->move(addr); if (current_tuple->isActive()) { candidates[m_size].setTuple(current_tuple->getTimeStamp(), addr); m_size++; } addr += step_offset; if ((uint64_t)addr >= end_of_block) addr -= block_size_bytes; if (addr == ptable->m_data[i]) flag_new = true; } int new_position = (int)((uint64_t)addr - (uint64_t)ptable->m_data[i]); ptable->m_evictPosition[i] = new_position; if (flag_new) ptable->m_stepPrime[i] = - ptable->m_stepPrime[i]; } if (last_full_block < block_num) { addr = ptable->m_data[last_full_block]; char* current_addr; for (int j = 0; j < pick_num_last_block; ++j) { current_addr = addr + (rand() % last_block_size) * tuple_size; current_tuple->move(current_addr); if (!current_tuple->isActive() || current_tuple->isEvicted()) continue; candidates[m_size].setTuple(current_tuple->getTimeStamp(), current_addr); m_size++; } } #else for (int i = 0; i < pick_num; i++) { // should we use a faster random generator? block_location = rand() % block_num; addr = ptable->m_data[block_location]; if ((block_location + 1) * block_size > used_tuple) location_size = (int)(used_tuple - block_location * block_size); else location_size = block_size; addr += (rand() % location_size) * tuple_size; current_tuple->move(addr); VOLT_DEBUG("Flip addr: %p\n", addr); if (!current_tuple->isActive() || current_tuple->isEvicted()) continue; candidates[m_size].setTuple(current_tuple->getTimeStamp(), addr); m_size++; } #endif } else { candidates = new EvictionTuple[active_tuple]; for (int i = 0; i < block_num; ++i) { addr = ptable->m_data[i]; if ((i + 1) * block_size > ptable->usedTupleCount()) location_size = (int)(ptable->usedTupleCount() - i * block_size); else location_size = block_size; for (int j = 0; j < location_size; j++) { current_tuple->move(addr); if (!current_tuple->isActive() || current_tuple->isEvicted()) { addr += tuple_size; continue; } VOLT_TRACE("Flip addr: %p\n", addr); candidates[m_size].setTuple(current_tuple->getTimeStamp(), addr); m_size++; addr += tuple_size; } } } sort(candidates, candidates + m_size, less <EvictionTuple>()); //VOLT_INFO("Size of eviction candidates: %lu %d %d\n", (long unsigned int)m_size, activeN, evictedN); }
void NVMAntiCacheDB::freeNVMBlock(uint32_t index) { m_NVMBlockFreeList.push_back(index); VOLT_DEBUG("list size: %d back: %u", (int)m_NVMBlockFreeList.size(), m_NVMBlockFreeList.back()); //m_blockIndex--; }
bool AggregateExecutorBase::p_init(AbstractPlanNode*, TempTableLimits* limits) { AggregatePlanNode* node = dynamic_cast<AggregatePlanNode*>(m_abstractNode); assert(node); m_inputExpressions = node->getAggregateInputExpressions(); for (int i = 0; i < m_inputExpressions.size(); i++) { VOLT_DEBUG("\nAGG INPUT EXPRESSION: %s\n", m_inputExpressions[i] ? m_inputExpressions[i]->debug().c_str() : "null"); } /* * Find the difference between the set of aggregate output columns * (output columns resulting from an aggregate) and output columns. * Columns that are not the result of aggregates are being passed * through from the input table. Do this extra work here rather then * serialize yet more data. */ std::vector<bool> outputColumnsResultingFromAggregates(node->getOutputSchema().size(), false); m_aggregateOutputColumns = node->getAggregateOutputColumns(); BOOST_FOREACH(int aOC, m_aggregateOutputColumns) { outputColumnsResultingFromAggregates[aOC] = true; } for (int ii = 0; ii < outputColumnsResultingFromAggregates.size(); ii++) { if (outputColumnsResultingFromAggregates[ii] == false) { m_passThroughColumns.push_back(ii); } } if (!node->isInline()) { setTempOutputTable(limits); } m_partialSerialGroupByColumns = node->getPartialGroupByColumns(); m_aggTypes = node->getAggregates(); m_distinctAggs = node->getDistinctAggregates(); m_groupByExpressions = node->getGroupByExpressions(); node->collectOutputExpressions(m_outputColumnExpressions); // m_passThroughColumns.size() == m_groupByExpressions.size() is not true, // Because group by unique column may be able to select other columns m_prePredicate = node->getPrePredicate(); m_postPredicate = node->getPostPredicate(); m_groupByKeySchema = constructGroupBySchema(false); m_groupByKeyPartialHashSchema = NULL; if (m_partialSerialGroupByColumns.size() > 0) { for (int ii = 0; ii < m_groupByExpressions.size(); ii++) { if (std::find(m_partialSerialGroupByColumns.begin(), m_partialSerialGroupByColumns.end(), ii) == m_partialSerialGroupByColumns.end() ) { // Find the partial hash group by columns m_partialHashGroupByColumns.push_back(ii);; } } m_groupByKeyPartialHashSchema = constructGroupBySchema(true); } return true; }
SerializableEEException::SerializableEEException(std::string message) : m_exceptionType(VOLT_EE_EXCEPTION_TYPE_EEEXCEPTION), m_message(message) { VOLT_DEBUG("Created SerializableEEException: default type, %s", message.c_str()); }