@@ -62,7 +62,37 @@ def switch_user(self, username, password):
62
62
def write_points (self , * args , ** kwargs ):
63
63
"""
64
64
Write to multiple time series names
65
- """
65
+
66
+ Parameters
67
+ ----------
68
+ batch_size : Optional. Int value to write the points in batches instead
69
+ of all at one time.
70
+ Useful for when doing data dumps from one database to another or
71
+ when doing a massive write operation
72
+ """
73
+
74
+ def list_chunks (l , n ):
75
+ """ Yield successive n-sized chunks from l.
76
+ """
77
+ for i in xrange (0 , len (l ), n ):
78
+ yield l [i :i + n ]
79
+
80
+ batch_size = kwargs .get ('batch_size' )
81
+ if batch_size :
82
+ for data in kwargs .get ('data' ):
83
+ name = data .get ('name' )
84
+ columns = data .get ('columns' )
85
+ point_list = data .get ('points' )
86
+ total_batches = len (point_list ) * 1.0 / batch_size
87
+ for batch in list_chunks (point_list , batch_size ):
88
+ data = [{"points" : batch ,
89
+ "name" : name ,
90
+ "columns" : columns }]
91
+ time_precision = kwargs .get ('time_precision' , 's' )
92
+ self .write_points_with_precision (data = data ,
93
+ time_precision = time_precision )
94
+ return True
95
+
66
96
return self .write_points_with_precision (* args , ** kwargs )
67
97
68
98
def write_points_with_precision (self , data , time_precision = 's' ):
0 commit comments