Thanks James.

On Thu, May 29, 2014 at 11:29 PM, James Taylor <[email protected]>
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 <[email protected]> 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