Return-Path: X-Original-To: apmail-ignite-dev-archive@minotaur.apache.org Delivered-To: apmail-ignite-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4C67F1746B for ; Fri, 20 Mar 2015 21:46:51 +0000 (UTC) Received: (qmail 64022 invoked by uid 500); 20 Mar 2015 21:40:05 -0000 Delivered-To: apmail-ignite-dev-archive@ignite.apache.org Received: (qmail 63982 invoked by uid 500); 20 Mar 2015 21:40:05 -0000 Mailing-List: contact dev-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list dev@ignite.incubator.apache.org Received: (qmail 63971 invoked by uid 99); 20 Mar 2015 21:40:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Mar 2015 21:40:05 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of vozerov@gridgain.com designates 209.85.216.173 as permitted sender) Received: from [209.85.216.173] (HELO mail-qc0-f173.google.com) (209.85.216.173) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Mar 2015 21:39:39 +0000 Received: by qcbkw5 with SMTP id kw5so104871288qcb.2 for ; Fri, 20 Mar 2015 14:38:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=ORFC7kGKjSkse4ay3U8fMkFoxRFqCAkuqFW5ZnVB7do=; b=BqiyR0Wg6VyxyRlI0ymNAsINU9zofhLd1yHOQuHP64Ham6qKt2BDeAFtxCpiGs7mJp pe2Ere5t38McVHMVGPRIPtbUDsyodFnky/iXA+1PSsfuolmOg0q4kkpe1SyUZsMB0F4p qvw9rl0OCoAJdx0XfWymBp95Iy+ih294j52Rmt2U0+o3cafVyLTpPsfw1N2BN1lRIzmB EqBlYR3ymvBLKZiWDaY9P0jsg31y7810oim/OqF5Aw3nb+7CagSc7i6EwYMORp0CI8hl OsHuaKZXvCrWWq2PBAz1cuQqii5rfIaQ1gpAMjD7aGLcqV7cZ+jJnBLqCuMOD8srqSqi IbLg== X-Gm-Message-State: ALoCoQla15odmASTbCQXeQUYxwL9g1J5i4eM/Ub+JRRbG+OjaR6tBZgiYJoBoWS0EJxf04mxbXpt MIME-Version: 1.0 X-Received: by 10.229.214.199 with SMTP id hb7mr87175675qcb.12.1426887531853; Fri, 20 Mar 2015 14:38:51 -0700 (PDT) Received: by 10.140.28.102 with HTTP; Fri, 20 Mar 2015 14:38:51 -0700 (PDT) Date: Sat, 21 Mar 2015 00:38:51 +0300 Message-ID: Subject: Queries API considerations. From: Vladimir Ozerov To: dev@ignite.incubator.apache.org Content-Type: multipart/alternative; boundary=001a1132f7ea78966a0511bf24a6 X-Virus-Checked: Checked by ClamAV on apache.org --001a1132f7ea78966a0511bf24a6 Content-Type: text/plain; charset=UTF-8 Guys, The more I look into our queries API, the more questions appears. 1) User can either iterate over result set, or get all returned values. In the latter case query is automatically closed after "getAll()" finished. But this is not the case for iterator. At least this is not mentioned is JavaDocs. For this reason instead of doing: for (CacheEntry entry : cache.query(...)) { } user will have to do the following: try (Query qry = cache.query(...)) { for (CacheEntry entry : qry) { } } Looks like we have to close query whenever end of results stream is reached, irrespective of whether this was getAll(), or iterator end. Thoughts? 2) Initial query inside contnuous query appears to be fundamentally wrong concept. Continuous query is about events. Regular query is about iteration over existing enries. Why do we mix them? They have nothing in common. If user want to run "initial query" ... just let him do that by hand after continuous query is started. Furthermore, IgniteCache.query() accepts SQL and TEXT queries. ContinuousQuery.initialQuery accepts SQL, TEXT and FIELDS queries, WTF? How are we going to explain user this semantics? Furthermore, from running regular queries user knows that when QueryCursor.getAll() is called, query is closed. But will continuous query be closed when the user call getAll() on initial query result? No, it won't. Another inconsistency. Furthermore, when a QueryCursor returned from IgniteCache.continuousQuery() method is closed, it closes both continuous and initial queries. But what if I want to release initial query resources, but leave continuous query running? It is impossible at the moment - either keep open both, or close both. I propose to remove initial query together with a cursor returned from IgniteCache.continuousQuery(). It has no value. Instead, continuousQuery() method should return a kind of "handle" which can be closed (e.g. extends AutoCloseable), nothing more. 3) ContinuousQuery extends Query. Query have only one property - page size. Continuous query does not use this. How come we expose not used property to the user? ContinuousQuery should not extend Query as it has nothing common with it except of a word "query" in name. Also, as we distinguish entries queries (SQL, TEXT) and fields queries, probably it does not make sense to make them share the same Query class. What if we define the following hierarchy: - Query, SqlQuery extends Query, TextQuery extends Query; - SqlFieldsQuery - ContinuousQuery It will map perfectly to existing methods: - query(Query) - fieldsQuery(SqlFIeldsQuery) - continuousQuery(ContinuousQuery). 4) Finally, instead of having paired methods "queryXXX" and "localQueryXXX", we can add "local" property to query classes and remove "localQueryXXX" methods from API. Thoughts? --001a1132f7ea78966a0511bf24a6--