Welcome to the official Driftr Blog! Driftr is a user-generated content site for travelers, by travelers.
 

Flickr Photo Streaming is back up

The good news is, Flickr reached photo number 2147483647 yesterday. Go Flickr!

The bad news is that number 2147483647 is the limit for signed integer data type.

How did that affect us?

Well, we use an awesome open source library called Phlickr to communicate with Flickr's API. Phlickr was treating photo IDs as signed integers and in turn stopping at 2147483647. As a result, images were missing from the display because they would be assigned the wrong photo ID.

If you're using the Phlickr client library, you need to update your library so that the photo IDs are treated as string and not integer (hint: look for sprintf.)



50 RESPONSES To "FLICKR PHOTO STREAMING IS BACK UP"

Long would also be perfectly acceptable.
Or just use an unsigned integer. For good meassure make it unsigned long.
No, string is a better solution. Even longs and unsigned longs will eventually run out. Remember that cameras are now close to outnumbering humans, and pretty soon we will have autonomous cameras all over the place snapping scheduled pictures. Human-scale numbers will no longer make sense in the future.
"Human-scale numbers"?

I think you mean, "machine-imposed numbers". Alternatively, you could use proper tools with infinitely bound integral types. Ever looked at the Church Numeral Encoding?
Mark: that is very optimistic to think that Flickr will hit the 9 quintillion photos mark before that 3rd party api is outdated.
> is very optimistic to think that Flickr will hit the 9 quintillion photos mark before ...

Once the world's population reaches 9 billion, that would only let each person upload a billion photos!

Er, ok, point taken.
"After this case and the next case, we only have 1 case left!"
No long would unlikely not do it. On alot of popular architectures, long is exactly similar to int.
using unsigned int would just mean flickr would get the same problem when the nr of images doubles.
unsigned long long is win.
Variable int and longs is only a problem in programing languages that are compiled to work with the processor like C or C++. It shouldn't be a problem with scripting languages.
Thanks guys for the feedback.

Actually, PHP doesn't support unsigned integers and I guess I could have used float instead of string to fix the bug.

Phlickr uses sprintf() to build the image URL and that function is a bit funky. For example, the type specifier (%u) supposed to indicate an unsigned integer but that doesn't really work since PHP doesn't support unsigned integers, so I opted to use string (%s) to be safe and solve the bug quickly.

I'll do my own testing with float and if that works I'll update the code.
*boggle* Use floats?

On most modern machines, an int is 4 bytes, and a float is 4 bytes. Moreover, some of those 4 bytes in the float are used up with the exponent. A simple application of the pigeonhole principle will show that there is a problem here!

Specifically, just because a float will go up way past 2147483647 doesn't mean it will treat 2147483647 and 2147483648 as different numbers (it won't).

You might get away with this for a while if you use double-precision floats (8 bytes), but that's just a really lame version of using a partly-neutered long long int. (Which, I suppose, if you don't have long long ints, is maybe justifiable, but is nontheless still Wrong.)

If you didn't want to use strings for this, a workable option would be using a pair of ints -- one for the first 9 digits of the number, and another for the next 9, giving you an 18-digit range. (Since you're making strings, dividing them on a power of 10 is easier than using a power of 2; normally you'd represent the number as int1*MAXINT+int2 in this kind of scheme.) But, unless you're doing calculations or are really pressed for memory space, a string should be fine.
Unless speed and database size are really, really important to you, just go with the string.
Tony Morris: By human-scale numbers, I mean numbers that are judged to be of sufficient size to deal with anything the human population of Earth can come up with.

The point is, we are about to be joined here on Earth, starting already but booming in about a decade or so, by a vastly larger population of robotic devices that generate digital artifacts like photographs. After that point, it no longer will make sense to talk about things in terms of "so many photographs for each person in the world." When dust motes have IP addresses, on-board cameras, and wireless connectivity, human-scale numbers will no longer make sense.

Some of the software we build today will persist into that era, so we need to start to accommodate larger numbers.
Actually, this how you represent real numbers in PHP using the sprintf() function and the float (%f) type specifier:

sprintf("http://www.mysite.com/?id=%.0f", $large_integer);

I think we'll stick with string (%s) since it works great in this situation since the number value isn't really used in any calculation and only in the image URL build.
[sigh]
Next time follow the API notes :)

http://www.flickr.com/services/api/misc.overview.html

"Note: The Flickr API exposes identifiers for users, photos, photosets and other uniquely identifiable objects. These IDs should always be treated as opaque strings, rather than integers of any specific type. The format of the IDs can change over time, so relying on the current format may cause you problems in the future."
If you know that a variable is numeric, it's good practice to cast the appropriate type on it, especially in dynamically typed languages like PHP.

Phlickr should be commended for using type specifiers other than string as a form of input sanitization and type enforcement.

I do understand Flickr's logic, but I don't think it's good practice.
"If you know that a variable is numeric, it's good practice to cast the appropriate type on it"

