public static Predicate<String> getLikePredicate(LikeFilter filter){ if(filter == null || !filter.hasPattern()) { return ALWAYS_TRUE; } if (SQL_LIKE_ANY_STRING_PATTERN.equals(filter.getPattern())) { return ALWAYS_TRUE; } final String patternString = RegexpUtil.sqlToRegexLike(filter.getPattern(), filter.hasEscape() ? filter.getEscape().charAt(0) : (char) 0); final Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE); return input -> pattern.matcher(input).matches(); }
/** * Helper method to create {@link SearchQuery} from {@link LikeFilter}. * @param fieldName Name of the field on which the like expression is applied. * @param likeFilter * @return {@link SearchQuery} for given arguments. Null if the <code>likeFilter</code> is null. */ public static SearchQuery createLikeFunctionExprNode(String fieldName, LikeFilter likeFilter) { if (likeFilter == null || !likeFilter.hasPattern()) { return null; } String pattern = likeFilter.getPattern(); if (SQL_LIKE_ANY_STRING_PATTERN.equals(pattern)) { return null; } String escape = likeFilter.hasEscape() ? likeFilter.getEscape() : null; return ExpressionConverter.getLikeQuery(fieldName, pattern, escape, true); }
public Builder mergeFrom(com.dremio.exec.proto.UserProtos.LikeFilter other) { if (other == com.dremio.exec.proto.UserProtos.LikeFilter.getDefaultInstance()) return this; if (other.hasPattern()) { bitField0_ |= 0x00000001; pattern_ = other.pattern_; onChanged(); } if (other.hasEscape()) { bitField0_ |= 0x00000002; escape_ = other.escape_; onChanged(); } this.mergeUnknownFields(other.getUnknownFields()); return this; }
public void writeTo(io.protostuff.Output output, com.dremio.exec.proto.UserProtos.LikeFilter message) throws java.io.IOException { if(message.hasPattern()) output.writeString(1, message.getPattern(), false); if(message.hasEscape()) output.writeString(2, message.getEscape(), false); } public boolean isInitialized(com.dremio.exec.proto.UserProtos.LikeFilter message)