Receiving data from a map
Use the Put method to receive data from a map through stream objects. There are two different ways of accomplishing this. The method chosen depends on the manner in which the data has to be sent to the resource.
- The data must be passed to the resource as a single, contiguous
buffer.In this example, the buffer is obtained from the stream and passed to the resource:
This copies the data from the stream page(s) to the buffer.mpiStreamGetSize (hStream, &nSizeOfData); pData = malloc(nSizeOfData); mpiStreamRead (hStream, pData, nSizeOfData, &iBytesRead);
- The data can be passed to the resource as a number of small buffers.In this example, each page is obtained from the stream and is then passed to the resource:
There might be scenarios where it is acceptable to send data to the resources in pieces, but the size of the pieces might not correspond to the size of a page. As an example, consider database rows. It is possible that a row of data spans across page boundaries. The adapter must expect and be able to handle this.while(TRUE) { mpiStreamIsEnd (hStream, &bIsEnd); if (bIsEnd) break; mpiStreamReadPage (hStream, &hPage); mpiStreamPageGetInfo (hPage, &pData, &nSizeOfPage, &nSizeOfData); MySendData (pData, nSizeOfData); }