public void writeConfig(SummarizerConfiguration conf, DataOutputStream dos) throws IOException { // save class (and its config) used to generate summaries dos.writeUTF(conf.getClassName()); dos.writeUTF(conf.getPropertyId()); WritableUtils.writeVInt(dos, conf.getOptions().size()); for (Entry<String,String> entry : conf.getOptions().entrySet()) { dos.writeUTF(entry.getKey()); dos.writeUTF(entry.getValue()); } }
public static Map<String,String> toTablePropertiesMap(List<SummarizerConfiguration> summarizers) { if (summarizers.size() == 0) { return Collections.emptyMap(); } Map<String,String> props = new HashMap<>(); for (SummarizerConfiguration sconf : summarizers) { String cid = sconf.getPropertyId(); String prefix = Property.TABLE_SUMMARIZER_PREFIX.getKey() + cid; if (props.containsKey(prefix)) { throw new IllegalArgumentException("Duplicate summarizer config id : " + cid); } props.put(prefix, sconf.getClassName()); Set<Entry<String,String>> es = sconf.getOptions().entrySet(); StringBuilder sb = new StringBuilder(prefix + ".opt."); int resetLen = sb.length(); for (Entry<String,String> entry : es) { sb.append(entry.getKey()); props.put(sb.toString(), entry.getValue()); sb.setLength(resetLen); } } return props; }
@Override public void addSummarizers(String tableName, SummarizerConfiguration... newConfigs) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { HashSet<SummarizerConfiguration> currentConfigs = new HashSet<>( SummarizerConfiguration.fromTableProperties(getProperties(tableName))); HashSet<SummarizerConfiguration> newConfigSet = new HashSet<>(Arrays.asList(newConfigs)); newConfigSet.removeIf(currentConfigs::contains); Set<String> newIds = newConfigSet.stream().map(SummarizerConfiguration::getPropertyId) .collect(toSet()); for (SummarizerConfiguration csc : currentConfigs) { if (newIds.contains(csc.getPropertyId())) { throw new IllegalArgumentException("Summarizer property id is in use by " + csc); } } Set<Entry<String,String>> es = SummarizerConfiguration.toTableProperties(newConfigSet) .entrySet(); for (Entry<String,String> entry : es) { setProperty(tableName, entry.getKey(), entry.getValue()); } }
public static TSummarizerConfiguration toThrift(SummarizerConfiguration sc) { return new TSummarizerConfiguration(sc.getClassName(), sc.getOptions(), sc.getPropertyId()); }