[
https://issues.apache.org/jira/browse/FLINK-3856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15276340#comment-15276340
]
ASF GitHub Bot commented on FLINK-3856:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/1959#discussion_r62495413
--- Diff:
flink-core/src/main/java/org/apache/flink/api/common/typeutils/base/DateComparator.java
---
@@ -59,15 +55,37 @@ public boolean isNormalizedKeyPrefixOnly(int keyBytes) {
}
@Override
- public void putNormalizedKey(Date lValue, MemorySegment target, int
offset, int numBytes) {
- long value = lValue.getTime() - Long.MIN_VALUE;
-
+ public void putNormalizedKey(Date record, MemorySegment target, int
offset, int numBytes) {
+ putNormalizedKeyDate(record, target, offset, numBytes);
+ }
+
+ @Override
+ public DateComparator duplicate() {
+ return new DateComparator(ascendingComparison);
+ }
+
+ //
--------------------------------------------------------------------------------------------
+ // Static Helpers for Date Comparison
+ //
--------------------------------------------------------------------------------------------
+
+ public static int compareSerializedDate(DataInputView firstSource,
DataInputView secondSource,
+ boolean ascendingComparison) throws IOException {
+ final long l1 = firstSource.readLong();
+ final long l2 = secondSource.readLong();
+ final int comp = (l1 < l2 ? -1 : (l1 == l2 ? 0 : 1));
+ return ascendingComparison ? comp : -comp;
+ }
+
+ public static void putNormalizedKeyDate(Date record, MemorySegment
target, int offset, int numBytes) {
+ final long value = record.getTime() - Long.MIN_VALUE;
+
// see IntValue for an explanation of the logic
if (numBytes == 8) {
// default case, full normalized key
target.putLongBigEndian(offset, value);
}
else if (numBytes <= 0) {
--- End diff --
Thanks for the explanation. You are right. I have changed it.
> Create types for java.sql.Date/Time/Timestamp
> ---------------------------------------------
>
> Key: FLINK-3856
> URL: https://issues.apache.org/jira/browse/FLINK-3856
> Project: Flink
> Issue Type: New Feature
> Components: Core
> Reporter: Timo Walther
> Assignee: Timo Walther
>
> At the moment there is only the {{Date}} type which is not sufficient for
> most use cases about time.
> The Table API would also benefit from having different types as output result.
> I would propose to add the three {{java.sql.}} types either as {{BasicTypes}}
> or in an additional class {{TimeTypes}}.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)