Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to handle billions of objects without "Outofmemory" error
    primarykey
    data
    text
    <p>I have an application which may needs to process billions of objects.Each object of is of TRange class type. These ranges are created at different parts of an algorithm which depends on certain conditions and other object properties. As a result, if you have 100 items, you can't directly create the 100th object without creating all the prior objects. If I create all the (billions of) objects and add to the collection, the system will throw Outofmemory error. Now I want to iterate through each object mainly for two purposes:</p> <ol> <li>To apply an operation for each TRange object(eg:Output certain properties)</li> <li>To get a cumulative sum of a certain property.(eg: Each range has a weight property and I want to retreive totalweight that is a sum of all the range weights).</li> </ol> <p>How do I effectively create an Iterator for these object without raising Outofmemory?</p> <p>I have handled the first case by passing a function pointer to the algorithm function. For eg:</p> <pre><code>procedure createRanges(aProc: TRangeProc);//aProc is a pointer to function that takes a //TRange var range: TRange; rangerec: TRangeRec; begin range:=TRange.Create; try while canCreateRange do begin//certain conditions needed to create a range rangerec := ReturnRangeRec; range.Update(rangerec);//don't create new, use the same object. if Assigned(aProc) then aProc(range); end; finally range.Free; end; end; </code></pre> <p>But the problem with this approach is that to add a new functionality, say to retrieve the Total weight I have mentioned earlier, either I have to duplicate the algorithm function or pass an optional out parameter. Please suggest some ideas.</p> <p>Thank you all in advance<br/> Pradeep</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload