Hi Ahmed,

    You can build a class hierarchy or util classes that hide the details
of serde particularly for your functions.  Numeric functions are such
examples:

https://github.com/apache/asterixdb/blob/master/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAddDescriptor.java

Best,
Yingyi


On Tue, Jul 11, 2017 at 10:50 AM, Ahmed Eldawy <eld...@cs.ucr.edu> wrote:

> Hi Yingyi,
>
> Thanks for your response. I understand that serialization/deserialization
> consumes some CPU cycles. Given the large number of functions we're
> planning to implement, we prefer a more productive method with a minimal
> number of code lines. If such an example exists, can you point us to an
> example of a UDF where AsterixDB automatically handles the
> serialization/deserialization while the function only handles the function
> logic?
>
> Thanks
> Ahmed
>
> On Tue, Jul 11, 2017 at 10:21 AM, Yingyi Bu <buyin...@gmail.com> wrote:
>
> > Hi Riyafa,
> >
> > -- My question is whether there's a simpler way to implement a
> > -- function where the arguments would be passed in the deserialized
> format
> > and
> > -- then in function implementation we can simply return the result rather
> > than
> > -- serializing it before returning.
> >
> >    The evaluator interface itself doesn't force an implementation to
> > deserialize the input and then serialize the output --- "input" is a
> region
> > of bytes and the "result" pointer can bind to the byte region for the
> > output:
> >    public void evaluate(IFrameTupleReference input, IPointable result)
> >
> >    SerDe consumes CPU time and thus for performance reasons, we don't
> pass
> > in deserialized Java objects as function parameters. Therefore, SerDe is
> > not mandatory for a function implementation and some existing functions
> do
> > not do SerDe.
> >
> > Best,
> > Yingyi
> >
> >
> > On Tue, Jul 11, 2017 at 10:03 AM, Riyafa Abdul Hameed <riy...@apache.org
> >
> > wrote:
> >
> > > Dear all,
> > >
> > > I have been creating a few functions that act on geometry datatype. In
> > each
> > > of these functions I have been serializing or/and serializing geometry
> or
> > > other datatypes. Some of these functions are STAreaDescriptor,
> > > STIntersectsDescriptor and STMakePointDescriptor. As can be seen in
> these
> > > implmentations[1] I am repeating code (Of course this is not the most
> > > efficient way to implement because we are using  the Esri api library,
> > but
> > > we have given precedence for convenience over efficiency at the
> moment).
> > > The number of functions to be implemented amounts to about 80[2]. This
> > > means same code might get repeated over and over again. The
> > implementations
> > > of other functions also seem to do the same thing (ie. to deserialize
> and
> > > then serialize)
> > >
> > > The problem is that the arguments passed to the function via
> > > "createEvaluatorFactory(final IScalarEvaluatorFactory[] args)" is not
> in
> > > the deserialized format and the  return value should be in the
> serialized
> > > format. My question is whether there's a simpler way to implement a
> > > function where the arguments would be passed in the deserialized format
> > and
> > > then in function implementation we can simply return the result rather
> > than
> > > serializing it before returning. This would simplify the function
> > > implementations and improve code reuse.
> > >
> > >
> > > [1] https://asterix-gerrit.ics.uci.edu/1838
> > > [2] https://postgis.net/docs/reference.html
> > >
> > > Thank you.
> > > Yours sincerely,
> > > Riyafa
> > >
> >
>
>
>
> --
>
> Ahmed Eldawy
> Assistant Professor
> Computer Science and Engineering
> http://www.cs.ucr.edu/~eldawy
> Tel: +1 (951) 827-5654 <(951)%20827-5654>
>

Reply via email to