incubator-crunch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kiyan Ahmadizadeh (JIRA)" <>
Subject [jira] [Updated] (CRUNCH-77) Scala PObjects should contain values of Scala types, not Java types.
Date Tue, 25 Sep 2012 01:25:07 GMT


Kiyan Ahmadizadeh updated CRUNCH-77:

    Attachment: CRUNCH-77.patch

This patch modifies the implementation of the Scala PObject as follows:

1. PObject is now a trait with a value() method.

2. A concrete class that implements the PObject trait and is backed by a JPObject is added.
This concrete class converts the value returned by the JPObject into the type of value returned
by the Scala PObject, through the use of an implicit value of type Converter[J, T].  

3. Instances of the type class Converter[J, T] are created for converting values from all
Java primitive types to their Scala equivalents (Byte, Short, Int, etc.)

4. An implicit function that returns an identity converter is also used (ie as a default,
if there is no conversion from the type encapsulated by the JPObject to the type encapsulated
by the PObject, the value from the JPObject is returned directly).

5. Implicit functions that return Converters for java.util.Collection => Seq and java.util.Map
=> Map are added.

6. A companion object for PObject is added, which knows how to create Scala PObjects from
Java PObjects.

7. Method asSeq added to PCollectionLike.scala, so now a PObject of a Scala Seq can be obtained
from a PCollection.

8. Method asMap added to PTable.scala so now a PObject of a Scala immutable Map can be obtained
from a PTable.

9. Tests for asSeq and asMap are added.

10. Tests for converting Java PObjects to Scala PObjects are added for primitives, collections,
and maps.  
> Scala PObjects should contain values of Scala types, not Java types.
> --------------------------------------------------------------------
>                 Key: CRUNCH-77
>                 URL:
>             Project: Crunch
>          Issue Type: Improvement
>          Components: Scrunch
>    Affects Versions: 0.4.0
>            Reporter: Kiyan Ahmadizadeh
>            Assignee: Kiyan Ahmadizadeh
>         Attachments: CRUNCH-77.patch
> The current implementation of PObjects in Scrunch simply wraps a Java PObject (JPObject)
and returns a value of the same type as that returned by the underlying JPObject.  This is
inconvenient, as users will likely wish to work with Scala types instead of Java types.
> PObjects in Scala should be modified to allow for conversions between Java and Scala
types when returning values from the PObject.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message