Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transferring huge list of strings to service layer

 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my data layer, I will be querying my data store to fetch a single column. But the rows will be large enough containing thousands of records.

My JDBC block of code will be something along these lines:



I have been bitten many times before by memory exhaustion errors. I want to avoid that and be in the know of the convention to take care of transfer of humongous list. How would you go about if this was your problem.

One more question that strikes me to be an issue is - Does it justify creating a Java bean when I have only one field?

Mods, don't know if this is more suited to the Java in general forum.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What will you do with those thousands of records after fetching them?
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send it to the client which is not necessarily a web presentation layer but a normal main method of a class. And when that is done read it one by one.
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The nature of the client is important because that determines if it makes sense to retrieve those thousands at all or not. Clients intended to be read by humans should not return more than 100 records at a time because humans won't be able to analyse that volume anyway. Typically one uses the ValueListHandler pattern to implement server side pagination and return the data in smaller chunks. That way you can control scalability by adjusting the page size. Of course this only works if the data can be processed/viewed in chunks.
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears to me that I am out of options here as the client should not be able to read records just that it should be transferred to it. I think I might have been kind of vague with the word read. Nonetheless I learned how the pagination is handled in the presentation layer by making use of Value List Handler and for that I am quite grateful.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic