wood burning stoves 2.0*
The moose likes Java Micro Edition and the fly likes Record ID's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Record ID Watch "Record ID New topic
Author

Record ID's

Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
Each record in a RecordStore has an Integer ID.

When a record is deleted, the ID is not reused.

Is it conceviable that you would ever run out of ID's?

I know that someone is going to say you will run out of memory before you run out of ID's, but what about the situation where you are regularly writing new records and deleting old ones?

What happens when you reach the ID limit? (Is it 2 billion?)

Does it throw an exception or will the device self destruct?

Regards,

Drew
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

The Universe will end, and there would be no more life.

Who says that the ID is not reused? I thought it was the record number, meaning the first record is record ID 1, whatever it is, then can be reused. Say you clear out the RecordStore then add records. Isn't the first one ID 1?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Drew Lane
Ranch Hand

Joined: May 13, 2001
Posts: 296
Originally posted by Mark Spritzler:
The Universe will end, and there would be no more life.

Who says that the ID is not reused? I thought it was the record number, meaning the first record is record ID 1, whatever it is, then can be reused. Say you clear out the RecordStore then add records. Isn't the first one ID 1?

Mark
I think it would depend on how you cleared the record store.

As I understand it, if you delete individual records then the record ID's are not reused. Please correct if I am wrong.

I suppose you could delete the whole RecordStore, however.

Drew
Jeff Jetton
Ranch Hand

Joined: Mar 29, 2005
Posts: 71
Originally posted by Drew Lane:

As I understand it, if you delete individual records then the record ID's are not reused. Please correct if I am wrong.


From my own experience, new records are added with a record ID that is one higher than the highest one used so far. So yes, if you do delete a record, that leaves a "hole" that doesn't seem to get filled.

However, just because I've never seen the RMS reuse a record ID, doesn't mean it never will. I don't know what the behavior of the RMS is when that highest record ID starts to get up towards the maximum positive integer value. Then again, I don't even know if all JVMs are supposed to work the same way, of if that sort of reuse decision is left up to the particular implementation.

It might be interesting to write a little test program to find all this out. Although it would be for purely academic reasons of course. We shouldn't be relying on a new record ID to be any particular value anyway. The Enumeration class is there to insulate you from that sort of thing.

- Jeff
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
According to the MIDP 2.0 specification:

- (Deleted) record ids are not reused: if one record store uses a record
id, it will be allocated to the corresponding record (until it is deleted)
You can update a record, though.
- Each record store has its own ordering and record ids


Eduardo Marques
Get ready for your SCMAD certification at J2MECertificate.com - See what all the buzz is about ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Record ID's
 
Similar Threads
Upload Rights
NX: Application Corporate Context
Passed!
URLyBird - Data file spec
how to get values from display table tag list?