You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2014/12/14 08:35:13 UTC

[jira] [Comment Edited] (CALCITE-529) Allow to pass java object via rexBuilder.makeLiteral()

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

Julian Hyde edited comment on CALCITE-529 at 12/14/14 7:34 AM:
---------------------------------------------------------------

setObject is only allowed if the type is serializable or there is an entry in the type-mapping for it. Otherwise there is no way to get it from the JDBC client to the server. Same kind of restrictions I am talking about.

I'm not talking about implementor's stash. Just create a UDF:

{code}
public StashUdf {
  private static final Map<String, Object> MAP = new HashMap<String, Object>();

  public Object apply(String handle) {
    return MAP.get(handle);
  }

  public static String register(Object o) {
    String handle = "k" + MAP.size();
    MAP.put(handle, o);
    return handle;
  }
}
{code}

In whatever code you want to reference an object, call StashUdf.register to get a handle, then generate a RexCall to StashUdf with that handle. {{Stash("k0")}} will evaluate to your object.


was (Author: julianhyde):
setObject is only allowed if the type is serializable or there is an entry in the type-mapping for it. Otherwise there is no way to get it from the JDBC client to the server. Same kind of restrictions I am talking about.

I'm not talking about implementor's stash. Just create a UDF:

{code}
public StashUdf {
  public Object apply(String handle) {
    return MAP.get(handle);
  }

  public static String register(Object o) {
    String handle = "k" + MAP.size();
    MAP.put(handle, o);
    return handle;
  }
}
{code}

In whatever code you want to reference an object, call StashUdf.register to get a handle, then generate a RexCall to StashUdf with that handle. {{Stash("k0")}} will evaluate to your object.

> Allow to pass java object via rexBuilder.makeLiteral()
> ------------------------------------------------------
>
>                 Key: CALCITE-529
>                 URL: https://issues.apache.org/jira/browse/CALCITE-529
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.0.0-incubating
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>              Labels: newbie
>
> Motivation: Rex is simpler that linq4j.
> For instance,
> 1) Sometimes it is easier to create a {{ProjectRel}} rather than lower the expression to low-level linq4j
> 2) XXXToEnumerableRule are easier to accomplish via TableFunctionScan. This allows to express the call via Rex and skip linq4j completely.
> For example: https://github.com/vlsi/mat-calcite-plugin/blob/master/MatCalcitePlugin/src/com/github/vlsi/mat/optiq/rules/InstanceAccessByClassIdRule.java#L43
> The problem is to pass non-literal java object to enumerable/interpreter conventions.
> For enumerable the implementation can use stash. For interpreter it can use the value as is, etc.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)