@@ -98,30 +98,40 @@ final class ReconMutil {
9898 * @param input names of input files to read
9999 */
100100 void launch (int [] threads , String output , String ... input ) {
101+
101102 reset ();
103+
104+ // spawn all the threads:
102105 readerThread = CompletableFuture .runAsync (() -> { read (threads [0 ], input ); });
103106 writerThread = CompletableFuture .runAsync (() -> { write (output ); });
104107 for (int i =0 ; i <threads [0 ]; i ++) {
105108 final int j = i ;
106109 decoThreads .offer (CompletableFuture .runAsync (() -> { decode (j ); }));
107110 procThreads .offer (CompletableFuture .runAsync (() -> { process (j ); }));
108111 }
112+
113+ // wait for the writer to be done:
109114 while (!writerThread .isDone ()) {
110115 sleep (100 );
116+
117+ // cleanup completed parallel threads:
111118 for (CompletableFuture f : decoThreads )
112119 if (f .isDone ()) decoThreads .remove (f );
113120 for (CompletableFuture f : procThreads )
114121 if (f .isDone ()) procThreads .remove (f );
122+
123+ // perform scaling test:
115124 if (threads .length > 1 && rethreadThread == null && writeEvents > 100 ) {
116125 rethreadThread = CompletableFuture .runAsync (() -> { rethread (BENCH_SECONDS ,threads ); });
117126 rethreadThread .join ();
118127 reset ();
119128 }
120129 }
121- if (!parser .getOption ("-P" ).isDefault ()) {
122- PostProcessor pp = new PostProcessor (parser .getInputList (), false , false );
123- pp .processFile (output , output );
124- }
130+
131+ //if (!parser.getOption("-P").isDefault()) {
132+ // PostProcessor pp = new PostProcessor(parser.getInputList(), false, false);
133+ // pp.processFile(output, output);
134+ //}
125135 }
126136
127137 /**
@@ -339,23 +349,25 @@ HipoWriterSorted open(String filename, ClaraYaml yaml) {
339349 HipoWriterSorted w = new HipoWriterSorted ();
340350 w .setCompressionType (2 );
341351 String d = ClasUtilsFile .getResourceDir ("CLAS12DIR" , "etc/bankdefs/hipo4" );
342- if (yaml .getSchemaDirectory () != null ) d = yaml .getSchemaDirectory ();
352+ if (yaml != null && yaml .getSchemaDirectory () != null ) d = yaml .getSchemaDirectory ();
343353 if (!parser .getOption ("-S" ).isDefault ()) d = parser .getOption ("-S" ).stringValue ();
344354 SchemaFactory s = new SchemaFactory ();
345355 s .initFromDirectory (d );
346- JSONObject json = yaml .filter ("writer" );
347- if (json .has ("wildcard" )) {
348- SchemaFactory s2 = s .reduce (json .getString ("wildcard" ));
349- w .getSchemaFactory ().copy (s2 );
350- }
351- else w .getSchemaFactory ().copy (s );
352- schemaBankList = new ArrayList <>();
353- if (json .has ("wildcard" )) {
354- if (json .optBoolean ("schema_filter" ,true )) {
355- int schemaSize = w .getSchemaFactory ().getSchemaList ().size ();
356- for (int i =0 ; i <schemaSize ; i ++) {
357- Bank dataBank = new Bank (w .getSchemaFactory ().getSchemaList ().get (i ));
358- schemaBankList .add (dataBank );
356+ if (yaml != null ) {
357+ JSONObject json = yaml .filter ("writer" );
358+ if (json .has ("wildcard" )) {
359+ SchemaFactory s2 = s .reduce (json .getString ("wildcard" ));
360+ w .getSchemaFactory ().copy (s2 );
361+ }
362+ else w .getSchemaFactory ().copy (s );
363+ schemaBankList = new ArrayList <>();
364+ if (json .has ("wildcard" )) {
365+ if (json .optBoolean ("schema_filter" ,true )) {
366+ int schemaSize = w .getSchemaFactory ().getSchemaList ().size ();
367+ for (int i =0 ; i <schemaSize ; i ++) {
368+ Bank dataBank = new Bank (w .getSchemaFactory ().getSchemaList ().get (i ));
369+ schemaBankList .add (dataBank );
370+ }
359371 }
360372 }
361373 }
@@ -406,7 +418,7 @@ void close() {
406418 }
407419
408420 /**
409- * Forcefully shutdown all threads, close files, and reset queuess and counters.
421+ * Forcefully shutdown all threads, close files, and reset queues and counters.
410422 */
411423 void reset () {
412424 for (CompletableFuture f : procThreads ) f .cancel (true );
0 commit comments