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

Mikhail Bautin commented on HIVE-4525:
--------------------------------------

h4. Design proposal

We have to be able to read the current {{TimestampWritable}}-serializable 
format for backward-compatibility, and write the format recognizable by the 
current {{TimestampWritable}} implementation for timestamps within the 
currently supported range. We can use the negative range of the {{VInt}} in the 
binary representation of the timestamp that normally represents the reversed 
decimal part to indicate the presence of an additional {{VInt}} field that 
stores the remaining bits of the {{seconds}} number (i.e. {{seconds >> 31}}). 
The meaning of the 7th bit of the first byte then changes from "has decimal" to 
"has decimal or >31 bits of seconds".

The following table summarizes the four logical cases of timestamp 
serialization. The first two are backward-compatible. The second two cases are 
unsupported by the current format, so they will not be recognized by the 
current version.

|| Seconds need >31 bits || Has decimal || 7th bit of the first byte || First 
VInt || Second VInt ||
| No | No | {{0}} | N/A | N/A |
| No | Yes | {{1}} | {{reversedDecimal}} | N/A |
| Yes | No | {{1}} | {{-1}} | {{seconds >> 31}} |
| Yes | Yes | {{1}} | {{-2 - reversedDecimal}} | {{seconds >> 31}} |



                
> Support timestamps earlier than 1970 and later than 2038
> --------------------------------------------------------
>
>                 Key: HIVE-4525
>                 URL: https://issues.apache.org/jira/browse/HIVE-4525
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Mikhail Bautin
>            Assignee: Mikhail Bautin
>
> TimestampWritable currently serializes timestamps using the lower 31 bits of 
> an int. This does not allow to store timestamps earlier than 1970 or later 
> than a certain point in 2038.

--
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: http://www.atlassian.com/software/jira

Reply via email to