@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); term = options.get("term").getBytes(UTF_8); for (int i = 0; i < right.length; i++) { right[i] = -1; } for (int i = 0; i < term.length; i++) { right[term[i] & 0xff] = i; } }
@Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { ColumnAgeOffFilter copy = (ColumnAgeOffFilter) super.deepCopy(env); copy.currentTime = currentTime; copy.ttls = ttls; return copy; }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("reqvis"); io.setDescription("ReqVisFilter hides entries without a visibility label"); return io; } }
@Override public boolean validateOptions(Map<String,String> options) { if (!super.validateOptions(options)) return false; try { Long.parseLong(options.get(TTL)); } catch (Exception e) { throw new IllegalArgumentException("bad long " + TTL + ":" + options.get(TTL)); } return true; }
/** * Creates a {@link RegExFilter} setting to ignore the version row in a table. * @return the {@link RegExFilter} {@link IteratorSetting}. */ public static IteratorSetting getVersionRegExFilterSetting() { final IteratorSetting regex = new IteratorSetting(30, "version_regex", RegExFilter.class); RegExFilter.setRegexs(regex, "(.*)urn:(.*)#version[\u0000|\u0001](.*)", null, null, null, false); Filter.setNegate(regex, true); return regex; }
@Override public boolean validateOptions(Map<String,String> options) { if (!super.validateOptions(options)) return false; try { this.ttls = new TTLSet(options); } catch (Exception e) { throw new IllegalArgumentException("bad TTL options", e); } return true; }
/** * Creates a {@link RegExFilter} setting to ignore the copy tool run time row in a table. * @return the {@link RegExFilter} {@link IteratorSetting}. */ public static IteratorSetting getCopyToolRunTimeRegExFilterSetting() { final IteratorSetting regex = new IteratorSetting(31, COPY_TOOL_RUN_TIME_LOCAL_NAME + "_regex", RegExFilter.class); RegExFilter.setRegexs(regex, "(.*)urn:(.*)#" + COPY_TOOL_RUN_TIME_LOCAL_NAME + "[\u0000|\u0001](.*)", null, null, null, false); Filter.setNegate(regex, true); return regex; }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); cso = new CfCqSliceOpts(options); }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("colageoff"); io.setDescription("ColumnAgeOffFilter ages off columns at different rates" + " given a time to live in milliseconds for each column"); io.addUnnamedOption("<col fam>[:<col qual>] <Long> (escape non-alphanum chars using %<hex>)"); return io; }
@Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { TimestampFilter copy = (TimestampFilter) super.deepCopy(env); copy.hasStart = hasStart; copy.start = start; copy.startInclusive = startInclusive; copy.hasEnd = hasEnd; copy.end = end; copy.endInclusive = endInclusive; return copy; }
@Override public boolean validateOptions(Map<String,String> options) { if (!super.validateOptions(options)) return false; try { if (options.containsKey(ROW_REGEX)) Pattern.compile(options.get(ROW_REGEX)).matcher(""); if (options.containsKey(COLF_REGEX)) Pattern.compile(options.get(COLF_REGEX)).matcher(""); if (options.containsKey(COLQ_REGEX)) Pattern.compile(options.get(COLQ_REGEX)).matcher(""); if (options.containsKey(VALUE_REGEX)) Pattern.compile(options.get(VALUE_REGEX)).matcher(""); } catch (Exception e) { throw new IllegalArgumentException("bad regex", e); } if (options.containsKey(ENCODING)) { try { String encodingOpt = options.get(ENCODING); this.encoding = Charset.forName(encodingOpt.isEmpty() ? ENCODING_DEFAULT : encodingOpt); } catch (UnsupportedCharsetException e) { throw new IllegalArgumentException("invalid encoding " + ENCODING + ":" + this.encoding, e); } } return true; }
/** * Creates a {@link RegExFilter} setting to ignore the copy tool time setting row in a table. * @return the {@link RegExFilter} {@link IteratorSetting}. */ public static IteratorSetting getCopyToolTimeOffsetRegExFilterSetting() { final IteratorSetting regex = new IteratorSetting(33, COPY_TOOL_TIME_OFFSET_LOCAL_NAME + "_regex", RegExFilter.class); RegExFilter.setRegexs(regex, "(.*)urn:(.*)#" + COPY_TOOL_TIME_OFFSET_LOCAL_NAME + "[\u0000|\u0001](.*)", null, null, null, false); Filter.setNegate(regex, true); return regex; }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { super.init(source, options, env); this.ttls = new TTLSet(options); currentTime = System.currentTimeMillis(); }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.addNamedOption(TTL, "time to live (milliseconds)"); io.addNamedOption(CURRENT_TIME, "if set, use the given value as the" + " absolute time in milliseconds as the current time of day"); io.setName("ageoff"); io.setDescription( "AgeOffFilter removes entries with timestamps more than <ttl> milliseconds old"); return io; }
@Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { AgeOffFilter copy = (AgeOffFilter) super.deepCopy(env); copy.currentTime = currentTime; copy.threshold = threshold; return copy; }
@Override public boolean validateOptions(Map<String,String> options) { if (!super.validateOptions(options)) return false; boolean hasStart = false;
/** * Creates a {@link RegExFilter} setting to ignore the version row in a table. * @return the {@link RegExFilter} {@link IteratorSetting}. */ public static IteratorSetting getVersionRegExFilterSetting() { final IteratorSetting regex = new IteratorSetting(30, "version_regex", RegExFilter.class); RegExFilter.setRegexs(regex, "(.*)urn:(.*)#version[\u0000|\u0001](.*)", null, null, null, false); Filter.setNegate(regex, true); return regex; }
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException { if (options == null) throw new IllegalArgumentException(TTL + " must be set for AgeOffFilter"); String ttl = options.get(TTL); if (ttl == null) throw new IllegalArgumentException(TTL + " must be set for AgeOffFilter"); super.init(source, options, env); threshold = Long.parseLong(ttl); String time = options.get(CURRENT_TIME); if (time != null) currentTime = Long.parseLong(time); else currentTime = System.currentTimeMillis(); // add sanity checks for threshold and currentTime? }
@Override public IteratorOptions describeOptions() { IteratorOptions io = super.describeOptions(); io.setName("visibilityFilter"); io.setDescription("The VisibilityFilter allows you to filter for key/value" + " pairs by a set of authorizations or filter invalid labels from corrupt" + " files."); io.addNamedOption(FILTER_INVALID_ONLY, "if 'true', the iterator is instructed to ignore the authorizations and" + " only filter invalid visibility labels (default: false)"); io.addNamedOption(AUTHS, "the serialized set of authorizations to filter against (default: empty" + " string, accepts only entries visible by all)"); return io; }
@Override public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) { ColumnSliceFilter result = (ColumnSliceFilter) super.deepCopy(env); result.startBound = startBound; result.startInclusive = startInclusive; result.endBound = endBound; result.endInclusive = endInclusive; return result; } }