messagingfw/msgsrvnstore/server/src/msvsearchsortcachemanager.cpp
changeset 15 ff168ad79dda
parent 0 8e480a14352b
child 35 f8ad95794a08
child 36 e7635922c074
equal deleted inserted replaced
3:28ae839b4c09 15:ff168ad79dda
    56   * @return None.
    56   * @return None.
    57   * Destructor
    57   * Destructor
    58   */
    58   */
    59  CMSvSearchSortCacheManager::~CMSvSearchSortCacheManager()
    59  CMSvSearchSortCacheManager::~CMSvSearchSortCacheManager()
    60  	{
    60  	{
       
    61 	iOutstandingSOSOperations = 0;
    61 	iMsvIdWithSortFieldArray.Close();
    62 	iMsvIdWithSortFieldArray.Close();
    62 	iToFindResultAsIdArray.Close();
    63 	iToFindResultAsIdArray.Close();
    63 	iFinalResultAsIdArray.Close();
    64 	iFinalResultAsIdArray.Close();
    64 	iUpdateIdsToCacheArray.Close();
    65 	iUpdateIdsToCacheArray.Close();
    65 	iDeltaCacheIdArray.Close();
    66 	iDeltaCacheIdArray.Close();
   142 void CMSvSearchSortCacheManager::ConstructL()
   143 void CMSvSearchSortCacheManager::ConstructL()
   143 	{
   144 	{
   144 	iProgress = KMsvSearchSortOpNone;
   145 	iProgress = KMsvSearchSortOpNone;
   145 	iCancelFlag = EFalse;
   146 	iCancelFlag = EFalse;
   146 	iExplicitSortOnDateTime = EFalse;
   147 	iExplicitSortOnDateTime = EFalse;
       
   148 
       
   149 	//For Simultaneously query
       
   150 	iOutstandingSOSOperations = 0;
       
   151 	
   147 	if(CMsvEntryFreePool::Instance()->iMsvMaximumCacheSize != NULL && CMsvEntryFreePool::Instance()->iMsvSearchSortCache)
   152 	if(CMsvEntryFreePool::Instance()->iMsvMaximumCacheSize != NULL && CMsvEntryFreePool::Instance()->iMsvSearchSortCache)
   148 		{
   153 		{
   149 		iMsvMaximumSearchSortCacheSize = ((CMsvEntryFreePool::Instance()->iMsvMaximumCacheSize * CMsvEntryFreePool::Instance()->iMsvSearchSortCache)/100)*1024 ;		
   154 		iMsvMaximumSearchSortCacheSize = ((CMsvEntryFreePool::Instance()->iMsvMaximumCacheSize * CMsvEntryFreePool::Instance()->iMsvSearchSortCache)/100)*1024 ;		
   150 		}
   155 		}
   151 	else
   156 	else
   910 		if(EIndexQuery == IsTypeOfQuery(aEntry))
   915 		if(EIndexQuery == IsTypeOfQuery(aEntry))
   911 			{
   916 			{
   912 			FinalResultAsIdL(aEntry);
   917 			FinalResultAsIdL(aEntry);
   913 			iReturnResultType = KFinalResult;
   918 			iReturnResultType = KFinalResult;
   914 			iProgress = KMsvSearchSortOpCompleted; 
   919 			iProgress = KMsvSearchSortOpCompleted; 
       
   920 			if(iOutstandingSOSOperations>0)
       
   921 				{
       
   922 				iOutstandingSOSOperations--;
       
   923 				}
   915 			}
   924 			}
   916 		else
   925 		else
   917 			{
   926 			{
   918 			FindResultAsIdL(aEntry);
   927 			FindResultAsIdL(aEntry);
   919 			iReturnResultType = KNewQuery;
   928 			iReturnResultType = KNewQuery;
   935 #else
   944 #else
   936 		if(EIndexQuery == IsTypeOfQuery(aEntry))
   945 		if(EIndexQuery == IsTypeOfQuery(aEntry))
   937 			{
   946 			{
   938 			FirstResultForInteraratorNewQueryL(aEntry);
   947 			FirstResultForInteraratorNewQueryL(aEntry);
   939 			iReturnResultType = KFinalResult;
   948 			iReturnResultType = KFinalResult;
       
   949 			if(iOutstandingSOSOperations>0)
       
   950 				{
       
   951 				iOutstandingSOSOperations--;
       
   952 				}
   940 			}
   953 			}
   941 #endif
   954 #endif
   942 		else 
   955 		else 
   943 			{
   956 			{
   944 			return KErrNotSupported;
   957 			return KErrNotSupported;
   984 #endif		
   997 #endif		
   985 			{
   998 			{
   986 			OnDemandUpdateCacheEntryL(aIndex);
   999 			OnDemandUpdateCacheEntryL(aIndex);
   987 			iReturnResultType = KFinalResult;
  1000 			iReturnResultType = KFinalResult;
   988 			iProgress = KMsvSearchSortOpCompleted; 
  1001 			iProgress = KMsvSearchSortOpCompleted; 
       
  1002 			if(iOutstandingSOSOperations>0)
       
  1003 				{
       
  1004 				iOutstandingSOSOperations--;
       
  1005 				}
   989 			}
  1006 			}
   990 		else
  1007 		else
   991 			{
  1008 			{
   992 			OnDemandUpdateCacheEntryL(aIndex);
  1009 			OnDemandUpdateCacheEntryL(aIndex);
   993 			if(!iSearchSortDeltaCache->iDeltaCacheDirtyFlag)
  1010 			if(!iSearchSortDeltaCache->iDeltaCacheDirtyFlag)
   994 				{
  1011 				{
   995 				iReturnResultType = KFinalResult;
  1012 				iReturnResultType = KFinalResult;
   996 				iProgress = KMsvSearchSortOpCompleted;  
  1013 				iProgress = KMsvSearchSortOpCompleted;
       
  1014 				if(iOutstandingSOSOperations>0)
       
  1015 					{
       
  1016 					iOutstandingSOSOperations--;
       
  1017 					}
   997 				}
  1018 				}
   998 			else
  1019 			else
   999 				{
  1020 				{
  1000 				for(TInt ii =0; ii<iSearchSortDeltaCache->iNewEntry.Count(); ii++ )
  1021 				for(TInt ii =0; ii<iSearchSortDeltaCache->iNewEntry.Count(); ii++ )
  1001 					{
  1022 					{
  1024 #endif		
  1045 #endif		
  1025 			{
  1046 			{
  1026 			FirstResultForInteraratorQueryIdL(aIndex);
  1047 			FirstResultForInteraratorQueryIdL(aIndex);
  1027 			iReturnResultType = KFinalResult;
  1048 			iReturnResultType = KFinalResult;
  1028 			iProgress = KMsvSearchSortOpIterationEnabled;
  1049 			iProgress = KMsvSearchSortOpIterationEnabled;
  1029 			}
  1050 			if(iOutstandingSOSOperations>0)
       
  1051 				{
       
  1052 				iOutstandingSOSOperations--;
       
  1053 				}
       
  1054  			}
  1030 		else 
  1055 		else 
  1031 			{
  1056 			{
  1032 			// Not Supported.
  1057 			// Not Supported.
  1033 			return KErrNotSupported;
  1058 			return KErrNotSupported;
  1034 			}
  1059 			}
  1342 	
  1367 	
  1343 	iMsvSearchSortCacheManager->iFinalResultAsIdArray.Reset();
  1368 	iMsvSearchSortCacheManager->iFinalResultAsIdArray.Reset();
  1344 	iSearchDbAdapter->GetSortedTMsvIdsfromTableL((*iManagerEntry)[aIndex-1]->iQueryID,iMsvSearchSortCacheManager->iFinalResultAsIdArray, (*iManagerEntry)[aIndex-1]->IsAscendingSort()/*Default = EFalse*/,(*iManagerEntry)[aIndex-1]->iMsgExplicitSortPart);
  1369 	iSearchDbAdapter->GetSortedTMsvIdsfromTableL((*iManagerEntry)[aIndex-1]->iQueryID,iMsvSearchSortCacheManager->iFinalResultAsIdArray, (*iManagerEntry)[aIndex-1]->IsAscendingSort()/*Default = EFalse*/,(*iManagerEntry)[aIndex-1]->iMsgExplicitSortPart);
  1345 	iReturnResultType = KFinalResult;
  1370 	iReturnResultType = KFinalResult;
  1346 	iProgress = KMsvSearchSortOpCompleted; 
  1371 	iProgress = KMsvSearchSortOpCompleted; 
       
  1372 	if(iOutstandingSOSOperations>0)
       
  1373 		{
       
  1374 		iOutstandingSOSOperations--;
       
  1375 		}
  1347 	aToUpdateDb.Reset();
  1376 	aToUpdateDb.Reset();
  1348 	}
  1377 	}
  1349 
  1378 
  1350 
  1379 
  1351 /**
  1380 /**
  1363 		iSearchDbAdapter->GetSortedTMsvIdsfromTableL((*iManagerEntry)[aIndex-1]->iQueryID,iMsvSearchSortCacheManager->iFinalResultAsIdArray, (*iManagerEntry)[aIndex-1]->IsAscendingSort(),(*iManagerEntry)[aIndex-1]->iMsgExplicitSortPart);
  1392 		iSearchDbAdapter->GetSortedTMsvIdsfromTableL((*iManagerEntry)[aIndex-1]->iQueryID,iMsvSearchSortCacheManager->iFinalResultAsIdArray, (*iManagerEntry)[aIndex-1]->IsAscendingSort(),(*iManagerEntry)[aIndex-1]->iMsgExplicitSortPart);
  1364 		iReturnResultType = KFinalResult;
  1393 		iReturnResultType = KFinalResult;
  1365 		iProgress = KMsvSearchSortOpCompleted; 
  1394 		iProgress = KMsvSearchSortOpCompleted; 
  1366 		}
  1395 		}
  1367 	iMsvSearchSortCacheManager->iMsvIdWithSortFieldArray.Reset();
  1396 	iMsvSearchSortCacheManager->iMsvIdWithSortFieldArray.Reset();
       
  1397     if(iOutstandingSOSOperations>0)
       
  1398         {
       
  1399         iOutstandingSOSOperations--;
       
  1400         }
  1368 	return iReturnResultType;
  1401 	return iReturnResultType;
  1369 	}
  1402 	}
  1370 
  1403 
  1371 
  1404 
  1372 /**
  1405 /**
  1401  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry, aEntry.iSortOnHeader, IsTypeOfQuery(aEntry), iReturnResultType);
  1434  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry, aEntry.iSortOnHeader, IsTypeOfQuery(aEntry), iReturnResultType);
  1402 #else 		
  1435 #else 		
  1403  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry);
  1436  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry);
  1404 #endif 		
  1437 #endif 		
  1405   		iProgress = KMsvSearchSortOpCompleted;
  1438   		iProgress = KMsvSearchSortOpCompleted;
       
  1439 		if(iOutstandingSOSOperations>0)
       
  1440 			{
       
  1441 			iOutstandingSOSOperations--;
       
  1442 			}
  1406  		}
  1443  		}
  1407 	else
  1444 	else
  1408 		{
  1445 		{
  1409 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB) 		
  1446 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB) 		
  1410  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry, aEntry.iSortOnHeader, IsTypeOfQuery(aEntry), iReturnResultType);
  1447  		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry, aEntry.iSortOnHeader, IsTypeOfQuery(aEntry), iReturnResultType);
  1411 #else 		
  1448 #else 		
  1412 		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry);
  1449 		iSearchDbAdapter->GetIdsInIteratorNewQueryL(aEntry);
  1413 #endif
  1450 #endif
  1414 		iProgress = KMsvSearchSortOpCompleted;
  1451 		iProgress = KMsvSearchSortOpCompleted;
       
  1452 		if(iOutstandingSOSOperations>0)
       
  1453 			{
       
  1454 			iOutstandingSOSOperations--;
       
  1455 			}
  1415 		}
  1456 		}
  1416 	}
  1457 	}
  1417 
  1458 
  1418 
  1459 
  1419 /**
  1460 /**
  1431  	if((*iManagerEntry)[index]->iResultType == EMsvResultAsTMsvId)
  1472  	if((*iManagerEntry)[index]->iResultType == EMsvResultAsTMsvId)
  1432  		{
  1473  		{
  1433  		//iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID);
  1474  		//iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID);
  1434  		iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID, (*iManagerEntry)[index]->IsAscendingSort(), (*iManagerEntry)[index]->iMsgExplicitSortPart);
  1475  		iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID, (*iManagerEntry)[index]->IsAscendingSort(), (*iManagerEntry)[index]->iMsgExplicitSortPart);
  1435   		iProgress = KMsvSearchSortOpCompleted;
  1476   		iProgress = KMsvSearchSortOpCompleted;
  1436  		}
  1477 		if(iOutstandingSOSOperations>0)
       
  1478 			{
       
  1479 			iOutstandingSOSOperations--;
       
  1480 			}
       
  1481    		}
  1437 	else
  1482 	else
  1438 		{
  1483 		{
  1439 		//iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID);
  1484 		//iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID);
  1440 		iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID, (*iManagerEntry)[index]->IsAscendingSort(), (*iManagerEntry)[index]->iMsgExplicitSortPart);
  1485 		iSearchDbAdapter->GetIdsInIteratorQueryIdL((*iManagerEntry)[index]->iQueryID, (*iManagerEntry)[index]->IsAscendingSort(), (*iManagerEntry)[index]->iMsgExplicitSortPart);
  1441 		iProgress = KMsvSearchSortOpCompleted;
  1486 		iProgress = KMsvSearchSortOpCompleted;
       
  1487 		if(iOutstandingSOSOperations>0)
       
  1488 			{
       
  1489 			iOutstandingSOSOperations--;
       
  1490 			}
  1442 		}
  1491 		}
  1443 	}
  1492 	}
  1444 
  1493 
  1445 /**
  1494 /**
  1446 * GetNextForInteraratorL() : 
  1495 * GetNextForInteraratorL() : 
  1457  	if((*iManagerEntry)[aIndex]->iResultType == EMsvResultAsTMsvId)
  1506  	if((*iManagerEntry)[aIndex]->iResultType == EMsvResultAsTMsvId)
  1458  		{
  1507  		{
  1459  		//iSearchDbAdapter->GetNextIdL( (*iManagerEntry)[aIndex]->iQueryID , iIteratorId,iIteratorRemainingResultCount);
  1508  		//iSearchDbAdapter->GetNextIdL( (*iManagerEntry)[aIndex]->iQueryID , iIteratorId,iIteratorRemainingResultCount);
  1460  		iSearchDbAdapter->GetNextIdL(iIteratorId,iIteratorRemainingResultCount);
  1509  		iSearchDbAdapter->GetNextIdL(iIteratorId,iIteratorRemainingResultCount);
  1461  		iProgress = KMsvSearchSortOpCompleted;
  1510  		iProgress = KMsvSearchSortOpCompleted;
       
  1511 		if(iIteratorRemainingResultCount == 0)
       
  1512 			{
       
  1513 			if(iOutstandingSOSOperations>0)
       
  1514 				{
       
  1515 				iOutstandingSOSOperations--;
       
  1516 				}
       
  1517 			}
  1462  		}
  1518  		}
  1463 	else
  1519 	else
  1464 		{
  1520 		{
  1465 		//iIteratorEntry
  1521 		//iIteratorEntry
  1466 		//iSearchDbAdapter->GetNextIdL((*iManagerEntry)[aIndex]->iQueryID , iIteratorId,iIteratorRemainingResultCount);
  1522 		//iSearchDbAdapter->GetNextIdL((*iManagerEntry)[aIndex]->iQueryID , iIteratorId,iIteratorRemainingResultCount);
  1467 		iSearchDbAdapter->GetNextIdL(iIteratorId,iIteratorRemainingResultCount);
  1523 		iSearchDbAdapter->GetNextIdL(iIteratorId,iIteratorRemainingResultCount);
  1468 		TMsvEntry *entry;
  1524 		TMsvEntry *entry;
  1469 		iServer.IndexAdapter().GetEntry(iIteratorId,entry);
  1525 		iServer.IndexAdapter().GetEntry(iIteratorId,entry);
  1470 		iIteratorEntry  = *entry;
  1526 		iIteratorEntry  = *entry;
  1471 		iProgress = KMsvSearchSortOpCompleted;
  1527 		iProgress = KMsvSearchSortOpCompleted;
       
  1528 		if(iIteratorRemainingResultCount == 0)
       
  1529 			{
       
  1530 			if(iOutstandingSOSOperations>0)
       
  1531 				{
       
  1532 				iOutstandingSOSOperations--;
       
  1533 				}
       
  1534        		}
  1472 		}
  1535 		}
  1473 	}
  1536 	}
  1474 
  1537 
  1475 
  1538 
  1476 /**
  1539 /**
  1548 */
  1611 */
  1549 
  1612 
  1550 TInt CMSvSearchSortCacheManager::CancelSearchSortOperation() const
  1613 TInt CMSvSearchSortCacheManager::CancelSearchSortOperation() const
  1551 	{
  1614 	{
  1552 	iMsvSearchSortCacheManager->iCancelFlag = ETrue;	
  1615 	iMsvSearchSortCacheManager->iCancelFlag = ETrue;	
       
  1616 	if(iOutstandingSOSOperations>0)
       
  1617 		{
       
  1618 		iOutstandingSOSOperations--;
       
  1619 		}
  1553 	return 0;
  1620 	return 0;
  1554 	}
  1621 	}
  1555 
  1622 
  1556 
  1623 
  1557 /**
  1624 /**
  1636 TSearchSortDbWrapper* CMSvSearchSortCacheManager::GetDbWrapper()
  1703 TSearchSortDbWrapper* CMSvSearchSortCacheManager::GetDbWrapper()
  1637 	{
  1704 	{
  1638 	return iSearchDbAdapter;
  1705 	return iSearchDbAdapter;
  1639 	}
  1706 	}
  1640 
  1707 
       
  1708 //For Simultaneously query
       
  1709 void CMSvSearchSortCacheManager::AddOutstandingSOSOperation()
       
  1710     {
       
  1711     iOutstandingSOSOperations++;
       
  1712     }
       
  1713 
       
  1714 TInt CMSvSearchSortCacheManager::OutstandingSOSOperations()
       
  1715     {
       
  1716     return iOutstandingSOSOperations;
       
  1717     }
       
  1718  
       
  1719 
       
  1720