30
30
class _QueryExecutionEndpointComponent (object ):
31
31
def __init__ (self , execution_context ):
32
32
self ._execution_context = execution_context
33
-
33
+
34
34
def __iter__ (self ):
35
35
return self
36
-
36
+
37
37
def next (self ):
38
38
return next (self ._execution_context )
39
39
40
40
def __next__ (self ):
41
41
# supports python 3 iterator
42
- return self .next ()
42
+ return self .next ()
43
43
44
44
class _QueryExecutionOrderByEndpointComponent (_QueryExecutionEndpointComponent ):
45
45
"""Represents an endpoint in handling an order by query.
46
-
46
+
47
47
For each processed orderby result it returns 'payload' item of the result
48
48
"""
49
49
def __init__ (self , execution_context ):
50
50
super (self .__class__ , self ).__init__ (execution_context )
51
-
51
+
52
52
def next (self ):
53
53
return next (self ._execution_context )['payload' ]
54
-
54
+
55
55
class _QueryExecutionTopEndpointComponent (_QueryExecutionEndpointComponent ):
56
56
"""Represents an endpoint in handling top query.
57
-
57
+
58
58
It only returns as many results as top arg specified.
59
59
"""
60
60
def __init__ (self , execution_context , top_count ):
61
61
super (self .__class__ , self ).__init__ (execution_context )
62
62
self ._top_count = top_count
63
-
63
+
64
64
def next (self ):
65
65
if (self ._top_count > 0 ):
66
66
res = next (self ._execution_context )
@@ -95,7 +95,7 @@ def next(self):
95
95
for item in res :
96
96
for operator in self ._local_aggregators :
97
97
if isinstance (item , dict ) and len (item .keys ()) > 0 :
98
- operator .aggregate (item [item .keys ()[ 0 ] ])
98
+ operator .aggregate (item [next ( iter ( item .keys ())) ])
99
99
elif isinstance (item , numbers .Number ):
100
100
operator .aggregate (item )
101
101
if self ._results is None :
@@ -107,4 +107,4 @@ def next(self):
107
107
self ._result_index += 1
108
108
return res
109
109
else :
110
- raise StopIteration
110
+ raise StopIteration
0 commit comments