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 8F4D0200C7C for ; Mon, 5 Jun 2017 22:28:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8DD88160BD4; Mon, 5 Jun 2017 20:28:36 +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 AC040160BBB for ; Mon, 5 Jun 2017 22:28:35 +0200 (CEST) Received: (qmail 51705 invoked by uid 500); 5 Jun 2017 20:28:34 -0000 Mailing-List: contact dev-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list dev@geode.apache.org Received: (qmail 51693 invoked by uid 99); 5 Jun 2017 20:28:34 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jun 2017 20:28:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 25E751AFC1A for ; Mon, 5 Jun 2017 20:28:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.48 X-Spam-Level: ** X-Spam-Status: No, score=2.48 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-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] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=pivotal-io.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id maf6c12EAzkA for ; Mon, 5 Jun 2017 20:28:31 +0000 (UTC) Received: from mail-qt0-f176.google.com (mail-qt0-f176.google.com [209.85.216.176]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id E28B35F5B9 for ; Mon, 5 Jun 2017 20:28:30 +0000 (UTC) Received: by mail-qt0-f176.google.com with SMTP id w1so102895291qtg.2 for ; Mon, 05 Jun 2017 13:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pivotal-io.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=93n9Ki6nwbwO7vSc0bdVqtunkyOeNlUiZ/EVyoz5t1Y=; b=yzSA2vQU5Hi/D9JQ69RG26iY6ZeA5p5gQt84BieOBpjcQ7BZysmCNDfEgynjmft7ON pExwrZdtiL6dpohE4jCObq+cHrh44UanFtzhwDpMsJo/UYjRhIfL4e2geWbaQSn7oB4a x/+OsB36j1vj8d99uIq+RRJg9okmbp5V6XW4E6C1yF8x4dJmbz5b0Up0foqtIqqWgeBu hS6RDswW/o/Pd0Ge7uCCXCgcw/dy2i3nCTU/WlXrRGBp1Bi9QMgeMTz+1nyUF0tJUZkc aPU+IhFNwQt9rFoP25w2zhXWdLSokwRz2FURgDzNmk5L/HYT1RWKMinpagxlG5n5GF3q e8Fw== 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=93n9Ki6nwbwO7vSc0bdVqtunkyOeNlUiZ/EVyoz5t1Y=; b=ihWzOy2jKW+qi2UzyjLArmySFKPNsbdivFARwAdsGgs3Z0451A0j4yHihImcOfy+Ab xPV8HoY6E8gWaPLYIFTxSt0r7ttoMTVcXacFYBcB1ybSfN7kGDcK8hoJDhvGmllyFMtO pchjbu+CaA9TAp536GAai1rlPR1UbG/EJfyBGQ4klH5hQGVA3BRlE+aqdRoIyT25MX+S 3p0BxX19zkc7QUKclaUtYdHtp1/r/P0KtZmREb1SrDv4cGspp0kuYtz0rQLdPtrYGS+X WG+8UBHtZWDTbqlqJvtNkEA4CGK99YIOciigLIyqBGtiIIuPtuuLeCsETEdLIkHd+Wmw heOQ== X-Gm-Message-State: AKS2vOxeCGhFSehJsnPdQD3y6E3jjhjxLqDEZnc23P+zxEVCec03l6ek CDzZA3emjSQj3hNv5yN1ncki98ewatRp X-Received: by 10.237.57.99 with SMTP id l90mr14165137qte.152.1496694509594; Mon, 05 Jun 2017 13:28:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.41.67 with HTTP; Mon, 5 Jun 2017 13:28:27 -0700 (PDT) Received: by 10.237.41.67 with HTTP; Mon, 5 Jun 2017 13:28:27 -0700 (PDT) In-Reply-To: References: <3777c347-f832-5422-a7a2-a279e63fefed@pivotal.io> From: Michael Stolz Date: Mon, 5 Jun 2017 16:28:27 -0400 Message-ID: Subject: Re: [DISCUSS] easy string based partitioning To: dev@geode.apache.org Content-Type: multipart/alternative; boundary="001a1140bf2c95144305513c5845" archived-at: Mon, 05 Jun 2017 20:28:36 -0000 --001a1140bf2c95144305513c5845 Content-Type: text/plain; charset="UTF-8" Yep that will work. -- Mike Stolz Principal Engineer - Gemfire Product Manager Mobile: 631-835-4771 On Jun 5, 2017 12:06 PM, "Darrel Schneider" wrote: > I pictured the top level parent region (your customer region) as not having > the StringPrefixPartitionResolver. Instead it would just use string keys > that have no prefix and use the default resolver. > It would be each co-located child region (your order region) that would > have the StringPrefixPartitionResolver and would format its keys to be > "parentKey:childKey". Does that make sense? Will it work? > > > On Mon, Jun 5, 2017 at 10:06 AM, Barry Oglesby > wrote: > > > The top-level region may not have / need a delimiter. If you have a > > customer region and a colocated orders region, the customer region key > > could be the customerId, and the orders region key could be the > > customerId:orderId. The colocation would be on the customerId. In the > > customer region, it doesn't need a delimiter. Is it ok that this idea > would > > require one? Maybe the top-level region shouldn't require a delimiter? If > > the StringPrefixPartitionResolver is using key.split(":"), the customer > > region would return the entire key. > > > > > > Thanks, > > Barry Oglesby > > > > > > On Mon, Jun 5, 2017 at 8:46 AM, Jens Deppe wrote: > > > > > I like the idea of keeping the configuration 'conventional' and thus > not > > > requiring any server configuration. As soon as you need to define a > regex > > > on the server you might as well be writing PartitionResolver code. > > > > > > As an aside I also think that using regexes to parse keys would also > > > introduce a measurable performance hit. > > > > > > --Jens > > > > > > On Mon, Jun 5, 2017 at 8:21 AM, Udo Kohlmeyer > > > wrote: > > > > > > > Whilst I like the idea to make something (and yes, > > > > DelimitedStringPartitionResolver is the simplest), I feel that we > > might > > > > be able to do one better. > > > > > > > > */Could/* one possibly have an /*SPEL*/ < > https://docs.spring.io/spring > > > > -framework/docs/current/spring-framework-reference/ > > > html/expressions.html>-based > > > > PartitionResolver for this? At least this way, we don't have to rely > on > > > > delimiters or a strong knowledge of REGEX. > > > > > > > > IMO, this would provide the greatest bang for buck implementation. > > > > > > > > --Udo > > > > > > > > > > > > > > > > > > > > On 6/2/17 19:15, Jacob Barrett wrote: > > > > > > > >> If you implement as regular expression the user doesn't have to > > reformat > > > >> their key to a specific format (akin to making them implement a > > class). > > > I > > > >> would concat the matching groups for generate the routing key. > > > >> > > > >> Consider RegEx: .*\bcorrelation=(\d+).*\bmaybe-something-else=(\w) > > > >> With Keys: > > > >> A: my,key;with:any-chars;unique=12345;correlation=678/and,maybe > > > >> -something-else=a > > > >> B: my,key;unique=876324;correlation=678;and,maybe- > > something-else=a,foo > > > >> C: somthing;different=988975;correlation=678;then,maybe- > > > something-else=ba > > > >> > > > >> Keys A and B would have routing key '678a'. Key C would have routing > > key > > > >> '678b'. > > > >> > > > >> -Jake > > > >> > > > >> > > > >> > > > >> Consider > > > >> > > > >> On Fri, Jun 2, 2017 at 4:02 PM Darrel Schneider < > > dschneider@pivotal.io> > > > >> wrote: > > > >> > > > >> Geode partitioned regions usually partition the data based on the > > key's > > > >>> hashcode. > > > >>> You can do your own partitioning by implementing the > > PartitionResolver > > > >>> interface and configuring it on the partitioned region. > > > >>> > > > >>> In some use cases needing to deploy your class that implements > > > >>> PartitionResolver can be problematic so we would like to find a way > > to > > > >>> offer partitioning based on a portion of the key (instead of the > > > default > > > >>> which uses the entire key) that does not require you to implement > > your > > > >>> own > > > >>> PartitionResolver and does not require you to deploy your own code > to > > > do > > > >>> the custom partitioning. > > > >>> > > > >>> Another group of users that do not want to implement > > PartitionResolver > > > >>> are > > > >>> non-java clients. So the solution is required to be usable by > > non-java > > > >>> geode clients without needing to reimplement the client to support > a > > > new > > > >>> feature. > > > >>> > > > >>> Another constraint on the solution is for it to be both easy to use > > and > > > >>> easy to implement. > > > >>> > > > >>> The proposed solution is to provide a class named: > > > >>> org.apache.geode.cache.StringPrefixPartitionResolver > > > >>> This class will implement PartitionResolver and have a default > > > >>> constructor. > > > >>> To use it you need to configure a partitioned region's > > > PartitionResolver > > > >>> using the already existing mechanism for this (api, gfsh, or xml). > > > >>> The StringPrefixPartitionResolver will require all keys on its > region > > > to > > > >>> be > > > >>> of type String. > > > >>> It also requires that the string key contains at least one ':' > > > character. > > > >>> The substring of the key that precedes the first ':' is the prefix > > that > > > >>> will be returned from "getRoutingObject". > > > >>> > > > >>> An example of doing this in gfsh is: > > > >>> create region --name=r1 --type=PARTITION > > > >>> --partition-resolver=org.apache.geode.cache.StringPrefixPart > > > >>> itionResolver > > > >>> > > > >>> Note that attempting to use a key that is not a String or does not > > > >>> contain > > > >>> a ':' will throw an exception. This is to help developers realize > > they > > > >>> made > > > >>> a mistake. > > > >>> > > > >>> Note that the delimiter is always a ':'. It would be easy to made > the > > > >>> delimiter configurable when using apis or xml but currently gfsh > does > > > not > > > >>> provide a way to pass parameters to the --partition-resolver create > > > >>> region > > > >>> option. > > > >>> > > > >>> The only public api change this proposal makes is the new > > > >>> StringPrefixPartitionResolver class. > > > >>> > > > >>> > > > > > > > > > > --001a1140bf2c95144305513c5845--