* @returns {{header: FrameHeader, chunk: Buffer, offset: number}}
(columnLength, rowLength, fromIndex, toIndex, cellValue, streamId)
| 1224 | * @returns {{header: FrameHeader, chunk: Buffer, offset: number}} |
| 1225 | */ |
| 1226 | function getBodyChunks(columnLength, rowLength, fromIndex, toIndex, cellValue, streamId) { |
| 1227 | let i; |
| 1228 | let fullChunk = [ |
| 1229 | //kind |
| 1230 | 0, 0, 0, types.resultKind.rows, |
| 1231 | //flags and column count |
| 1232 | 0, 0, 0, 1, 0, 0, 0, columnLength, |
| 1233 | //column names |
| 1234 | 0, 1, 97, //string 'a' as ksname |
| 1235 | 0, 1, 98 //string 'b' as tablename |
| 1236 | ]; |
| 1237 | for (i = 0; i < columnLength; i++) { |
| 1238 | fullChunk = fullChunk.concat([ |
| 1239 | 0, 1, 99 + i, //string name, starting by 'c' as column name |
| 1240 | 0, types.dataTypes.text //short datatype |
| 1241 | ]); |
| 1242 | } |
| 1243 | //rows length |
| 1244 | fullChunk = fullChunk.concat([0, 0, 0, rowLength || 0]); |
| 1245 | for (i = 0; i < rowLength; i++) { |
| 1246 | let rowChunk = []; |
| 1247 | for (let j = 0; j < columnLength; j++) { |
| 1248 | //4 bytes length + bytes of each column value |
| 1249 | if (!cellValue) { |
| 1250 | rowChunk.push(0); |
| 1251 | rowChunk.push(0); |
| 1252 | rowChunk.push(0); |
| 1253 | rowChunk.push(1); |
| 1254 | //value |
| 1255 | rowChunk.push(j); |
| 1256 | } |
| 1257 | else { |
| 1258 | rowChunk = rowChunk.concat(cellValue); |
| 1259 | } |
| 1260 | } |
| 1261 | fullChunk = fullChunk.concat(rowChunk); |
| 1262 | } |
| 1263 | |
| 1264 | return { |
| 1265 | header: getFrameHeader(fullChunk.length, types.opcodes.result, null, null, streamId), |
| 1266 | chunk: utils.allocBufferFromArray(fullChunk.slice(fromIndex, toIndex || undefined)), |
| 1267 | offset: 0 |
| 1268 | }; |
| 1269 | } |
| 1270 | |
| 1271 | function getEventData(eventType, value) { |
| 1272 | const bodyArray = []; |
no test coverage detected