Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AC03A11831 for ; Fri, 1 Aug 2014 12:53:39 +0000 (UTC) Received: (qmail 84807 invoked by uid 500); 1 Aug 2014 12:53:39 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 84769 invoked by uid 500); 1 Aug 2014 12:53:39 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 84756 invoked by uid 99); 1 Aug 2014 12:53:39 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Aug 2014 12:53:39 +0000 Date: Fri, 1 Aug 2014 12:53:39 +0000 (UTC) From: =?utf-8?Q?Andr=C3=A9s_de_la_Pe=C3=B1a_=28JIRA=29?= To: commits@cassandra.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CASSANDRA-7575) Custom 2i validation MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CASSANDRA-7575?page=3Dcom.atlas= sian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D= 14082204#comment-14082204 ]=20 Andr=C3=A9s de la Pe=C3=B1a commented on CASSANDRA-7575: ---------------------------------------------- [~sbtourist], I suppose that the problem is due to trailing white spaces in= the patch file. I'm uploading a new version without trailing whitespaces. = These are the steps I've followed to apply the patch without warnings: {code} git clone https://github.com/apache/cassandra.git git checkout cassandra-2.1 git apply 2i_validation_v3.patch {code} Sorry for the inconvenience. > Custom 2i validation > -------------------- > > Key: CASSANDRA-7575 > URL: https://issues.apache.org/jira/browse/CASSANDRA-7575 > Project: Cassandra > Issue Type: Improvement > Components: API > Reporter: Andr=C3=A9s de la Pe=C3=B1a > Assignee: Andr=C3=A9s de la Pe=C3=B1a > Priority: Minor > Labels: 2i, cql3, secondaryIndex, secondary_index, select > Fix For: 2.1.1 > > Attachments: 2i_validation.patch, 2i_validation_v2.patch, 2i_vali= dation_v3.patch > > > There are several projects using custom secondary indexes as an extension= point to integrate C* with other systems such as Solr or Lucene. The usual= approach is to embed third party indexing queries in CQL clauses.=20 > For example, [DSE Search|http://www.datastax.com/what-we-offer/products-s= ervices/datastax-enterprise] embeds Solr syntax this way: > {code} > SELECT title FROM solr WHERE solr_query=3D'title:natio*'; > {code} > [Stratio platform|https://github.com/Stratio/stratio-cassandra] embeds cu= stom JSON syntax for searching in Lucene indexes: > {code} > SELECT * FROM tweets WHERE lucene=3D'{ > filter : { > type: "range", > field: "time", > lower: "2014/04/25", > upper: "2014/04/1" > }, > query : { > type: "phrase",=20 > field: "body",=20 > values: ["big", "data"] > }, > sort : {fields: [ {field:"time", reverse:true} ] } > }'; > {code} > Tuplejump [Stargate|http://tuplejump.github.io/stargate/] also uses the S= tratio's open source JSON syntax: > {code} > SELECT name,company FROM PERSON WHERE stargate =3D'{ > filter: { > type: "range", > field: "company", > lower: "a", > upper: "p" > }, > sort:{ > fields: [{field:"name",reverse:true}] > } > }'; > {code} > These syntaxes are validated by the corresponding 2i implementation. This= validation is done behind the StorageProxy command distribution. So, far a= s I know, there is no way to give rich feedback about syntax errors to CQL = users. > I'm uploading a patch with some changes trying to improve this. I propose= adding an empty validation method to SecondaryIndexSearcher that can be ov= erridden by custom 2i implementations: > {code} > public void validate(List clause) {} > {code} > And call it from SelectStatement#getRangeCommand: > {code} > ColumnFamilyStore cfs =3D Keyspace.open(keyspace()).getColumnFamilyStore(= columnFamily()); > for (SecondaryIndexSearcher searcher : cfs.indexManager.getIndexS= earchersForQuery(expressions)) > { > try > { > searcher.validate(expressions); > } > catch (RuntimeException e) > { > String exceptionMessage =3D e.getMessage(); > if (exceptionMessage !=3D null=20 > && !exceptionMessage.trim().isEmpty()) > throw new InvalidRequestException( > "Invalid index expression: " + e.getMessage()= ); > else > throw new InvalidRequestException( > "Invalid index expression"); > } > } > {code} > In this way C* allows custom 2i implementations to give feedback about sy= ntax errors. > We are currently using these changes in a fork with no problems. -- This message was sent by Atlassian JIRA (v6.2#6252)