@@ -16,13 +16,12 @@ import {
1616 TimestampUnit ,
1717} from "../utils" ;
1818
19+ // Default maximum length for table and column names.
1920const DEFAULT_MAX_NAME_LENGTH = 127 ;
2021
21- /** @classdesc
22- * The QuestDB client's API provides methods to connect to the database, ingest data, and close the connection.
23- * If no custom agent is configured, the Sender will use its own agent which overrides some default values
24- * of <i>undici.Agent</i>. The Sender's own agent uses persistent connections with 1 minute idle timeout, pipelines requests default to 1.
25- * </p>
22+ /**
23+ * Abstract base class for SenderBuffer implementations. <br>
24+ * Provides common functionality for writing data into the buffer.
2625 */
2726abstract class SenderBufferBase implements SenderBuffer {
2827 private bufferSize : number ;
@@ -40,7 +39,7 @@ abstract class SenderBufferBase implements SenderBuffer {
4039 protected readonly log : Logger ;
4140
4241 /**
43- * Creates an instance of Sender .
42+ * Creates an instance of SenderBufferBase .
4443 *
4544 * @param {SenderOptions } options - Sender configuration object. <br>
4645 * See SenderOptions documentation for detailed description of configuration options. <br>
@@ -68,7 +67,7 @@ abstract class SenderBufferBase implements SenderBuffer {
6867 }
6968
7069 /**
71- * Extends the size of the sender's buffer. <br>
70+ * Extends the size of the buffer. <br>
7271 * Can be used to increase the size of buffer if overflown.
7372 * The buffer's content is copied into the new buffer.
7473 *
@@ -112,22 +111,20 @@ abstract class SenderBufferBase implements SenderBuffer {
112111 }
113112
114113 /**
115- * @ignore
116- * @return {Buffer } Returns a cropped buffer, or null if there is nothing to send.
117- * The returned buffer is backed by the sender's buffer.
118- * Used only in tests.
114+ * @return {Buffer } Returns a cropped buffer, or null if there is nothing to send. <br>
115+ * The returned buffer is backed by this buffer instance, meaning the view can change as the buffer is mutated.
116+ * Used only in tests to assert the buffer's content.
119117 */
120118 toBufferView ( pos = this . endOfLastRow ) : Buffer {
121119 return pos > 0 ? this . buffer . subarray ( 0 , pos ) : null ;
122120 }
123121
124122 /**
125- * @ignore
126- * @return {Buffer|null } Returns a cropped buffer ready to send to the server, or null if there is nothing to send.
127- * The returned buffer is a copy of the sender's buffer.
128- * It also compacts the Sender's buffer.
123+ * @return {Buffer } Returns a cropped buffer ready to send to the server, or null if there is nothing to send. <br>
124+ * The returned buffer is a copy of this buffer.
125+ * It also compacts the buffer.
129126 */
130- toBufferNew ( pos = this . endOfLastRow ) : Buffer | null {
127+ toBufferNew ( pos = this . endOfLastRow ) : Buffer {
131128 if ( pos > 0 ) {
132129 const data = Buffer . allocUnsafe ( pos ) ;
133130 this . buffer . copy ( data , 0 , 0 , pos ) ;
@@ -138,7 +135,7 @@ abstract class SenderBufferBase implements SenderBuffer {
138135 }
139136
140137 /**
141- * Write the table name into the buffer of the sender .
138+ * Write the table name into the buffer.
142139 *
143140 * @param {string } table - Table name.
144141 * @return {Sender } Returns with a reference to this sender.
@@ -158,7 +155,7 @@ abstract class SenderBufferBase implements SenderBuffer {
158155 }
159156
160157 /**
161- * Write a symbol name and value into the buffer of the sender .
158+ * Write a symbol name and value into the buffer.
162159 *
163160 * @param {string } name - Symbol name.
164161 * @param {unknown } value - Symbol value, toString() is called to extract the actual symbol value from the parameter.
@@ -185,7 +182,7 @@ abstract class SenderBufferBase implements SenderBuffer {
185182 }
186183
187184 /**
188- * Write a string column with its value into the buffer of the sender .
185+ * Write a string column with its value into the buffer.
189186 *
190187 * @param {string } name - Column name.
191188 * @param {string } value - Column value, accepts only string values.
@@ -207,7 +204,7 @@ abstract class SenderBufferBase implements SenderBuffer {
207204 }
208205
209206 /**
210- * Write a boolean column with its value into the buffer of the sender .
207+ * Write a boolean column with its value into the buffer.
211208 *
212209 * @param {string } name - Column name.
213210 * @param {boolean } value - Column value, accepts only boolean values.
@@ -227,7 +224,7 @@ abstract class SenderBufferBase implements SenderBuffer {
227224 }
228225
229226 /**
230- * Write a float column with its value into the buffer of the sender .
227+ * Write a float column with its value into the buffer.
231228 *
232229 * @param {string } name - Column name.
233230 * @param {number } value - Column value, accepts only number values.
@@ -236,11 +233,12 @@ abstract class SenderBufferBase implements SenderBuffer {
236233 abstract floatColumn ( name : string , value : number ) : SenderBuffer ;
237234
238235 /**
239- * Write an integer column with its value into the buffer of the sender .
236+ * Write an integer column with its value into the buffer.
240237 *
241238 * @param {string } name - Column name.
242239 * @param {number } value - Column value, accepts only number values.
243240 * @return {Sender } Returns with a reference to this sender.
241+ * @throws Error if the value is not an integer
244242 */
245243 intColumn ( name : string , value : number ) : SenderBuffer {
246244 if ( ! Number . isInteger ( value ) ) {
@@ -256,7 +254,7 @@ abstract class SenderBufferBase implements SenderBuffer {
256254 }
257255
258256 /**
259- * Write a timestamp column with its value into the buffer of the sender .
257+ * Write a timestamp column with its value into the buffer.
260258 *
261259 * @param {string } name - Column name.
262260 * @param {number | bigint } value - Epoch timestamp, accepts numbers or BigInts.
@@ -282,7 +280,7 @@ abstract class SenderBufferBase implements SenderBuffer {
282280 }
283281
284282 /**
285- * Closing the row after writing the designated timestamp into the buffer of the sender .
283+ * Closing the row after writing the designated timestamp into the buffer.
286284 *
287285 * @param {number | bigint } timestamp - Designated epoch timestamp, accepts numbers or BigInts.
288286 * @param {string } [unit=us] - Timestamp unit. Supported values: 'ns' - nanoseconds, 'us' - microseconds, 'ms' - milliseconds. Defaults to 'us'.
@@ -308,7 +306,7 @@ abstract class SenderBufferBase implements SenderBuffer {
308306 }
309307
310308 /**
311- * Closing the row without writing designated timestamp into the buffer of the sender . <br>
309+ * Closing the row without writing designated timestamp into the buffer. <br>
312310 * Designated timestamp will be populated by the server on this record.
313311 */
314312 atNow ( ) {
@@ -323,7 +321,7 @@ abstract class SenderBufferBase implements SenderBuffer {
323321 }
324322
325323 /**
326- * Returns the current position of the buffer.
324+ * Returns the current position of the buffer. <br>
327325 * New data will be written into the buffer starting from this position.
328326 */
329327 currentPosition ( ) : number {
0 commit comments