@@ -2191,7 +2191,7 @@ End
21912191/// - One for each entrySourceType, mapped via EntrySourceTypeMapper()
21922192threadsafe Function/WAVE GetLBRowCache ( WAVE values)
21932193
2194- variable actual, sweepNo, first, last
2194+ variable actual, sweepNo, first, last, expected
21952195 string key
21962196
21972197 variable versionOfNewWave = 6
@@ -2202,32 +2202,39 @@ threadsafe Function/WAVE GetLBRowCache(WAVE values)
22022202 WAVE /Z/ D wv = CA_TryFetchingEntryFromCache ( key, options = CA_OPTS_NO_DUPLICATE)
22032203
22042204 if ( ExistsWithCorrectLayoutVersion ( wv, versionOfNewWave))
2205- if ( actual == GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT))
2205+ expected = GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT)
2206+
2207+ if ( actual == expected)
22062208 return wv
22072209 elseif ( ! MU_RunningInMainThread () && GetLockState ( values) == 1 )
22082210 return wv
22092211 else
2210- // new entries were added so we need to propagate all entries to LABNOTEBOOK_GET_RANGE
2211- // for sweep numbers >= than the currently acquired sweep
2212- // this is required as the `last` element of the range can be changed if you add labnotebook
2213- // entries and then query them and then add again.
2214-
2215- if ( IsNumericWave ( values))
2216- WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2217- elseif ( IsTextWave ( values))
2218- WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2219- endif
2220-
2221- if ( IsFinite ( sweepNo))
2222- EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_GET_RANGE)
2223- first = limit ( sweepNo - 1, 0, Inf )
2224- last = sweepNo
2225- Multithread wv[ first, last][][] = LABNOTEBOOK_GET_RANGE
2226-
2227- // now we are up to date
2228- SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2229-
2230- return wv
2212+ if ( actual > expected)
2213+ // new entries were added so we need to propagate all entries to LABNOTEBOOK_GET_RANGE
2214+ // for sweep numbers >= than the currently acquired sweep
2215+ // this is required as the `last` element of the range can be changed if you add labnotebook
2216+ // entries and then query them and then add again.
2217+
2218+ if ( IsNumericWave ( values))
2219+ WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2220+ elseif ( IsTextWave ( values))
2221+ WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2222+ endif
2223+
2224+ if ( IsFinite ( sweepNo))
2225+ EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_GET_RANGE)
2226+ first = limit ( sweepNo - 1, 0, Inf )
2227+ last = sweepNo
2228+ Multithread wv[ first, last][][] = LABNOTEBOOK_GET_RANGE
2229+
2230+ // now we are up to date
2231+ SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2232+
2233+ return wv
2234+ endif
2235+ else
2236+ // cache across experiments, so the stored wave modification is
2237+ // larger than the last labnotebook we cached, go for a full reset
22312238 endif
22322239 endif
22332240 else
@@ -2266,7 +2273,7 @@ End
22662273/// could not be found, and #LABNOTEBOOK_UNCACHED_VALUE if the cache is empty.
22672274threadsafe Function/WAVE GetLBIndexCache ( WAVE values)
22682275
2269- variable actual, sweepNo, first, last
2276+ variable actual, sweepNo, first, last, expected
22702277 string key
22712278
22722279 variable versionOfNewWave = 5
@@ -2277,30 +2284,37 @@ threadsafe Function/WAVE GetLBIndexCache(WAVE values)
22772284 WAVE /Z/ D wv = CA_TryFetchingEntryFromCache ( key, options = CA_OPTS_NO_DUPLICATE)
22782285
22792286 if ( ExistsWithCorrectLayoutVersion ( wv, versionOfNewWave))
2280- if ( actual == GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT))
2287+ expected = GetNumberFromWaveNote ( wv, LABNOTEBOOK_MOD_COUNT)
2288+
2289+ if ( actual == expected)
22812290 return wv
22822291 elseif ( ! MU_RunningInMainThread () && GetLockState ( values) == 1 )
22832292 return wv
22842293 else
2285- // new entries were added so we need to propagate all entries to uncached values
2286- // for sweep numbers >= than the currently acquired sweep
2287-
2288- if ( IsNumericWave ( values))
2289- WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2290- elseif ( IsTextWave ( values))
2291- WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2292- endif
2293-
2294- if ( IsFinite ( sweepNo))
2295- EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_UNCACHED_VALUE)
2296- first = limit ( sweepNo - 1, 0, Inf )
2297- last = sweepNo
2298- Multithread wv[ first, last][][] = LABNOTEBOOK_UNCACHED_VALUE
2299-
2300- // now we are up to date
2301- SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2302-
2303- return wv
2294+ if ( actual > expected)
2295+ // new entries were added so we need to propagate all entries to uncached values
2296+ // for sweep numbers >= than the currently acquired sweep
2297+
2298+ if ( IsNumericWave ( values))
2299+ WAVE /Z sweeps = GetLastSweepWithSetting ( values, "SweepNum" , sweepNo)
2300+ elseif ( IsTextWave ( values))
2301+ WAVE /Z sweeps = GetLastSweepWithSettingText ( values, "SweepNum" , sweepNo)
2302+ endif
2303+
2304+ if ( IsFinite ( sweepNo))
2305+ EnsureLargeEnoughWave ( wv, indexShouldExist = sweepNo, dimension = ROWS, initialValue = LABNOTEBOOK_UNCACHED_VALUE)
2306+ first = limit ( sweepNo - 1, 0, Inf )
2307+ last = sweepNo
2308+ Multithread wv[ first, last][][] = LABNOTEBOOK_UNCACHED_VALUE
2309+
2310+ // now we are up to date
2311+ SetNumberInWaveNote ( wv, LABNOTEBOOK_MOD_COUNT, actual)
2312+
2313+ return wv
2314+ endif
2315+ else
2316+ // cache across experiments, so the stored wave modification is
2317+ // larger than the last labnotebook we cached, go for a full reset
23042318 endif
23052319 endif
23062320 else
0 commit comments