This discussion is archived
2 Replies Latest reply: Jun 12, 2008 5:31 AM by 807591 RSS

How should I handle this? - Large String.

807591 Newbie
Currently Being Moderated
Here is my situation.

I am running a spell check and returning a HTML report with all the misspelled words in bold.

The thing is there could be hundres of records in the database that get return to the spell check and I have to check around 8 varchar(max) fields in each record.

I began doing this with a StringBuffer but I am thinking this is going to kill memory. So I was thinking about using a StringWriter to create the string but I am assuming this is also going to kill memory. In fact im sure whatever I do there will be alot of memory usage.

I am thinking returning a large chunk of HTML to my JSP might be slow. Another option I thought of would be to generate a PDF or something and return a link to the file. I was also thinking of subclassing my transport class to hold the spelling correction HTML and return a collection of them to the JSP and iterate throught them.

Any thoughs on how I should habndle this?

Thanks,

Al
  • 1. Re: How should I handle this? - Large String.
    807591 Newbie
    Currently Being Moderated
    I began doing this with a StringBuffer but I am thinking this is going to kill memory
    Unless you've profiled and know that you have memory problems, don't spend a lot of your time worrying about them.

    Any thoughs on how I should habndle this?
    Do the simplest thing that could possibly work. Then analyze and change if necessary.

    You don't say how large your strings are. Are we talking 10kb or 10mb? If the latter, you're going to have issues with whatever you do, including downloading all that text from server. If the former, it's not going to make a big different whatever you do, so don't sweat it. Since you're talking varchars, which I believe have a 64k limit under ANSI-92, it sounds like the former.

    If you run into problems with simple StringBuffer manipulation, you can think of some sort of piped approach: design your spell-checker to take a Reader as input, and a Writer as output.
  • 2. Re: How should I handle this? - Large String.
    807591 Newbie
    Currently Being Moderated
    Thanks. The String could potentionally be huge varchar(max) in SQL Server can stor up to 2gigs, but I most of our users only use about 100K.

    I'll use the StringBuffer and see how it goes.

    Al