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 266EE200BF7 for ; Mon, 9 Jan 2017 20:32:17 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 24FBE160B3E; Mon, 9 Jan 2017 19:32:17 +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 1DBD1160B2F for ; Mon, 9 Jan 2017 20:32:15 +0100 (CET) Received: (qmail 10032 invoked by uid 500); 9 Jan 2017 19:32:14 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 10013 invoked by uid 99); 9 Jan 2017 19:32:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jan 2017 19:32:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id EEE8AC6EED for ; Mon, 9 Jan 2017 19:32:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id tSzHTPjCiwIT for ; Mon, 9 Jan 2017 19:32:12 +0000 (UTC) Received: from mail-yw0-f170.google.com (mail-yw0-f170.google.com [209.85.161.170]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id A0CA260E83 for ; Mon, 9 Jan 2017 19:32:10 +0000 (UTC) Received: by mail-yw0-f170.google.com with SMTP id a10so434881972ywa.3 for ; Mon, 09 Jan 2017 11:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=dTXcnmdUT4U29WgN2huqJN46tOHQWTubq0NGtuZmaTA=; b=dTh/Qu5ZF5V4cTiswEPSi/P9eaEJKPGHxZ+rUEWQRfAhnfpV8Tb+eKafikpAtP1phz BTleMupKg66KGOdoYf8Jf6WhRWnYTwl9iHO0TDjaBF7VbWuL8vPzEXLevwInDem3kD5m lKjZaQLVdeDwRGxGXav5B5V+BAPnYFFTwd9XAppUnPFrJ3f2PWbKG+SJG8PlH2zMXhZP yFXeMIaZzliGgi8c9N5yA/HW+dkCUXcaylzetYVBisT4MAgnZcTOnvV9qw3Yu0nv6jA7 8AM+ZwCpF42i/DcQYAP8CAgCyHWd4AOf6m5Qrm3rHFZwy2d+bVqwaB+ULqJx7RkMYzfB crMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=dTXcnmdUT4U29WgN2huqJN46tOHQWTubq0NGtuZmaTA=; b=m5/b+AwHgSesBgn/mYlaC9E/jBbNfEMIzIwO/ZvCb5n8ANKS7arzl6gJs8ifF2bvcP 1PMBxTjVpwJh0s9OGagQg26cRzZIpTwHAqzNGTBsIPfYZPAa59Ktsc8tX/BMGPQegvzr WRacm4/MZOsNZfF8OavCYwOFilT8jNHIca3jo8ioOCA3rXzfRFVbjma14uLX7M/QGgmG Kn5UGE4hjlFcjauW9xi79Pq8MGw8a7EdTkegK3pB4eaFr3/sYm65lhe0gF6MyLr7s5UL MYvm5yScg74CIGzqAljMndRBpsylKkcShmRnD2XOGoaSMaoMdqD3V90TEEvlFVCvqEMC uyzw== X-Gm-Message-State: AIkVDXJCYnlgJU13dM6X8sH0KqF2OqW3BhEYvqeGLh1gZYt7SA0u4UBs/FhxTzcIuT8LY8aGJOP3mdO00z+9oA== X-Received: by 10.129.179.8 with SMTP id r8mr87486443ywh.156.1483990329909; Mon, 09 Jan 2017 11:32:09 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.244.79 with HTTP; Mon, 9 Jan 2017 11:32:09 -0800 (PST) In-Reply-To: References: <84D6C4B7-6FD6-4106-BE19-C2EFAA0C97E7@gmail.com> From: Ted Yu Date: Mon, 9 Jan 2017 11:32:09 -0800 Message-ID: Subject: Re: Is it possible to implement a NOT filter in Hbase? To: "user@hbase.apache.org" Content-Type: multipart/alternative; boundary=94eb2c14665a76ed930545ae6c0b archived-at: Mon, 09 Jan 2017 19:32:17 -0000 --94eb2c14665a76ed930545ae6c0b Content-Type: text/plain; charset=UTF-8 Your first approach is more general (beneficial to more users). However, looks like neither of us has the bandwidth to make it work. On Mon, Jan 9, 2017 at 11:30 AM, Carl M wrote: > Hi Ted, > > > Just to tell that unfortunately i wasn't seeing any > INCLUDE_AND_SEEK_NEXT_ROW nor INCLUDE_AND_NEXT_COL when debuging so adding > them were not going to make any difference. > > > Nevetherless i implement De Morgan's law as you second suggestion (it was > easier as I expected) and it's working, so thanks again for that! > > Best, > > ________________________________ > De: Ted Yu > Enviado: lunes, 02 de enero de 2017 11:36 p.m. > Para: user@hbase.apache.org > Asunto: Re: Is it possible to implement a NOT filter in Hbase? > > There is INCLUDE_AND_SEEK_NEXT_ROW which was not accounted for in the > nested if statement. > > Is it possible for you to come up with unit test showing what you observe ? > > If you don't have time, please consider using De Morgan's law. > > Cheers > > On Mon, Jan 2, 2017 at 5:19 PM, Carl M wrote: > > > Thanks for your response Ted. > > > > > > I did the change, unfortunately it doesn't make any difference. > > > > > > Best, > > > > ________________________________ > > De: Ted Yu > > Enviado: lunes, 02 de enero de 2017 07:58 p.m. > > Para: user@hbase.apache.org > > Asunto: Re: Is it possible to implement a NOT filter in Hbase? > > > > In the nested if statement, can you also handle NEXT_COL return code ? > > > > It should be translated to INCLUDE_AND_NEXT_COL > > > > Cheers > > > > > On Jan 2, 2017, at 1:54 PM, Carl M wrote: > > > > > > Sorry for not being clear enough. > > > > > > > > > Maybe i misunderstand your suggestion, but what I've done in implement > > my own filter, wrapping a FilterList > > > > > > public class NotFilterList extends Filter { > > > private FilterList filter; > > > > > > public NotFilterList(final List rowFilters) { > > > this.filter = new FilterList(rowFilters); > > > } > > > > > > public void reset() throws IOException { > > > this.filter.reset(); > > > } > > > > > > public boolean filterRowKey(byte[] rowKey, int offset, int length) > > throws IOException { > > > return this.filter.filterRowKey(rowKey, offset, length); > > > } > > > > > > public boolean filterAllRemaining() throws IOException { > > > return this.filter.filterAllRemaining(); > > > } > > > > > > public ReturnCode filterKeyValue(Cell v) throws IOException { > > > ReturnCode code = this.filter.filterKeyValue(v); > > > > > > if (code == ReturnCode.INCLUDE) > > > code = ReturnCode.SKIP; > > > else if (code == ReturnCode.INCLUDE_AND_NEXT_COL) > > > code = ReturnCode.NEXT_COL; > > > else if (code == ReturnCode.NEXT_ROW) > > > code = ReturnCode.INCLUDE_AND_NEXT_COL; > > > else if (code == ReturnCode.SKIP) { > > > code = ReturnCode.INCLUDE; > > > } > > > > > > return code; > > > } > > > > > > public Cell transformCell(Cell v) throws IOException { > > > return this.filter.transformCell(v); > > > } > > > > > > public KeyValue transform(KeyValue currentKV) throws IOException { > > > return this.filter.transform(currentKV); > > > } > > > > > > public void filterRowCells(List kvs) throws IOException { > > > this.filter.filterRowCells(kvs); > > > } > > > > > > public boolean hasFilterRow() { > > > return this.filter.hasFilterRow(); > > > } > > > > > > public boolean filterRow() throws IOException { > > > return this.filter.filterRow(); > > > } > > > > > > public KeyValue getNextKeyHint(KeyValue currentKV) throws > IOException > > { > > > return this.filter.getNextKeyHint(currentKV); > > > } > > > > > > public Cell getNextCellHint(Cell currentKV) throws IOException { > > > return this.filter.getNextCellHint(currentKV); > > > } > > > > > > public boolean isFamilyEssential(byte[] name) throws IOException { > > > return this.filter.isFamilyEssential(name); > > > } > > > > > > public byte[] toByteArray() throws IOException { > > > return this.filter.toByteArray(); > > > } > > > > > > public static NotFilterList parseFrom(final byte [] pbBytes) throws > > DeserializationException { > > > FilterList filterList = FilterList.parseFrom(pbBytes); > > > return new NotFilterList(filterList.getFilters()); > > > } > > > > > > boolean areSerializedFieldsEqual(Filter other) { > > > return this.filter.areSerializedFieldsEqual(other); > > > } > > > > > > } > > > > > > > > > What I mean is that filterKeyValue in the way i have it now, return > the > > right results but only the fields that were not originally skipped. > > > > > > > > > So for example, if i have two rows each one with two fields > > > > > > Row 1 > > > > > > Name: Bill > > > > > > Surname: Gates > > > > > > > > > Row 2 > > > > > > Name: Steve > > > > > > Surname: Jobs > > > > > > > > > And I want to query for Rows that doesn't have Name 'Bill' > > > > > > NOT (Name='Bill') > > > > > > > > > What I get as result from Hbase with this NotFilter is > > > > > > Row 2 > > > > > > Surname: Jobs > > > > > > > > > I suppose it's related to the cell "Name: Steve" skipped in the first > > place (before reversing the ReturnCode). > > > > > > > > > Best, > > > > > > > > > > > > ________________________________ > > > De: Ted Yu > > > Enviado: lunes, 02 de enero de 2017 06:31 p.m. > > > Para: user@hbase.apache.org > > > Asunto: Re: Is it possible to implement a NOT filter in Hbase? > > > > > > bq. the cell/value that was originally skip is not return > > > > > > Can you be a bit more specific (with a concrete example) : the skipped > > cell > > > would not be returned (as indicated by the ReturnCode). > > > > > > Thanks > > > > > >> On Mon, Jan 2, 2017 at 1:06 PM, Carl M > wrote: > > >> > > >> Hi Ted, > > >> > > >> > > >> I tried your suggestion, unfortunately it doesn't work as expected. I > > >> don't fully understand FilterList, but if a cell value was skip and I > > >> reverse the ReturnCode, i get the right row but the cell/value that > was > > >> originally skip is not return. > > >> > > >> I also tried reversing only filterRow() method of FilterList, but I > got > > >> the same behaviour (the original cell/value missing). > > >> > > >> > > >> Best, > > >> > > >> > > >> ________________________________ > > >> De: Ted Yu > > >> Enviado: viernes, 30 de diciembre de 2016 12:56 p.m. > > >> Para: user@hbase.apache.org > > >> Asunto: Re: Is it possible to implement a NOT filter in Hbase? > > >> > > >> I think the ReturnCode opposite INCLUDE_AND_NEXT_COL is NEXT_COL : > > you're > > >> not interested in any version of the current Cell. > > >> > > >> Cheers > > >> > > >>> On Fri, Dec 30, 2016 at 4:53 AM, Carl M > > wrote: > > >>> > > >>> Thanks Ted! Great idea replacing the value in filterKeyValue. > Although > > >> I'm > > >>> not quite sure looking at FilterList code if only INCLUDE/SKIP should > > be > > >>> replaced, and which should be the correct replacement for > > >>> INCLUDE_AND_NEXT_COL. What do you think? If not maybe i should try to > > >>> implement DeMorgan's law but I think it would be harder. > > >>> > > >>> > > >>> Best, > > >>> > > >>> ________________________________ > > >>> De: Ted Yu > > >>> Enviado: jueves, 29 de diciembre de 2016 06:10 p.m. > > >>> Para: user@hbase.apache.org > > >>> Asunto: Re: Is it possible to implement a NOT filter in Hbase? > > >>> > > >>> You can try negating the ReturnCode from filterKeyValue() (at the > root > > of > > >>> FilterList): > > >>> > > >>> abstract public ReturnCode filterKeyValue(final Cell v) throws > > >>> IOException; > > >>> > > >>> INCLUDE -> SKIP > > >>> > > >>> SKIP -> INCLUDE > > >>> > > >>> Alternatively, you can use De Morgan's law to transfer the condition: > > >>> > > >>> NOT (a = '123' AND b = '456') becomes > > >>> > > >>> (NOT a = '123') OR (b = '456') > > >>> > > >>>> On Thu, Dec 29, 2016 at 12:56 PM, Carl M > > >>> wrote: > > >>> > > >>>> Hi guys > > >>>> > > >>>> > > >>>> I'm trying to implement some kind of NOT filter in Hbase, but don't > > >> know > > >>>> if possible, I'm playing with FilterIfMissing and > FilterList.Operator > > >> but > > >>>> without luck. > > >>>> > > >>>> > > >>>> I know how to return rows not having a specific column, but I mean > > >>>> something like returning rows NOT fullfilling a condition, where > > >>> condition > > >>>> could be not only a SingleColumnValueFilter but a combined condition > > >> with > > >>>> FilterList. In SQL would be something like this for example > > >>>> > > >>>> > > >>>> SELECT * FROM table WHERE NOT (a = '123' AND b = '456'); > > >>>> > > >>>> > > >>>> Thanks in advance, > > >> > > > --94eb2c14665a76ed930545ae6c0b--