CS6320:  SW Engineering of Web Based Systems

 

Goolge App Engine - Multivalued Properties

  • can store more than one value for a single property.

  • How do you test for equality in A query=

    • if any of the multiple property's values is equal to the filter value.

Example storing multy valued properties -- JAVA low level api use List class

Entity trophyCase = new Entity("TrophyCase");
List<String> trophyNames = new ArrayList<String>();
trophyNames.add("Goblin Rush Bronze");
trophyNames.add("10-Hut! (built 10 huts)");
trophyNames.add("Moon Landing");
trophyCase.setProperty("trophyNames", trophyNames);
ds.put(trophyCase);


// ...
// Key tcKey = ...
Entity newTrophyCase = ds.get(tcKey);
@SuppressWarnings("unchecked")
List<String> newTrophyNames = (List<String>) trophyCase.getProperty("trophyNames");

Example JAVA when mutlipe values of a property of different data type --use List<Object>

Entity EntityObject = new Entity("MyKind");
List<Object> setOfThings= new ArrayList<Object>();
setOfThings.add("Goblin Rush Bronze");
setOfThings.add(293.33);
setOfThings.add("Moon Landing");
EntityObject.setProperty("thePropertyName", setOfThings);
ds.put(EntityObject);

 

Remember that List (or Collection) is not a datastore type. It can only contain native
types, and not another Collection.

 

 

Exploding Indexes -- CAUTION with multiple valued properties

 

if an entity has more than one property with multiple values, and
more than one multivalued property appears in an index, the index must contain one
row for each combination of values to represent the entity completely.

 


If you're not careful, the number of index rows that need to be updated when the entity
changes could grow very large.

 


To help prevent "exploding indexes" from causing problems, App Engine limits the
number of property values—that is, the number of rows times the number of columns
—a single entity can occupy in an index. The limit is 5,000 property values, high enough
for normal use, but low enough to prevent unusual index sizes from inhibiting updates.

 

 

© Lynne Grewe