@@ -1169,12 +1169,22 @@ Table* AntiCacheEvictionManager::evictBlockInBatch(PersistentTable *table, Persi
11691169
11701170bool AntiCacheEvictionManager::readEvictedBlock (PersistentTable *table, int32_t block_id, int32_t tuple_offset) {
11711171
1172- bool already_unevicted = table->isAlreadyUnEvicted (block_id);
1172+ int already_unevicted = table->isAlreadyUnEvicted (block_id);
11731173 if (already_unevicted && table->mergeStrategy ()) { // this block has already been read
11741174 VOLT_WARN (" Block 0x%x has already been read." , block_id);
11751175 return true ;
11761176 }
11771177
1178+ if (already_unevicted) { // this block has already been read, but it is tuple-merge strategy
1179+ table->insertUnevictedBlock (table->getUnevictedBlocks (already_unevicted - 1 ));
1180+ table->insertTupleOffset (tuple_offset);
1181+
1182+ VOLT_DEBUG (" BLOCK %u TUPLE %d - unevicted blocks size is %d" ,
1183+ block_id, tuple_offset, already_unevicted);
1184+
1185+ return true ;
1186+ }
1187+
11781188 /*
11791189 * Finds the AntiCacheDB* instance associated with the needed block_id
11801190 */
@@ -1239,8 +1249,11 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
12391249 table->insertTupleOffset (tuple_offset);
12401250
12411251
1242- table->insertUnevictedBlockID (std::pair<int32_t ,int16_t >(block_id, 0 ));
1252+ table->insertUnevictedBlockID (std::pair<int32_t ,int32_t >(block_id, table-> unevictedBlocksSize () ));
12431253
1254+ VOLT_DEBUG (" BLOCK %u TUPLE %d - unevicted blocks size is %d" ,
1255+ block_id, tuple_offset, static_cast <int >(table->unevictedBlocksSize ()));
1256+
12441257 delete value;
12451258 } catch (UnknownBlockAccessException e) {
12461259 throw e;
@@ -1642,11 +1655,22 @@ bool AntiCacheEvictionManager::mergeUnevictedTuples(PersistentTable *table) {
16421655
16431656
16441657
1645- delete [] table->getUnevictedBlocks (i);
1658+ if (table->mergeStrategy ())
1659+ delete [] table->getUnevictedBlocks (i);
16461660 // table->clearUnevictedBlocks(i);
16471661 }
16481662
1663+ VOLT_DEBUG (" unevicted blockIDs size %d" , static_cast <int >(table->getUnevictedBlockIDs ().size ()));
16491664 VOLT_DEBUG (" unevicted blocks size %d" , static_cast <int >(table->unevictedBlocksSize ()));
1665+ if (!table->mergeStrategy ()) {
1666+ map <int32_t , int32_t > unevictedBlockIDs = table->getUnevictedBlockIDs ();
1667+ for (map <int32_t , int32_t >::iterator itr = unevictedBlockIDs.begin (); itr != unevictedBlockIDs.end ();
1668+ itr++) {
1669+ // printf("bid:%d idx:%d\n", itr->first, itr->second);
1670+ delete [] table->getUnevictedBlocks (itr->second - 1 );
1671+ }
1672+ table->clearUnevictedBlockIDs ();
1673+ }
16501674 table->clearUnevictedBlocks ();
16511675 table->clearMergeTupleOffsets ();
16521676
0 commit comments