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 1CEC1200C6E for ; Mon, 8 May 2017 18:07:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1B8C1160BA5; Mon, 8 May 2017 16:07:45 +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 3B50E160B99 for ; Mon, 8 May 2017 18:07:44 +0200 (CEST) Received: (qmail 33696 invoked by uid 500); 8 May 2017 16:07:43 -0000 Mailing-List: contact dev-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list dev@polygene.apache.org Received: (qmail 33684 invoked by uid 99); 8 May 2017 16:07:43 -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; Mon, 08 May 2017 16:07:43 +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 B58921806A4 for ; Mon, 8 May 2017 16:07:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-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, HEADER_FROM_DIFFERENT_DOMAINS=0.001, 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: spamd3-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 (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ROJ0A0D1dCdv for ; Mon, 8 May 2017 16:07:40 +0000 (UTC) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 307335FAF9 for ; Mon, 8 May 2017 16:07:40 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id 142so70403596wma.1 for ; Mon, 08 May 2017 09:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=fxDUEcOkQRK6/utA+pMzG3CTYwMiVKeu17gKg/O3QLk=; b=ELbigUhbP6vPVYSZfxFmPwoSv8GMSICISGGc0KXAPvbRiPFiWXlE6fxN2lzrVO6t++ X5OcvdHWPK7io29GeeL/SkbLeka4YNt+t3vfyoR6k2vWcF9SSiW2mnc80pSvlis4ISPa QpdgboiFhrV7H3xeowLP1kZRfXqT8uNHhSH/n3Uj/VPAgnaHJyKHN9oc3YaYAgXZVWI9 vnetbHaeR4uoEVm1c6PZ0TmDQMafRybO2tWUvSpzg/lhhwOu33aBn58oD7eJLU84f2HO YDe7s3Y+wp+KzAK4//g/Uf3YpJkNGEzCG7xIaNZwXNH5ShfCyGZwVY49zvjqu0eUy/ae Tajg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=fxDUEcOkQRK6/utA+pMzG3CTYwMiVKeu17gKg/O3QLk=; b=NbQyB3WttaNf4nE+p7jZU9+vgNhhHfvw/yvB+D4M1Jhy5IcCjn6m4eZl+6bn5KFyes B9kschuBVuvpLd28+SfCXcL2Fy+Jj+QdtppEByNhgCIswCR6N0kooZ6EVQ6HtqWAjJEV fwdybRVp9Cv0In24MDdksdGwFiDAQ2Bnt0pUWYpLVUp8txP9qZU+Rw65N2cDFxE5T4PD hCMftvZ1Eqr/BG1LQRuryyOiXUXnpVQZvtY5K3vv2KCeKGB+zbpaByJ415zZKVygjMv0 rO91teX/MVTNfIJSoo/wLYU4eKhZqf/3+bGpTNE0zh/1udRFdGetoSEBYISp2E5y8Beq ExtA== X-Gm-Message-State: AODbwcCPY3AAeKwqZ/prZAfOadpXrRUosRtPcHkJvQOHzTNk+DKd0Flv cVMGY/mNMYo9zEenWr4TRZ5EvqgNzw== X-Received: by 10.25.219.156 with SMTP id t28mr10984066lfi.42.1494259659054; Mon, 08 May 2017 09:07:39 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.46.83.28 with HTTP; Mon, 8 May 2017 09:07:18 -0700 (PDT) In-Reply-To: <2b7672ee-ab14-4a4e-5779-e9f0d3c10ff1@gmail.com> References: <59104647.1010206@apache.org> <2b7672ee-ab14-4a4e-5779-e9f0d3c10ff1@gmail.com> From: Niclas Hedhman Date: Tue, 9 May 2017 00:07:18 +0800 X-Google-Sender-Auth: 9eW5-qml7JwCCjIeS14BjdWjTcI Message-ID: Subject: Re: SPI issue? To: dev@polygene.apache.org Content-Type: multipart/alternative; boundary=94eb2c184bfa2e23c8054f0570d6 archived-at: Mon, 08 May 2017 16:07:45 -0000 --94eb2c184bfa2e23c8054f0570d6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hey Kent, been a while.... yeah, why not? I will try to make one sweep across all API, SPI and Bootstrap interfaces to ensure, a. Consistent ordering, b. lambdas at the end of parameter list. Cheers Niclas On Mon, May 8, 2017 at 11:26 PM, Kent S=C3=B8lvsten wrote: > A small nitty-gritty thought ... > > is it worthwhile swapping the arguments of #entityStateOf, such that all > methods have an entityReference as 1st argument? (another way of > creating a bit more consistency) > > /Kent > > public interface EntityStoreUnitOfWork > { > EntityState newEntityState( EntityReference anIdentity, > EntityDescriptor entityDescriptor ) > throws EntityStoreException; > > EntityState entityStateOf( ModuleDescriptor module, > EntityReference anIdentity ) > throws EntityStoreException, EntityNotFoundException; > > String versionOf( EntityReference anIdentity ) throws > > EntityStoreException; > > > } > > Den 08-05-2017 kl. 16:34 skrev Niclas Hedhman: > > Yeah, you kind of got to the same conclusion as I did... i.e. not sure > what > > to do. If we add the EntityDescriptor, there should be some semantics o= n > > what it means, not arbitrarily from ES to ES. > > > > I think we just keep it as it is. > > > > On Mon, May 8, 2017 at 6:19 PM, Paul Merlin > wrote: > > > >> Hey Niclas, > >> > >> Niclas Hedhman a =C3=A9crit : > >>> Peddling with this JOOQ ES (or whatever it ends up being called), I > found > >>> an inconsistency in the EntityStore SPI. > >>> > >>> > >>> public interface EntityStoreUnitOfWork > >>> { > >>> EntityState newEntityState( EntityReference anIdentity, > >>> EntityDescriptor entityDescriptor ) > >>> throws EntityStoreException; > >>> > >>> EntityState entityStateOf( ModuleDescriptor module, > >>> EntityReference anIdentity ) > >>> throws EntityStoreException, EntityNotFoundException; > >>> > >>> String versionOf( EntityReference anIdentity ) throws > >> EntityStoreException; > >>> } > >>> > >>> > >>> It is not consistent to pass the EntityDescriptor in newEntityState() > but > >>> not in entityStateOf(). In the latter case, it is expected that the > >>> EntityStore have saved away the type, and able to look it up from the > >>> Module, when the caller already have the EntityDescriptor readily > >> available. > >>> Can anyone think of a case where it is not better to pass the > >>> EntityDescriptor from the caller? > >>> > >>> It might be related to looking up via a super type, and if then savin= g, > >>> then there is a chance that the "old fields" are no long present. And > to > >>> avoid that, push the whole "what is the lowest subclass of this > identity" > >>> to the entitystore. > >>> > >>> I think my question is, what is the proper semantics around entity > >>> subclasses? Is it really the "saved type" that is the deserialized > type, > >> or > >>> is it the "requested type" that should be the deserialized type? > >>> > >>> I am not sure either way, and would like to hear more arguments one w= ay > >> or > >>> the other. > >> Yeah, agreed that it doesn't feel consistent at first sight. > >> > >> BUT, > >> When creating an entity we don't have anything else than its > >> EntityDescriptor. > >> When saving the entity its `type` is set to the main type of its > >> EntityDescriptor. > >> Then, when fetching an entity the ES will load the whole state and use > >> the stored `type` to lookup the corresponding EntityDescriptor, and fa= il > >> with a NoSuchEntityTypeException if not found. > >> > >> As you wrote, this means that you can fetch an Entity using a super > >> type, the loaded state will however contain all the data described by > >> the EntityDescriptor used on creation. API-wise you'll only be able to > >> mutate the entity using the "requested type" but under the hood, the > >> whole state is kept. > >> > >> I think it makes sense. Especially when thinking about key/value backe= d > >> EntityStores where the whole state is a "blob". > >> > >> If we change that SPI so that `entityStateOf(..)` takes an > >> EntityDescriptor then it would mean that EntityStores could have the > >> opportunity to only load a "view" of the entity and have to handle > >> supplementary fields non destructively. As I see it adds a feature to > >> the SPI and a new responsibility for EntityStores. > >> > >> Key/Value stores could then still do as they do today, possibly > >> validating that the saved EntityDescriptor types include all of the > >> requested EntityDescriptor types. Or some sort of validation. It's an > >> extra responsibility for the EntityStores. > >> > >> More evolved EntityStores could then only load "views" of entities, no= t > >> the whole saved state. But they also should be able to update state no= n > >> destructively. > >> > >> I'd say it's a tradeoff between capabilities and implicit > >> responsibilities for implementations. I'm not against adding the featu= re > >> to the SPI but then we should at least properly document it so > >> asumptions are crystal clear. > >> > >> Does that help? > >> > >> Cheers > >> > >> /Paul > >> > >> > >> > > > > --=20 Niclas Hedhman, Software Developer http://polygene.apache.org - New Energy for Java --94eb2c184bfa2e23c8054f0570d6--