开发者

What object to hold a large amount of text in?

开发者 https://www.devze.com 2023-03-20 06:02 出处:网络
I am planning a Seaside app to hold text, a single instance which may be up to, say, 5Mb. What kind of object is best for this?

I am planning a Seaside app to hold text, a single instance which may be up to, say, 5Mb. What kind of object is best for this?

I would also like to do some iterations over this text.

开发者_如何学GoThanks, Vince

Edit: Thanks for your replies thus far. The file is a CSV file that takes ~40 minutes to generate from a legacy finance system, so it must be pre-generated and stored. Each line is a customer record and I need to pull each one out and use the values as and when the customer logs in. Customer access is not predictable and interfacing with the legacy system to generate each line on the fly is a very last resort.


Given that the file takes that long to generate and that you need more-or-less random access to the file later on, I would opt for parsing the file and keeping the structured data in memory afterwards.

There is a CSV Parser project on Squeaksource that you can use. It will create a structured object tree of the CSV records that you can use.


Use an external Text file and some instance of a specific class as representation of that file. Use the oop of the object as the name of the file.


Just use a collection of customers, and fill it from the CSV, as Johan said. Depending on your accessing needs you can use a Dictionary or an OrderedCollection to hold it.


5 megs is nothing. Don't worry about that.

If you can't reify those CSV records into objects (after parsing and instantiating them), then a Collection of Strings or even Streams would be just fine.

If you need keyed lookup then a Dictionary or LookupTable would do the job.

I had 100 megs of text data in memory (1 millon rows), and even persisted in the image (image save) with no problems.

Regards.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号