Skip to content

Commit 141e664

Browse files
author
aviau
committed
Removed Points object
1 parent c226c13 commit 141e664

File tree

4 files changed

+28
-155
lines changed

4 files changed

+28
-155
lines changed

influxdb/point.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

influxdb/resultset.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
from influxdb.point import Point
4-
53
_sentinel = object()
64

75

@@ -43,15 +41,15 @@ def __getitem__(self, key):
4341
# like 'show retention policies' ..
4442
if key is None:
4543
for point in serie['values']:
46-
yield Point(None, serie['columns'], point)
44+
yield self.point_from_cols_vals(serie['columns'], point)
4745

4846
elif name in (None, serie_name):
4947
# by default if no tags was provided then
5048
# we will matches every returned serie
5149
serie_tags = serie.get('tags', {})
5250
if tags is None or self._tag_matches(serie_tags, tags):
5351
for point in serie['values']:
54-
yield Point(serie_name, serie['columns'], point, serie_tags)
52+
yield self.point_from_cols_vals(serie['columns'], point)
5553

5654
def __repr__(self):
5755
return str(self.raw)
@@ -101,4 +99,11 @@ def items(self):
10199
items.append(
102100
(serie_key, self[serie_key])
103101
)
104-
return items
102+
return items
103+
104+
@staticmethod
105+
def point_from_cols_vals(cols, vals):
106+
point = {}
107+
for col_index, col_name in enumerate(cols):
108+
point[col_name] = vals[col_index]
109+
return point

tests/influxdb/point_test.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/influxdb/resultset_test.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import unittest
44

55
from influxdb.resultset import ResultSet
6-
from influxdb.point import Point
76

87

98
class TestResultSet(unittest.TestCase):
@@ -40,36 +39,22 @@ def test_filter_by_name(self):
4039
self.assertEqual(
4140
list(self.rs['cpu_load_short']),
4241
[
43-
Point("cpu_load_short", ["time", "value"],
44-
["2015-01-29T21:51:28.968422294Z", 0.64],
45-
tags={"host": "server01", "region": "us-west"}),
46-
Point("cpu_load_short", ["time", "value"],
47-
["2015-01-29T21:51:28.968422294Z", 0.64],
48-
tags={"host": "server02", "region": "us-west"})
42+
{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'},
43+
{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}
4944
]
5045
)
5146

5247
def test_filter_by_tags(self):
5348
self.assertEqual(
5449
list(self.rs[('cpu_load_short', {"host": "server01"})]),
55-
[
56-
Point(
57-
"cpu_load_short", ["time", "value"],
58-
["2015-01-29T21:51:28.968422294Z", 0.64],
59-
tags={"host": "server01", "region": "us-west"}
60-
)
61-
]
50+
[{'time': '2015-01-29T21:51:28.968422294Z', 'value': 0.64}]
6251
)
6352

6453
self.assertEqual(
6554
list(self.rs[('cpu_load_short', {"region": "us-west"})]),
6655
[
67-
Point("cpu_load_short", ["time", "value"],
68-
["2015-01-29T21:51:28.968422294Z", 0.64],
69-
tags={"host": "server01", "region": "us-west"}),
70-
Point("cpu_load_short", ["time", "value"],
71-
["2015-01-29T21:51:28.968422294Z", 0.64],
72-
tags={"host": "server02", "region": "us-west"}),
56+
{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'},
57+
{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}
7358
]
7459
)
7560

@@ -98,21 +83,25 @@ def test_items(self):
9883
[
9984
(
10085
('cpu_load_short', {'host': 'server01', 'region': 'us-west'}),
101-
[Point("cpu_load_short", ["time", "value"],
102-
["2015-01-29T21:51:28.968422294Z", 0.64],
103-
tags={"host": "server01", "region": "us-west"})]
86+
[{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}]
10487
),
10588
(
10689
('cpu_load_short', {'host': 'server02', 'region': 'us-west'}),
107-
[Point("cpu_load_short", ["time", "value"],
108-
["2015-01-29T21:51:28.968422294Z", 0.64],
109-
tags={"host": "server02", "region": "us-west"})]
90+
[{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}]
11091
),
11192
(
11293
('other_serie', {'host': 'server01', 'region': 'us-west'}),
113-
[Point("other_serie", ["time", "value"],
114-
["2015-01-29T21:51:28.968422294Z", 0.64],
115-
tags={"host": "server01", "region": "us-west"})]
94+
[{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}]
11695
)
11796
]
11897
)
98+
99+
def test_point_from_cols_vals(self):
100+
cols = ['col1', 'col2']
101+
vals = [1, '2']
102+
103+
point = ResultSet.point_from_cols_vals(cols, vals)
104+
self.assertDictEqual(
105+
point,
106+
{'col1': 1, 'col2': '2'}
107+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy