OLAPCellWriteBuffer

When working with OLAP databases, you must set cell values frequently. In many cases, you must set the values of thousands or even millions of cells. Naturally, such operations should be performed as fast as possible. The fastest solution is to combine many requests to the OLAP into a single one. That is the purpose of the OLAPCellWriteBuffer data type and its functions. An OLAPCellWriteBuffer object accumulates operations on cells and eventually commits them all at once.

You can create an OLAPCellWriteBuffer object like this:

OLAPConnection connection = OLAPCreateNamedConnection("");
OLAPCellWriteBuffer buffer = OLAPCreateCellWriteBuffer(olapconnection);
OLAPSetAutoCommit(buffer, true);
OLAPSetMaxUncommittedValues(buffer, 100);

If you set the auto-commit property of an OLAPCellWriteBuffer, it sends its content automatically to the OLAP. The content is sent when the number of elements in the buffer reaches a certain threshold. You can adjust the threshold with the OLAPSetMaxUncommittedValues function. In the code above the buffer sends its content to the OLAP as soon as it contains more than 100 entries.

To fill the buffer, you can use several functions:

string cubeName = “DEMO”;
OLAPCellWriteBufferWriteNumber(buffer, cubeName, "Element1", "Element2", "Element3");
OLAPCellWriteBufferSetComment(buffer, cubeName, "A Comment", "Element1", "Element2", "Element4");
OLAPCellWriteBufferDeleteComment(buffer, cubeName, "Element1", "Element2", "Element5");
OLAPCellWriteBufferDeleteValue(buffer, cubeName, "Element1", "Element2", "Element6");
OLAPCellWriteBufferDeleteCell(buffer, cubeName, "Element1", "Element2", "Element7");

Eventually, you must commit the buffer’s content to the OLAP database:

OLAPCommitCellWriteBuffer(buffer);