| 173 | |
| 174 | |
| 175 | USHORT REMOTE_compute_batch_size(rem_port* port, |
| 176 | USHORT buffer_used, P_OP op_code, |
| 177 | const rem_fmt* format) |
| 178 | { |
| 179 | /************************************** |
| 180 | * |
| 181 | * R E M O T E _ c o m p u t e _ b a t c h _ s i z e |
| 182 | * |
| 183 | ************************************** |
| 184 | * |
| 185 | * Functional description |
| 186 | * |
| 187 | * When batches of records are returned, they are returned as |
| 188 | * follows: |
| 189 | * <op_fetch_response> <data_record 1> |
| 190 | * <op_fetch_response> <data_record 2> |
| 191 | * ... |
| 192 | * <op_fetch_response> <data_record n-1> |
| 193 | * <op_fetch_response> <data_record n> |
| 194 | * |
| 195 | * end-of-batch is indicated by setting p_sqldata_messages to |
| 196 | * 0 in the op_fetch_response. End of cursor is indicated |
| 197 | * by setting p_sqldata_status to a non-zero value. Note |
| 198 | * that a fetch CAN be attempted after end of cursor, this |
| 199 | * is sent to the server for the server to return the appropriate |
| 200 | * error code. |
| 201 | * |
| 202 | * Each data block has one overhead packet |
| 203 | * to indicate the data is present. |
| 204 | * |
| 205 | * (See also op_send in receive_msg() - which is a kissing cousin |
| 206 | * to this routine) |
| 207 | * |
| 208 | * Here we make a guess for the optimal number of records to |
| 209 | * send in each batch. This is important as we wait for the |
| 210 | * whole batch to be received before we return the first item |
| 211 | * to the client program. How many are cached on the client also |
| 212 | * impacts client-side memory utilization. |
| 213 | * |
| 214 | * We optimize the number by how many can fit into a packet. |
| 215 | * The client calculates this number (n from the list above) |
| 216 | * and sends it to the server. |
| 217 | * |
| 218 | * The data size is either the XDR data representation, or the |
| 219 | * actual message size (rounded up) if this is a symmetric |
| 220 | * architecture connection. |
| 221 | * |
| 222 | **************************************/ |
| 223 | |
| 224 | const USHORT op_overhead = (USHORT) xdr_protocol_overhead(op_code); |
| 225 | |
| 226 | #ifdef DEBUG |
| 227 | fprintf(stderr, |
| 228 | "port_buff_size = %d fmt_net_length = %d fmt_length = %d overhead = %d\n", |
| 229 | port->port_buff_size, format->fmt_net_length, |
| 230 | format->fmt_length, op_overhead); |
| 231 | #endif |
| 232 |
no test coverage detected