Forum BigDB How to specify double as opposed to int when creating in AS3

Discussion and help relating to the PlayerIO database solution, BigDB.

How to specify double as opposed to int when creating in AS3

Postby actionsprite » July 22nd, 2010, 12:26 am

Hi,
I'm creating objects from AS3 via loadOrCreate, one of these Object fields is a number that can be as low as 3 digits, or up to 12. I need to be able to force the 3 digit numbers to be created as Double so that I can use an index to sort them all from lowest to highest.

Is there a way to do this? At the moment if the index is set to type int, it will ignore all the double entries, and vice versa.

Cheers,
JMC
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am

Re: How to specify double as opposed to int when creating in AS3

Postby Benjaminsen » July 22nd, 2010, 4:18 pm

Interesting issue, I have noted it as a bug and will get back to you ASAP

[Edit]
A bit more info

The bug is a result of a bug in the flash player that results in us not being able to determine the type of a number reliable. Thus we simply send in values in the smallest possible way. This was all fine until we added indexes which ignores values of the wrong type.

The good news is that it's fixed now for all cases where the user did not send in data in the wrong format.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: How to specify double as opposed to int when creating in AS3

Postby actionsprite » July 30th, 2010, 1:16 am

Hey Chris, any news on this one?
actionsprite
 
Posts: 21
Joined: June 26th, 2010, 1:01 am

Re: How to specify double as opposed to int when creating in AS3

Postby Henrik » August 3rd, 2010, 2:25 pm

Hey Actionsprite,

This issue should be fixed now. When you work with numerical indexes from AS3, BigDB will now try to interpret your given numbers as the type of the index. In your specific example, if you set the type of the property in your index to Long or Double, then any objects you create from AS3 that has a numeric value in that property will be indexed.

There are some rules though, BigDB will only try the following conversions:
int -> uint
int, uint -> long
int, uint, long -> float
int, uint, long, float -> double

This means that decimal numbers will never be converted to integers. If the index type of a property is "int", and you try to store an object with the value 100.0 in that property, it will not be indexed. It also means that larger types will not be converted to smaller types. If you store a double value in a property with the index type of float, it will not be indexed.

BigDB will also perform this conversion for method parameters, for example the parameters to the LoadRange method. If you have an index with a property of the type double, and you do a LoadRange to get all objects with a value between 100 and 200.0, this will work just fine, even though those two numbers are an int and a float, technically.
Henrik
.IO
 
Posts: 1855
Joined: January 4th, 2010, 1:53 pm


Return to BigDB