List of usage examples for org.apache.lucene.util.automaton ByteRunAutomaton run
public boolean run(byte[] s, int offset, int length)
From source file:io.crate.expression.operator.RegexpMatchOperator.java
License:Apache License
@Override public Boolean evaluate(Input<BytesRef>... args) { assert args.length == 2 : "invalid number of arguments"; BytesRef source = args[0].value();//from w w w. ja v a 2 s . c o m if (source == null) { return null; } BytesRef pattern = args[1].value(); if (pattern == null) { return null; } String sPattern = pattern.utf8ToString(); if (isPcrePattern(sPattern)) { return source.utf8ToString().matches(sPattern); } else { RegExp regexp = new RegExp(sPattern); ByteRunAutomaton regexpRunAutomaton = new ByteRunAutomaton(regexp.toAutomaton()); return regexpRunAutomaton.run(source.bytes, source.offset, source.length); } }
From source file:io.crate.operation.operator.RegexpMatchOperator.java
License:Apache License
@Override public Boolean evaluate(Input<BytesRef>... args) { assert args.length == 2 : "invalid number of arguments"; BytesRef source = args[0].value();/*from w w w.ja v a2 s .co m*/ if (source == null) { return null; } BytesRef pattern = args[1].value(); if (pattern == null) { return null; } if (isPcrePattern(pattern)) { return source.utf8ToString().matches(pattern.utf8ToString()); } else { RegExp regexp = new RegExp(pattern.utf8ToString()); ByteRunAutomaton regexpRunAutomaton = new ByteRunAutomaton(regexp.toAutomaton()); return regexpRunAutomaton.run(source.bytes, source.offset, source.length); } }