33 #include "thumbnailpanic.h" |
33 #include "thumbnailpanic.h" |
34 #include "thumbnailmanagerconstants.h" |
34 #include "thumbnailmanagerconstants.h" |
35 #include "thumbnailserver.h" |
35 #include "thumbnailserver.h" |
36 |
36 |
37 |
37 |
38 _LIT8( KThumbnailSqlConfig, "page_size=16384; cache_size=32;" ); |
38 _LIT8( KThumbnailSqlConfig, "page_size=32768; cache_size=32;" ); |
39 |
39 |
40 const TInt KStreamBufferSize = 1024 * 8; |
40 const TInt KStreamBufferSize = 1024 * 8; |
41 const TInt KMajor = 3; |
41 const TInt KMajor = 3; |
42 const TInt KMinor = 2; |
42 const TInt KMinor = 2; |
43 |
43 |
414 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailDeletedTable err=%d", err ); |
422 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailDeletedTable err=%d", err ); |
415 User::LeaveIfError( err ); |
423 User::LeaveIfError( err ); |
416 |
424 |
417 err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 ); |
425 err = iDatabase.Exec( KThumbnailCreateInfoTableIndex1 ); |
418 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err ); |
426 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateInfoTableIndex1 err=%d", err ); |
419 User::LeaveIfError( err ); |
|
420 |
|
421 err = iDatabase.Exec( KThumbnailCreateDeletedTableIndex ); |
|
422 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailCreateDeletedTableIndex err=%d", err ); |
|
423 User::LeaveIfError( err ); |
427 User::LeaveIfError( err ); |
424 |
428 |
425 err = iDatabase.Exec(KThumbnailVersionTable); |
429 err = iDatabase.Exec(KThumbnailVersionTable); |
426 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err ); |
430 TN_DEBUG2( "CThumbnailStore::CreateTablesL() KThumbnailVersionTable err=%d", err ); |
427 User::LeaveIfError( err ); |
431 User::LeaveIfError( err ); |
1934 { |
1938 { |
1935 // cache empty or db unusable |
1939 // cache empty or db unusable |
1936 return; |
1940 return; |
1937 } |
1941 } |
1938 |
1942 |
1939 // fixed batch size if MTP sync on |
1943 // longer flush allowed if MTP sync on |
1940 TInt MPXHarvesting(0); |
1944 TInt MPXHarvesting(0); |
1941 TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting); |
1945 TInt ret = RProperty::Get(KTAGDPSNotification, KMPXHarvesting, MPXHarvesting); |
1942 if(ret != KErrNone) |
1946 if(ret != KErrNone) |
1943 { |
1947 { |
1944 TN_DEBUG2( "CThumbnailStore::FlushCacheTable() error checking MTP sync: %d", ret); |
1948 TN_DEBUG2( "CThumbnailStore::FlushCacheTable() error checking MTP sync: %d", ret); |
1945 } |
1949 } |
1946 |
1950 |
1947 if(MPXHarvesting && iBatchItemCount < KMaxBatchItemsMTP && !aForce) |
1951 //set init max flush delay |
1948 { |
1952 TInt aMaxFlushDelay(KMaxFlushDelay); |
1949 TN_DEBUG1("CThumbnailStore::FlushCacheTable() MTP sync, fixed batch..."); |
1953 |
1950 |
1954 if(MPXHarvesting) |
1951 //some items in cache |
1955 { |
1952 StartAutoFlush(); |
1956 //MTP or MPX harvesting active, allow longer flush -> bigger batch size |
1953 return; |
1957 TN_DEBUG1("CThumbnailStore::FlushCacheTable() MTP sync, longer flush.."); |
1954 } |
1958 aMaxFlushDelay = KMaxMTPFlushDelay; |
1955 else if(!MPXHarvesting && iBatchItemCount < iBatchFlushItemCount && !aForce) |
1959 } |
|
1960 |
|
1961 //1st item in batch |
|
1962 if( iBatchItemCount == 1) |
|
1963 { |
|
1964 //adjust batch size dynamically between min and max based on previous flush speed |
|
1965 if(iPreviousFlushDelay > 0 ) |
|
1966 { |
|
1967 iBatchFlushItemCount = (aMaxFlushDelay/iPreviousFlushDelay)*iBatchFlushItemCount; |
|
1968 |
|
1969 if(iBatchFlushItemCount < KMInBatchItems) |
|
1970 { |
|
1971 iBatchFlushItemCount = KMInBatchItems; |
|
1972 } |
|
1973 else if(iBatchFlushItemCount > KMaxBatchItems) |
|
1974 { |
|
1975 iBatchFlushItemCount = KMaxBatchItems; |
|
1976 } |
|
1977 } |
|
1978 else |
|
1979 { |
|
1980 //cannot calculate, init values set to min |
|
1981 iBatchFlushItemCount = KMInBatchItems; |
|
1982 } |
|
1983 } |
|
1984 |
|
1985 TN_DEBUG3("CThumbnailStore::FlushCacheTable() iBatchFlushItemCount = %d, iBatchItemCount = %d", iBatchFlushItemCount, iBatchItemCount); |
|
1986 |
|
1987 if( iBatchItemCount < iBatchFlushItemCount && !aForce) |
1956 { |
1988 { |
1957 //some items in cache |
1989 //some items in cache |
1958 StartAutoFlush(); |
1990 StartAutoFlush(); |
1959 return; |
1991 return; |
1960 } |
1992 } |
2012 // open new |
2044 // open new |
2013 TRAP_IGNORE(OpenDatabaseL(ETrue)); |
2045 TRAP_IGNORE(OpenDatabaseL(ETrue)); |
2014 } |
2046 } |
2015 |
2047 |
2016 iStopFlush.UniversalTime(); |
2048 iStopFlush.UniversalTime(); |
2017 TInt aFlushDelay = (TInt)iStopFlush.MicroSecondsFrom(iStartFlush).Int64()/1000; |
2049 iPreviousFlushDelay = (TInt)iStopFlush.MicroSecondsFrom(iStartFlush).Int64()/1000; |
2018 |
2050 |
2019 TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", aFlushDelay); |
2051 TN_DEBUG2( "CThumbnailStore::FlushCacheTable() took %d ms", iPreviousFlushDelay); |
2020 |
2052 |
2021 //adjust batch size dynamically between min and max based on read flush speed |
|
2022 if (!MPXHarvesting) |
|
2023 { |
|
2024 //increase batch count if there room for one more item (based on average time per item) |
|
2025 if( aFlushDelay < KMaxFlushDelay && iBatchFlushItemCount < KMaxBatchItems ) |
|
2026 { |
|
2027 iBatchFlushItemCount++; |
|
2028 } |
|
2029 //decrease batch count if we exeeced max time allowed in flushing the TEMP table |
|
2030 else if(aFlushDelay > KMaxFlushDelay && iBatchFlushItemCount > KMInBatchItems ) |
|
2031 { |
|
2032 iBatchFlushItemCount--; |
|
2033 } |
|
2034 } |
|
2035 |
|
2036 //cache flushed |
2053 //cache flushed |
2037 iBatchItemCount = 0; |
2054 iBatchItemCount = 0; |
2038 |
2055 |
2039 TN_DEBUG2("CThumbnailStore::FlushCacheTable() out iBatchFlushItemCount = %d", iBatchFlushItemCount); |
2056 TN_DEBUG1("CThumbnailStore::FlushCacheTable() out"); |
2040 } |
2057 } |
2041 |
2058 |
2042 // ----------------------------------------------------------------------------- |
2059 // ----------------------------------------------------------------------------- |
2043 // StartAutoFlush() |
2060 // StartAutoFlush() |
2044 // ----------------------------------------------------------------------------- |
2061 // ----------------------------------------------------------------------------- |