FWIW you can declare a field @Embedded Map<String, anything> in
Objectify and this will create a series of "native" properties in the
low level entity.  Ie:

class MyEntity {
    @Id Long id;
    @Embedded Map<String, Long> strings;
}

If the map contained { prop1 : 12 } then you could filter by:

ofy.query(MyEntity.class).filter("strings.prop1", 12)

Of course the value could be a Set<String> instead of Long.

But yeah, this will make the datastore viewer difficult to read if you
have wildly different properties for each entity.  Nothing you can do
about that if you don't want to make the collection an opaque
serialized blob.

Jeff

On Fri, Nov 4, 2011 at 1:44 AM, Matthew Jaggard <matt...@jaggard.org.uk> wrote:
> From previous threads, it seems that the datastore prefers few large
> entities to more smaller ones - this is also reflected in pricing, you
> pay per operation as well as per byte. Storing a Map of Name->Value is
> exactly what the datastore is made for.
>
> I did talk to Jeff at Objectify about this (because I'm using
> Objectify for all my other entities) and he said that although this
> use case is probably valid and I'm (clearly now) not the only one
> doing it, making Objectify handle this case would complicate it too
> much. I think I agree with this, especially since the datastore
> handles properties like this so nicely.
>
> In addition, I can now make use of Objectify's CachingDatastoreService
> which means I don't have to worry about Memcache :-)
>
> One thought - can you search based on an item in a collection? If not
> and you do need to search based on these values, you might need to be
> more creative about how to split them.
> MyName->MyValue1
> and
> MyName->MyValue2
> which might become...
> MyName->Collection([MyValue1, MyValue2])
> or perhaps...
> MyName.1->MyValue1
> and
> MyName.2->MyValue2
> if MyName.1 will never be a property name itself, and you can deal
> with parsing this.
>
> Thanks,
> Mat.
>
> On 4 November 2011 07:53, Mister Schtief <lisc...@gmail.com> wrote:
>> hi gerald,
>>
>> thx for your answer but this is the ugliest solution ;) why serializing all
>> pairs and storing them in one.property .... it will never be searchable...
>>
>> using one entity property for every map.entry or using one entity of a key
>> value pair type, thats the question ;)
>>
>> schtief
>>
>> Am 04.11.2011 07:10 schrieb "Gerald Tan" <woefulwab...@gmail.com>:
>>>
>>> You can serialize a Map<String,String> property into a byte array to be
>>> stored in the entity
>>> The easiest way to do this would be to use Objectify with the @Serialized
>>> annotation
>>>
>>> http://code.google.com/p/objectify-appengine/wiki/IntroductionToObjectify#@Embedded
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/google-appengine-java/-/_tZZPKf5r6cJ.
>>> To post to this group, send email to
>>> google-appengine-java@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> google-appengine-java+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to google-appengine-java@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-appengine-java+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine for Java" group.
> To post to this group, send email to google-appengine-java@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine-java+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to