@@ -1175,7 +1175,7 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
11751175
11761176 int already_unevicted = table->isAlreadyUnEvicted (block_id);
11771177 if (already_unevicted && table->mergeStrategy ()) { // this block has already been read
1178- VOLT_WARN (" Block 0x%x has already been read." , block_id);
1178+ VOLT_WARN (" Block %d has already been read." , block_id);
11791179 return true ;
11801180 }
11811181
@@ -1189,14 +1189,26 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
11891189
11901190 AntiCacheDB* antiCacheDB = m_db_lookup[ACID];
11911191
1192+ if (!antiCacheDB->validateBlock (_block_id)) {
1193+ VOLT_WARN (" Block %d has already been read from another table." , block_id);
1194+ return true ;
1195+ }
1196+
11921197 if (already_unevicted) { // this block has already been read, but it is tuple-merge strategy
1198+ /* This is a HACK!! CHANGE LATER!!
1199+ for (int k = 0; k < (int)table->unevictedBlocksSize(); ++k) {
1200+ if (table->getMergeTupleOffset(k) == tuple_offset) {
1201+ return true;
1202+ }
1203+ }*/
1204+
11931205 table->insertUnevictedBlock (table->getUnevictedBlocks (already_unevicted - 1 ));
11941206 table->insertTupleOffset (tuple_offset);
11951207
11961208 antiCacheDB->removeSingleTupleStats (_block_id);
11971209
11981210 VOLT_DEBUG (" BLOCK %u TUPLE %d - unevicted blocks size is %d" ,
1199- block_id, tuple_offset, already_unevicted );
1211+ block_id, tuple_offset, ( int )table-> unevictedBlocksSize () );
12001212
12011213 return true ;
12021214 }
@@ -1221,6 +1233,8 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
12211233 // AntiCacheDB* antiCacheDB = table->getAntiCacheDB();
12221234
12231235 try {
1236+ VOLT_DEBUG (" BLOCK %u %d - unevicted blocks size is %d - alreadyUevicted %d" ,
1237+ _block_id, block_id, static_cast <int >(table->unevictedBlocksSize ()), already_unevicted);
12241238 AntiCacheBlock* value = antiCacheDB->readBlock (_block_id, 0 );
12251239
12261240 // allocate the memory for this block
@@ -1250,12 +1264,11 @@ bool AntiCacheEvictionManager::readEvictedBlock(PersistentTable *table, int32_t
12501264 }
12511265
12521266 table->insertUnevictedBlock (unevicted_tuples);
1253- VOLT_DEBUG (" BLOCK %u - unevicted blocks size is %d" ,
1254- _block_id, static_cast <int >(table->unevictedBlocksSize ()));
12551267 table->insertTupleOffset (tuple_offset);
12561268
12571269
12581270 table->insertUnevictedBlockID (std::pair<int32_t ,int32_t >(block_id, table->unevictedBlocksSize ()));
1271+ VOLT_DEBUG (" after insert: alreadyUnevicted %d - IDs size %ld" , table->isAlreadyUnEvicted (block_id), table->getUnevictedBlockIDs ().size ());
12591272
12601273 VOLT_DEBUG (" BLOCK %u TUPLE %d - unevicted blocks size is %d" ,
12611274 block_id, tuple_offset, static_cast <int >(table->unevictedBlocksSize ()));
@@ -1575,23 +1588,25 @@ bool AntiCacheEvictionManager::mergeUnevictedTuples(PersistentTable *table) {
15751588#ifdef VOLT_INFO_ENABLED
15761589 VOLT_INFO (" Merging %d blocks for table %s." , num_blocks, table->name ().c_str ());
15771590#endif
1591+ VOLT_INFO (" Merging %d blocks for table %s." , num_blocks, table->name ().c_str ());
15781592
15791593 for (int i = 0 ; i < num_blocks; i++) {
15801594 // XXX: have to put block size, which we don't know, so just put something large, like 10MB
15811595 ReferenceSerializeInput in (table->getUnevictedBlocks (i), 10485760 );
15821596
1597+ merge_tuple_offset = table->getMergeTupleOffset (i); // what to do about this?
1598+ VOLT_DEBUG (" Merge Tuple offset is %d" , merge_tuple_offset);
1599+
15831600 // Read in all the meta-data
15841601 int num_tables = in.readInt ();
15851602 std::vector<std::string> tableNames;
15861603 std::vector<int > numTuples;
15871604 for (int j = 0 ; j < num_tables; j++){
15881605 tableNames.push_back (in.readTextString ());
15891606 numTuples.push_back (in.readInt ());
1607+ VOLT_TRACE (" %s" , tableNames[j].c_str ());
15901608 }
15911609
1592- merge_tuple_offset = table->getMergeTupleOffset (i); // what to do about this?
1593- // VOLT_INFO("Tuple offset is %d", merge_tuple_offset);
1594-
15951610 int count = 0 ;
15961611 for (std::vector<std::string>::iterator it = tableNames.begin () ; it != tableNames.end (); ++it){
15971612 PersistentTable *tableInBlock = dynamic_cast <PersistentTable*>(m_engine->getTable (*it));
@@ -1686,6 +1701,8 @@ bool AntiCacheEvictionManager::mergeUnevictedTuples(PersistentTable *table) {
16861701 }
16871702 table->clearUnevictedBlocks ();
16881703 table->clearMergeTupleOffsets ();
1704+ VOLT_DEBUG (" unevicted blockIDs size %d" , static_cast <int >(table->getUnevictedBlockIDs ().size ()));
1705+ VOLT_DEBUG (" unevicted blocks size %d" , static_cast <int >(table->unevictedBlocksSize ()));
16891706
16901707 // VOLT_ERROR("Active Tuple Count: %d -- %d", (int)active_tuple_count, (int)table->activeTupleCount());
16911708#ifndef ANTICACHE_TIMESTAMPS
@@ -1721,6 +1738,17 @@ void AntiCacheEvictionManager::recordEvictedAccess(catalog::Table* catalogTable,
17211738 if (m_blockable_accesses && !(block_id & 0x00080000 )) {
17221739 m_blockable_accesses = false ;
17231740 }
1741+
1742+ /*
1743+ if (m_evicted_filter.find(block_id) != m_evicted_filter.end())
1744+ if (m_evicted_filter[block_id].find(tuple_id) != m_evicted_filter[block_id].end()) {
1745+ VOLT_ERROR("try skipping %d %d", block_id, tuple_id);
1746+ return;
1747+ }
1748+
1749+ (m_evicted_filter[block_id]).insert(tuple_id);*/
1750+ // VOLT_ERROR("try reading %d %d", block_id, tuple_id);
1751+
17241752 m_evicted_tables.push_back (catalogTable);
17251753 m_evicted_block_ids.push_back (block_id);
17261754 m_evicted_offsets.push_back (tuple_id);
@@ -1745,14 +1773,14 @@ void AntiCacheEvictionManager::throwEvictedAccessException() {
17451773 // copy the block ids into an array
17461774 int num_blocks = 0 ;
17471775 for (vector<int32_t >::iterator itr = m_evicted_block_ids.begin (); itr != m_evicted_block_ids.end (); ++itr) {
1748- VOLT_DEBUG (" Marking block %d as being needed for uneviction" , *itr);
1776+ VOLT_TRACE (" Marking block %d as being needed for uneviction" , *itr);
17491777 block_ids[num_blocks++] = *itr;
17501778 }
17511779
17521780 // copy the tuple offsets into an array
17531781 int num_tuples = 0 ;
17541782 for (vector<int32_t >::iterator itr = m_evicted_offsets.begin (); itr != m_evicted_offsets.end (); ++itr) {
1755- VOLT_DEBUG (" Marking tuple %d from %s as being needed for uneviction" , *itr, m_evicted_tables[num_tuples]->name ().c_str ());
1783+ VOLT_TRACE (" Marking tuple %d from %s as being needed for uneviction" , *itr, m_evicted_tables[num_tuples]->name ().c_str ());
17561784 tuple_ids[num_tuples++] = *itr;
17571785 }
17581786
@@ -1761,7 +1789,7 @@ void AntiCacheEvictionManager::throwEvictedAccessException() {
17611789
17621790 // Do we really want to throw this here?
17631791 // FIXME We need to support multiple tables in the exception data
1764- VOLT_INFO (" Throwing EvictedTupleAccessException for table %s (%d) "
1792+ VOLT_DEBUG (" Throwing EvictedTupleAccessException for table %s (%d) "
17651793 " [num_blocks=%d / num_tuples=%d]" ,
17661794 catalogTable->name ().c_str (), catalogTable->relativeIndex (),
17671795 num_blocks, num_tuples);
0 commit comments