@Override
    public byte[] toByteArray() {
      ComparatorProtos.RegexStringComparator.Builder builder =
        ComparatorProtos.RegexStringComparator.newBuilder();
      builder.setPattern(regex);
      builder.setPatternFlags(joniToPatternFlags(pattern.getOptions()));
      builder.setCharset(encoding.getCharsetName());
      builder.setEngine(EngineType.JONI.name());
      return builder.build().toByteArray();
    }
Implementation of the Engine interface using Jruby's joni regex engine.
<p>
This engine operates on byte arrays directly so is expected to be more GC friendly, and
reportedly is twice as fast as Java's Pattern engine.
<p>
NOTE: Only the {@link Pattern} flags CASE_INSENSITIVE, DOTALL, and MULTILINE are supported.
hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RegexStringComparator.java