コード例 #1
0
    def test_retrieve_from_v4_trendstore(self):
        table_names = [self.data.partition_a.table().name]
        start = self.data.timestamp_1
        end = self.data.timestamp_1
        entity = self.data.entities[1]
        entities = [entity.id]

        column_names = [
            "CellID",
            "CCR",
            "CCRatts",
            "Drops"]

        create_column = partial(Column, self.data.partition_a.table())

        columns = map(create_column, column_names)

        r = retrieve(self.conn, SCHEMA, table_names, columns, entities, start, end)

        eq_(len(r), 1)

        first_result = head(r)

        entity_id, timestamp, c1, c2, c3, c4 = first_result

        eq_(entity_id, entity.id)
        eq_(c4, 18)
コード例 #2
0
ファイル: plugin.py プロジェクト: hendrikx-itc/python-minerva
    def retrieve(self, datasources, gp, entitytype, trend_names, entities,
        start, end, subquery_filter=None, relation_table_name=None, limit=None):

        with closing(self.conn.cursor()) as cursor:
            if isinstance(entitytype, str):
                entitytype = get_entitytype(cursor, entitytype)

            table_names = get_table_names_v4(cursor, datasources, gp, entitytype,
                    start, end)

        return retrieve(self.conn, schema.name, table_names, trend_names, entities,
            start, end, subquery_filter, relation_table_name, limit,
            entitytype=entitytype)
コード例 #3
0
    def test_retrieve(self):
        table_a = self.data.partition_a.table()
        table_b = self.data.partition_b.table()
        table_c = self.data.partition_c.table()

        table_names = [
            table_a.name,
            table_b.name,
            table_c.name]
        start = self.data.timestamp_1
        end = self.data.timestamp_1

        table_a_cols = [
            Column("CellID"),
            Column("CCR"),
            Column("CCRatts"),
            Column("Drops")]

        table_b_cols = [
            Column("counter_a"),
            Column("counter_b")]

        table_c_cols = [
            Column("counter_x"),
            Column("counter_y")]

        system_columns = [Column("entity_id"), Column("timestamp")]

        columns = table_a_cols + table_b_cols + table_c_cols

        with closing(self.conn.cursor()) as cursor:
            table_a.select(system_columns + table_a_cols).execute(cursor)
            logging.debug(unlines(render_result(cursor)))

            table_b.select(system_columns + table_b_cols).execute(cursor)
            logging.debug(unlines(render_result(cursor)))

            table_c.select(system_columns + table_c_cols).execute(cursor)
            logging.debug(unlines(render_result(cursor)))

        r = retrieve(self.conn, SCHEMA, table_names, columns, None, start, end,
                entitytype=self.data.entitytype)

        data = [["entity_id", "timestamp"] + [c.name for c in columns]] + r

        logging.debug(unlines(render_source(data)))

        eq_(len(r), 5)
コード例 #4
0
    def test_retrieve_multi_table_time(self):
        table_d_1 = self.data.partition_d_1.table()
        table_d_2 = self.data.partition_d_2.table()
        table_names = [table_d_1.name, table_d_2.name]
        start = self.data.timestamp_1 - timedelta(seconds=60)
        end = self.data.timestamp_2
        entity = self.data.entities[1]
        entities = [entity.id]

        column_names = [
            "counter_x"]

        columns = map(Column, column_names)

        r = retrieve(self.conn, SCHEMA, table_names, columns, entities, start, end)

        eq_(len(r), 2)

        first_result = head(r)

        entity_id, timestamp, c1 = first_result

        eq_(entity_id, entity.id)
        eq_(c1, 110)