Fortunately, flickr told us clearly that it is not numeric. It's an opaque string. Converting them to ints isn't any kind of "type enforcement"-- you don't get to make the rules! At best it would be a space savings, but it's quite an inappropriate one here.
I agree that Phlickr should have followed Flickr's API recommendation because they "don't get to make the rules," but I still do understand the rationale behind Phlickr's defensive programming implementation.
If you're a blogger (or a blog reader), you're painfully familiar with people who try to raise their own websites' search engine rankings by submitting linked blog comments like "Visit my discount pharmaceuticals site." This is called comment spam, we don't like it either, and we've been testing a new tag that blocks it. From now on, when Google sees the attribute (rel="nofollow") on hyperlinks, those links won't get any credit when we rank websites in our search results. This isn't a negative vote for the site where the comment was posted; it's just a way to make sure that spammers get no benefit from abusing public areas like blog comments, trackbacks, and referrer lists.
Penis enlargement products at guaranteed cheap price!

penis enlargement pills, penis enlargement patches, penis enlargement devices, penis enlargement exercises, penis enlargement gel, and penis enlargement treatments with FDA approroved guaranteed. www.gordoniihoodia.net
FDA approroved guaranteed,free coupons on all products.Goodluck.American top penis enlargement vigrx plus's online store with very CHEAP PRICES Goodluck
http://www.penisenlargementincs.com
Penis enlargement treatments, solutions and natural herbal medicines to enlarge your penis naturally like 2-3 inches gain in penis size without any hesitation, worries and side effects for making your life more pleasureable and excited. www.penissizeenlargement.net
What is the imaginary world coming to?
Buyaviagra.net - viagra is used to treat impotence in men. Viagra increases the body's ability to achieve and maintain an erection during sexual stimulation. Viagra does not protect you from getting sexually transmitted diseases, including HIV. Boost your Sexual night with long lasting sex with VIAGRA. www.buyaviagra.net
Acomplia (rimonabant) is an anti-obesity drug. It was approved for marketing in the European Union in June 2006. Rimonabant is not yet approved for use in the United States, where it is known as Zimulti. www.acompliaonline.com
Information about best penis enlargement products penis enlargement pills penis enlargement device breast enlargement breast enlargement pills and other natural herbs, herbal remedies, herbal medicine, medicinal herbs, and herbal supplements for better health and healing.
http://www.nice-remedies.com
Penis enlargement for men introducing the best products for penis enlargement like Size Genetics – Mxman Pills – Prosolution – Jelq device – Jes Extender – Vigrx - Natural Gain Plus and many more health supplements.
http://www.smart-herbals.com
Unbeleivable technology is moving so quick and we can only keep up with so much
Love yor site it is a great idear and agreat way for the traveler to research information.
god work mkeep it up.
best of post so far bro
that was a nice post
that was a nice post
thanks
that was a nice post
American largest natural herbal health care products reviews for men and women health, general and sexual health, skin care and weight loss and much much more at free shipping in america with lowest price ever! www.gordoniihoodia.net
that was a nice post
Breast Enlargement & Breast Enhancement the first clinically proven option for the size and shape, information about breast beauty,boobs augmentation, boobs exercises, size and supplements at Ravissent.com.
that was interesting
Generic Acomplia is an Anti Obesity Drug that is Best Weight loss product in UK and Europe. www.genericacomplia.us
Penis enlargement products reviews for penis size enlargement by world's best natural herbal penis enlargement products like (penis pills, penis patches, penis devices, penis exercises and penis pumps) for increase penis size in girth and length in weeks with more harder and solid erections at www.penissizeenlargement.net
thanks for the info there
Natural Herbalz - We Care Your Health
An America's Best Online Natural herbal health care products Review Store On Mens and Womens health, Skin Care, General Health, Sexual Health, Hair Care, Weight loss and More Health Care products, Treatments, Articles and Information. www.naturalherbalz.com
Do herbal breast pills really work after all? From our online surveys it shows that a large number of women have tried the different pills out there. So what really works and what is just garbage? We let women vote on the different pills out on the market and tell us what worked or did not work for them. From the polls and information we have created our "pill review section" so that you can stop wasting time and money on dead end herbal supplements.
Do herbal breast pills really work after all? From our online surveys it shows that a large number of women have tried the different pills out there. So what really works and what is just garbage? We let women vote on the different pills out on the market and tell us what worked or did not work for them. From the polls and information we have created our "pill review section" so that you can stop wasting time and money on dead end herbal supplements.
Compare Breast Enhancers
Want to know what makes one Breast Enhancement pill different from another brand? Take a look here to see what makes one better than another.
It has been shown that women can increase their bust size 2 cup sizes when taking all natural Tobustan as directed.
Brepid is an all herbal supplement pill used to balance the hormonal levels in the female body. Brepid is used to achieve new growth tissue and firm up the breast during usage.

leave a comment

Name (required)
Email (hidden - required)
Website
Do butterflies swim or fly? (required)