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 86597200D33 for ; Wed, 25 Oct 2017 00:04:05 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 849691609C8; Tue, 24 Oct 2017 22:04:05 +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 D381B160BF2 for ; Wed, 25 Oct 2017 00:04:04 +0200 (CEST) Received: (qmail 3566 invoked by uid 500); 24 Oct 2017 22:04:04 -0000 Mailing-List: contact issues-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 issues@drill.apache.org Received: (qmail 3557 invoked by uid 99); 24 Oct 2017 22:04:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Oct 2017 22:04:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 31320180582 for ; Tue, 24 Oct 2017 22:04:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.001 X-Spam-Level: X-Spam-Status: No, score=-100.001 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id zV8IUvbs0-Ns for ; Tue, 24 Oct 2017 22:04:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 46D6B5FBEA for ; Tue, 24 Oct 2017 22:04:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 7AA0AE0D4E for ; Tue, 24 Oct 2017 22:04:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 3270A212F5 for ; Tue, 24 Oct 2017 22:04:00 +0000 (UTC) Date: Tue, 24 Oct 2017 22:04:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@drill.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DRILL-5879) Optimize "Like" operator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 24 Oct 2017 22:04:05 -0000 [ https://issues.apache.org/jira/browse/DRILL-5879?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16217782#comment-16217782 ] ASF GitHub Bot commented on DRILL-5879: --------------------------------------- Github user sachouche commented on a diff in the pull request: https://github.com/apache/drill/pull/1001#discussion_r146705325 --- Diff: exec/java-exec/src/main/codegen/templates/CastFunctionsSrcVarLenTargetVarLen.java --- @@ -73,6 +73,9 @@ public void eval() { out.start = in.start; if (charCount <= length.value || length.value == 0 ) { out.end = in.end; + if (charCount == (out.end - out.start)) { + out.asciiMode = org.apache.drill.exec.expr.holders.VarCharHolder.CHAR_MODE_IS_ASCII; // we can conclude this string is ASCII --- End diff -- - As previously stated (when responding to Paul'd comment), the expression framework is able to use the same VarCharHolder input variable when it is shared amongst multiple expressions - If the original column was of type var-binary, then the expression framework will include a cast to var-char - The cast logic will also compute the string length - Using this information to deduce whether the string is pure ASCII or not - UTF-8 encoding uses 1 byte for ASCII and 2, 3, or 4 for other character sets - If the encoded length and character length are equal, then this means this is an ASCII string > Optimize "Like" operator > ------------------------ > > Key: DRILL-5879 > URL: https://issues.apache.org/jira/browse/DRILL-5879 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Relational Operators > Environment: * > Reporter: salim achouche > Assignee: salim achouche > Priority: Minor > Fix For: 1.12.0 > > > Query: select from where colA like '%a%' or colA like '%xyz%'; > Improvement Opportunities > # Avoid isAscii computation (full access of the input string) since we're dealing with the same column twice > # Optimize the "contains" for-loop > Implementation Details > 1) > * Added a new integer variable "asciiMode" to the VarCharHolder class > * The default value is -1 which indicates this info is not known > * Otherwise this value will be set to either 1 or 0 based on the string being in ASCII mode or Unicode > * The execution plan already shares the same VarCharHolder instance for all evaluations of the same column value > * The asciiMode will be correctly set during the first LIKE evaluation and will be reused across other LIKE evaluations > 2) > * The "Contains" LIKE operation is quite expensive as the code needs to access the input string to perform character based comparisons > * Created 4 versions of the same for-loop to a) make the loop simpler to optimize (Vectorization) and b) minimize comparisons > Benchmarks > * Lineitem table 100GB > * Query: select l_returnflag, count(*) from dfs.`` where l_comment not like '%a%' or l_comment like '%the%' group by l_returnflag > * Before changes: 33sec > * After changes : 27sec -- This message was sent by Atlassian JIRA (v6.4.14#64029)