asterixdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xikui Wang <xik...@uci.edu>
Subject Re: Derived types in Java UDF?
Date Tue, 12 Mar 2019 00:49:46 GMT
Hi Sandra,

You can use derived data types in UDFs, and I think you've got most of the
parts right. One thing you should do it to define the termsFrequencies in
your Java UDF code to be a JOrderedList or JUnorderedList instead of a Java
Array. This should resolve the error. I've created an example of how to do
that in a Java UDF. You can find it here [1]. When constructing this
example, I found a minor bug in reading an array of record objects, but
writing it, in your case, should be fine. This will be fixed once the patch
[2] is merged.

[1]
https://asterix-gerrit.ics.uci.edu/#/c/3264/1/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/UpperCaseFunction.java
[2] https://asterix-gerrit.ics.uci.edu/#/c/3264/

Best,
Xikui

On Mon, Mar 11, 2019 at 2:20 AM sandraskarshaug@gmail.com <
sandraskarshaug@gmail.com> wrote:

> Hi,
>
> I have a Java UDF, with input being a record containing an id as well as
> some text. The UDF outputs a record of type RelevantTweetType, by setting
> three additional fields, with one of them being an array of
> TermFrequencyType objects (see type below). Calling
> result.setField("termFrequencies", x) with the second parameter x being a
> JRecord[] results in an error, of course, since it is not an instance of
> type IJObject. I was wondering if it is possible to set an array of a
> datatype (TermFrequencyType) as a record field in a Java UDF, and if so,
> how? Or are the record fields limited to being primitive types when set in
> a Java UDF?
>
> CREATE TYPE RelevantTweetType AS CLOSED {
>   id: int32,
>   text: string,
>   threadid: int32,
>   relevant: boolean,
>   termsFrequencies: [TermFrequencyType]
> };
>
> CREATE TYPE TermFrequencyType AS CLOSED {
>   term: string,
>   frequency: int32
> };
>
> Thanks in advance,
> Sandra
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message