@@ -157,16 +157,25 @@ class db_copy_mgr_t
157157
158158 /* *
159159 * Start a new table row.
160+ *
161+ * Also starts a new buffer if either the table is not the same as
162+ * the table of currently buffered data or no buffer is pending.
160163 */
161164 void new_line (std::shared_ptr<db_target_descr_t > const &table);
162165
163166 /* *
164167 * Finish a table row.
165168 *
166- * Adds the row delimiter to the buffer.
169+ * Adds the row delimiter to the buffer. If the buffer is at capacity
170+ * it will be forwarded to the copy thread.
167171 */
168172 void finish_line ();
169173
174+ /* *
175+ * Add many simple columns.
176+ *
177+ * See add_column().
178+ */
170179 template <typename T, typename ...ARGS>
171180 void add_columns (T value, ARGS&&... args)
172181 {
@@ -180,21 +189,41 @@ class db_copy_mgr_t
180189 add_column (value);
181190 }
182191
183- // / Add a column entry of simple type.
192+ /* *
193+ * Add a column entry of simple type.
194+ *
195+ * Writes the column with the escaping apporpriate for the type and
196+ * a column delimiter.
197+ */
184198 template <typename T>
185199 void add_column (T value)
186200 {
187201 add_value (value);
188202 m_current->buffer += ' \t ' ;
189203 }
190204
191- // / Add an empty column.
205+ /* *
206+ * Add an empty column.
207+ *
208+ * Adds a NULL value for the column.
209+ */
192210 void add_null_column () { m_current->buffer += " \\ N\t " ; }
193211
194- // / Start an array column.
212+ /* *
213+ * Start an array column.
214+ *
215+ * An array is a list of simple elements of the same type.
216+ *
217+ * Must be finished with a call to finish_array().
218+ */
195219 void new_array () { m_current->buffer += " {" ; }
196220
197- // / Add a single value to an array column
221+ /* *
222+ * Add a single value to an array column.
223+ *
224+ * Adds the value in the format appropriate for an array and a value
225+ * separator.
226+ */
198227 template <typename T>
199228 void add_array_elem (T value)
200229 {
@@ -212,7 +241,12 @@ class db_copy_mgr_t
212241 m_current->buffer += " \" ," ;
213242 }
214243
215- // / Finish an array column.
244+ /* *
245+ * Finish an array column previously started with new_array().
246+ *
247+ * The array may be empty. If it does contain elements, the separator after
248+ * the final element is replaced with the closing array bracket.
249+ */
216250 void finish_array ()
217251 {
218252 auto idx = m_current->buffer .size () - 1 ;
@@ -223,14 +257,30 @@ class db_copy_mgr_t
223257 m_current->buffer += ' \t ' ;
224258 }
225259
226- // / Start a hash column.
260+ /* *
261+ * Start a hash column.
262+ *
263+ * A hash column contains a list of key/value pairs. May be represented
264+ * by a hstore or json in Postgresql.
265+ *
266+ * currently a hstore column is written which does not have any start
267+ * markers.
268+ *
269+ * Must be closed with a finish_hash() call.
270+ */
227271 void new_hash () { /* nothing */ }
228272
229273 void add_hash_elem (std::string const &k, std::string const &v)
230274 {
231275 add_hash_elem (k.c_str (), v.c_str ());
232276 }
233277
278+ /* *
279+ * Add a key/value pair to a hash column.
280+ *
281+ * Key and value must be strings and will be appropriately escaped.
282+ * A separator for the next pair is added at the end.
283+ */
234284 void add_hash_elem (char const *k, char const *v)
235285 {
236286 m_current->buffer += ' "' ;
@@ -240,6 +290,12 @@ class db_copy_mgr_t
240290 m_current->buffer += " \" ," ;
241291 }
242292
293+ /* *
294+ * Close a hash previously started with new_hash().
295+ *
296+ * The hash may be empty. If elements were present, the separator
297+ * of the final element is overwritten with the closing \t.
298+ */
243299 void finish_hash ()
244300 {
245301 auto idx = m_current->buffer .size () - 1 ;
@@ -250,6 +306,11 @@ class db_copy_mgr_t
250306 }
251307 }
252308
309+ /* *
310+ * Add a column with the given WKB geometry in WKB hex format.
311+ *
312+ * The geometry is converted on-the-fly from WKB binary to WKB hex.
313+ */
253314 void add_hex_geom (std::string const &wkb)
254315 {
255316 char const *lookup_hex = " 0123456789ABCDEF" ;
0 commit comments