Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Record ID's

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic