Answer the question
In order to leave comments, you need to log in
How to count the number of numbers greater than the amount of memory?
Good time of the day!
Help me understand and find the right direction, I'm doing a test task. I need to "calculate and pass the number of numbers that exceeds the amount of available memory".
Those. does this need to be done with some kind of buffer (such as a text file) or are there more advanced techniques in php?
Answer the question
In order to leave comments, you need to log in
Where do the numbers come from, where do they go, exactly how to count and transmit.
They would cut out all the words in general except for one, so that it would be clearer xD
To count, you must first take them and collect them in a heap, if they go in a stream, then collect them somewhere in the database / file.
And then just send the pieces further.
You can also calculate the file in stream mode, for example, without reading the whole file at a time. (google for the name of the PL + streaming reader).
on coffee grounds if you guess, then such an answer.
зарплатой потом поделитесь?)
Count in portions that fit in memory, give in portions. If you need to give the total volume in the headers, then add it to the disk during the calculation, simultaneously calculating the volume, then give the headers to give from the disk in portions ... Something like that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question