Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for storing large strings as multiple attribute/value pairs #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mikrado
Copy link

@mikrado mikrado commented May 26, 2011

I am using SimpleJPA as persistence framework to access SimpleDB and found this piece of software very helpful.

I have recently added support for storing strings larger than 1024k by transparently splitting the string across multiple attribute value pairs in SimpleDB.

In my webapplication there is a form where users normally enter short strings but are allowed to enter longer texts as well. I can now transparently store these strings in a single property without the need to persist the property in S3.

I would like to contribute my changes to the SimpleJPA project. You can find details below. What do you think?

Details:

I have modified the Save-operation such that strings being larger than 1024k in UTF-8 are splitted into several chunks. Each chunk contains upto 1020k of data. Appended to the data is a counter which persists the order of chunks. Special care is taken not to split special characters which need more than one byte in UTF-8 encoding.

I have modified the ObjectBuilder accordingly: If there are multiple values for an attribute, the counter is retrieved and the values are concatenated in the correct order.

There is a new class for testing.

@treeder
Copy link
Member

treeder commented May 26, 2011

Does this replace the s3 storage? If so, is it configurable? s3 should still be the default to maintain backwards compatibility. Maybe as part of an annotation you can specify the strategy, ie s3 or split?

@mikrado
Copy link
Author

mikrado commented May 26, 2011

This does not replace s3. If property is annotated with @lob, s3 is used. Otherwise string is stored in SimpleDB. With the new code, there is simply no more exception if string is not annotated with @lob and larger than 1024k.

jayther added a commit to jayther/simplejpa that referenced this pull request May 3, 2014
…lti-attributes, added OFFSET keyword support, and serialize objects to Base64.

WARNING: Had to comment out foreign key and lobkey support due to its dependencies on beans and enhancers. Will re-add them when I have time to do it without beans and enhancers.
WARNING: core/tests will have some commented/removed code, will add proper tests concerning the major changes.

Removed most dependencies on get/set methods, beans, and enhancers.
(There are still some enhancers and beans somewhere, but most of them shouldn't be used)
Long strings get split to multiple attribute/value pairs (most code from appoxy#5 , adapted for more recent changes in SimpleJPA)
Any serializable objects in members will be serialized into Base64 string (uses long strings split change).
Added OFFSET keyword support, which does a count query and uses the next token to get wanted items (as suggested by AWS people).
Added utility constructor in EntityManagerFactoryImp.
SimpleJPA should ignore static fields now.

Updated README.markdown (and fixed some stuff so it's actually readable).

Signed-off-by: jayther <[email protected]>
jayther added a commit to jayther/simplejpa that referenced this pull request May 3, 2014
…lti-attributes, added OFFSET keyword support, and serialize objects to Base64.

WARNING: Had to comment out foreign key and lobkey support due to its dependencies on beans and enhancers. Will re-add them when I have time to do it without beans and enhancers.
WARNING: core/tests will have some commented/removed code, will add proper tests concerning the major changes.

Removed most dependencies on get/set methods, beans, and enhancers.
(There are still some enhancers and beans somewhere, but most of them shouldn't be used)
Long strings get split to multiple attribute/value pairs (most code from appoxy#5 , adapted for more recent changes in SimpleJPA)
Any serializable objects in members will be serialized into Base64 string (uses long strings split change).
Added OFFSET keyword support, which does a count query and uses the next token to get wanted items (as suggested by AWS people).
Added utility constructor in EntityManagerFactoryImp.
SimpleJPA should ignore static fields now.

Updated README.markdown (and fixed some stuff so it's actually readable).

Signed-off-by: jayther <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants