@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; }
public TTLSet(Map<String,String> objectStrings) { super(); for (Entry<String,String> entry : objectStrings.entrySet()) { String column = entry.getKey(); String ttl = entry.getValue().trim(); // skip the negate option, it will cause an exception to be thrown if (column.equals(NEGATE) && (ttl.isEmpty() || ttl.equalsIgnoreCase("true") || ttl.equalsIgnoreCase("false"))) { continue; } Long l = Long.parseLong(ttl); Pair<Text,Text> colPair = ColumnSet.decodeColumns(column); if (colPair.getSecond() == null) { addObject(colPair.getFirst(), l); } else { addObject(colPair.getFirst(), colPair.getSecond(), l); } } } }
public TTLSet(Map<String,String> objectStrings) { super(); for (Entry<String,String> entry : objectStrings.entrySet()) { String column = entry.getKey(); String ttl = entry.getValue().trim(); // skip the negate option, it will cause an exception to be thrown if (column.equals(NEGATE) && (ttl.isEmpty() || ttl.equalsIgnoreCase("true") || ttl.equalsIgnoreCase("false"))) { continue; } Long l = Long.parseLong(ttl); Pair<Text,Text> colPair = ColumnSet.decodeColumns(column); if (colPair.getSecond() == null) { addObject(colPair.getFirst(), l); } else { addObject(colPair.getFirst(), colPair.getSecond(), l); } } } }
@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 boolean validateOptions(Map<String,String> options) { if (super.validateOptions(options) == false) return false; try { this.ttls = new TTLSet(options); } catch (Exception e) { throw new IllegalArgumentException("bad TTL options", e); } return true; }
@Override public boolean accept(Key k, Value v) { Long threshold = ttls.getObject(k); if (threshold == null) return true; if (currentTime - k.getTimestamp() > threshold) return false; return true; }
@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 boolean accept(Key k, Value v) { Long threshold = ttls.getObject(k); if (threshold == null) return true; return currentTime - k.getTimestamp() <= threshold; }