Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What makes a record unique?

 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By locking, i understand that we must lock ON A RECORD, but what exactly makes this record unique? Is it it's position in the file? I mean, should i keep each record stored in an array of some type and use it's position to determine whether it is locked or not?

Thanks in advance,
Marzo.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marzo, the records are identified by their position in the file. Record 0 is the first record. So record(n) is to be found at an offset in the file that is computed from (n times the record length) plus the offset from the beginning of the file to record 0. You do not need to have an array of records in memory, you can read one record into a buffer, update it, and write it back to the file.

You can keep your lock objects in an array, so that record n has its lock at position n in the array.
[ October 01, 2005: Message edited by: Barry Gaunt ]
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Barry.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic