@@ -171,9 +171,9 @@ private void runCaptureMode(QueryPlanSnapshotCliOptions options) throws Exceptio
171171
172172 private void runSingleQueryCapture (QueryPlanSnapshotCliOptions options ,
173173 QueryPlanSnapshotStoreSupport .StoreRuntime storeRuntime ) throws Exception {
174- for ( Theme theme : Theme . values ()) {
175- QueryPlanSnapshotStoreSupport . loadThemeData (storeRuntime . repository , theme );
176- }
174+ QueryPlanSnapshotStoreSupport . ThemeDataLoadStatus themeDataLoadStatus = QueryPlanSnapshotStoreSupport
175+ . ensureThemeDataLoaded (storeRuntime );
176+ printThemeDataLoadStatus ( themeDataLoadStatus );
177177 BenchmarkQuery benchmarkQuery = resolveBenchmarkQuery (options );
178178 String queryText = resolveQueryText (options , benchmarkQuery );
179179 String querySource = benchmarkQuery == null ? "direct" : "theme-index" ;
@@ -182,7 +182,8 @@ private void runSingleQueryCapture(QueryPlanSnapshotCliOptions options,
182182 ? options .outputDirectory
183183 : defaultOutputDirectory (options .store );
184184
185- FeatureFlagCollector featureFlags = createFeatureFlagCollector (options , storeRuntime , querySource );
185+ FeatureFlagCollector featureFlags = createFeatureFlagCollector (options , storeRuntime , querySource ,
186+ themeDataLoadStatus );
186187 QueryPlanCaptureContext context = createContext (options , benchmarkQuery , queryText , querySource , queryId ,
187188 outputDirectory , featureFlags );
188189 QueryPlanCapture capture = new QueryPlanCapture ();
@@ -218,15 +219,14 @@ private void runAllThemeQueriesCapture(QueryPlanSnapshotCliOptions options,
218219 Path outputDirectory = options .outputDirectory != null
219220 ? options .outputDirectory
220221 : defaultOutputDirectory (options .store );
222+ QueryPlanSnapshotStoreSupport .ThemeDataLoadStatus themeDataLoadStatus = QueryPlanSnapshotStoreSupport
223+ .ensureThemeDataLoaded (storeRuntime );
224+ printThemeDataLoadStatus (themeDataLoadStatus );
221225 QueryPlanCapture capture = new QueryPlanCapture ();
222226 Theme [] allThemes = Theme .values ();
223227 int total = allThemes .length * ThemeQueryCatalog .QUERY_COUNT ;
224228 int current = 0 ;
225229
226- for (Theme theme : allThemes ) {
227- QueryPlanSnapshotStoreSupport .loadThemeData (storeRuntime .repository , theme );
228- }
229-
230230 for (Theme theme : allThemes ) {
231231 for (int queryIndex = 0 ; queryIndex < ThemeQueryCatalog .QUERY_COUNT ; queryIndex ++) {
232232 current ++;
@@ -239,7 +239,7 @@ private void runAllThemeQueriesCapture(QueryPlanSnapshotCliOptions options,
239239 String queryId = defaultQueryId (perQueryOptions , benchmarkQuery );
240240
241241 FeatureFlagCollector featureFlags = createFeatureFlagCollector (perQueryOptions , storeRuntime ,
242- querySource );
242+ querySource , themeDataLoadStatus );
243243 QueryPlanCaptureContext context = createContext (perQueryOptions , benchmarkQuery , queryText , querySource ,
244244 queryId , outputDirectory , featureFlags );
245245
@@ -883,6 +883,19 @@ private void printThemeQueries(Theme theme) {
883883 }
884884 }
885885
886+ private void printThemeDataLoadStatus (QueryPlanSnapshotStoreSupport .ThemeDataLoadStatus themeDataLoadStatus ) {
887+ if (themeDataLoadStatus .lmdbFullyLoadedSizeBytes == null ) {
888+ return ;
889+ }
890+ if (themeDataLoadStatus .reusedLmdbData ) {
891+ output .println ("LMDB data already fully loaded (" + themeDataLoadStatus .lmdbFullyLoadedSizeBytes
892+ + " bytes). Skipping reload." );
893+ return ;
894+ }
895+ output .println ("LMDB data loaded. Recorded fully-loaded size=" + themeDataLoadStatus .lmdbFullyLoadedSizeBytes
896+ + " bytes." );
897+ }
898+
886899 private static QueryPlanCaptureContext createContext (QueryPlanSnapshotCliOptions options ,
887900 BenchmarkQuery benchmarkQuery ,
888901 String queryText , String querySource , String queryId , Path outputDirectory ,
@@ -916,7 +929,8 @@ private static QueryPlanCaptureContext createContext(QueryPlanSnapshotCliOptions
916929 }
917930
918931 private static FeatureFlagCollector createFeatureFlagCollector (QueryPlanSnapshotCliOptions options ,
919- QueryPlanSnapshotStoreSupport .StoreRuntime storeRuntime , String querySource ) {
932+ QueryPlanSnapshotStoreSupport .StoreRuntime storeRuntime , String querySource ,
933+ QueryPlanSnapshotStoreSupport .ThemeDataLoadStatus themeDataLoadStatus ) {
920934 FeatureFlagCollector featureFlags = new FeatureFlagCollector ()
921935 .addValue ("cli.store" , options .store .id )
922936 .addValue ("cli.theme" , options .theme .name ())
@@ -944,6 +958,11 @@ private static FeatureFlagCollector createFeatureFlagCollector(QueryPlanSnapshot
944958 .addReflectiveField ("lmdbConfig.autoGrow" , storeRuntime .lmdbStoreConfig , "autoGrow" )
945959 .addReflectiveGetter ("lmdbConfig.valueDbSize" , storeRuntime .lmdbStoreConfig , "getValueDBSize" )
946960 .addReflectiveGetter ("lmdbConfig.tripleDbSize" , storeRuntime .lmdbStoreConfig , "getTripleDBSize" );
961+ if (themeDataLoadStatus .lmdbFullyLoadedSizeBytes != null ) {
962+ featureFlags .addValue ("lmdbData.fullyLoadedSizeBytes" ,
963+ themeDataLoadStatus .lmdbFullyLoadedSizeBytes .toString ());
964+ }
965+ featureFlags .addValue ("lmdbData.reusedWithoutReload" , Boolean .toString (themeDataLoadStatus .reusedLmdbData ));
947966 }
948967
949968 QueryPlanCapture .registerConfiguredFeatureFlags (featureFlags );
0 commit comments