예제 #1
0
    def __init__(self, **desc):
        Domain.__init__(self, **desc)
        self.type = "time"
        self.NULL = Null
        self.min = Date(self.min)
        self.max = Date(self.max)
        self.interval = Duration(self.interval)

        if self.partitions:
            # IGNORE THE min, max, interval
            if not self.key:
                Log.error("Must have a key value")

            Log.error("not implemented yet")

            # VERIFY PARTITIONS DO NOT OVERLAP
            return
        elif not all([self.min, self.max, self.interval]):
            Log.error("Can not handle missing parameter")

        self.key = "min"
        self.partitions = wrap([{
            "min": v,
            "max": v + self.interval,
            "dataIndex": i
        } for i, v in enumerate(Date.range(self.min, self.max, self.interval))
                                ])
예제 #2
0
    def __init__(self, **desc):
        Domain.__init__(self, **desc)
        self.type = "time"
        self.NULL = Null
        self.min = Date(self.min)
        self.max = Date(self.max)
        self.interval = Duration(self.interval)

        if self.partitions:
            # IGNORE THE min, max, interval
            if not self.key:
                Log.error("Must have a key value")

            Log.error("not implemented yet")

            # VERIFY PARTITIONS DO NOT OVERLAP
            return
        elif not all([self.min, self.max, self.interval]):
            Log.error("Can not handle missing parameter")

        self.key = "min"
        self.partitions = wrap([
            {"min": v, "max": v + self.interval, "dataIndex": i}
            for i, v in enumerate(Date.range(self.min, self.max, self.interval))
        ])
예제 #3
0
 def test_count_over_time(self):
     test = {
         "data": simple_test_data,
         "query": {
             "from":
             TEST_TABLE,
             "edges": [{
                 "value": "run.timestamp",
                 "allowNulls": False,
                 "domain": {
                     "type": "time",
                     "min": "today-week",
                     "max": "today",
                     "interval": "day"
                 }
             }]
         },
         "expecting_list": {
             "meta": {
                 "format": "list"
             },
             "data": [{
                 "run": {
                     "timestamp": (FROM_DATE + 0 * DAY).unix
                 },
                 "count": 0
             }, {
                 "run": {
                     "timestamp": (FROM_DATE + 1 * DAY).unix
                 },
                 "count": 6
             }, {
                 "run": {
                     "timestamp": (FROM_DATE + 2 * DAY).unix
                 },
                 "count": 5
             }, {
                 "run": {
                     "timestamp": (FROM_DATE + 3 * DAY).unix
                 },
                 "count": 4
             }, {
                 "run": {
                     "timestamp": (FROM_DATE + 4 * DAY).unix
                 },
                 "count": 3
             }, {
                 "run": {
                     "timestamp": (FROM_DATE + 5 * DAY).unix
                 },
                 "count": 2
             }, {
                 "run": {
                     "timestamp": (FROM_DATE + 6 * DAY).unix
                 },
                 "count": 1
             }]
         },
         "expecting_table": {
             "meta": {
                 "format": "table"
             },
             "header": ["run.timestamp", "count"],
             "data": [[(FROM_DATE + 0 * DAY).unix, 0],
                      [(FROM_DATE + 1 * DAY).unix, 6],
                      [(FROM_DATE + 2 * DAY).unix, 5],
                      [(FROM_DATE + 3 * DAY).unix, 4],
                      [(FROM_DATE + 4 * DAY).unix, 3],
                      [(FROM_DATE + 5 * DAY).unix, 2],
                      [(FROM_DATE + 6 * DAY).unix, 1]]
         },
         "expecting_cube": {
             "meta": {
                 "format": "cube"
             },
             "edges": [{
                 "name": "run.timestamp",
                 "domain": {
                     "type":
                     "time",
                     "key":
                     "min",
                     "partitions": [{
                         "dataIndex": i,
                         "min": m.unix,
                         "max": (m + DAY).unix
                     } for i, m in enumerate(
                         Date.range(FROM_DATE, TO_DATE, DAY))],
                     "min":
                     FROM_DATE.unix,
                     "max":
                     TO_DATE.unix,
                     "interval":
                     DAY.seconds
                 }
             }],
             "data": {
                 "count": [0, 6, 5, 4, 3, 2, 1]
             }
         }
     }
     self.utils.execute_es_tests(test)