Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5784B200D2B for ; Thu, 19 Oct 2017 02:45:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5445C160BEB; Thu, 19 Oct 2017 00:45:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9AF15160BEA for ; Thu, 19 Oct 2017 02:45:39 +0200 (CEST) Received: (qmail 48545 invoked by uid 500); 19 Oct 2017 00:45:33 -0000 Mailing-List: contact dev-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@drill.apache.org Delivered-To: mailing list dev@drill.apache.org Received: (qmail 48342 invoked by uid 99); 19 Oct 2017 00:45:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Oct 2017 00:45:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 68B02DFAB2; Thu, 19 Oct 2017 00:45:32 +0000 (UTC) From: paul-rogers To: dev@drill.apache.org Reply-To: dev@drill.apache.org References: In-Reply-To: Subject: [GitHub] drill pull request #1001: JIRA DRILL-5879: Like operator performance improve... Content-Type: text/plain Message-Id: <20171019004532.68B02DFAB2@git1-us-west.apache.org> Date: Thu, 19 Oct 2017 00:45:32 +0000 (UTC) archived-at: Thu, 19 Oct 2017 00:45:40 -0000 Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/1001#discussion_r145576718 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SqlPatternContainsMatcher.java --- @@ -17,36 +17,133 @@ */ package org.apache.drill.exec.expr.fn.impl; -public class SqlPatternContainsMatcher implements SqlPatternMatcher { +public final class SqlPatternContainsMatcher implements SqlPatternMatcher { final String patternString; CharSequence charSequenceWrapper; final int patternLength; public SqlPatternContainsMatcher(String patternString, CharSequence charSequenceWrapper) { - this.patternString = patternString; + this.patternString = patternString; this.charSequenceWrapper = charSequenceWrapper; - patternLength = patternString.length(); + patternLength = patternString.length(); } @Override - public int match() { - final int txtLength = charSequenceWrapper.length(); - int patternIndex = 0; - int txtIndex = 0; + public final int match() { + // The idea is to write loops with simple condition checks to allow the Java Hotspot vectorize + // the generate code. + if (patternLength == 1) { + return match_1(); + } else if (patternLength == 2) { + return match_2(); + } else if (patternLength == 3) { + return match_3(); + } else { + return match_N(); + } + } + + private final int match_1() { --- End diff -- See note about UTF-8. If we don't care about the match position (that is, we don't need `strpos()`, and all we care is whether it matches or not, then we can do the work on the undecoded UTF-8 bytes, saving a large amount of complexity. ---