org.apache.accumulo.core.iterators.Filter类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中org.apache.accumulo.core.iterators.Filter类的一些代码示例,展示了Filter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Filter类的具体详情如下:
包路径:org.apache.accumulo.core.iterators.Filter
类名称:Filter

Filter介绍

[英]A SortedKeyValueIterator that filters entries from its source iterator. Subclasses must implement an accept method: public boolean accept(Key k, Value v); Key/Value pairs for which the accept method returns true are said to match the filter. By default, this class iterates over entries that match its filter. This iterator takes an optional "negate" boolean parameter that defaults to false. If negate is set to true, this class instead omits entries that match its filter, thus iterating over entries that do not match its filter.
[中]一种SortedKeyValueIterator,用于从源迭代器中筛选条目。子类必须实现一个accept方法:公共布尔accept(键k,值v);accept方法返回true的键/值对称为与筛选器匹配。默认情况下,该类迭代匹配其筛选器的条目。此迭代器接受一个可选的“否定”布尔参数,该参数默认为false。如果将negate设置为true,则该类将忽略与其筛选器匹配的条目,从而对与其筛选器不匹配的条目进行迭代。

代码示例

代码示例来源:origin: apache/accumulo

@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;
 }
}

代码示例来源:origin: apache/accumulo

@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
 ColumnAgeOffFilter copy = (ColumnAgeOffFilter) super.deepCopy(env);
 copy.currentTime = currentTime;
 copy.ttls = ttls;
 return copy;
}

代码示例来源:origin: apache/accumulo

@Override
 public IteratorOptions describeOptions() {
  IteratorOptions io = super.describeOptions();
  io.setName("reqvis");
  io.setDescription("ReqVisFilter hides entries without a visibility label");
  return io;
 }
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: org.apache.rya/rya.export.accumulo

/**
 * 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;
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: apache/incubator-rya

/**
 * 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;
}

代码示例来源:origin: apache/accumulo

@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);
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: apache/incubator-rya

/**
 * 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;
}

代码示例来源:origin: apache/accumulo

@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();
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: apache/accumulo

@Override
public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
 AgeOffFilter copy = (AgeOffFilter) super.deepCopy(env);
 copy.currentTime = currentTime;
 copy.threshold = threshold;
 return copy;
}

代码示例来源:origin: apache/accumulo

@Override
public boolean validateOptions(Map<String,String> options) {
 if (!super.validateOptions(options))
  return false;
 boolean hasStart = false;

代码示例来源:origin: apache/incubator-rya

/**
 * 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;
}

代码示例来源:origin: apache/accumulo

@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?
}

代码示例来源:origin: apache/accumulo

@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;
}

代码示例来源:origin: apache/accumulo

@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;
 }
}

相关文章