/** * Decodes table properties with the prefix {@code table.summarizer} into * {@link SummarizerConfiguration} objects. Table properties with prefixes other than * {@code table.summarizer} are ignored. */ public static Collection<SummarizerConfiguration> fromTableProperties(Map<String,String> props) { return fromTableProperties(props.entrySet()); }
@Override public List<SummarizerConfiguration> listSummarizers(String tableName) throws AccumuloException, TableNotFoundException { return new ArrayList<>(SummarizerConfiguration.fromTableProperties(getProperties(tableName))); }
@Override public boolean shouldCompact(Entry<FileRef,DataFileValue> file, MajorCompactionRequest request) { if (!gatherCalled) { Collection<SummarizerConfiguration> configs = SummarizerConfiguration .fromTableProperties(request.getTableProperties()); return configs.size() > 0; } if (!summaryConfigured) { return false; } // Its possible the set of files could change between gather and now. So this will default to // compacting any files that are unknown. return !okFiles.contains(file.getKey()); } }
@Override public boolean shouldCompact(MajorCompactionRequest request) { Collection<SummarizerConfiguration> configuredSummarizers = SummarizerConfiguration .fromTableProperties(request.getTableProperties()); // check if delete summarizer is configured for table if (configuredSummarizers.stream().map(sc -> sc.getClassName()) .anyMatch(cn -> cn.equals(DeletesSummarizer.class.getName()))) { // This is called before gatherInformation, so need to always queue for compaction until // context // can be gathered. Also its not safe to request summary // information here as its a blocking operation. Blocking operations are not allowed in // shouldCompact. return true; } else { return super.shouldCompact(request); } }
@Override public void removeSummarizers(String tableName, Predicate<SummarizerConfiguration> predicate) throws AccumuloException, TableNotFoundException, AccumuloSecurityException { Collection<SummarizerConfiguration> summarizerConfigs = SummarizerConfiguration .fromTableProperties(getProperties(tableName)); for (SummarizerConfiguration sc : summarizerConfigs) { if (predicate.test(sc)) { Set<String> ks = sc.toTableProperties().keySet(); for (String key : ks) { removeProperty(tableName, key); } } } }
@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()); } }
gatherCalled = true; Collection<SummarizerConfiguration> configs = SummarizerConfiguration .fromTableProperties(request.getTableProperties()); if (configs.size() == 0) { summaryConfigured = false;