You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Nikolay Izhikov (JIRA)" <ji...@apache.org> on 2017/07/10 14:42:00 UTC

[jira] [Comment Edited] (IGNITE-425) Introduce transformers for continuous queries

    [ https://issues.apache.org/jira/browse/IGNITE-425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16080420#comment-16080420 ] 

Nikolay Izhikov edited comment on IGNITE-425 at 7/10/17 2:41 PM:
-----------------------------------------------------------------

# Other parts of Ignite \[1] use IgniteClosure \[2] as transformer. I think we can reuse interface. Thoughts?
# Do we need to provide backward compatibility for a ContinuousQuery as it a public API?
We will broke all client code that using ContinuousQuery if simply add one more generic parameter(ContinuousQuery<K, V, T>)
# Which way of implementation is preferable?
## First way to implement feature is create GenericContinuousQuery. 
Internal code will use new GenericContinuousQuery but all client code that using ContinuousQuery still be valid(see first code example)
## Second way ContinuousQueryWIthTransformer extends ContinuousQuery.
Internal code has to check which instance it has when execute some logic(see second code example)

{code:java}
public final class GenericContinuousQuery<K, V, T> extends Query<Cacne.Entry<K, V>> {
    /* new method to add */
    public GenericContinuousQuery<K, V, T> setRemoteTransformerFactory(Factory<? extends ContinuousQueryTransformer<K, V, T>> factory) { ..}

    //other new methods
}

public final class ContinuousQuery<K, V> extends GenericContinuousQuery<K, V, V> {
    public ContinuousQuery() {
        setRemoteTransformerFactory(new Factory<IgniteClosure<V, V>> {
            public IgniteClosure<V, V> create() {
                return new IgniteClosure<V, V> {
                    public V apply(V e) { return e; }
                }
            }
        });
    }
}
{code}

{code:java}
public final class ContinuousQueryWithTransformer<K, V, T> extends ContinuousQuery<K, V> {
    /* new method to add */
    public GenericContinuousQuery<K, V, T> setRemoteTransformerFactory(Factory<? extends ContinuousQueryTransformer<K, V, T>> factory) { ..}

    //other new methods
}
{code}

\[1] https://www.gridgain.com/sdk/pe/latest/javadoc/org/apache/ignite/IgniteCache.html#query(org.apache.ignite.cache.query.Query,%20org.apache.ignite.lang.IgniteClosure)
\[2] https://www.gridgain.com/sdk/pe/latest/javadoc/org/apache/ignite/lang/IgniteClosure.html


was (Author: nizhikov):
# Other parts of Ignite \[1] use IgniteClosure \[2] as transformer. I think we can reuse interface. Thoughts?
# Do we need to provide backward compatibility for a ContinuousQuery as it a public API?
We will broke all client code that using ContinuousQuery if simply add one more generic parameter(ContinuousQuery<K, V, T>)
# Which way of implementation is preferable?
## First way to implement feature is create GenericContinuousQuery. 
Internal code will use new GenericContinuousQuery but all client code that using ContinuousQuery still be valid(see first code example)
## Second way ContinuousQueryWIthTransformer extends ContinuousQuery.
Internal code has to check which instance it has when execute some logic

{code:java}
public final class GenericContinuousQuery<K, V, T> extends Query<Cacne.Entry<K, V>> {
    /* new method to add */
    public GenericContinuousQuery<K, V, T> setRemoteTransformerFactory(Factory<? extends ContinuousQueryTransformer<K, V, T>> factory) { ..}

    //other new methods
}

public final class ContinuousQuery<K, V> extends GenericContinuousQuery<K, V, V> {
    public ContinuousQuery() {
        setRemoteTransformerFactory(new Factory<IgniteClosure<V, V>> {
            public IgniteClosure<V, V> create() {
                return new IgniteClosure<V, V> {
                    public V apply(V e) { return e; }
                }
            }
        });
    }
}
{code}

{code:java}
public final class ContinuousQueryWithTransformer<K, V, T> extends ContinuousQuery<K, V> {
    /* new method to add */
    public GenericContinuousQuery<K, V, T> setRemoteTransformerFactory(Factory<? extends ContinuousQueryTransformer<K, V, T>> factory) { ..}

    //other new methods
}
{code}

\[1] https://www.gridgain.com/sdk/pe/latest/javadoc/org/apache/ignite/IgniteCache.html#query(org.apache.ignite.cache.query.Query,%20org.apache.ignite.lang.IgniteClosure)
\[2] https://www.gridgain.com/sdk/pe/latest/javadoc/org/apache/ignite/lang/IgniteClosure.html

> Introduce transformers for continuous queries
> ---------------------------------------------
>
>                 Key: IGNITE-425
>                 URL: https://issues.apache.org/jira/browse/IGNITE-425
>             Project: Ignite
>          Issue Type: Sub-task
>          Components: cache
>            Reporter: Yakov Zhdanov
>            Assignee: Nikolay Izhikov
>
> Currently if updated entry passes the filter, it is sent to node initiated the query entirely. It would be good to provide user with the ability to transform entry and, for example, select only fields that are important. This may bring huge economy to traffic and lower GC pressure as well.
> Possible signatures will be:
> {noformat}
> public final class ContinuousQuery<K, V, T> {..} // T is a type transformer transforms to
> public ContinuousQuery<K, V, T> setLocalListener(Listener<T> locLsnr) {..} // Probably, we will have to introduce new listener type, since user may want to wipe out key as well.
> /* new method to add */
> public ContinuousQuery<K, V, T> setRemoteTransformerFactory(Factory<? extends ContinuousQueryTransformer<K, V, T>> factory) { ..}
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)