Skip to content

Commit 6ee14a6

Browse files
authored
new wildcard feature from Gagik (#321)
1 parent 1c0eea7 commit 6ee14a6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

common-tools/clara-io/src/main/java/org/jlab/io/clara/HipoToHipoWriter.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.jlab.clara.std.services.EventWriterException;
1212
import org.jlab.jnp.hipo4.data.Bank;
1313
import org.jlab.jnp.hipo4.data.Event;
14+
import org.jlab.jnp.hipo4.data.SchemaFactory;
1415
import org.jlab.jnp.hipo4.io.HipoWriter;
1516
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
1617
import org.jlab.jnp.utils.file.FileUtils;
@@ -25,6 +26,8 @@ public class HipoToHipoWriter extends AbstractEventWriterService<HipoWriterSorte
2526
private static final String CONF_COMPRESSION = "compression";
2627
private static final String CONF_SCHEMA_DIR = "schema_dir";
2728
private static final String CONF_SCHEMA_FILTER = "schema_filter";
29+
private static final String CONF_SCHEMA_WILDCARD = "wildcard";
30+
2831
private final List<Bank> schemaBankList = new ArrayList<Bank>();
2932
private final StringSubstitutor envSubstitutor = new StringSubstitutor(System.getenv());
3033

@@ -56,9 +59,19 @@ private void configure(HipoWriterSorted writer, JSONObject opts) {
5659
schemaDir = envSubstitutor.replace(schemaDir);
5760
System.out.printf("%s service: schema directory = %s%n", getName(), schemaDir);
5861
}
59-
writer.getSchemaFactory().initFromDirectory(schemaDir);
6062

61-
if (opts.has(CONF_SCHEMA_DIR)) {
63+
SchemaFactory factory = new SchemaFactory();
64+
factory.initFromDirectory(schemaDir);
65+
66+
if(opts.has(CONF_SCHEMA_WILDCARD)==true){
67+
String wildcard = opts.getString("wildcard");
68+
SchemaFactory f2 = factory.reduce(wildcard);
69+
writer.getSchemaFactory().copy(f2);
70+
} else {
71+
writer.getSchemaFactory().copy(factory);
72+
}
73+
74+
if (opts.has(CONF_SCHEMA_DIR)==true||opts.has(CONF_SCHEMA_WILDCARD)==true) {
6275
boolean useFilter = opts.optBoolean(CONF_SCHEMA_FILTER, true);
6376
System.out.printf("%s service: schema filter = %b%n", getName(), useFilter);
6477
if(useFilter==true){
@@ -69,6 +82,10 @@ private void configure(HipoWriterSorted writer, JSONObject opts) {
6982
}
7083
}
7184
}
85+
86+
System.out.printf("SERVICE WRITER :: [filter] %s\n",opts.has(HipoToHipoWriter.CONF_SCHEMA_FILTER));
87+
System.out.printf("SERVICE WRITER :: [dir] %s\n",opts.has(HipoToHipoWriter.CONF_SCHEMA_DIR));
88+
System.out.printf("SERVICE WRITER :: [wildcard] %s\n",opts.has(HipoToHipoWriter.CONF_SCHEMA_WILDCARD));
7289
}
7390

7491
private Method getSchemaFilterSetter() throws NoSuchMethodException, SecurityException {

0 commit comments

Comments
 (0)