You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by jackylk <gi...@git.apache.org> on 2017/12/05 15:52:28 UTC
[GitHub] carbondata pull request #1565: [CARBONDATA-1518][Pre-Aggregate]Support creat...
Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1565#discussion_r154988752
--- Diff: core/src/main/java/org/apache/carbondata/core/preagg/TimeSeriesUDF.java ---
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.carbondata.core.preagg;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+/**
+ * class for applying timeseries udf
+ */
+public class TimeSeriesUDF {
+
+ public final List<String> TIMESERIES_FUNCTION = new ArrayList<>();
+
+ // thread local for keeping calender instance
+ private ThreadLocal<Calendar> calanderThreadLocal = new ThreadLocal<>();
+
+ /**
+ * singleton instance
+ */
+ public static final TimeSeriesUDF INSTANCE = new TimeSeriesUDF();
+
+ private TimeSeriesUDF() {
+ initialize();
+ }
+
+ /**
+ * Below method will be used to apply udf on data provided
+ * Method will work based on below logic.
+ * Data: 2016-7-23 01:01:30,10
+ * Year Level UDF will return: 2016-1-1 00:00:00,0
+ * Month Level UDF will return: 2016-7-1 00:00:00,0
+ * Day Level UDF will return: 2016-7-23 00:00:00,0
+ * Hour Level UDF will return: 2016-7-23 01:00:00,0
+ * Minute Level UDF will return: 2016-7-23 01:01:00,0
+ * Second Level UDF will return: 2016-7-23 01:01:30,0
+ * If function does not match with any of the above functions
+ * it will throw exception
--- End diff --
mention it is IllegalArgumentException explicitly
---