Skip Navigation

Seeing the same pictures...

Travel Forums System Talk Seeing the same pictures...

Page
  • 1
  • 2

Last Post

11. Posted by Sander (Moderator 4835 posts) 11y

Okay, since you asked for it... *fingers hovering over keyboard, all ready to give a long-winded technical explanation with at least four new terms per line that you probably will also be unfamiliar with*

No actually, let me see if I can really explain this...

Okay. Information. There's a lot of it. That there is a lot is good, but also bad.
Let's stick with the photographs example. We have... well, I don't know how many, but many featured photographs here on travellerspoint now.
Now, in the dark ages of computers, what we'd do is create one long list of information about all the photographs. Envision notepad, and every time someone uploads a photograph, we add a line of the textfile in notepad with the name of this file, how large it is, who uploaded it, etc.
Then, when we want to do something like show a list of pictures, we read in the file, and for each line, show the picture.
This works well if there are only a few pictures, but when the list is getting thousands and thousands of lines long, that doesn't work so well anymore - reading a file takes time, and we'd have to do this every single time...
It especially doesn't work very well if you don't want to show all photographs, but only a few of them (say only the pictures uploaded by you). Now you still need to look at all these lines of the names of photographs, while you're not even interested in most them. And looking at those lines takes time. Maybe only 0.005 seconds per line, but for a thousand pictures, that's 5 seconds spent looking at information that you don't want. The site would be crawlingly slow if that's what we did.
The problem is, we can't just skip reading all those lines, because we don't know which lines hold the information on the pictures that we do want.

Now, a hash table is a solution to (part of) this problem. Basically you take something unique about the picture, throw this into a special mathematical function (called a hash function), and you get a "random number" back. Say you have space to hold a list of tenthousand pictures, then the number will be randomly chosen between 0 and 10,000, but for a given picture, every time you throw it through the function, you'll get the same number. So instead of just writing the information about a newly uploaded photograph right below the information of the previous one - you store it on the linenumber that you got out of the hash function.
Now later on you will no longer need to read all the lines in the file, but instead just calculate the hash values, and then read only those lines you're interested in.

There's far more to it, and there are major inaccuracies in the above, but I think this is already quite a lot, and accurate enough for the time being... :D

Of course, a lot of modern computing doesn't even expose hash tables to programmers anymore - it just all happens transparently, and we do these magical things with databases which just happen to work really really quickly, so we don't need to think about any of this at all. :)

12. Posted by Wocca (Inactive 3745 posts) 11y

You are right about long-winded & unfamiliarity. I have absolutely no idea what you are talking about. Even though I have studied computer engineering and graphic art, I must have forgotten it all by now it seems. A dissertation on technical perfection only tends to confuse. Any chance of a simple answer in lay terms without the "blog" thoughts?

13. Posted by Sander (Moderator 4835 posts) 11y

You need to understand the problemspace before you can understand what it is, as it's a technical solution to the problem.

But okay, really, really general: a hash-table is a way to store information in such a way that it can easily be retrieved.

'course, that sentence describes several score things which aren't hash-tables as well, but... :)

14. Posted by Wocca (Inactive 3745 posts) 11y

Cheers Sander ...

15. Posted by Cupcake (Travel Guru 8468 posts) 11y

(nodding head again...ummmm uhhhh....I had my son read it, but computers are his life. HE gets it!;) Thank you for trying to explain it to me.
:)

16. Posted by Isadora (Travel Guru 13926 posts) 11y

Reminds me of the old "random number generator" programs with a twist for photographs. Thanks Sander, made (mostly) complete sense to me. (I must admit, I knew what "hash tables" were so that helped.)

17. Posted by Sam I Am (Admin 5588 posts) 11y

Hi Greg,

Sander's absolutely right about the random photos (probably the other stuff too but I am lost on that myself!). The front page shows randomly one of the last 20 pics that have been featured. This generally coincides with upload dates and changes gradually but if Pete or me had a spree and there were a lot of great photos uploaded we could theoretically feature 20 new ones in one day and push the first 20 back. The reason for limiting it to 20 is purely for processing times as there are several hundred photos now featured and growing daily, as well as several thousand visits to the home page daily. It also keeps the pics fresh and new for visitors that come back a lot. So far nothing new.

However, you might very well see that same picture displayed on some other pages randomly, even if it is not one of the 20 latest featured .... Currently this is only the case on the members profile pages or on the destination specific pages (Australia for example). Here the random picture displayed is also limited to the last 20, but it is then further limited to either the last 20 uploaded by the member (member profile page) or the last 20 featured about that destination (destination guides).

For most destinations, there are less than 20 pics so they will all display but for Oz it shouldn't be the case. I haven't actually confirmed this with the code by the way, but am 90% sure that should be accurate. Anyway, my point was that you could still find the same picture appearing randomly on other areas of TP, besides of course the travel photo gallery itself!

Cheers,

Sam

18. Posted by GregW (Travel Guru 2635 posts) 11y

Quoting Sam I Am

The front page shows randomly one of the last 20 pics that have been featured.

Right, so the reason I see the same pictures again within the same day is because there is only 20 to choose from. If you come more than 20 times in a day, then you are bound to see the same picture again.

Really, this speaks to how much I am addicted to coming to the site more than any sort of computer related topic...

Greg

19. Posted by areinstein (Travel Guru 2788 posts) 11y

Quoting GregW

I thought I did good by avoiding the use of the term "hash-table" but apparently not...

And here I thought Greg was referring to himself doing some type of drugs on his table...while he logs on TP

20. Posted by Peter (Admin 5813 posts) 11y

Yes, the main reason is it's limited to the last 20 featured photos, done to ensure that new pictures are displayed prominently for a period. Otherwise, over hundreds of photos, newly featured ones would barely be noticed! There is a good stream of nice photos coming in though, so I'd say on average the 20 featured pics last just over a week at the moment.

Also though, when you're not logged in to TP, the front page only refreshes every 15 minutes, including the photo.

Page
  • 1
  • 2