public Summarizer getSummarizer(SummarizerConfiguration conf) { try { return newSummarizer(conf.getClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException e) { throw new RuntimeException(e); } } }
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()); } }
@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); } }
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; }
/** * @param summary * a summary * @param checkType * If true will try to ensure the classname from * {@link Summary#getSummarizerConfiguration()} is an instance of * {@link CountingSummarizer}. However this check can only succeed if the class is on the * classpath. For cases where the summary data needs to be used and the class is not on * the classpath, set this to false. */ public CounterSummary(Summary summary, boolean checkType) { if (checkType) { String className = summary.getSummarizerConfiguration().getClassName(); try { getClass().getClassLoader().loadClass(className).asSubclass(CountingSummarizer.class); } catch (ClassCastException e) { throw new IllegalArgumentException( className + " is not an instance of " + CountingSummarizer.class.getSimpleName(), e); } catch (ClassNotFoundException e) { throw new IllegalArgumentException( "Unable to check summary was produced by a " + CountingSummarizer.class.getSimpleName(), e); } } this.stats = summary.getStatistics(); }
public Gatherer(ClientContext context, TSummaryRequest request, AccumuloConfiguration tableConfig, CryptoService cryptoService) { this.ctx = context; this.tableId = Table.ID.of(request.tableId); this.startRow = ByteBufferUtil.toText(request.bounds.startRow); this.endRow = ByteBufferUtil.toText(request.bounds.endRow); this.clipRange = new Range(startRow, false, endRow, true); this.summaries = request.getSummarizers().stream().map(SummarizerConfigurationUtil::fromThrift) .collect(Collectors.toSet()); this.request = request; this.cryptoService = cryptoService; this.summarizerPattern = request.getSummarizerPattern(); if (summarizerPattern != null) { Pattern pattern = Pattern.compile(summarizerPattern); // The way conf is converted to string below is documented in the API, so consider this when // making changes! summarySelector = conf -> pattern .matcher(conf.getClassName() + " " + new TreeMap<>(conf.getOptions())).matches(); if (!summaries.isEmpty()) { summarySelector = summarySelector.or(conf -> summaries.contains(conf)); } } else if (!summaries.isEmpty()) { summarySelector = conf -> summaries.contains(conf); } else { summarySelector = conf -> true; } this.factory = new SummarizerFactory(tableConfig); }
public static TSummarizerConfiguration toThrift(SummarizerConfiguration sc) { return new TSummarizerConfiguration(sc.getClassName(), sc.getOptions(), sc.getPropertyId()); }
super.gatherInformation(request); Predicate<SummarizerConfiguration> summarizerPredicate = conf -> conf.getClassName() .equals(DeletesSummarizer.class.getName()) && conf.getOptions().isEmpty();