Based on a cursory look, it seems like either will work, since all you're
doing is converting to bytes anyway.

Thanks,
James


On Thu, May 29, 2014 at 2:52 PM, faisal moeen <fmorak...@gmail.com> wrote:

> Is it a correction James?
> Because your previous code is working fine as well.
>
> Regards
>
>
> On Thu, May 29, 2014 at 11:44 PM, James Taylor <jamestay...@apache.org>
> wrote:
>
> > One correction, you need to instantiate the correct kind of array:
> >
> > // Use Apache commons to convert from double[] to Double[]
> > Double[] doubleArray = ArrayUtils.toObject(mydoubleArray);
> > ptr.set( PDataType.DOUBLE_ARRAY.toByte(
> >                 new PhoenixArray.PrimitiveDoublePhoenixArray(
> >                     PDataType.DOUBLE, doubleArray) );
> >
> > This could be made simpler.
> >
> > Thanks,
> > James
> >
> >
> >
> >
> > On Thu, May 29, 2014 at 2:29 PM, James Taylor <jamestay...@apache.org>
> > wrote:
> >
> > > Hi Faisal,
> > > You need to pass through a PhoenixArray to the toBytes method, like
> this:
> > >
> > > // Use Apache commons to convert from double[] to Double[]
> > > Double[] doubleArray = ArrayUtils.toObject(mydoubleArray);
> > > ptr.set( PDataType.DOUBLE_ARRAY.toBytes(new
> > > PhoenixArray(PDataType.DOUBLE, doubleArray) );
> > >
> > > Note that underneath, the Double[] is going to stored as a double[], so
> > > it' be pretty trivial to add new constructors for PhoenixArray that
> take
> > > an array of a primitive type.
> > >
> > > Thanks,
> > > James
> > >
> > >
> > > On Thu, May 29, 2014 at 1:56 PM, faisal moeen <fmorak...@gmail.com>
> > wrote:
> > >
> > >> Hi,
> > >>
> > >> I am writing a custom function which return a double[]. How to do it?
> > >> I am doing the following but double[] is not castable to PhoenixArray
> :
> > >>
> > >> ptr.set( PDataType.DOUBLE_ARRAY.toBytes(mydoubleArray) );
> > >>
> > >> but this throws an exception:
> > >>
> > >>         java.lang.ClassCastException: [D cannot be cast to
> > >> org.apache.phoenix.schema.PhoenixArray
> > >> at
> > >>
> org.apache.phoenix.schema.PArrayDataType.toBytes(PArrayDataType.java:54)
> > >> at org.apache.phoenix.schema.PDataType$35.toBytes(PDataType.java:4112)
> > >> at org.apache.phoenix.schema.PDataType$35.toBytes(PDataType.java:4107)
> > >> at
> > >>
> > >>
> >
> de.tuberlin.dima.hbasealgebra.test.PhoenixTests.testtest(PhoenixTests.java:28)
> > >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >> at
> > >>
> > >>
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> > >> at
> > >>
> > >>
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > >> at java.lang.reflect.Method.invoke(Method.java:606)
> > >> at
> > >>
> > >>
> >
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> > >> at
> > >>
> > >>
> >
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> > >> at
> > >>
> > >>
> >
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> > >> at
> > >>
> > >>
> >
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> > >> at
> > >>
> > >>
> >
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> > >> at
> > >>
> > >>
> >
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> > >> at
> > >>
> > >>
> >
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
> > >> at
> > >>
> > >>
> >
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
> > >> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
> > >> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
> > >> at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
> > >> at
> > >>
> > >>
> >
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
> > >> at
> > >>
> > >>
> >
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> > >> at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
> > >> at
> > >>
> > >>
> >
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> > >> at
> > >>
> > >>
> >
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> > >> at
> > >>
> > >>
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> > >> at
> > >>
> > >>
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> > >> at
> > >>
> > >>
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> > >> at
> > >>
> > >>
> >
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> > >>
> > >>
> > >>
> > >> --
> > >>
> > >> Regards
> > >> Faisal Moeen
> > >>
> > >
> > >
> >
>
>
>
> --
>
> Regards
> Faisal Moeen
>

Reply via email to