The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.

Forum Discussion

gkeushkerian's avatar
gkeushkerian
New Contributor II
3 years ago
Solved

Switch scenario, period and value members when looping data buffer cells

Hi. I am trying to forecast OpEx accounts based on a seeding method. I am storing the method on a specific month by account and some UD dimensions and based on the selected method want to apply diffe...
  • JackLacava's avatar
    3 years ago

    Basically in every loop you are:

    1. retrieving a very thin databuffer
    2. storing it into a new place
    3. clearing the buffer

    This is memory-light (good) but network-intensive (bad).

    An alternative could be:

    1. retrieving the buffer
    2. copying cells from there into a target buffer

    ... and then saving the buffer in one go at the end of the loop. This would be heavier in memory but much lighter on the network/database. To clarify, something like this:

     

    Dim targetBuffer as new DataBuffer()
    
    For Each cell As DataBufferCell In driverDataBuffer.DataBufferCells.Values
    	Select Case cell.CellAmount
    		case 104
    			Dim tempBuf as DataBuffer = api.data.GetDataBufferUsingFormula("FilterMembers(....)")
    			for each tempCell as DataBufferCell in tempBuf.DataBufferCells.Values
    				targetBuffer.SetCell(si, new DataBufferCell(tempCell))
    			next
    		...
    next
    
    api.Data.SetDataBuffer(targetBuffer, destinationExpressionInfo,,, "O#Import",,,,,,,,,, True)
    				
    			 

     

    Do your benchmarking, but I suspect this would be significantly faster.