@@ -1210,8 +1210,9 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
12101210
12111211 table->insertUnevictedBlock (table->getUnevictedBlocks (already_unevicted - 1 ));
12121212 table->insertTupleOffset (tuple_offset);
1213+ table->insertBlockID (block_id);
12131214
1214- antiCacheDB->removeSingleTupleStats (_block_id);
1215+ antiCacheDB->removeSingleTupleStats (_block_id, 1 );
12151216
12161217 VOLT_DEBUG (" BLOCK %u TUPLE %d - unevicted blocks size is %d" ,
12171218 block_id, tuple_offset, (int )table->unevictedBlocksSize ());
@@ -1271,6 +1272,7 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
12711272
12721273 table->insertUnevictedBlock (unevicted_tuples);
12731274 table->insertTupleOffset (tuple_offset);
1275+ table->insertBlockID (block_id);
12741276
12751277
12761278 table->insertUnevictedBlockID (std::pair<int32_t ,int32_t >(block_id, table->unevictedBlocksSize ()));
@@ -1613,6 +1615,13 @@ bool AntiCacheEvictionManager::mergeUnevictedTuples(PersistentTable *table) {
16131615 VOLT_TRACE (" %s" , tableNames[j].c_str ());
16141616 }
16151617
1618+ // Get ACDB for this tuple. That is used for correct stats tuple-merge strategy
1619+ int32_t block_id = table->getBlockID (i);
1620+ uint16_t _block_id = (int16_t )(block_id & 0x0000FFFF );
1621+ int16_t ACID = (int16_t )((block_id & 0x00070000 ) >> 16 );
1622+ VOLT_DEBUG (" block_id: %8x ACID: %d _block_id: %d blocking: %d\n " , block_id, ACID, _block_id, (int )blocking);
1623+ AntiCacheDB* antiCacheDB = m_db_lookup[ACID];
1624+
16161625 int count = 0 ;
16171626 for (std::vector<std::string>::iterator it = tableNames.begin () ; it != tableNames.end (); ++it){
16181627 PersistentTable *tableInBlock = dynamic_cast <PersistentTable*>(m_engine->getTable (*it));
@@ -1623,7 +1632,12 @@ bool AntiCacheEvictionManager::mergeUnevictedTuples(PersistentTable *table) {
16231632 int64_t bytes_unevicted = 0 ;
16241633 int tuplesRead = 0 ;
16251634 if (!table->mergeStrategy ()) {
1626- bytes_unevicted += tableInBlock->unevictTuple (&in, merge_tuple_offset, merge_tuple_offset, (bool )table->mergeStrategy ());
1635+ int64_t current_unevicted = tableInBlock->unevictTuple (&in, merge_tuple_offset, merge_tuple_offset, (bool )table->mergeStrategy ());
1636+ bytes_unevicted += current_unevicted;
1637+ if (current_unevicted == 0 ) {
1638+ antiCacheDB->removeSingleTupleStats (_block_id, -1 );
1639+ // printf("Add back: %u %u\n", ACID, _block_id);
1640+ }
16271641 } else {
16281642 for (int j = 0 ; j < num_tuples_in_block; j++)
16291643 {
@@ -1707,6 +1721,7 @@ bool AntiCacheEvictionManager::mergeUnevictedTuples(PersistentTable *table) {
17071721 }
17081722 table->clearUnevictedBlocks ();
17091723 table->clearMergeTupleOffsets ();
1724+ table->clearBlockIDs ();
17101725 VOLT_DEBUG (" unevicted blockIDs size %d" , static_cast <int >(table->getUnevictedBlockIDs ().size ()));
17111726 VOLT_DEBUG (" unevicted blocks size %d" , static_cast <int >(table->unevictedBlocksSize ()));
17121727
0 commit comments