NCBI C++ ToolKit
|
Go to the source code of this file.
Go to the SVN repository for this file.
Classes | |
struct | dblib_buffer_row |
Macros | |
#define | BUFFER_CHECK(buf) do {} while(0) |
Typedefs | |
typedef struct dblib_buffer_row | DBLIB_BUFFER_ROW |
Definition at line 80 of file buffering.h.
typedef struct dblib_buffer_row DBLIB_BUFFER_ROW |
|
static |
Called by dbnextrow Returns a row buffer index, or -1 to indicate the buffer is full.
Definition at line 487 of file buffering.h.
References assert, buf, buffer_idx_increment(), buffer_is_full(), buffer_row_address(), tds_column::column_cur_size, tds_result_info::columns, dbproc, free(), i, if(), NULL, tds_result_info::num_cols, tds_result_info::ref_count, row, tds_dblib_dbprocess::row_buf, tds_free_results, tds_free_row, and tds_new0.
Definition at line 463 of file buffering.h.
References assert, buf, buffer_reset(), dbproc, NULL, tds_dblib_dbprocess::row_buf, and tds_new0.
|
static |
A few words on the buffering design.
DBPROC_ROWBUF::buf is a block of row buffers, managed as a ring, indexed by head, tail, and current:
head – where new elements are inserted. tail – oldest element. current – active row (read by dbgetrow/dbnextrow)
capacity is the number of rows that buf can hold.
Each element in buf is preceded by its row_number: the result_set row number, determined by counting the rows as they're received from the server. Applications communicate to db-lib in row numbers, not buffer indices.
Semantics: head == 0 && tail == capacity is the initial condition. head == tail means the buffer is full, except when capacity is 1. head < tail means the buffer has wrapped around.
Whether or not buffering is active is governed by dbproc->dbopts[DBBUFFER].optactive.
number of rows in the buffer
Definition at line 112 of file buffering.h.
References buf, and BUFFER_CHECK.
Referenced by buffer_delete_rows(), buffer_is_full(), and buffer_struct_print().
Return the current row buffer index.
We strive to validate it first. It must be: between zero and capacity (obviously), and between the head and the tail, logically.
If the head has wrapped the tail, it shouldn't be in no man's land. IOW, if capacity is 9, head is 3 and tail is 7, good rows are 7-8 and 0-2. (Row 3 is about-to-be-inserted, and 4-6 are not in use.) Here's a diagram: d d d ! ! ! ! d d 0 1 2 3 4 5 6 7 8 ^ ^ Head Tail
The special case is capacity == 1, meaning there's no buffering, and head == tail === 0.
Definition at line 405 of file buffering.h.
References assert, buf, buffer_struct_print(), dbproc, and tds_dblib_dbprocess::row_buf.
|
static |
Deleting a row from the buffer doesn't affect memory allocation.
It just makes the space available for a different row.
Definition at line 275 of file buffering.h.
References buf, BUFFER_CHECK, buffer_count(), buffer_free_row(), buffer_idx_increment(), buffer_reset(), buffer_struct_print(), and i.
|
static |
Definition at line 177 of file buffering.h.
References buf, BUFFER_CHECK, buffer_free_row(), i, NULL, and TDS_ZERO_FREE.
Referenced by buffer_set_capacity().
|
static |
Definition at line 153 of file buffering.h.
References NULL, row, tds_free_results, tds_free_row, and TDS_ZERO_FREE.
Referenced by buffer_delete_rows(), and buffer_free().
|
static |
Convert an index to a row number.
Definition at line 231 of file buffering.h.
References buf, BUFFER_CHECK, buffer_row_address(), and dblib_buffer_row::row.
Referenced by buffer_row2idx().
|
static |
Definition at line 202 of file buffering.h.
References buf.
Referenced by buffer_add_row(), buffer_delete_rows(), buffer_row2idx(), and buffer_transfer_bound_data().
|
static |
Definition at line 132 of file buffering.h.
References buf, BUFFER_CHECK, buffer_struct_print(), head, TDS_DBG_FUNC, and tdsdump_log.
Referenced by buffer_transfer_bound_data().
|
static |
Can the buffer be written to?
Definition at line 124 of file buffering.h.
References buf, BUFFER_CHECK, and buffer_count().
Referenced by buffer_add_row().
|
static |
Definition at line 194 of file buffering.h.
References buf, and BUFFER_CHECK.
Referenced by buffer_alloc(), and buffer_delete_rows().
|
static |
Convert a row number to an index.
Definition at line 241 of file buffering.h.
References assert, buf, BUFFER_CHECK, buffer_idx2row(), buffer_idx_increment(), and i.
|
static |
Given an index, return the row storage, including the DBINT row number prefix.
Definition at line 215 of file buffering.h.
References buf, BUFFER_CHECK, buffer_struct_print(), NULL, TDS_DBG_WARN, and tdsdump_log.
Referenced by buffer_add_row(), buffer_idx2row(), and buffer_transfer_bound_data().
Save current row into row buffer.
Definition at line 533 of file buffering.h.
References buf, dbproc, row, tds_dblib_dbprocess::row_buf, SUCCEED, and tds_alloc_row.
Definition at line 434 of file buffering.h.
References assert, buf, BUFFER_CHECK, buffer_free(), dbproc, and tds_dblib_dbprocess::row_buf.
|
static |
Definition at line 373 of file buffering.h.
References assert, buf, buffer_count(), TDS_DBG_FUNC, and tdsdump_log.
Referenced by buffer_current_index(), buffer_delete_rows(), buffer_index_valid(), and buffer_row_address().
|
static |
Transfer data from buffer/tds back to client.
Definition at line 307 of file buffering.h.
References assert, buf, BUFFER_CHECK, buffer_idx_increment(), buffer_index_valid(), buffer_row_address(), tds_column::column_bindlen, tds_column::column_bindtype, tds_column::column_cur_size, tds_column::column_data, tds_column::column_nullbind, tds_column::column_size, tds_column::column_type, tds_column::column_varaddr, copy_data_to_host_var, dbgetnull, dbproc, i, is_blob_col, row, TDS_DBG_FUNC, tds_get_conversion_type, and tdsdump_log.