Hello.
My Environment;
- Nokia E61 / Series 60 3rd Edition
- MIDP 2.0/CLDC 1.1
- Memory: 50MB, I think.
I have RMS tables that have variable length records;however, I can estimate the maximum size for a record in each table. The estimated sizes are;
RMS Table A:4935 bytes
RMS Table B:2086 bytes
RMS Table C:2441 bytes
RMS Table D:2483 bytes
Would it be to wasteful if I created RMS records with max size that a record can occupy? For instance, when writing a record to "Table A", I would do the following;
Regardless of actually size of a particular record, it's max estimated size is always allocated.Code:byte[] outbuf = new byte[4935]; fill_table_a_data(outbuf); RecordStore rs = RecordStore.openRecordStore("A", true); rs.addRecord(outbuf, 0, outbuf.length); rs.closeRecodStore();
For reading record from "Table A" I would do;
I don't know the minimum around of memory RMS consumes per record, for instance, a record of length 20 bytes would occupy 1K of RMS records so 1024 - 20 is being wasted, but if it's >= 5 4935 then it would not lost anything.Code:byte[] table_a_buf = new byte[ 4935 ]; RecordStore rs = RecordStore.openRecordStore("A", false); rs.getRecord( some_recordID, table_a_buf, 0, table_a_buf.length ); rs.closeRecordStore(); // sometime later in the program I would do if (byteCompare( table_a_buf, NAME_OFFSET, "FUP" )) { doSomeAction( table_a_buf, NAME_OFFSET ); }
Also I do not have to keep creating a new buffer everytime I read a record from "Table A".
The above sizes are estimated by DBA that mobile will download from server, on average it could be a lot less than the maximum estimated size.
Another strategy would be to try to compute the average size of each record and only increase buffer when needed but I lose befenits of static size records, namely, I can't do something like;
What do you guys think? Will I quickly exhaust RMS memory with this method? I believe that all devices will be using memory cards of at least 50MB but i'm not sure. and there can be about 300 records so RMS would require;Code:if (compareBytes( table_a_outbuf, OFFSET_OF_NAME )) == 0) { doSomeActions(); }
"Table A": 1445K
"Table B": 611K
"Table C": 715K
"Table D": 727K
-----------------
Total: 3498K
Also, records get deleted often, and I don't know how this affects RMS, for instance, what happens to the space allocated by the record store?
If RMS becomes full, I can post a message to user telling them to delete RMS Tables and resync with server to defragment RMS if deleted records consumes space in a RMS table.
I would appreciate any input on this. I have already read document at Sun on RecordStore but I didn't find it useful for answering this question.
Thanks!




Reply With Quote

