Search in sources :

Example 1 with Builder

use of org.apache.accumulo.core.client.summary.SummarizerConfiguration.Builder in project accumulo by apache.

the class SummarizerConfigurationUtil method getSummarizerConfigsFiltered.

private static List<SummarizerConfiguration> getSummarizerConfigsFiltered(SortedMap<String, String> sprops) {
    if (sprops.size() == 0) {
        return Collections.emptyList();
    }
    SummarizerConfiguration.Builder builder = null;
    List<SummarizerConfiguration> configs = new ArrayList<>();
    final int preLen = Property.TABLE_SUMMARIZER_PREFIX.getKey().length();
    for (Entry<String, String> entry : sprops.entrySet()) {
        String k = entry.getKey().substring(preLen);
        String[] tokens = k.split("\\.");
        String id = tokens[0];
        if (tokens.length == 1) {
            if (builder != null) {
                configs.add(builder.build());
            }
            builder = SummarizerConfiguration.builder(entry.getValue()).setPropertyId(id);
        } else if (tokens.length == 3 || tokens[1].equals("opt")) {
            builder.addOption(tokens[2], entry.getValue());
        } else {
            throw new IllegalArgumentException("Unable to parse summarizer property : " + k);
        }
    }
    configs.add(builder.build());
    return configs;
}
Also used : ArrayList(java.util.ArrayList) Builder(org.apache.accumulo.core.client.summary.SummarizerConfiguration.Builder) SummarizerConfiguration(org.apache.accumulo.core.client.summary.SummarizerConfiguration) TSummarizerConfiguration(org.apache.accumulo.core.data.thrift.TSummarizerConfiguration)

Example 2 with Builder

use of org.apache.accumulo.core.client.summary.SummarizerConfiguration.Builder in project accumulo by apache.

the class SummarizerConfigurationUtil method fromThrift.

public static SummarizerConfiguration fromThrift(TSummarizerConfiguration config) {
    Builder builder = SummarizerConfiguration.builder(config.getClassname());
    builder.setPropertyId(config.getConfigId());
    builder.addOptions(config.getOptions());
    return builder.build();
}
Also used : Builder(org.apache.accumulo.core.client.summary.SummarizerConfiguration.Builder)

Aggregations

Builder (org.apache.accumulo.core.client.summary.SummarizerConfiguration.Builder)2 ArrayList (java.util.ArrayList)1 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)1 TSummarizerConfiguration (org.apache.accumulo.core.data.thrift.TSummarizerConfiguration)1