本文整理了Java中io.krakens.grok.api.Grok.getSaved_pattern()
方法的一些代码示例,展示了Grok.getSaved_pattern()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Grok.getSaved_pattern()
方法的具体详情如下:
包路径:io.krakens.grok.api.Grok
类名称:Grok
方法名:getSaved_pattern
暂无
代码示例来源:origin: io.krakens/java-grok
/**
* Sort by regex complexity.
*
* @param groks Map of the pattern name and grok instance
* @return the map sorted by grok pattern complexity
*/
private Map<String, Grok> sort(Map<String, Grok> groks) {
List<Grok> groky = new ArrayList<Grok>(groks.values());
Map<String, Grok> grokMap = new LinkedHashMap<String, Grok>();
Collections.sort(groky, new Comparator<Grok>() {
public int compare(Grok g1, Grok g2) {
return (this.complexity(g1.getNamedRegex()) < this.complexity(g2.getNamedRegex())) ? 1 : 0;
}
private int complexity(String expandedPattern) {
int score = 0;
score += expandedPattern.split("\\Q" + "|" + "\\E", -1).length - 1;
score += expandedPattern.length();
return score;
}
});
for (Grok grok : groky) {
grokMap.put(grok.getSaved_pattern(), grok);
}
return grokMap;
}
代码示例来源:origin: thekrakken/java-grok
/**
* Sort by regex complexity.
*
* @param groks Map of the pattern name and grok instance
* @return the map sorted by grok pattern complexity
*/
private Map<String, Grok> sort(Map<String, Grok> groks) {
List<Grok> groky = new ArrayList<Grok>(groks.values());
Map<String, Grok> grokMap = new LinkedHashMap<String, Grok>();
Collections.sort(groky, new Comparator<Grok>() {
public int compare(Grok g1, Grok g2) {
return (this.complexity(g1.getNamedRegex()) < this.complexity(g2.getNamedRegex())) ? 1 : 0;
}
private int complexity(String expandedPattern) {
int score = 0;
score += expandedPattern.split("\\Q" + "|" + "\\E", -1).length - 1;
score += expandedPattern.length();
return score;
}
});
for (Grok grok : groky) {
grokMap.put(grok.getSaved_pattern(), grok);
}
return grokMap;
}
内容来源于网络,如有侵权,请联系作者删除!