Forum BigDB Can't load range

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

Can't load range

Postby kidkid » January 6th, 2011, 9:49 am

Hi,
I have a database and some records on it.
I have created a indexes called "CreatedDate"
I want to load its record so I have using this code:

m_client.bigDB.loadRange(m_strFlashesTable,"CreatedDate",[new Date("2010,10,01")],new Date("2010,10,01"),new Date("2010,10,29"),100,HandleGetFlashesByDateSuccess);

and

m_client.bigDB.loadRange(m_strFlashesTable,"CreatedDate",null,null,null,5,HandleGetFlashesByDateSuccess);

The callback function is :
protected function HandleGetFlashesByDateSuccess(objArr: Array):void{
var lengh: int = objArr.length;
Alert.show("Get Success");

}

But lengh is always zero. I don't know why this code can't load objects.
Is something wrong with my code ?
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby kidkid » January 6th, 2011, 9:59 am

I think the problem is Date Type.
I dont' know what I should do.
I has tested with int type and it seem ok. :|
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby Oliver » January 6th, 2011, 2:42 pm

What type did you use for the index. Most likely you'll want to use DateTime and not Date
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Can't load range

Postby Henrik » January 6th, 2011, 2:46 pm

Two things:

If your index only has a single property, you should pass in null in the "path" argument, not a date.

Are you sure AS3 can parse that string as a valid date? What happens if you try something like this:

Code: Select all
m_client.bigDB.loadRange(m_strFlashesTable, "CreatedDate", null, new Date(2010,10,01), new Date(2010,10,29), 100, HandleGetFlashesByDateSuccess);
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Can't load range

Postby kidkid » January 7th, 2011, 9:05 am

Hey thanks for your quick reply.

I has loaded it today with last code.
I don't know why.
I will check it again.
Thanks so much.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby kidkid » January 10th, 2011, 9:08 am

Hi I have checked it and I has found a funny problem.

If I use this statement for load DB:
m_ctrServerController.GetFlashesByDate(new Date("2010,10,01"),
new Date("2010,11,01"),20,
HandleGetFlashesSuccess,
HandleGetFlashesFail);

it'll load nothing.

But If I change it to :
m_ctrServerController.GetFlashesByDate(new Date("2010,10,01"),
new Date(2010,11,01),20,
HandleGetFlashesSuccess,
HandleGetFlashesFail);

It'll load success.

And I don't know why basically.

I will post a video soon.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby kidkid » January 10th, 2011, 9:43 am

kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby Henrik » January 10th, 2011, 10:57 am

kidkid wrote:new Date("2010,11,01")

This means: Parse the string "2010,11,01" as a date, and that can either result in 11th of January or 1st of November, depending on the locale of the machine that the code is running on. Don't do that.

kidkid wrote:new Date(2010,11,01)

This means: Make a new date with the year 2010, the month 11, and the day 01, which always returns the 1st of November. You should write your date literals like this.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Can't load range

Postby kidkid » January 10th, 2011, 3:42 pm

I don't know why I couldn't reply.
Maybe my network down.

:| Still don't know whether this reply will be posted.

@Henrik: please look at my code again, if I use new Date(2010,11,01) for both case, I also get error.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby Henrik » January 10th, 2011, 4:01 pm

kidkid wrote:@Henrik: please look at my code again, if I use new Date(2010,11,01) for both case, I also get error.

Do you get an actual error, or do you not get any records back?

Does your table contain any objects with a CreatedDate between 1st of October 2010 and 1st of November 2010?

When you called your method with the arguments new Date("2010,10,01") and new Date(2010,11,01), you were asking it to load objects from that table with a CreatedDate between 10th of January 2010 and 1st of November 2010, maybe the objects you got then had a CreatedDate between 10th of January and 1st of October so that they would show up in that load, but not the one you actually wanted?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Can't load range

Postby kidkid » January 12th, 2011, 9:29 am

yes I have uploaded some records in that range.

Now, I have changed the index, and I have problem relate to its collection.

First, I changed the index from date: DateTime to month:int
And I also deleted old record and add some new records.
I has been waiting for hour to see its index collection, but it just collect some of my record.

Please, take a look at my attached picture.

Thanks.
Attachments
flashes_1_index.png
Collected record in index table
flashes_1_index.png (22.65 KiB) Viewed 30418 times
flashes_1.png
Record with Month Property
flashes_1.png (25.76 KiB) Viewed 30418 times
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby kidkid » January 12th, 2011, 9:44 am

wao, it so strange.
I created a new index (called CreatedMonth with Month property).
And just after a minute, it collected 13 entries.

I go back and take a look in CreatedDate
it just 4 entries.

what does this mean ?
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Can't load range

Postby Henrik » January 13th, 2011, 12:54 pm

Hm, it looks like something went wrong when it re-indexed your table.

What happens if you delete the CreatedDate index, and then re-create it, and wait for the info-box that says "Index is currently being rebuilt" to disappear?

Does it take very long for the info-box to disappear?

Does the re-created index contain 13 entries like it should?
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Can't load range

Postby kidkid » January 14th, 2011, 12:07 pm

Yes, I has deleted it and re-created it again.
And it's ok. :)

uhm, I don't know why but should we have a refresh method so that user could try to force index re-collect item again ?
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am


Return to BigDB