How can I use a fetch result as a hashmap ?

How can I use a fetch result as a hashmap ?

  

Hello 


My app fetches a talk list with the post user's icon.

But it fetches one icon for each row of a post.

(if a user have 2 post, the app seems to get 2 binary data for the icon)


I'd like to first fetch a user list with the icon, and then fetch the talk list 

with the id of user list, and just to show the icon with through a link to the user list ( in hashmap )


Could your tell me how can I do this , or if there is other way to do this ?


here is my data fetch

Hi Tenchi,

The fact that you see the binary for a users icon multiple times in your aggregate doesn't necessarily mean that it is fetched two times. It just means that when you use your aggregate, that for every task the related users attributes are available.

Do you experience an performance problem with your current solution? If not, I suggest you keep the current aggregate.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Tenchi,

The fact that you see the binary for a users icon multiple times in your aggregate doesn't necessarily mean that it is fetched two times. It just means that when you use your aggregate, that for every task the related users attributes are available.

Do you experience an performance problem with your current solution? If not, I suggest you keep the current aggregate.

Regards,

Daniel

Hello Daniël 


Thanks for your reply. The performance is obviously became late, when I change a icon(1byte) to a heavier one(400byte).And also it is late when it fetches 3 talks than fetches one. So I thought it gets the binary data as many times as the number of row.


This is data sources for the fetch.

Solution

Hello Tenchi.

You are right in saying that the aggregate will return every row with its own pibture information, even if this information is "repeated".

I would try two different approaches here.

1. Being a mobile application (as it seems), I would use a local storage to store the icons. This sinchronization can be made at the moment the conversation is being fetched. So, you fetch the ID's and if the id is not found locally you can download them and than use this to show the icons. In this situation, the talk and the icons would be loaded separately.

2. Create a web page to download the icons and in the mobile, fetch the "URL" and use it in the image, instead of a direct image. While I didn't tested it in mobile, I think it will work the same way as in web: cache. So the first time image is loaded, it is loaded from the server, the others will be fetched from cache. 

I would prefer the option 2 for a potential big number of images.

Hope this helps.

Cheers

Solution

Eduardo Jauch wrote:

Hello Tenchi.

You are right in saying that the aggregate will return every row with its own pibture information, even if this information is "repeated".

I would try two different approaches here.

1. Being a mobile application (as it seems), I would use a local storage to store the icons. This sinchronization can be made at the moment the conversation is being fetched. So, you fetch the ID's and if the id is not found locally you can download them and than use this to show the icons. In this situation, the talk and the icons would be loaded separately.

2. Create a web page to download the icons and in the mobile, fetch the "URL" and use it in the image, instead of a direct image. While I didn't tested it in mobile, I think it will work the same way as in web: cache. So the first time image is loaded, it is loaded from the server, the others will be fetched from cache. 

I would prefer the option 2 for a potential big number of images.

Hope this helps.

Cheers

Thank you Eduardo!

 I'd like to try both those approaches and choose one performs better.