@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("max"); io.setDescription("MaxCombiner interprets Values as Longs and finds their" + " maximum. A variety of encodings (variable length, fixed length, or" + " string) are available"); return io; } }
public static List<Long> arrayAdd(List<Long> la, List<Long> lb) { if (la.size() > lb.size()) { for (int i = 0; i < lb.size(); i++) { la.set(i, LongCombiner.safeAdd(la.get(i), lb.get(i))); } return la; } else { for (int i = 0; i < la.size(); i++) { lb.set(i, LongCombiner.safeAdd(lb.get(i), la.get(i))); } return lb; } }
private void setEncoder(Map<String,String> options) { String type = options.get(TYPE); if (type == null) throw new IllegalArgumentException("no type specified"); if (type.startsWith(CLASS_PREFIX)) { setEncoder(type.substring(CLASS_PREFIX.length())); testEncoder(42L); } else { switch (Type.valueOf(type)) { case VARLEN: setEncoder(VAR_LEN_ENCODER); return; case FIXEDLEN: setEncoder(FIXED_LEN_ENCODER); return; case STRING: setEncoder(STRING_ENCODER); return; default: throw new IllegalArgumentException(); } } }
LongCombiner.setEncodingType(summer, LongCombiner.Type.STRING); LongCombiner.setCombineAllColumns(summer, true); c.tableOperations().attachIterator(t2, summer);
/** Put a SummingIterator on all columns. */ public static void assignDegreeAccumulator(String tableName, Connector c) { IteratorSetting cfg = null; try { cfg = c.tableOperations().getIteratorSetting(tableName, ITER_SUMALL_NAME, IteratorUtil.IteratorScope.scan); } catch (AccumuloSecurityException | AccumuloException ignored) { } catch (TableNotFoundException e) { log.warn(tableName + " does not exist", e); } if (cfg != null) { log.info("table "+tableName+": iterator "+ITER_SUMALL_NAME+" already exists with priority "+cfg.getPriority()+" and options: "+cfg.getOptions()); } else { cfg = new IteratorSetting(2, ITER_SUMALL_NAME, SummingCombiner.class); //Combiner.setColumns(cfg, columnList); Combiner.setCombineAllColumns(cfg, true); LongCombiner.setEncodingType(cfg, LongCombiner.Type.STRING); try { //c.tableOperations().checkIteratorConflicts(tableName, cfg, EnumSet.allOf(IteratorUtil.IteratorScope.class)); c.tableOperations().attachIterator(tableName, cfg); } catch (AccumuloSecurityException | AccumuloException e) { log.warn("error trying to add "+ITER_SUMALL_NAME+" iterator to " + tableName, e); } catch (TableNotFoundException e) { log.warn(tableName + " does not exist", e); } } }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); setEncoder(options); }
LongCombiner.setEncodingType(itSet, LongCombiner.Type.STRING);
@Override public boolean validateOptions(Map<String,String> options) { if (!super.validateOptions(options)) return false; try { setEncoder(options); } catch (Exception e) { throw new IllegalArgumentException("bad encoder option", e); } return true; }
private void setEncoder(Map<String,String> options) { String type = options.get(TYPE); if (type == null) throw new IllegalArgumentException("no type specified"); if (type.startsWith(CLASS_PREFIX)) { setEncoder(type.substring(CLASS_PREFIX.length())); testEncoder(42l); } else { switch (Type.valueOf(type)) { case VARLEN: setEncoder(VAR_LEN_ENCODER); return; case FIXEDLEN: setEncoder(FIXED_LEN_ENCODER); return; case STRING: setEncoder(STRING_ENCODER); return; default: throw new IllegalArgumentException(); } } }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("sum"); io.setDescription("SummingCombiner interprets Values as Longs and adds them" + " together. A variety of encodings (variable length, fixed length, or" + " string) are available"); return io; } }
@Override public boolean validateOptions(Map<String,String> options) { if (super.validateOptions(options) == false) return false; try { setEncoder(options); } catch (Exception e) { throw new IllegalArgumentException("bad encoder option", e); } return true; }
public static List<Long> arrayAdd(List<Long> la, List<Long> lb) { if (la.size() > lb.size()) { for (int i = 0; i < lb.size(); i++) { la.set(i, LongCombiner.safeAdd(la.get(i), lb.get(i))); } return la; } else { for (int i = 0; i < la.size(); i++) { lb.set(i, LongCombiner.safeAdd(lb.get(i), la.get(i))); } return lb; } }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("min"); io.setDescription("MinCombiner interprets Values as Longs and finds their" + " minimum. A variety of encodings (variable length, fixed length, or" + " string) are available"); return io; } }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); setEncoder(options); }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("min"); io.setDescription("MinCombiner interprets Values as Longs and finds their" + " minimum. A variety of encodings (variable length, fixed length, or" + " string) are available"); return io; } }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("max"); io.setDescription("MaxCombiner interprets Values as Longs and finds their" + " maximum. A variety of encodings (variable length, fixed length, or" + " string) are available"); return io; } }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("sum"); io.setDescription("SummingCombiner interprets Values as Longs and adds them" + " together. A variety of encodings (variable length, fixed length, or" + " string) are available"); return io; } }