How Hard Can You Push TinyDb?

1,769 views
Skip to first unread message

ccmus...@gmail.com

unread,
Jan 3, 2014, 12:14:54 AM1/3/14
to mitappinv...@googlegroups.com
I am sure these questions have been addressed somewhere by someone, but I'd like to get definitive answers from the gurus of this forum:

1. What is the maximum number of tag TinyDb can store?

2. When this maximum number of tag is exceeded, will TinyDb return an error message (like "max number of tags exceeded") an error code (like "error number 1234567890") or the program just bomb out?

3. What is the maximum size (length, number of characters) of each tag's content?

fturbak

unread,
Jan 3, 2014, 8:21:52 AM1/3/14
to mitappinv...@googlegroups.com, ccmus...@gmail.com
On Friday, January 3, 2014 12:14:54 AM UTC-5, ccmus...@gmail.com wrote:
I am sure these questions have been addressed somewhere by someone, but I'd like to get definitive answers from the gurus of this forum:

1. What is the maximum number of tag TinyDb can store?

Under the hood, TinyDB is implemented in terms of android.content.SharedPreferences. According to this Stack Overflow post, share preferences are represented as an XML file stored in /data/data/[package name]/shared_prefs/[app name].xml. So the only space limitations involved are whether the device can store this file. There is no inherent limit on the number of tags. 
 

2. When this maximum number of tag is exceeded, will TinyDb return an error message (like "max number of tags exceeded") an error code (like "error number 1234567890") or the program just bomb out?

The source code uses an android.content.SharedPreferences.Editor to store key/value pairs, and uses its commit operation to commit the transaction. It's not clear from the documentation what happens if there's not enough space for the resulting XML file. I would assume the commit returns false in this case, but I'm not sure. However, there's no check for the false case in the App Inventor code, so my best guess is that this would fail silently. We'll look into this case. 
 

3. What is the maximum size (length, number of characters) of each tag's content?

The content of each tag (which can be an arbitrary value) is converted to JSON and is stored as a string. As in the answer to question #1, there is no inherent limitation on the size of this string.  

- lyn -

Jos Flores

unread,
Jan 3, 2014, 12:08:39 PM1/3/14
to fturbak, mitappinventortest, CCMUSAVideo .
with regards to question 3, there are some limitations that you can see here:

http://developer.android.com/reference/java/util/prefs/Preferences.html#MAX_KEY_LENGTH
http://developer.android.com/reference/java/util/prefs/Preferences.html#MAX_VALUE_LENGTH

So key length is 80 chars, and value length is 8192 chars.

cheers,
José
> --
> You received this message because you are subscribed to the Google Groups
> "MIT App Inventor Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mitappinventort...@googlegroups.com.
> To post to this group, send email to mitappinv...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mitappinventortest/f49cb4fe-810c-4a63-9bcd-89eaef819883%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

fturbak

unread,
Jan 3, 2014, 12:49:38 PM1/3/14
to mitappinv...@googlegroups.com, fturbak, CCMUSAVideo .
The comments in this Stack Overflow post point out that the limitations on the Preference class don't apply to the SharedPreferences class. 

Indeed, I just wrote two simple App Inventor 2 apps to verify this (attached). The TinyDBKeyLimit app starts with a key that's one character long and keeps doubling it until the application crashes. The TindyDBValueLimit app is similar, but keeps doubling the stored value string until the app crashes. In both cases, the app does not crash until after a key/value length of 8,388,608 characters is reported.  So the Preference limitations are clearly irrelevant for SharedPreferences and TinyDB.

- lyn -
TinyDBKeyLimit.aia
TinyDBValueLimit.aia
Reply all
Reply to author
Forward
0 new messages