MCPcopy
hub / github.com/mongodb/node-mongodb-native / makeSections

Method makeSections

src/cmap/commands.ts:588–601  ·  view source on GitHub ↗

* Add the sections to the OP_MSG request's buffers and returns the length.

(buffers: Uint8Array[], document: Document)

Source from the content-addressed store, hash-verified

586 * Add the sections to the OP_MSG request's buffers and returns the length.
587 */
588 makeSections(buffers: Uint8Array[], document: Document): number {
589 const sequencesBuffer = this.extractDocumentSequences(document);
590 const payloadTypeBuffer = ByteUtils.allocateUnsafe(1);
591 payloadTypeBuffer[0] = 0;
592
593 const documentBuffer = this.serializeBson(document);
594 // First section, type 0
595 buffers.push(payloadTypeBuffer);
596 buffers.push(documentBuffer);
597 // Subsequent sections, type 1
598 buffers.push(sequencesBuffer);
599
600 return payloadTypeBuffer.length + documentBuffer.length + sequencesBuffer.length;
601 }
602
603 /**
604 * Extracts the document sequences from the command document and returns

Callers 1

toBinMethod · 0.95

Calls 3

serializeBsonMethod · 0.95
pushMethod · 0.45

Tested by

no test coverage detected