pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Szita (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PIG-4748) DateTimeWritable forgets Chronology
Date Fri, 17 Mar 2017 14:11:41 GMT

    [ https://issues.apache.org/jira/browse/PIG-4748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15930015#comment-15930015
] 

Adam Szita commented on PIG-4748:
---------------------------------

Thanks for the comments [~rohini], I've uploaded a new patch to address them: [^PIG-4748.3.patch]

Questions:
1, Yes, if we only supply the zone as offset (e.g +01:00) we won't find this in the zone list,
so -1 will be the position in the zone list.
This is why we have to send the offset as millis as well.
2, Joda time returns offsetAsMillis in integer. If we want to keep a general approach we should
leave this as is. We could argue that a +00:00:00.001 zone offset doesn't make sense and we
could programatically save some memory by transforming it to short by dividing it and loosing
some precision. However I would rather go with the general approach.

Comments:
1, Done
2, Done
3, Done, I think the previous solution would have worked as well but in the new patch I made
this cleaner and made use of UDFContext()
4, Done, one of the tuples has a DateTime object where the zone information is deliberately
left to be default. So I had to apply a little trick at result comparation.
5, Done, test classes are merged

> DateTimeWritable forgets Chronology
> -----------------------------------
>
>                 Key: PIG-4748
>                 URL: https://issues.apache.org/jira/browse/PIG-4748
>             Project: Pig
>          Issue Type: Bug
>          Components: impl
>    Affects Versions: 0.16.0
>            Reporter: Martin Junghanns
>            Assignee: Adam Szita
>             Fix For: 0.17.0
>
>         Attachments: PIG-4748.2.patch, PIG-4748.3.patch, PIG-4748.patch
>
>
> The following test fails:
> {code}
> @Test
> public void foo() throws IOException {
>     DateTime nowIn = DateTime.now();
>     DateTimeWritable in = new DateTimeWritable(nowIn);
>     ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
>     DataOutputStream dataOut = new DataOutputStream(outputStream);
>     in.write(dataOut);
>     dataOut.flush();
>     // read from byte[]
>     DateTimeWritable out = new DateTimeWritable();
>     ByteArrayInputStream inputStream = new ByteArrayInputStream(
>       outputStream.toByteArray());
>     DataInputStream dataIn = new DataInputStream(inputStream);
>     out.readFields(dataIn);
>     assertEquals(in.get(), out.get());
> }
> {code}
> In equals(), the original instance has
> {code}
> ISOChronology[Europe/Berlin]
> {code}
> while the deserialized instance has
> {code}
> ISOChronology[+01:00]
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message