shaofengshi commented on a change in pull request #159: KYLIN-3403 filter code 
system add one type of Date
URL: https://github.com/apache/kylin/pull/159#discussion_r198400219
 
 

 ##########
 File path: 
core-metadata/src/main/java/org/apache/kylin/metadata/filter/FilterCodeSystemFactory.java
 ##########
 @@ -95,4 +99,32 @@ public int compare(Object o, Object t1) {
         }
     }
 
+    private static class DateCodeSystem implements IFilterCodeSystem<String> {
+
+        @Override
+        public boolean isNull(String code) {
+            return code == null;
+        }
+
+        @Override
+        public void serialize(String code, ByteBuffer buf) {
+            BytesUtil.writeUTFString(code, buf);
+        }
+
+        @Override
+        public String deserialize(ByteBuffer buf) {
+            return BytesUtil.readUTFString(buf);
+        }
+
+        @Override
+        public int compare(String o1, String o2) {
+            try {
+                long d1 = DateFormat.stringToMillis(o1);
+                long d2 = DateFormat.stringToMillis(o2);
+                return Long.compare(d1, d2);
+            } catch (IllegalArgumentException e) {
+                return o1.compareTo(o2);
 
 Review comment:
   The exception shouldn't be caught silently; It should throw an error here, 
as using string comparator may return the wrong result.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to